valgrind: r3818 - in trunk/coregrind: . m_syscalls

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

valgrind: r3818 - in trunk/coregrind: . m_syscalls

svn-2
Author: sewardj
Date: 2005-05-31 00:52:47 +0100 (Tue, 31 May 2005)
New Revision: 3818

Modified:
   trunk/coregrind/m_debuglog.c
   trunk/coregrind/m_syscalls/syscalls.c
   trunk/coregrind/pub_core_debuglog.h
   trunk/coregrind/vg_main.c
Log:
debug-logging (-d) totally didn't work when one Valgrindified process
exec's another.  This commit fixes it.



Modified: trunk/coregrind/m_debuglog.c
===================================================================
--- trunk/coregrind/m_debuglog.c 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/m_debuglog.c 2005-05-30 23:52:47 UTC (rev 3818)
@@ -449,8 +449,8 @@
 
 static Int loglevel = 0;
 
+/* Module startup. */
 /* EXPORTED */
-/* Module startup. */
 void VG_(debugLog_startup) ( Int level, HChar* who )
 {
    if (level < 0)  level = 0;
@@ -462,6 +462,16 @@
                  who, loglevel);
 }
 
+/* Get the logging threshold level, as set by the most recent call to
+   VG_(debugLog_startup), or zero if there have been no such calls so
+   far. */
+/* EXPORTED */
+Int VG_(debugLog_getLevel) ( void )
+{
+   return loglevel;
+}
+
+
 /* ------------ */
 
 typedef

Modified: trunk/coregrind/m_syscalls/syscalls.c
===================================================================
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:52:47 UTC (rev 3818)
@@ -29,6 +29,7 @@
 */
 
 #include "core.h"
+#include "pub_core_debuglog.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_stacktrace.h"
 #include "pub_core_syscalls.h"
@@ -964,10 +965,17 @@
       }
       return False;
    }
-   else if (soft && fd >= VG_(fd_soft_limit)) {
+   else
+   if (soft && fd >= VG_(fd_soft_limit)) {
       return False;
    }
-   return True;
+   else
+   if (fd == 2 && VG_(debugLog_getLevel)() > 0) {
+      return False;
+   }
+   else {
+      return True;
+   }
 }
 
 
@@ -2369,6 +2377,8 @@
       path = VG_(build_child_exename)();
    }
 
+   VG_(debugLog)(1, "syscalls", "Exec of %s\n", (HChar*)ARG1);
+
    if (0) {
       Char **cpp;
 

Modified: trunk/coregrind/pub_core_debuglog.h
===================================================================
--- trunk/coregrind/pub_core_debuglog.h 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/pub_core_debuglog.h 2005-05-30 23:52:47 UTC (rev 3818)
@@ -58,6 +58,14 @@
 extern
 void VG_(debugLog_startup) ( Int level, HChar* who );
 
+
+/* Get the logging threshold level, as set by the most recent call to
+   VG_(debugLog_startup), or zero if there have been no such calls so
+   far. */
+extern
+Int VG_(debugLog_getLevel) ( void );
+
+
 /* Send debugging output.  Nothing happens unless 'level'
    does not exceed the logging threshold level. */
 extern
@@ -65,6 +73,7 @@
 void VG_(debugLog) ( Int level, const HChar* modulename,
                                 const HChar* format, ... );
 
+
 /* A simple vprintf().  For each emitted byte, (*send) is called with
    that byte, and 'send_arg2' as its second param. */
 extern

Modified: trunk/coregrind/vg_main.c
===================================================================
--- trunk/coregrind/vg_main.c 2005-05-30 23:20:51 UTC (rev 3817)
+++ trunk/coregrind/vg_main.c 2005-05-30 23:52:47 UTC (rev 3818)
@@ -2480,17 +2480,17 @@
       "-d"s were specified.  This is a pre-scan of the command line. */
    loglevel = 0;
    for (i = 1; i < argc; i++) {
-     if (argv[i][0] != '-')
-        break;
-     if (0 == local_strcmp(argv[i], "--"))
-        break;
-     if (0 == local_strcmp(argv[i], "-d"))
-        loglevel++;
+      if (argv[i][0] != '-')
+         break;
+      if (0 == local_strcmp(argv[i], "--"))
+         break;
+      if (0 == local_strcmp(argv[i], "-d"))
+         loglevel++;
    }
 
    /* ... and start the debug logger.  Now we can safely emit logging
       messages all through startup. */
-   VG_(debugLog_startup)(loglevel, "Stage 2");
+   VG_(debugLog_startup)(loglevel, "Stage 2 (main)");
 
    //============================================================
    // Command line argument handling order:
@@ -2540,6 +2540,22 @@
    get_command_line(argc, argv, &vg_argc, &vg_argv, &cl_argv);
    pre_process_cmd_line_options(&need_help, &tool, &exec);
 
+   /* If this process was created by exec done by another Valgrind
+      process, the arguments will only show up at this point.  Hence
+      we need to also snoop around in vg_argv to see if anyone is
+      asking for debug logging. */
+   if (loglevel == 0) {
+      for (i = 1; i < vg_argc; i++) {
+         if (vg_argv[i][0] != '-')
+            break;
+         if (0 == local_strcmp(vg_argv[i], "--"))
+            break;
+         if (0 == local_strcmp(vg_argv[i], "-d"))
+            loglevel++;
+      }
+      VG_(debugLog_startup)(loglevel, "Stage 2 (second go)");
+   }
+
    //==============================================================
    // Nb: once a tool is specified, the tool.so must be loaded even if
    // they specified --help or didn't specify a client program.



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers