Implement gdb/pretty_print.py#767
Conversation
|
So when I tried testing the pretty printer against the most recent version of main, I ran into some segfaults. I think the commit a7cff49 was likely causing issues. I think this just reveals that the pretty printer was too coupled to the internals of jank's object system. I decided to add two additional c-api functions to help get the data I need from jank's objects for pretty printing:
|
| def jank_opaque_box_type(val): | ||
| def jank_box_canonical_type(val): | ||
| address = jank_address(val) | ||
| canonical_type = gdb.parse_and_eval(f"((jank::runtime::obj::opaque_box*){address})->canonical_type.c_str()") |
There was a problem hiding this comment.
The problem is that these addresses are untagged. Pointers are represented in NaN space now, so untagged pointers need to be tagged first. Check out the big comment block in oref.hpp for more details.
| auto const str(try_object<obj::persistent_string>(reinterpret_cast<object *>(o))); | ||
| return str->data.c_str(); |
There was a problem hiding this comment.
- I would expect this to do
.to_string()on the object, so it works on any object - I think what you want is
to_code_string(), which is different fromto_stringsince it puts quotes around strings and#'in front of vars and such
| return op_box->data; | ||
| } | ||
|
|
||
| char const *jank_box_canonical_type(jank_object_ref o) |
There was a problem hiding this comment.
I would prefer to not have this fn, if you can just use untagged to get your object_ref.
|
Thank you, Chris! |
I wanted to improve the debugging experience for myself in vscode, so I put together this pretty printer for gdb. Here is what the UI looks like when combined with #761:
It also requires some setup of gdb to work well: https://gist.github.com/djblue/c0c992710897a78eed3688e984e76d7e is a vscode gdb setup.