Good afternoon.

There is a certain application that loads plugins on startup (I mean a binary file in which the implementation of several classes is located under the plug-in; such a file cannot be executed separately from the parent application), calls a couple of functions described in these plugins and unloads them from memory.

The question is : can gdb “join” to such a plugin for debugging (i.e., will join before any code in the plugin is executed)?

There is, of course, a head-on solution — to place an interrupt in the host application immediately after the plug-in code has been loaded but not yet executed (but this application is quite voluminous and it will take a long time to find the right place in it).
I came up with another solution (which I am using at the moment) - I launch the application in the debugger, wait for the plugins to load and complete the work. Then I put a breakpoint on the desired method ( bp "[NSColor blueColor]" ), run the application again, stop at the breakpoint and memorize the offset for this point. Then either I step manually, or calculate the desired offset, based on that found above. But this is somehow ugly, there must be another way, I guess.

Thank.

  • If you understand correctly, the application does dlopen () on .so (.dll). And also you want to make attachments in gdb to an already running application? As far as I understand, if the attachment has already made a dlopen (by the time of your attachment), then you can put br on the code in the plugin, otherwise how? After all, the application itself must download the plugin. - avp
  • @avp, at the moment of creating the question, I was stuck on the fact that the plugin for some reason! = library. I do not know why. Here is the second way that I described really suits me, but it is a bit annoying that the displacements there turn out by themselves other than in the assembler listing of the plug-in code. I just thought that maybe there is an opportunity to somehow connect to it (the plug-in) separately (again, I did not take into account that the application itself starts it) and work with "correct" offset'ami. - VioLet 1:01 pm
  • @VioLet, although the question is closed, but apparently possible . Sach was sealed in gdb and saw: (gdb) br me_pro22 Function "me_pro22" is not defined. Make breakpoint pending on future library load? (y or [n]) y Breakpoint 1 (me_pro22) pending. (gdb) Here, apparently, is the answer for your plugin. - avp
  • @avp, yes, you can set breakpoint on any function in the plugin / library. Only for me it (breakpoint) works only after re-launching the program (as I described it in question) - apparently because my plugin is in fact dynamically linked shared library. - VioLet

0