socket, I guess this option doesn't make any sense. Caveat emptor.
</li><br><p>
+ <li><code>--gdb-path=/path/to/gdb</code>
+ <p>This specifies how Valgrind will invoke GDB. By default, it
+ will use whatever GDB is detected at build time,
+ which is usually <code>/usr/bin/gdb</code>. Using this command,
+ you can specify some alternative path to the GDB you want to
+ use.
+ </li><br><p>
+
+ <li><code>--input-fd=<number></code> [default=0, stdin]<br>
+ <p>When using <code>--gdb-attach=yes</code> and
+ <code>--gen-suppressions=yes</code>, Valgrind will stop
+ so as to read keyboard input from you, when each error occurs.
+ By default it reads from the standard input (stdin), which is
+ problematic for programs which close stdin. This option
+ allows you to specify an alternative file descriptor from
+ which to read input.
+ </li><br><p>
+
<li><code>--gen-suppressions=no</code> [the default]<br>
<code>--gen-suppressions=yes</code>
<p>When enabled, Valgrind will pause after every error shown,
VG_(getpid)(), action
);
- res = VG_(read)(0 /*stdin*/, &ch, 1);
+ res = VG_(read)(VG_(clo_input_fd), &ch, 1);
if (res != 1) goto ioerror;
/* res == 1 */
if (ch == '\n') return False;
if (ch != 'N' && ch != 'n' && ch != 'Y' && ch != 'y'
&& ch != 'C' && ch != 'c') goto again;
- res = VG_(read)(0 /*stdin*/, &ch2, 1);
+ res = VG_(read)(VG_(clo_input_fd), &ch2, 1);
if (res != 1) goto ioerror;
if (ch2 != '\n') goto again;
extern Bool VG_(clo_error_limit);
/* Enquire about whether to attach to GDB at errors? default: NO */
extern Bool VG_(clo_GDB_attach);
+/* The path to GDB? default: whatever ./configure found */
+extern Char* VG_(clo_GDB_path);
/* Enquire about generating a suppression for each error? default: NO */
extern Bool VG_(clo_gen_suppressions);
/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
extern Int VG_(clo_logfile_fd);
extern Char* VG_(clo_logfile_name);
+/* The file descriptor to read for input. default: 0 == stdin */
+extern Int VG_(clo_input_fd);
/* The number of suppression files specified. */
extern Int VG_(clo_n_suppressions);
/* The names of the suppression files. */
/* Define, and set defaults. */
Bool VG_(clo_error_limit) = True;
Bool VG_(clo_GDB_attach) = False;
+Char* VG_(clo_GDB_path) = GDB_PATH;
Bool VG_(clo_gen_suppressions) = False;
Int VG_(sanity_level) = 1;
Int VG_(clo_verbosity) = 1;
Int VG_(clo_logfile_fd) = 2;
Char* VG_(clo_logfile_name) = NULL;
+Int VG_(clo_input_fd) = 0; /* stdin */
Int VG_(clo_n_suppressions) = 0;
Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
Bool VG_(clo_profile) = False;
" -q --quiet run silently; only print error msgs\n"
" -v --verbose be more verbose, incl counts of errors\n"
" --gdb-attach=no|yes start GDB when errors detected? [no]\n"
+" --gdb-path=/path/to/gdb path to the GDB to use [/usr/bin/gdb]\n"
" --gen-suppressions=no|yes print suppressions for errors detected [no]\n"
" --demangle=no|yes automatically demangle C++ names? [yes]\n"
" --num-callers=<number> show <num> callers in stack traces [4]\n"
" --run-libc-freeres=no|yes Free up glibc memory at exit? [yes]\n"
" --logfile-fd=<number> file descriptor for messages [2=stderr]\n"
" --logfile=<file> log messages to <file>.pid<pid>\n"
+" --input-fd=<number> file descriptor for (gdb) input [0=stdin]\n"
" --logsocket=ipaddr:port log messages to socket ipaddr:port\n"
" --suppressions=<filename> suppress errors described in\n"
" suppressions file <filename>\n"
else if (VG_CLO_STREQ(argv[i], "--gdb-attach=no"))
VG_(clo_GDB_attach) = False;
+ else if (VG_CLO_STREQN(11,argv[i], "--gdb-path="))
+ VG_(clo_GDB_path) = &argv[i][11];
+
else if (VG_CLO_STREQ(argv[i], "--gen-suppressions=yes"))
VG_(clo_gen_suppressions) = True;
else if (VG_CLO_STREQ(argv[i], "--gen-suppressions=no"))
VG_(clo_logfile_name) = &argv[i][12];
}
+ else if (VG_CLO_STREQN(11, argv[i], "--input-fd="))
+ VG_(clo_input_fd) = (Int)VG_(atoll)(&argv[i][11]);
+
else if (VG_CLO_STREQN(15, argv[i], "--suppressions=")) {
if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
Int res;
UChar buf[100];
-#define TO_STRING(x) TO_STRING2(x)
-#define TO_STRING2(x) #x
-
VG_(sprintf)(buf, "%s -nw /proc/%d/exe %d",
- TO_STRING(GDB_PATH), VG_(getpid)(), VG_(getpid)());
+ VG_(clo_GDB_path), VG_(getpid)(), VG_(getpid)());
VG_(message)(Vg_UserMsg, "starting GDB with cmd: %s", buf);
res = VG_(system)(buf);
if (res == 0) {
VG_(message)(Vg_UserMsg, "Apparently failed!");
VG_(message)(Vg_UserMsg, "");
}
-#undef TO_STRING
-#undef TO_STRING2
}