You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
|
|
2
|
3
|
4
|
5
(4) |
6
(3) |
7
(3) |
8
(2) |
|
9
(1) |
10
(1) |
11
(2) |
12
(2) |
13
(3) |
14
(7) |
15
(2) |
|
16
|
17
|
18
(1) |
19
|
20
(4) |
21
(1) |
22
(1) |
|
23
|
24
|
25
(2) |
26
(1) |
27
(2) |
28
(2) |
29
(1) |
|
From: Paul F. <pj...@wa...> - 2020-02-08 19:43:49
|
> On 7 Feb 2020, at 16:57, Paul Floyd <pj...@wa...> wrote:
>
>
>
>> On 14 Mar 2019, at 19:16, Ed Maste <em...@fr...> wrote:
>>
>> On Thu, 14 Mar 2019 at 11:20, Tom Hughes <tom...@so...> wrote:
>>>
>>> commit 09566120e705d8831aaa7076b439d3ad90b78773
>>> Author: Tom Hughes <to...@co...>
>>> Date: Thu Mar 14 15:15:41 2019 +0000
>>>
>>> Suppress FSGSBASE flag from cpuid results
>>>
>>> We don't support {rd,wr}{fs,gs}base so we shouldn't say we do.
>>
>> Thanks, I have rebased the FreeBSD patch set on master now and the
>> test results are consistent with earlier runs.
>>
>
>
> Hi
>
> Since I have a bit of free time on my hands (one more week in theory), I’ve also been looking at the FreeBSD port of Valgrind.
>
> Has any work been done on this since last March?
>
> I now have FreeBSD 12.1 reinstalled with Phil Longstaff’s work plus a few of my changes. It seems to work at least for trivial tests - I haven’t yet tried running the regression tests.
>
> At the moment there are 4 things that I see that I need to do
>
> 1. Rebase everything onto the main Valgrind development branch
> 2. I’ve noticed that there is a big issue with clang compiled executables. The problem is that the binaries have 3 PT_LOAD sections (ro, rx, rw) while GCC (and clang on Linux) only generates 2 (rw and rx). This is causing symtab loading to fail. This limits the usefulness somewhat.
> 3. There were a lot of syscall changes in FreeBSD 12, so I think that ‘configure’ needs to handle/define a freebsd_version variable.
> 4. There are still quite a few missing syscalls.
An update on this
1. I’ve done the rebase. That was fun. Looks like most of the regtests are failing though, and there seems to be an issue with reading semaphores.
2. I’m still seeing this problem, though I’ve seen that Mark Wielaard made a change that should that looks like it should fix this. I’ll look at that next.
3 and 4. No progress yet.
A+
Paul
|
|
From: Philippe W. <phi...@so...> - 2020-02-08 13:49:08
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=fe9c80daa266558eb357025822dcde3b74b8a4be commit fe9c80daa266558eb357025822dcde3b74b8a4be Author: Philippe Waroquiers <phi...@sk...> Date: Sat Feb 8 13:01:24 2020 +0100 Add option -T to vgdb to output timestamps in vgdb information/error messages Also cleanup some trailink blanks. Diff: --- NEWS | 2 + coregrind/vgdb-invoker-none.c | 8 +-- coregrind/vgdb-invoker-ptrace.c | 86 ++++++++++++++++---------------- coregrind/vgdb.c | 108 +++++++++++++++++++++++----------------- coregrind/vgdb.h | 25 ++++++---- docs/xml/manual-core-adv.xml | 7 +++ 6 files changed, 135 insertions(+), 101 deletions(-) diff --git a/NEWS b/NEWS index c9ec9fa..79b3d7c 100644 --- a/NEWS +++ b/NEWS @@ -53,6 +53,8 @@ support for X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux. * New and modified GDB server monitor features: + - Option -T tells vgdb to output a timestamp in the vgdb information messages. + - The gdbserver monitor commands that require an address and an optional length argument now accepts the alternate 'C like' syntax "address[length]". For example, the memcheck command "monitor who_points_at 0x12345678 120" diff --git a/coregrind/vgdb-invoker-none.c b/coregrind/vgdb-invoker-none.c index 8acf9e0..561638d 100644 --- a/coregrind/vgdb-invoker-none.c +++ b/coregrind/vgdb-invoker-none.c @@ -31,10 +31,10 @@ void invoker_restrictions_msg(void) { - fprintf(stderr, - "Note: vgdb invoker not implemented on this platform.\n" - "For more info: read user manual section" - " 'Limitations of the Valgrind gdbserver'.\n"); + TSFPRINTF(stderr, + "Note: vgdb invoker not implemented on this platform.\n" + "For more info: read user manual section" + " 'Limitations of the Valgrind gdbserver'.\n"); } void invoker_cleanup_restore_and_detach(void *v_pid) diff --git a/coregrind/vgdb-invoker-ptrace.c b/coregrind/vgdb-invoker-ptrace.c index 5a4104e..cb37677 100644 --- a/coregrind/vgdb-invoker-ptrace.c +++ b/coregrind/vgdb-invoker-ptrace.c @@ -110,20 +110,20 @@ int ptrace_read_memory (pid_t inferior_pid, CORE_ADDR memaddr, /* Allocate buffer of that many longwords. */ register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); - + /* Read all the longwords */ for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, + buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0); if (errno) return errno; } - + /* Copy appropriate bytes out of the buffer. */ - memcpy (myaddr, + memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), len); - + return 0; } @@ -133,7 +133,7 @@ int ptrace_read_memory (pid_t inferior_pid, CORE_ADDR memaddr, returns the value of errno. */ __attribute__((unused)) /* not used on all platforms */ static -int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, +int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, const void *myaddr, size_t len) { register int i; @@ -141,24 +141,24 @@ int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE); /* Round ending address up; get number of longwords that makes. */ register int count - = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) + = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) / sizeof (PTRACE_XFER_TYPE); /* Allocate buffer of that many longwords. */ - register PTRACE_XFER_TYPE *buffer + register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); - + if (debuglevel >= 1) { DEBUG (1, "Writing "); for (i = 0; i < len; i++) PDEBUG (1, "%02x", ((const unsigned char*)myaddr)[i]); PDEBUG(1, " to %p\n", (void *) memaddr); } - + /* Fill start and end extra bytes of buffer with existing memory data. */ - + buffer[0] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0); - + if (count > 1) { buffer[count - 1] = ptrace (PTRACE_PEEKTEXT, inferior_pid, @@ -166,22 +166,22 @@ int ptrace_write_memory (pid_t inferior_pid, CORE_ADDR memaddr, * sizeof (PTRACE_XFER_TYPE)), 0); } - + /* Copy data to be written over corresponding part of buffer */ - - memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), + + memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), myaddr, len); - + /* Write the entire buffer. */ - + for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - ptrace (PTRACE_POKETEXT, inferior_pid, + ptrace (PTRACE_POKETEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]); if (errno) return errno; } - + return 0; } @@ -209,18 +209,18 @@ HChar* name_of_ThreadStatus ( ThreadStatus status ) } } -static +static char *status_image (int status) { static char result[256]; // large enough int sz = 0; #define APPEND(...) sz += snprintf (result+sz, 256 - sz - 1, __VA_ARGS__) - + result[0] = 0; if (WIFEXITED(status)) APPEND ("WIFEXITED %d ", WEXITSTATUS(status)); - + if (WIFSIGNALED(status)) { APPEND ("WIFSIGNALED %d ", WTERMSIG(status)); if (WCOREDUMP(status)) APPEND ("WCOREDUMP "); @@ -259,10 +259,10 @@ Bool waitstopped (pid_t pid, int signal_expected, const char *msg) DEBUG(1, "waitstopped %s before waitpid signal_expected %d\n", msg, signal_expected); p = waitpid(pid, &status, __WALL); - DEBUG(1, "after waitpid pid %d p %d status 0x%x %s\n", pid, p, + DEBUG(1, "after waitpid pid %d p %d status 0x%x %s\n", pid, p, status, status_image (status)); if (p != pid) { - ERROR(errno, "%s waitpid pid %d in waitstopped %d status 0x%x %s\n", + ERROR(errno, "%s waitpid pid %d in waitstopped %d status 0x%x %s\n", msg, pid, p, status, status_image (status)); return False; } @@ -300,7 +300,7 @@ Bool waitstopped (pid_t pid, int signal_expected, const char *msg) // realloc a bigger queue, and store new signal at the end. // This is not very efficient but we assume not many sigs are queued. signal_queue_sz++; - signal_queue = vrealloc(signal_queue, + signal_queue = vrealloc(signal_queue, sizeof(siginfo_t) * signal_queue_sz); newsiginfo = signal_queue + (signal_queue_sz - 1); @@ -340,7 +340,7 @@ Bool stop (pid_t pid, const char *msg) ERROR(errno, "%s SIGSTOP pid %d %ld\n", msg, pid, res); return False; } - + return waitstopped (pid, SIGSTOP, msg); } @@ -354,7 +354,7 @@ Bool attach (pid_t pid, const char *msg) long res; static Bool output_error = True; static Bool initial_attach = True; - // For a ptrace_scope protected system, we do not want to output + // For a ptrace_scope protected system, we do not want to output // repetitively attach error. We will output once an error // for the initial_attach. Once the 1st attach has succeeded, we // again show all errors. @@ -375,7 +375,7 @@ Bool attach (pid_t pid, const char *msg) return waitstopped(pid, SIGSTOP, msg); } -/* once we are attached to the pid, get the list of threads and stop +/* once we are attached to the pid, get the list of threads and stop them all. Returns True if all threads properly suspended, False otherwise. */ static @@ -420,7 +420,7 @@ Bool acquire_and_suspend_threads (pid_t pid) ERROR(rw, "status ptrace_read_memory\n"); return False; } - + rw = ptrace_read_memory(pid, vgt+off_lwpid, &(vgdb_threads[i].lwpid), sizeof(Int)); @@ -428,14 +428,14 @@ Bool acquire_and_suspend_threads (pid_t pid) ERROR(rw, "lwpid ptrace_read_memory\n"); return False; } - + if (vgdb_threads[i].status != VgTs_Empty) { DEBUG(1, "found tid %d status %s lwpid %d\n", i, name_of_ThreadStatus(vgdb_threads[i].status), vgdb_threads[i].lwpid); nr_live_threads++; if (vgdb_threads[i].lwpid <= 1) { - if (vgdb_threads[i].lwpid == 0 + if (vgdb_threads[i].lwpid == 0 && vgdb_threads[i].status == VgTs_Init) { DEBUG(1, "not set lwpid tid %d status %s lwpid %d\n", i, name_of_ThreadStatus(vgdb_threads[i].status), @@ -455,7 +455,7 @@ Bool acquire_and_suspend_threads (pid_t pid) pid_found = True; } else { if (!attach(vgdb_threads[i].lwpid, "attach_thread")) { - ERROR(0, "ERROR attach pid %d tid %d\n", + ERROR(0, "ERROR attach pid %d tid %d\n", vgdb_threads[i].lwpid, i); return False; } @@ -483,7 +483,7 @@ void detach_from_all_threads (pid_t pid) if (vgdb_threads[i].status == VgTs_Init && vgdb_threads[i].lwpid == 0) { DEBUG(1, "skipping PTRACE_DETACH pid %d tid %d status %s\n", - vgdb_threads[i].lwpid, i, + vgdb_threads[i].lwpid, i, name_of_ThreadStatus (vgdb_threads[i].status)); } else { if (vgdb_threads[i].lwpid == pid) { @@ -491,11 +491,11 @@ void detach_from_all_threads (pid_t pid) pid_found = True; } DEBUG(1, "PTRACE_DETACH pid %d tid %d status %s\n", - vgdb_threads[i].lwpid, i, + vgdb_threads[i].lwpid, i, name_of_ThreadStatus (vgdb_threads[i].status)); res = ptrace (PTRACE_DETACH, vgdb_threads[i].lwpid, NULL, NULL); if (res != 0) { - ERROR(errno, "PTRACE_DETACH pid %d tid %d status %s res %ld\n", + ERROR(errno, "PTRACE_DETACH pid %d tid %d status %s res %ld\n", vgdb_threads[i].lwpid, i, name_of_ThreadStatus (vgdb_threads[i].status), res); @@ -544,7 +544,7 @@ static int has_working_ptrace_getregset = -1; #endif /* Get the registers from pid into regs. - regs_bsz value gives the length of *regs. + regs_bsz value gives the length of *regs. Returns True if all ok, otherwise False. */ static Bool getregs (pid_t pid, void *regs, long regs_bsz) @@ -660,7 +660,7 @@ Bool getregs (pid_t pid, void *regs, long regs_bsz) } /* Set the registers of pid to regs. - regs_bsz value gives the length of *regs. + regs_bsz value gives the length of *regs. Returns True if all ok, otherwise False. */ static Bool setregs (pid_t pid, void *regs, long regs_bsz) @@ -885,8 +885,8 @@ Bool invoker_invoke_gdbserver (pid_t pid) sp = sp - regsize; DEBUG(1, "push check arg ptrace_write_memory\n"); assert(regsize == sizeof(check)); - rw = ptrace_write_memory(pid, sp, - &check, + rw = ptrace_write_memory(pid, sp, + &check, regsize); if (rw != 0) { ERROR(rw, "push check arg ptrace_write_memory"); @@ -898,7 +898,7 @@ Bool invoker_invoke_gdbserver (pid_t pid) DEBUG(1, "push bad_return return address ptrace_write_memory\n"); // Note that for a 64 bits vgdb, only 4 bytes of NULL bad_return // are written. - rw = ptrace_write_memory(pid, sp, + rw = ptrace_write_memory(pid, sp, &bad_return, regsize); if (rw != 0) { @@ -1070,7 +1070,7 @@ Bool invoker_invoke_gdbserver (pid_t pid) else { assert(0); } - + if (!setregs(pid, &user_mod.regs, sizeof(user_mod.regs))) { detach_from_all_threads(pid); return False; @@ -1080,9 +1080,9 @@ Bool invoker_invoke_gdbserver (pid_t pid) must restore the registers in case of cleanup. */ pid_of_save_regs = pid; pid_of_save_regs_continued = False; - - /* We PTRACE_CONT-inue pid. + + /* We PTRACE_CONT-inue pid. Either gdbserver will be invoked directly (if all threads are interruptible) or gdbserver will be called soon by the scheduler. In the first case, diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c index 8d21359..745fe32 100644 --- a/coregrind/vgdb.c +++ b/coregrind/vgdb.c @@ -67,9 +67,28 @@ */ int debuglevel; -struct timeval dbgtv; +Bool timestamp = False; +char timestamp_out[20]; static char *vgdb_prefix = NULL; +char *timestamp_str (Bool produce) +{ + static char out[50]; + char *ptr; + struct timeval dbgtv; + struct tm *ts_tm; + + if (produce) { + gettimeofday(&dbgtv, NULL); + ts_tm = localtime(&dbgtv.tv_sec); + ptr = out + strftime(out, sizeof(out), "%H:%M:%S", ts_tm); + sprintf(ptr, ".%6.6ld ", dbgtv.tv_usec); + } else { + out[0] = 0; + } + return out; +} + /* Will be set to True when any condition indicating we have to shutdown is encountered. */ Bool shutting_down = False; @@ -488,8 +507,7 @@ void wait_for_gdb_connect(int in_port) if (-1 == bind(listen_gdb, (struct sockaddr *)&addr, sizeof(addr))) { XERROR(errno, "bind failed"); } - fprintf(stderr, "listening on port %d ...", in_port); - fflush(stderr); + TSFPRINTF(stderr, "listening on port %d ...", in_port); if (-1 == listen(listen_gdb, 1)) { XERROR(errno, "error listen failed"); } @@ -570,7 +588,7 @@ readchar(int fd) if (bufcnt <= 0) { if (bufcnt == 0) { - fprintf(stderr, "readchar: Got EOF\n"); + TSFPRINTF(stderr, "readchar: Got EOF\n"); return -2; } else { ERROR(errno, "readchar\n"); @@ -636,8 +654,8 @@ getpkt(char *buf, int fromfd, int ackfd) if (csum == (c1 << 4) + c2) break; - fprintf(stderr, "Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", - (c1 << 4) + c2, csum, buf); + TSFPRINTF(stderr, "Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", + (c1 << 4) + c2, csum, buf); if (write(ackfd, "-", 1) != 1) ERROR(0, "error when writing - (nack)\n"); else @@ -822,8 +840,7 @@ void gdb_relay(int pid) int to_pid = -1; /* fd to write to pid */ int shutdown_loop = 0; - fprintf(stderr, "relaying data between gdb and process %d\n", pid); - fflush(stderr); + TSFPRINTF(stderr, "relaying data between gdb and process %d\n", pid); if (max_invoke_ms > 0) pthread_create(&invoke_gdbserver_in_valgrind_thread, NULL, @@ -986,8 +1003,7 @@ void standalone_send_commands(int pid, } for (nc = 0; nc <= last_command; nc++) { - fprintf(stderr, "sending command %s to pid %d\n", commands[nc], pid); - fflush(stderr); + TSFPRINTF(stderr, "sending command %s to pid %d\n", commands[nc], pid); /* prepare hexcommand $qRcmd,xxxx....................xx#cc */ hexcommand = vmalloc(packet_len_for_command(commands[nc])); @@ -1077,7 +1093,7 @@ void report_pid(int pid, Bool on_stdout) int fd, i; FILE *out = on_stdout ? stdout : stderr; - fprintf(out, "use --pid=%d for ", pid); + TSFPRINTF(out, "use --pid=%d for ", pid); sprintf(cmdline_file, "/proc/%d/cmdline", pid); fd = open(cmdline_file, O_RDONLY); @@ -1121,7 +1137,7 @@ void usage(void) " OPTIONS are [--pid=<number>] [--vgdb-prefix=<prefix>]\n" " [--wait=<number>] [--max-invoke-ms=<number>]\n" " [--port=<portnr>\n" -" [--cmd-time-out=<number>] [-l] [-D] [-d]\n" +" [--cmd-time-out=<number>] [-l] [-T] [-D] [-d]\n" " \n" " --pid arg must be given if multiple Valgrind gdbservers are found.\n" " --vgdb-prefix arg must be given to both Valgrind and vgdb utility\n" @@ -1136,6 +1152,7 @@ void usage(void) " --cmd-time-out (default 99999999) tells vgdb to exit if the found Valgrind\n" " gdbserver has not processed a command after number seconds\n" " -l arg tells to show the list of running Valgrind gdbserver and then exit.\n" +" -T arg tells to add timestamps to vgdb information messages.\n" " -D arg tells to show shared mem status and then exit.\n" " -d arg tells to show debug info. Multiple -d args for more debug info\n" "\n" @@ -1165,7 +1182,7 @@ int search_arg_pid(int arg_pid, int check_trials, Bool show_list) int pid = -1; if (arg_pid == 0 || arg_pid < -1) { - fprintf(stderr, "vgdb error: invalid pid %d given\n", arg_pid); + TSFPRINTF(stderr, "vgdb error: invalid pid %d given\n", arg_pid); exit(1); } else { /* search for a matching named fifo. @@ -1251,7 +1268,7 @@ int search_arg_pid(int arg_pid, int check_trials, Bool show_list) } } else if (nr_valid_pid > 1) { if (nr_valid_pid == 2) { - fprintf + TSFPRINTF (stderr, "no --pid= arg given" " and multiple valgrind pids found:\n"); @@ -1284,10 +1301,10 @@ int search_arg_pid(int arg_pid, int check_trials, Bool show_list) exit(1); } else if (pid == -1) { if (arg_pid == -1) - fprintf(stderr, "vgdb error: no FIFO found and no pid given\n"); + TSFPRINTF(stderr, "vgdb error: no FIFO found and no pid given\n"); else - fprintf(stderr, "vgdb error: no FIFO found matching pid %d\n", - arg_pid); + TSFPRINTF(stderr, "vgdb error: no FIFO found matching pid %d\n", + arg_pid); exit(1); } else if (pid == -2) { @@ -1369,35 +1386,37 @@ void parse_options(int argc, char** argv, show_shared_mem = True; } else if (is_opt(argv[i], "-l")) { show_list = True; + } else if (is_opt(argv[i], "-T")) { + timestamp = True; } else if (is_opt(argv[i], "--pid=")) { int newpid; if (!numeric_val(argv[i], &newpid)) { - fprintf(stderr, "invalid --pid argument %s\n", argv[i]); + TSFPRINTF(stderr, "invalid --pid argument %s\n", argv[i]); arg_errors++; } else if (arg_pid != -1) { - fprintf(stderr, "multiple --pid arguments given\n"); + TSFPRINTF(stderr, "multiple --pid arguments given\n"); arg_errors++; } else { arg_pid = newpid; } } else if (is_opt(argv[i], "--wait=")) { if (!numeric_val(argv[i], &check_trials)) { - fprintf(stderr, "invalid --wait argument %s\n", argv[i]); + TSFPRINTF(stderr, "invalid --wait argument %s\n", argv[i]); arg_errors++; } } else if (is_opt(argv[i], "--max-invoke-ms=")) { if (!numeric_val(argv[i], &max_invoke_ms)) { - fprintf(stderr, "invalid --max-invoke-ms argument %s\n", argv[i]); + TSFPRINTF(stderr, "invalid --max-invoke-ms argument %s\n", argv[i]); arg_errors++; } } else if (is_opt(argv[i], "--cmd-time-out=")) { if (!numeric_val(argv[i], &cmd_time_out)) { - fprintf(stderr, "invalid --cmd-time-out argument %s\n", argv[i]); + TSFPRINTF(stderr, "invalid --cmd-time-out argument %s\n", argv[i]); arg_errors++; } } else if (is_opt(argv[i], "--port=")) { if (!numeric_val(argv[i], &int_port)) { - fprintf(stderr, "invalid --port argument %s\n", argv[i]); + TSFPRINTF(stderr, "invalid --port argument %s\n", argv[i]); arg_errors++; } } else if (is_opt(argv[i], "--vgdb-prefix=")) { @@ -1407,7 +1426,7 @@ void parse_options(int argc, char** argv, commands[last_command] = vmalloc(1); commands[last_command][0] = '\0'; } else if (0 == strncmp(argv[i], "-", 1)) { - fprintf(stderr, "unknown or invalid argument %s\n", argv[i]); + TSFPRINTF(stderr, "unknown or invalid argument %s\n", argv[i]); arg_errors++; } else { int len; @@ -1424,7 +1443,7 @@ void parse_options(int argc, char** argv, strcat(commands[last_command], " "); strcat(commands[last_command], argv[i]); if (packet_len_for_command(commands[last_command]) > PBUFSIZ) { - fprintf(stderr, "command %s too long\n", commands[last_command]); + TSFPRINTF(stderr, "command %s too long\n", commands[last_command]); arg_errors++; } @@ -1440,38 +1459,38 @@ void parse_options(int argc, char** argv, && int_port == 0 && last_command == -1) { arg_errors++; - fprintf(stderr, - "Using vgdb standalone implies to give -D or -l or a COMMAND\n"); + TSFPRINTF(stderr, + "Using vgdb standalone implies to give -D or -l or a COMMAND\n"); } if (show_shared_mem && show_list) { arg_errors++; - fprintf(stderr, - "Can't use both -D and -l options\n"); + TSFPRINTF(stderr, + "Can't use both -D and -l options\n"); } if (max_invoke_ms > 0 && cmd_time_out != NEVER && (cmd_time_out * 1000) <= max_invoke_ms) { arg_errors++; - fprintf(stderr, - "--max-invoke-ms must be < --cmd-time-out * 1000\n"); + TSFPRINTF(stderr, + "--max-invoke-ms must be < --cmd-time-out * 1000\n"); } if (show_list && arg_pid != -1) { arg_errors++; - fprintf(stderr, - "Can't use both --pid and -l options\n"); + TSFPRINTF(stderr, + "Can't use both --pid and -l options\n"); } if (int_port > 0 && last_command != -1) { arg_errors++; - fprintf(stderr, - "Can't use --port to send commands\n"); + TSFPRINTF(stderr, + "Can't use --port to send commands\n"); } if (arg_errors > 0) { - fprintf(stderr, "args error. Try `vgdb --help` for more information\n"); + TSFPRINTF(stderr, "args error. Try `vgdb --help` for more information\n"); exit(1); } @@ -1520,15 +1539,14 @@ int main(int argc, char** argv) wait_for_gdb_connect(in_port); if (show_shared_mem) { - fprintf(stderr, - "vgdb %d " - "written_by_vgdb %d " - "seen_by_valgrind %d\n" - "vgdb pid %d\n", - VS_vgdb_pid, - VS_written_by_vgdb, - VS_seen_by_valgrind, - VS_vgdb_pid); + TSFPRINTF(stderr, + "vgdb %d " + "written_by_vgdb %d " + "seen_by_valgrind %d\n", + VS_vgdb_pid, + VS_written_by_vgdb, + VS_seen_by_valgrind); + TSFPRINTF(stderr, "vgdb pid %d\n", VS_vgdb_pid); exit(0); } diff --git a/coregrind/vgdb.h b/coregrind/vgdb.h index 4ca765e..0355329 100644 --- a/coregrind/vgdb.h +++ b/coregrind/vgdb.h @@ -35,14 +35,19 @@ #include <sys/types.h> +extern Bool timestamp; +extern char *timestamp_str (Bool produce); extern int debuglevel; -extern struct timeval dbgtv; -/* if level <= debuglevel, print timestamp, then print provided by debug info */ + +/* Optionally prints a timestamp, then prints the given info. This should + be used only at the beginning of a new line. */ +#define TSFPRINTF(stream, ...) ( \ + fprintf(stream, "%s", timestamp_str(timestamp)), \ + fprintf(stream, __VA_ARGS__),fflush(stream)) + +/* if level <= debuglevel, print timestamp, then prints provided debug info */ #define DEBUG(level, ...) (level <= debuglevel ? \ - gettimeofday(&dbgtv, NULL), \ - fprintf(stderr, "%ld.%6.6ld ", \ - (long int)dbgtv.tv_sec, \ - (long int)dbgtv.tv_usec), \ + fprintf(stderr, "%s", timestamp_str(True)), \ fprintf(stderr, __VA_ARGS__),fflush(stderr) \ : 0) @@ -51,15 +56,17 @@ extern struct timeval dbgtv; fprintf(stderr, __VA_ARGS__),fflush(stderr) \ : 0) -/* if errno != 0, +/* if errno != 0, report the errno and fprintf the ... varargs on stderr. */ #define ERROR(errno, ...) ((errno == 0 ? 0 : perror("syscall failed")), \ + fprintf(stderr, "%s", timestamp_str(timestamp)), \ fprintf(stderr, __VA_ARGS__), \ fflush(stderr)) /* same as ERROR, but also exits with status 1 */ #define XERROR(errno, ...) ((errno == 0 ? 0 : perror("syscall failed")), \ - fprintf(stderr, __VA_ARGS__), \ - fflush(stderr), \ + fprintf(stderr, "%s", timestamp_str(timestamp)), \ + fprintf(stderr, __VA_ARGS__), \ + fflush(stderr), \ exit(1)) /* Calls malloc (size). Exits if memory can't be allocated. */ diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index 362b916..e94a402 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -1264,6 +1264,13 @@ vgdb v.set log_output -c leak_check any </varlistentry> <varlistentry> + <term><option>-T</option></term> + <listitem><para>Instructs vgdb to add timestamps to vgdb + information messages. + </para></listitem> + </varlistentry> + + <varlistentry> <term><option>-D</option></term> <listitem><para>Instructs a standalone vgdb to show the state of the shared memory used by the Valgrind gdbserver. vgdb |