[ob] Fix valgrind warnings for amd64
Daniel Jacobowitz
drow@false.org
Tue Mar 27 15:34:00 GMT 2007
If you start GDB with an amd64 binary and set a breakpoint, valgrind
spews out a few pages of errors. It was not easy to track this down,
since valgrind is not very helpful about conditional moves - it does
not consider them to be a control transfer, so the warning doesn't
appear until much later on.
Anyway, the problem was "if (cache.frameless_p)" in
amd64_skip_prologue. The other two uses of a cache zalloc it and set
defaults, but that one didn't. The obvious fix is to use the same
initialization code; memset would not be right since frameless_p
should default to 1.
Tested on amd64-linux, no changes, and committed.
--
Daniel Jacobowitz
CodeSourcery
2007-03-27 Daniel Jacobowitz <dan@codesourcery.com>
* amd64-tdep.c (amd64_init_frame_cache): New function.
(amd64_alloc_frame_cache, amd64_skip_prologue): Use it.
--- amd64-tdep.c (revision 348)
+++ amd64-tdep.c (local)
@@ -726,16 +726,13 @@ struct amd64_frame_cache
int frameless_p;
};
-/* Allocate and initialize a frame cache. */
+/* Initialize a frame cache. */
-static struct amd64_frame_cache *
-amd64_alloc_frame_cache (void)
+static void
+amd64_init_frame_cache (struct amd64_frame_cache *cache)
{
- struct amd64_frame_cache *cache;
int i;
- cache = FRAME_OBSTACK_ZALLOC (struct amd64_frame_cache);
-
/* Base address. */
cache->base = 0;
cache->sp_offset = -8;
@@ -749,7 +746,17 @@ amd64_alloc_frame_cache (void)
/* Frameless until proven otherwise. */
cache->frameless_p = 1;
+}
+/* Allocate and initialize a frame cache. */
+
+static struct amd64_frame_cache *
+amd64_alloc_frame_cache (void)
+{
+ struct amd64_frame_cache *cache;
+
+ cache = FRAME_OBSTACK_ZALLOC (struct amd64_frame_cache);
+ amd64_init_frame_cache (cache);
return cache;
}
@@ -810,6 +817,7 @@ amd64_skip_prologue (CORE_ADDR start_pc)
struct amd64_frame_cache cache;
CORE_ADDR pc;
+ amd64_init_frame_cache (&cache);
pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffffLL, &cache);
if (cache.frameless_p)
return start_pc;
More information about the Gdb-patches
mailing list