epasveer / seer

Seer - a gui frontend to gdb
GNU General Public License v3.0
2.11k stars 67 forks source link

Seemingly impossible to put breakpoints in shared libraries #133

Closed DarkDefender closed 1 year ago

DarkDefender commented 1 year ago

I'm trying to debug some KDE applications and a lot of the code is not compiled into the binary but shared libraries that is loaded at run time. When I try to put break points in regular gdb, I simply just answer "yes" to the Make breakpoint pending on future shared library load? question and I'm good.

However in seer this doesn't seem to be possible, so I can't really debug the application properly as only a tiny fraction of the program is included in the binary.

Would it be possible to add an option for this in the future?

epasveer commented 1 year ago

Can you try this?

When creating the breakpoint, click on the "Pending" option. The fast way of creating a breakpoint (double-clicking a line of source) will not turn this on by default. However, the RMB on a line of source will give you an opportunity to enable this. Same with the "Add a new breakpoint" button in the breakpoint list.

image

image

Let me know how it turns out.

DarkDefender commented 1 year ago

Ah, I wasn't clear enough. I'm talking about creating breakpoints for function names. So either here: screenshot

Or when passing a break function_X command in the "gdb commands before run" panel.

When debugging larger projects I usually specify functions and only fall back to filenames and line number where there is a naming conflict. Do you think specifying function names like this when libraries are involved would be something you would support in the future?

epasveer commented 1 year ago

Ah, I see. Thanks for the use case. To confirm, the "Break in" function is in a shared library that hasn't been loaded yet?

If native gdb can do it, Seer should be able to. I'll work on it.

DarkDefender commented 1 year ago

To confirm, the "Break in" function is in a shared library that hasn't been loaded yet?

Yepp, that is correct.

If native gdb can do it, Seer should be able to. I'll work on it.

Thank you! Would it be possible to also introduce break points like these when pausing execution of the program as well? From what I can tell, it seems like it is only possible to define line breakpoints with the current UI after seergdb has attached itself to the program.

epasveer commented 1 year ago

only possible to define line breakpoints

I think I understand your question. Try this.

In the Breakpoints tab, click on the New Breakpoint button.

image

It will bring up a blank Breakpoint dialog.

image

Then enter the function name on the Function edit field - and select Pending. Click OK.

image

You should see it appear in the list of breakpoints.

image

A note, though. Once you populate these breakpoints, you can save them to a file. Kind of like a project file for your executable.

image

The next time you run Seer, you can load this breakpoint file.

image

Or:

% seergdb --break-load breakpoints.seer  myprogram one two three
DarkDefender commented 1 year ago

Ah, sorry, I am blind XD I could have sworn that I didn't see any "Function" entry in the "create new breakpoint" dialogue. Sorry for wasting your time.

epasveer commented 1 year ago

It's all good.

I'll still look into adding the "Pending" flag for the "Break in" method.

image

I'm going to keep this task opened for a little longer.

epasveer commented 1 year ago

The latest snapshot has the fix. Specifying a function name in the "Break in" text field will add the "pending" flag.

epasveer commented 1 year ago

Closing task. Reopen or create a new task if required.