[lldb-dev] Questions for module/symbol load/unload events
Greg Clayton via lldb-dev
lldb-dev at lists.llvm.org
Mon Feb 29 12:43:37 PST 2016
In general where you see the event bits defined like SBTarget.h for your case, the class that contains the event bit definitions:
class SBTarget
{
public:
//------------------------------------------------------------------
// Broadcaster bits.
//------------------------------------------------------------------
enum
{
eBroadcastBitBreakpointChanged = (1 << 0),
eBroadcastBitModulesLoaded = (1 << 1),
eBroadcastBitModulesUnloaded = (1 << 2),
eBroadcastBitWatchpointChanged = (1 << 3),
eBroadcastBitSymbolsLoaded = (1 << 4)
};
...
Also contains all of the static functions that can extract data from those events:
class SBTarget
{
public:
...
static bool
EventIsTargetEvent (const lldb::SBEvent &event);
static lldb::SBTarget
GetTargetFromEvent (const lldb::SBEvent &event);
static uint32_t
GetNumModulesFromEvent (const lldb::SBEvent &event);
static lldb::SBModule
GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event);
Greg Clayton
> On Feb 29, 2016, at 11:59 AM, Jeffrey Tan via lldb-dev <lldb-dev at lists.llvm.org> wrote:
>
> This is very useful, thanks for the info!
>
> On Mon, Feb 29, 2016 at 10:36 AM, Jim Ingham <jingham at apple.com> wrote:
>
>> On Feb 27, 2016, at 8:34 PM, Jeffrey Tan via lldb-dev <lldb-dev at lists.llvm.org> wrote:
>>
>> Hi,
>>
>> I am trying to listen for module/symbol load/unload events and display them in output UI so that debugger users can have a basic clue what is debugger busy doing while launching a big executable linking many shared libraries.
>>
>> Questions:
>> 1. I did not find an API to get current load/unload module during module events. I was expecting some static API like lldb.SBModule(or SBTarget).GetModuleFromEvent(SBEvent), but this does not exists. I tried to treat current PC's module as loading module in module load/unload events. But that does not work too(I think because process is not stopped in module load/unload events). Do I miss something here?
>
> From SBTarget.h:
>
> static uint32_t
> GetNumModulesFromEvent (const lldb::SBEvent &event);
>
> static lldb::SBModule
> GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event);
>
> Note, you can also cause the process to stop with modules are loaded with the setting:
>
> target.process.stop-on-sharedlibrary-events
>
> if that is more convenient for you.
>
>>
>> 2. Even though "image list" shows I have around 42 modules loaded in process, I only got two module load events. Why is that?
>
> On OS X the loader loads the closure of modules for whatever it is loading, and only stops and informs the debugger when this is all done. So it is quite usual to see only a few load events even though many modules get loaded.
>
>
>>
>> 3. Even though I added lldb.SBTarget.eBroadcastBitSymbolsLoaded, there is no event of type eBroadcastBitSymbolsLoaded generated. Is it expected? Apparently I have the symbols next to the binary.
>
> That event gets sent when symbols are added to an already loaded module. It is so a UI will know to refresh the backtrace, local variables, source view, etc when code goes from having no symbols to having some symbols. Those actions are not needed if the library & its symbols get loaded simultaneously, so it isn’t sent in that case.
>
> Jim
>
>
>>
>> This is tested on mac OSX lldb.
>>
>> Jeffrey
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
More information about the lldb-dev
mailing list