using gbd to debug a program reading from stdin

E

equinox

Okay, I am really new to this gdb issue.. my program usually takes an
argument from stdin.. the program name is
test.. so this is how I normally execute it without using gdb:

test < file.c

now I want to be able to run that test program under gdb as I see this
segmentation fault which I can't trace... can anyone show me how to do
that? I am quite new to this gdb issues.. What I am confused mainly is
that how do I instruct gdb to read from a stdin, in other words in my
example above.. how do I set it so that it takes file.c from stdin??
 
N

Nate Eldredge

equinox said:
Okay, I am really new to this gdb issue.. my program usually takes an
argument from stdin.. the program name is
test.. so this is how I normally execute it without using gdb:

test < file.c

now I want to be able to run that test program under gdb as I see this
segmentation fault which I can't trace... can anyone show me how to do
that? I am quite new to this gdb issues.. What I am confused mainly is
that how do I instruct gdb to read from a stdin, in other words in my
example above.. how do I set it so that it takes file.c from stdin??

This isn't really a question for comp.lang.c, but better for some
newsgroup about gdb. However, the answer is simple. Start gdb with
"gdb ./test", and give it the command "run <file.c".
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top