"catch throw" vs. "b __cxa_throw"

Andrew Burgess aburgess@redhat.com
Mon Aug 15 11:10:44 GMT 2022


Tom Kacvinsky via Gdb <gdb@sourceware.org> writes:

> We happened to notice that with gdb 7.6.1, "catch throw" caught an exception
> (a logic_error exception from initializing a std::string with nullptr).
> However, with
> GDB 11.1 and 12.1 (I have not tested earlier versions than that), we did
> not break
> on the exception when using "catch throw".  However, I was able to break
> when
> I used "b __cxa_throw"
>
> I looked in sourceware's bugzilla for a report on this, but I didn't see
> anything.
> I also perused the code and from what I could gather, "catch throw"
> basically
> mapped to setting a breakpoint on __cxa_throw.  I did not figure out the
> logic
> for "catch throw" in the GDB 12.1 source.
>
> What is really odd is that "catch throw" works fine for some small examples,
> but the use case I have where it is not working is our full blown project
> (a mix
> of C, C++ and Ada) and I wouldn't know where to begin constructing an MRE.
>
> Any ideas as to what is going on with this?

No clue what's going wrong here, but you could use 'maint info
breakpoints' to discover the exact address where the 'catch throw' has
placed a breakpoint.

>From that you might be able to figure out why you're hitting your
breakpoint, but not the 'catch throw' breakpoint.

Thanks,
Andrew



More information about the Gdb mailing list