[lldb-dev] External API available from within debugged process

Ilya Kulakov via lldb-dev lldb-dev at lists.llvm.org
Wed Jan 8 11:32:33 PST 2020


Hi,

I was recently working on a debugging utility code in my app that ultimately needed to access some of the non-exported symbols from a linked shared library.

This code would only be run under DEBUG builds and is only useful when debugger's CLI is present. With that constraint I hoped to somehow utilize debugger
in recovering an address of the non-exported-but-in-symbols-table function.

A straightforward solution is to pause the debugger, run the necessary image lookup command and then store the result into some global variable.
This unfortunately requires manual user interaction.

Less straightforward solution is to have an LLDB script run automatically after the shared library gets loaded (hook or some for-sure-loaded breakpoint).
This is not ideal since I seldom script the debugger (learning curve is daunting) and would still require user interaction to set up the script (maybe a major obstacle for the end user).

A "Simple" solution that popped in my mind  was to talk to the debugger directly from within the app. Via the C API or remote access (XPC, D-Bus etc).
But I couldn't find anything even remotely similar neither for lldb nor gdb.

Did I overlook it? Is there a solid reason to not to have such API exposed?

I understand that many debugger's capabilities are outright dangerous to provide from within the app, but it would be nice to have an access to readonly lookups.

Best Regards,
Ilya Kulakov



More information about the lldb-dev mailing list