From: O'Donnell, T. (S. US) <tom...@si...> - 2011-07-11 19:25:13
|
Dear All, I am trying to debug a simple program, sfsegyheader, using gdb (I recompiled Madagascar using gcc with the -g option) gdb sfsegyheader < plane.rsf tracl=tracl.rsf > tfile.rsf $ gdb sfsegyheader (gdb) run < filter.rsf tracl=tracl.rsf > tfile.rsf Starting program: /usr/local/rsf/bin/bin/sfsegyheader < filter.rsf tracl=tracl.r sf > tfile.rsf [New Thread 3360.0x17ac] [New Thread 3360.0x1668] And it hangs.......... If I run it from the console I get: $ sfsegyheader < filter.rsf tracl=tracl.rsf > tfile.rsf sfsegyheader: Need filesize=1Segmentation fault (core dumped) Different results. I think the problem is that gdb is not recognizing the stdin redirection to filter.rsf. It thinks that stdin is still stdin. Specifically, in simtab.c void sf_simtab_input (sf_simtab table, FILE* fp, FILE* out) /*< extract parameters from a file >*/ { char line[LINELEN], word[LINELEN], *cl, *cw; int c; enum {START, INAWORD, STRING} state; while (NULL != fgets(line,4,fp)) { It seems to be waiting here for input from the console. What am I doing wrong? Or alternatively, how do people debug these programs? Thanks, Tom |