Hi Dennis,

First off, sorry for the delay. I was finishing up my west coast tour.

Yes, I have code for this. However, it's not entirely portable, but with
a little effort, your should have it running on the major machines of
interest. 

What the code does is this:

It watches for SIGBUS, SIGFPE, SIGSEGV and SIGABRT signals. SIGABRT is
generated by assert statements unless the code is compiled with 
#define NDEBUG as defined in your /usr/include/assert.h

When the signal is delivered, the signal handler immediately
forks (duplicates) the process and puts the 'old' process to sleep with
a call to pause(). 

Then the code sets up the arguments to the debugger (currently GDB)
and execs it. You might need to tweak the arguments for DBX. I've tried
to go through and comment the code as much as possible for readability.

Let me know if I can help further or if this doesn't work on your
system.

#include 
#include 
#include 
#include 
#include 
#include 

#define DEBUGGER "/usr/bin/gdb"

char *program_name;

static void dbg_handler(int signum)
{
  pid_t pid;

  pid = fork();
  if (pid == -1)
    return;

  if (pid != 0) /* parent */
    {
      char p2[16];
      FILE *f;

      /* Stringify the pid for the debugger arg list */
      sprintf(p2,"%d",pid);

      /* gdb -q   */
      /* -q means quiet! */

      execlp(DEBUGGER,DEBUGGER,"-q",program_name,p2,NULL);
    }

  pause();
}

/* Test driver */

int main(int argc, char **argv)
{
  program_name = argv[0];

  /* Note that signal() is really antiquated. Real programmers should
     use sigaction. */

  signal(SIGABRT,dbg_handler);
  signal(SIGSEGV,dbg_handler);
  signal(SIGBUS,dbg_handler);
  signal(SIGFPE,dbg_handler);

  assert(0);

  exit(1);
}

Dennis Cottel wrote:
> 
> Hi, Phil,
> 
> At the end of the Ptools meeting last week after Kevin's HPDF talk, I
> commented from the audience that I'd like my debugger to invoke
> automatically when, say, an assert failed.  It seemed like lots of
> people in the room knew how to do this, and you offered to show me how.
> 
> What I'd like in the debugger is the capability that exists on Windows
> (NT) where if there's a fault, it says "Do you want to debug this" and
> then opens the debugger pointing to the faulting location.  How can this
> be done portably with current debuggers?
> 
> Thanks for your help,        --Dennis
> 
>    Dennis Cottel, dennis@spawar.navy.mil, (619) 553-1645
>    SPAWAR Systems Center, San Diego, CA