Re: Building gdb-9.1 on OSX: gdb's exceptions are not getting caught

Paul Koning
2020-04-14T20:27:19Z

> On Apr 14, 2020, at 4:23 PM, krokus via Gdb <gdb@sourceware.org> wrote:
>
> gdb 9.1 is being built from sources .tar.gz on OSX 10.13 with clang 8.0.
> The build proceeds successfully, resulting in a runnable gdb binary
> (properly codesign'ed).
>
> I get the (gdb) prompt. Known commands (e.g. info) are properly executed.
> However entering an incorrect command results in Abort trap: 6 with the
> message:
> "libc++abi.dylib: terminating with uncaught exception of type
> gdb_exeption_error"
>
> I'm trying to diagnose why gdb appears to be failing to catch its own
> exceptions.
>
> In case of executing an incorrect command, the try/catch handling is
> supposed to be done in event-top.c::gdb_rl_callback_handler(). Indeed, the
> crash log (see below) shows this entry which correctly proceeds to
> throw_it() , yet never gets caught back at the gdb_rl_callback_handler().
>
> I even tried to explicitly put a throw("catch-this") in the
> gdb_rl_callback_handler() and then added a catch(...) clause in hope to
> catch it there rightaway. Yet it goes uncaught, as if there's no catch
> there.
>
> Anybody experienced similar issues with non-functioning exceptions while
> building on OSX?
>
> The configure flags I used:
> ../configure --disable-binutils
> --enable-targets="x86_64-apple-darwin,x86_64-linux-gnu,i686-linux-gnu"
> --without-lzma --without-python"

I recently built it, and after some messing around with signatures and the like, it seems to work. It certainly has no trouble with invalid commands.

(gdb) show config
This GDB was configured as follows:
configure --host=x86_64-apple-darwin18.7.0 --target=x86_64-apple-darwin18.7.0
--with-auto-load-dir=:${prefix}/share/auto-load
--with-auto-load-safe-path=:${prefix}/share/auto-load
--with-expat
--with-gdb-datadir=/usr/local/share/gdb (relocatable)
--with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
--without-libunwind-ia64
--without-lzma
--without-babeltrace
--without-intel-pt
--with-mpfr
--without-xxhash
--without-python
--without-guile
--disable-source-highlight
--with-separate-debug-dir=/usr/local/lib/debug (relocatable)

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)
(gdb) wrongcommand
Undefined command: "wrongcommand". Try "help".
(gdb)

paul