Symbols for dynamic labels
Closed this issue · 6 comments
Hi,
Long time no speak. Hope you are well!
I'm trying to figure out a way to add a dynamic label to some code I'm generating, and give it a symbol a debugger can find at runtime. I've managed to use dynamic labels for control flow just fine, but I can't see a way to add a symbol for them.
Is it possible?
(I've looked at static labels, but their name has to be &'static str
, but I'll need symbol names to be generated at runtime)
Cheers
Generating debugging information for JITted code at runtime is likely dependent on the debugger you're using. GDB has some information on how to do it here: https://sourceware.org/gdb/onlinedocs/gdb/JIT-Interface.html , but actually implementing this is on you. Dynasm-rs assemblers provide an API where you can get the offset of a dynamic label from its ID, and so you can tell GDB that code at that offset has a name of your choosing.
For some reason I thought gdb could trap based on basic symbol addresses too? Maybe I'm wrong.
I'm not sure what you mean? Either way the labels you use in dynasm-rs aren't true symbols as you'd find them in the binary. They're just entries in some HashMap. If you want to be able to use them in a debugger you'll have to inform your debugger of them at runtime.
Thanks.
I'm not that familiar with GDB, sorry.