gcc question
Alexandre Oliva
oliva@lsd.ic.unicamp.br
Tue Feb 1 23:45:00 GMT 2000
On Feb 2, 2000, Sang-Kil Lee <sklee@synopsys.COM> wrote:
> I ran it and it finished successfully but didn't invoke a debugger(ex.
> gdb).
It's not supposed to. `-g' just tells the compiler to add debugging
information to the program.
> Of course, I know that I can invoke the binary code using gdb(ex.
> unix_prompt> gdb <binary_code>).
That's what you'll have to do.
> But what I want is that the debugger is invoked as soon as I run the
> binary code.
> Is it possible to attach the debugger to the binary code?
Well, it *is* possible to do, but you don't really want to do that.
You'd have to fork() the process right in the beginning of main(),
execlp("gdb", argv[0], pid_of_other_process, NULL) in one of the
processes and kill(getpid(), SIGSTOP) in the other, so that it waits
for gdb to attach to it. pid_of_other_process is the result of
converting the pid of the other process to a string.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them
More information about the Gcc
mailing list