From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [RFC PATCH] Appease Valgrind over ptrace calls.
Date: Thu, 14 Feb 2013 18:38:00 -0000 [thread overview]
Message-ID: <20130214183800.4809.80774.stgit@brno.lan> (raw)
Trying out Valgrind on gdbserver, on x86_64, I get these annoying warnings:
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x430FB2: x86_linux_update_xmltarget (linux-x86-low.c:1250)
==3987== by 0x4310F7: x86_linux_process_qsupported (linux-x86-low.c:1304)
==3987== by 0x42BD07: linux_process_qsupported (linux-low.c:5253)
==3987== by 0x40CF75: handle_query (server.c:1571)
==3987== by 0x41045E: process_serial_event (server.c:2930)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
==3987== by 0x410137: main (server.c:2781)
==3987==
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x431009: x86_linux_update_xmltarget (linux-x86-low.c:1258)
==3987== by 0x4310F7: x86_linux_process_qsupported (linux-x86-low.c:1304)
==3987== by 0x42BD07: linux_process_qsupported (linux-low.c:5253)
==3987== by 0x40CF75: handle_query (server.c:1571)
==3987== by 0x41045E: process_serial_event (server.c:2930)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
==3987== by 0x410137: main (server.c:2781)
==3987==
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x435AD9: i387_xsave_to_cache (i387-fp.c:477)
==3987== by 0x42FD67: x86_store_xstateregset (linux-x86-low.c:353)
==3987== by 0x42A01C: regsets_fetch_inferior_registers (linux-low.c:4063)
==3987== by 0x42A7FC: linux_fetch_registers (linux-low.c:4355)
==3987== by 0x40675B: get_thread_regcache (regcache.c:50)
==3987== by 0x408D0F: prepare_resume_reply (remote-utils.c:1337)
==3987== by 0x40F5CC: handle_status (server.c:2372)
==3987== by 0x41077F: process_serial_event (server.c:3029)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
It seems like Valgrind doesn't understand that ptrace writes to the
buffers in question, so throws out false positives.
Valgrind on GDB spews out equivalent warnings.
This patch works around it in gdbserver. Is there a better way to do
this perhaps?
Hmm, nut, I'm now wondering why we don't see many more ptrace-related
warnings in other cases. Maybe Valgrind does know about ptrace, but
not about PTRACE_GETREGSET?
gdb/gdbserver/
2013-02-14 Pedro Alves <palves@redhat.com>
* linux-low.c (regsets_fetch_inferior_registers)
---
gdb/gdbserver/linux-low.c | 6 ++++--
gdb/gdbserver/linux-x86-low.c | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c52cd2e..00214da 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4022,7 +4022,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache)
continue;
}
- buf = xmalloc (regset->size);
+ /* Zero out the buffer to appease Valgrind. */
+ buf = xcalloc (1, regset->size);
nt_type = regset->nt_type;
if (nt_type)
@@ -4092,7 +4093,8 @@ regsets_store_inferior_registers (struct regcache *regcache)
continue;
}
- buf = xmalloc (regset->size);
+ /* Zero out the buffer to appease Valgrind. */
+ buf = xcalloc (1, regset->size);
/* First fill the buffer with the current register set contents,
in case there are any items in the kernel's regset that are
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 31657d3..604ecd6 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -1224,7 +1224,9 @@ x86_linux_update_xmltarget (void)
/* Check if XSAVE extended state is supported. */
if (have_ptrace_getregset == -1)
{
- unsigned long long xstateregs[I386_XSTATE_SSE_SIZE / sizeof (long long)];
+ /* Zeroed out to appease Valgrind. */
+ unsigned long long
+ xstateregs[I386_XSTATE_SSE_SIZE / sizeof (long long)] = {0};
struct iovec iov;
iov.iov_base = xstateregs;
next reply other threads:[~2013-02-14 18:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-14 18:38 Pedro Alves [this message]
2013-02-14 18:41 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130214183800.4809.80774.stgit@brno.lan \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox