[COFF] Conditions, AKA exceptions.
Ralph Corderoy
ralph at inputplus.co.uk
Sun Mar 12 20:44:17 AEST 2023
Hi Ted,
> > > cmd = aprintf("gdb -batch -ex backtrace '%s/bk' %u 1>&%d 2>&%d",
> > > bin, getpid(), fileno(f), fileno(f));
...
> > It works surprisingly often, i.e. the process is healthy enough to
> > run system(3).
>
> On Linux (or some other system using glibc) a limited facility is
> built into the C library. So you can just do somthing like this:
...
> frames = backtrace(stack_syms, 32);
> backtrace_symbols_fd(stack_syms, frames, 2);
Since ’99, yes. :-) backtrace(3) says glibc 2.1 added it.
> I use this for the fsck for ext4, and the nice thing is that even with
> a stripped binary.
>
> For example:
Yes, that is nice.
> https://github.com/tytso/e2fsprogs/blob/master/e2fsck/sigcatcher.c#L379
Thanks, I've made a note.
Do you ever find things are so messed up that stdio has trouble whereas
using write(2) with compile-time memory allocations for a buffer would
have a better chance of reaching the TTY?
--
Cheers, Ralph.
More information about the COFF
mailing list