|
From: <sv...@va...> - 2005-05-30 23:52:52
|
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 @@
=20
static Int loglevel =3D 0;
=20
+/* Module startup. */
/* EXPORTED */
-/* Module startup. */
void VG_(debugLog_startup) ( Int level, HChar* who )
{
if (level < 0) level =3D 0;
@@ -462,6 +462,16 @@
who, loglevel);
}
=20
+/* 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;
+}
+
+
/* ------------ */
=20
typedef=20
Modified: trunk/coregrind/m_syscalls/syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:20:51 UTC (rev 38=
17)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-30 23:52:47 UTC (rev 38=
18)
@@ -29,6 +29,7 @@
*/
=20
#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 >=3D VG_(fd_soft_limit)) {
+ else=20
+ if (soft && fd >=3D VG_(fd_soft_limit)) {
return False;
}
- return True;
+ else=20
+ if (fd =3D=3D 2 && VG_(debugLog_getLevel)() > 0) {
+ return False;
+ }=20
+ else {
+ return True;
+ }
}
=20
=20
@@ -2369,6 +2377,8 @@
path =3D VG_(build_child_exename)();
}
=20
+ VG_(debugLog)(1, "syscalls", "Exec of %s\n", (HChar*)ARG1);
+
if (0) {
Char **cpp;
=20
Modified: trunk/coregrind/pub_core_debuglog.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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=20
void VG_(debugLog_startup) ( Int level, HChar* who );
=20
+
+/* 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'=20
does not exceed the logging threshold level. */
extern
@@ -65,6 +73,7 @@
void VG_(debugLog) ( Int level, const HChar* modulename,
const HChar* format, ... );
=20
+
/* 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D 0;
for (i =3D 1; i < argc; i++) {
- if (argv[i][0] !=3D '-')
- break;
- if (0 =3D=3D local_strcmp(argv[i], "--"))=20
- break;
- if (0 =3D=3D local_strcmp(argv[i], "-d"))=20
- loglevel++;
+ if (argv[i][0] !=3D '-')
+ break;
+ if (0 =3D=3D local_strcmp(argv[i], "--"))=20
+ break;
+ if (0 =3D=3D local_strcmp(argv[i], "-d"))=20
+ loglevel++;
}
=20
/* ... 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)");
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// 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);
=20
+ /* 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 =3D=3D 0) {
+ for (i =3D 1; i < vg_argc; i++) {
+ if (vg_argv[i][0] !=3D '-')
+ break;
+ if (0 =3D=3D local_strcmp(vg_argv[i], "--"))=20
+ break;
+ if (0 =3D=3D local_strcmp(vg_argv[i], "-d"))=20
+ loglevel++;
+ }
+ VG_(debugLog_startup)(loglevel, "Stage 2 (second go)");
+ }
+
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// Nb: once a tool is specified, the tool.so must be loaded even if=20
// they specified --help or didn't specify a client program.
|