-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track source-level program state when debug info is present #1552
Comments
I am currently working on this source-level support in KLEE as part of my ongoing research. I hope to eventually contribute it back here once it's ready for general use. |
@jryans That sounds super interesting. Just to clarify, KLEE supports debug information as long as your bitcode is compiled with it, i.e. But I guess you are more focusing on the variable names? You plan to utilise the Sounds great and useful! 😄 |
Ah of course, I forgot about this use of debug info when writing up the issue. 😅 I have edited my original post to acknowledge this existing support as part of stack trace reporting, so hopefully that will avoid any confusion. 🙂
Yes, exactly. Glad to hear it sounds useful! 😄 |
Context
KLEE tracks program state at the LLVM IR level. For some applications, it would be helpful to know how this maps back to some source-level state in whichever language was compiled to IR.
For example, the following C function...
...becomes something like the following IR using Clang 13 (
-O1
)......which makes no mention of source-level variables like
y
, and KLEE is thus unable to follow them as it executes. This also means KLEE cannot report errors in terms of source-level variables either.Desired outcome
Compilers like Clang can add debug info to the LLVM IR (enabled via the
-g
flag), which traditionally is emitted to a native binary and then read by debuggers like GDB, LLDB, etc. While current KLEE does use the file / line / column annotations in debug info when reporting stack traces, it could go further. As a future enhancement, it would be great for KLEE to use the variable debug info to map its IR-level program state up to source-level constructs when reporting to the user.Workaround
While it's not the same as a real mapping of variables using debug info, you can get a modestly better view if your compiler names IR values based on source-level constructs. With Clang, you can add
-fno-discard-value-names
to achieve this, which gives something like the following......where some of the IR values (such as
%n
for the function argument) appear with their source-level names. To be clear, this only tweaks the names alone. An unoptimised version would also have a%y
IR value for the source-level variabley
, but that value was removed by the optimiser, so we no longer see that name here. Source-level variables move through numerous IR values and memory locations during computation, so this value naming workaround is not enough to follow source-level program state.The text was updated successfully, but these errors were encountered: