This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Avoid internal error in paddress
- From: "Pierre Muller" <muller at ics dot u-strasbg dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 8 Jul 2009 10:02:53 +0200
- Subject: [RFA] Avoid internal error in paddress
I reported an internal error
in gdbtui at startup
concerning the recently modified paddress function:
http://sourceware.org/ml/gdb/2009-07/msg00052.html
I suspect that this internal error could bite
us elsewhere, this is why I propose the following patch:
Pierre Muller
Pascal language support maintainer for GDB
Tested on gcc16 Compiler Farm:
the changes found do not seem to be related to the patch...
< Test Run By muller on Wed Jul 8 09:44:56 2009 (without patch)
---
> Test Run By muller on Wed Jul 8 09:17:05 2009 (with patch)
3512c3512
< PASS: gdb.base/foll-fork.exp: set follow child, hit tbreak
---
> FAIL: gdb.base/foll-fork.exp: (timeout) set follow child, hit tbreak
3524c3524
< PASS: gdb.base/foll-fork.exp: set follow parent, hit tbreak
---
> FAIL: gdb.base/foll-fork.exp: (timeout) set follow parent, hit tbreak
2009-07-08 Pierre Muller <muller@ics.u-strasbg.fr>
* utils.c (paddress): Handle case of NULL GDBARCH parameter.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.213
diff -u -p -r1.213 utils.c
--- utils.c 2 Jul 2009 17:21:07 -0000 1.213
+++ utils.c 8 Jul 2009 07:04:20 -0000
@@ -2859,7 +2859,12 @@ paddress (struct gdbarch *gdbarch, CORE_
either zero or sign extended. Should gdbarch_address_to_pointer or
some ADDRESS_TO_PRINTABLE() be used to do the conversion? */
- int addr_bit = gdbarch_addr_bit (gdbarch);
+ int addr_bit;
+ /* Avoid internal error by using CORE_ADDR size if gdbarch is NULL. */
+ if (gdbarch)
+ addr_bit = gdbarch_addr_bit (gdbarch);
+ else
+ addr_bit = sizeof (CORE_ADDR) * HOST_CHAR_BIT;
if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
addr &= ((CORE_ADDR) 1 << addr_bit) - 1;