From: Julian Seward Date: Sun, 13 Jul 2003 10:54:33 +0000 (+0000) Subject: Add patch from Sami Liedes making GDB use more flexible: X-Git-Tag: svn/VALGRIND_2_0_0~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7f560b8e1efde2b3464d81cf4ec9a8a690299bd;p=thirdparty%2Fvalgrind.git Add patch from Sami Liedes making GDB use more flexible: --gdb-path=/path/to/gdb allows running some alternate GDB --input-fd= allows reading input from some fd other than stdin I even updated the docs :-) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1754 --- diff --git a/coregrind/docs/coregrind_core.html b/coregrind/docs/coregrind_core.html index d9cc537389..9f82ec2a30 100644 --- a/coregrind/docs/coregrind_core.html +++ b/coregrind/docs/coregrind_core.html @@ -577,6 +577,24 @@ follows: socket, I guess this option doesn't make any sense. Caveat emptor.

+

  • --gdb-path=/path/to/gdb +

    This specifies how Valgrind will invoke GDB. By default, it + will use whatever GDB is detected at build time, + which is usually /usr/bin/gdb. Using this command, + you can specify some alternative path to the GDB you want to + use. +


  • + +

  • --input-fd=<number> [default=0, stdin]
    +

    When using --gdb-attach=yes and + --gen-suppressions=yes, 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. +


  • +

  • --gen-suppressions=no [the default]
    --gen-suppressions=yes

    When enabled, Valgrind will pause after every error shown, diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index edc559471d..3276d1eed7 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -130,14 +130,14 @@ Bool VG_(is_action_requested) ( Char* action, Bool* clo ) 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; diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index b7b229736e..aeb5c2380c 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -175,6 +175,8 @@ typedef 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. */ @@ -205,6 +207,8 @@ extern VgLogTo VG_(clo_log_to); 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. */ diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index b89a411c56..34ee4fe74d 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -512,6 +512,7 @@ UInt VG_(num_scheduling_events_MAJOR) = 0; /* 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; @@ -523,6 +524,7 @@ VgLogTo VG_(clo_log_to) = VgLogTo_Fd; 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; @@ -610,6 +612,7 @@ static void usage ( void ) " -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= show callers in stack traces [4]\n" @@ -618,6 +621,7 @@ static void usage ( void ) " --run-libc-freeres=no|yes Free up glibc memory at exit? [yes]\n" " --logfile-fd= file descriptor for messages [2=stderr]\n" " --logfile= log messages to .pid\n" +" --input-fd= file descriptor for (gdb) input [0=stdin]\n" " --logsocket=ipaddr:port log messages to socket ipaddr:port\n" " --suppressions= suppress errors described in\n" " suppressions file \n" @@ -920,6 +924,9 @@ static void process_cmd_line_options ( void ) 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")) @@ -959,6 +966,9 @@ static void process_cmd_line_options ( void ) 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."); @@ -1764,11 +1774,8 @@ extern void VG_(start_GDB_whilst_on_client_stack) ( void ) 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) { @@ -1779,8 +1786,6 @@ extern void VG_(start_GDB_whilst_on_client_stack) ( void ) VG_(message)(Vg_UserMsg, "Apparently failed!"); VG_(message)(Vg_UserMsg, ""); } -#undef TO_STRING -#undef TO_STRING2 }