Advice on debugging possible exception or crash

Chris Katko ckatko at gmail.com
Thu Jul 6 19:53:39 UTC 2023


On Thursday, 6 July 2023 at 06:00:04 UTC, Cecil Ward wrote:
> My program is instrumented with a load of writeflns. At one 
> point it looks as though it suddenly quits prematurely because 
> the expected writeflns are not seen in the output. It could be 
> that I am just reading the flow of control wrong as it goes 
> ret, ret etc. I’m wondering if it is throwing an exception, or 
> has a fault initiating a crash, perhaps even due to the 
> fetching of arguments of one of the writeflns. In my limited 
> experience, exceptions produce an error message though, and I’m 
> not seeing anything. Any advice on how to debug this, silent 
> termination ?
>
> I don’t have a debugger on this machine, but on an x86-64 box I 
> could use gdb if I first take the time to work out how.

one thing I do is have gdb/lldb break on d assert, before it 
destroys the stack. That helped me catch a class of bugs.

```sh
# in the gdb interface before running
break _d_assertp
break _d_assert
break _d_assert_msg

# or to combine it into the commandline:
gdb -ex "break _d_assert" -ex "break _d_assert_msg" -ex "run $1" 
./main

# can also add it to your .gdbinit startup code.
```


More information about the Digitalmars-d-learn mailing list