This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch, testsuite] store memory address in unsigned type
- From: Yao Qi <yao at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 13 May 2011 19:06:52 +0800
- Subject: [patch, testsuite] store memory address in unsigned type
In gdb.trace/tfile.c:add_memory_block(), we store memory address in
long, and assign (extend) to long long. It is not correct if the MSB of
address is 1, and signed extension will fill the upper 32-bit of long
long with 1, which is not what we want here.
This patch is to use unsigned type. OK?
--
Yao (éå)
gdb/testsuite/
2011-05-13 Yao Qi <yao@codesourcery.com>
* gdb.trace/tfile.c (add_memory_block): Store address in unsigned
type.
Index: testsuite/gdb.trace/tfile.c
===================================================================
--- testsuite/gdb.trace/tfile.c (revision 325446)
+++ testsuite/gdb.trace/tfile.c (working copy)
@@ -49,13 +49,13 @@
add_memory_block (char *addr, int size)
{
short short_x;
- long long ll_x;
+ unsigned long long ll_x;
*((char *) trptr) = 'M';
trptr += 1;
- ll_x = (long) addr;
- memcpy (trptr, &ll_x, sizeof (long long));
- trptr += sizeof (long long);
+ ll_x = (unsigned long) addr;
+ memcpy (trptr, &ll_x, sizeof (unsigned long long));
+ trptr += sizeof (unsigned long long);
short_x = size;
memcpy (trptr, &short_x, 2);
trptr += 2;