gdb -args

M

moongeegee

Base on the gdb manu we can pass argument as gdb --args gcc -02 -c
foo.c
But how to use makefile instead of gcc
I try gdb --args make -f Makefile.test but failed.
Please help.
Thanks
 
R

red floyd

moongeegee said:
Base on the gdb manu we can pass argument as gdb --args gcc -02 -c
foo.c
But how to use makefile instead of gcc
I try gdb --args make -f Makefile.test but failed.
Please help.
Thanks

Wrong group. Try gnu.g++.help or something similar.
 
J

Jeff Schwab

moongeegee said:
Base on the gdb manu we can pass argument as gdb --args gcc -02 -c
foo.c
But how to use makefile instead of gcc
I try gdb --args make -f Makefile.test but failed.

This is a C++ language discussion group. Your post is off-topic for two
reasons: (1) You are using C, which is very different from C++, and (2)
gdb is a general-purpose debugging tool, and not an aspect of the C++
programming language.

Below is one possible (not particularly scalable) approach. You will
likely get a better answer in a more appropriate group.

$ ls
Makefile foo.c
$ cat Makefile
CC=gcc
DB=gdb
EXT=.c
CFLAGS=-ansi -pedantic
DBFLAGS=--quiet

INVOCATION=$(CC) $(CFLAGS) -o $(TARGET) $(TARGET)$(EXT)

$(TARGET): $(TARGET)$(EXT)
$(INVOCATION)

db:
$(DB) $(DBFLAGS) --args $(INVOCATION)
$ TARGET=foo make
gcc -ansi -pedantic -o foo foo.c
$ ls
Makefile foo foo.c
$ rm foo
$ TARGET=foo make db
gdb --quiet --args gcc -ansi -pedantic -o foo foo.c
Reading symbols from /export/home/jeff/opt/gcc-mine/bin/gcc...done.
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) run
Starting program: /export/home/jeff/opt/gcc-mine/bin/gcc -ansi -pedantic
-o foo foo.c
Reading symbols from /lib64/ld-linux-x86-64.so.2...done.
Reading symbols from /lib64/libc.so.6...done.

Program exited normally.
(gdb) quit
$ ls
Makefile foo foo.c
$ ./foo
http://groups.google.com/group/gnu.g++.help/msg/013a9d6e220077ae
$
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top