This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc question
- To: sklee at synopsys dot COM
- Subject: Re: gcc question
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 02 Feb 2000 05:45:40 -0200
- Cc: gcc at gcc dot gnu dot org
- References: <3897DBAA.A3350A09@synopsys.com>
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