]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add patch from Sami Liedes <sliedes@cc.hut.fi> making GDB use more flexible:
authorJulian Seward <jseward@acm.org>
Sun, 13 Jul 2003 10:54:33 +0000 (10:54 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 13 Jul 2003 10:54:33 +0000 (10:54 +0000)
--gdb-path=/path/to/gdb   allows running some alternate GDB
--input-fd=<n>            allows reading input from some fd other than stdin
I even updated the docs :-)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1754

coregrind/docs/coregrind_core.html
coregrind/vg_errcontext.c
coregrind/vg_include.h
coregrind/vg_main.c

index d9cc53738923f2ccd99b86a78d0ee274e984e547..9f82ec2a3085f581587d8a0b0ce27e16969e5cb8 100644 (file)
@@ -577,6 +577,24 @@ follows:
       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=&lt;number&gt;</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,
index edc559471df3ea7df24ac1cb33a150e52fa82b31..3276d1eed73c1a0c989a447b439aab3417990bb7 100644 (file)
@@ -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;
 
index b7b229736efc6b98a54b653b1324263bcb34c588..aeb5c2380ca103b7bbbb368fcc70bcc02bc414a2 100644 (file)
@@ -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. */
index b89a411c56db73fe1f0208db97a5e3d3c07b5060..34ee4fe74de48b2a731425be57d442c7450c6b13 100644 (file)
@@ -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=<number>    show <num> 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=<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"
@@ -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
 }