AndresR
AndresR

Reputation: 608

How to make gdb break on 'symbol lookup error'

I'm using gdb to debug my program. It is still work-in-progress so some symbols are not yet defined (and errors are masked out during link). When I run the code I occasionally get 'symbol lookup error', when an undefined function is called (as expected) and the program immediately finishes.

I would like gdb to break at that function call so that I can identify the offending line and program status at that point.

Is there any flag or break point location I could use to make gdb stop prior to the program finishing?

Upvotes: 3

Views: 1516

Answers (1)

Employed Russian
Employed Russian

Reputation: 213877

Is there any flag or break point location I could use

You can break _dl_signal_error or catch syscall exit_group.

The latter will stop when you process is about to exit regardless of why that is happening.

Update:

When using newer GLIBC versions (at least GLIBC-2.31), use _dl_signal_exception instead of _dl_signal_error.

Upvotes: 4

Related Questions