Make LLDB IR data formatters more robust #7927
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a followup on #7828 to fix bugs that were causing CodeLLDB to give wrong values and hang (see vadimcn/codelldb#1302) because I didn't realize that these data formatters can be passed either a value of a given type or a pointer to a value of that type, and need to handle both cases. I also introduced loop bounds to prevent hangs in the case where these synthetic values are constructed for things like uninitialized variables.
From looking at the preexisting data formatters from #4272 in
source/core/core_lldb.py
, it seems like they technically have similar bugs to this, but since those types are simpler, it's unclear to me whether that can actually manifest in meaningful ways like these bugs insource/slang/slang_lldb.py
were doing.Anyways, to test this, put a breakpoint here:
slang/source/slang/slang-emit-cpp.cpp
Line 1733 in 6d39980
And use this
.vscode/launch.json
for CodeLLDB:Before this PR, the
inst
variable will display in the debug pane as{kIROp_StringLit 0x00007fffffff5f68}
, which is the wrong pointer value. You can also check this by runningp inst
in the Debug Console, which will print this:In contrast, running
p *inst
prints the correct pointer value:But as you can see, in that case the synthetic
[value]
child is completely missing.Then if you try to expand
inst
in the debug pane, CodeLLDB will hang (or at least it does when I try this).After this PR, the hex integer for the pointer is always consistent, and CodeLLDB does not hang in the debug pane when you expand
inst
, and shows the correct[value]
child just like when runningv *inst
.As an aside: after this PR, the
[value]
child is still missing when specifically runningp *inst
in the Debug Console. It is possible to fix this:However, that makes the debugger run significantly slower, so I'm choosing not do do it here.