I am writing a program for implementing the Dinic max-flow algorithm over a network. Networks can be written either manually or loaded from a file using stdin redirection. I was able to use gdb to debug a program with small files (about 30 lines), but I have problems trying to debug a program with large files (> 1000 lines). The code itself is as follows:
uint32_t read_lines = 0; while(!feof(stdin)) { err = fscanf(stdin, "%u %u %u\n", &n1, &n2, &c); if (err != 3) { printf("read_lines=%u\n", read_lines); } read_lines += 1; fprintf(debug, "line %u: %u %u %u\n", read_lines, n1, n2, c); }
If I run the program without gdb, it starts, not normal, because it generates a segmentation error (for this reason I try to use gdb), but it goes through this part of the "parsing" of the input file (and write it to the debug output file) . However, if I type:
gdb --args ./dinic --mode=NUM --verbose=LOW (gdb) b 61 (gdb) run < tests/numterc.in
I get:
(gdb) Program exited with 01 code.
and when I open the debug file about 2000 lines, when it should be no more than 1000, this is the length of the input file.
I repeat, this happens with "large" files, it works correctly with small ones. The question will be, am I missing something when using gdb, or is it a gdb error?
c redirect stdin gdb
Leandro demarco
source share