aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2007-12-17 17:49:29 +0000
committerMaciej W. Rozycki <macro@linux-mips.org>2007-12-17 17:49:29 +0000
commit9544c605b634aa6fd72e24537c327dcce5f3a306 (patch)
treeaeffb183db2fe0b702b2525932df982cec9d4a7e
parentaa707ed0e50465d070ac4a5a8f03ef07c5042319 (diff)
downloadgdb-9544c605b634aa6fd72e24537c327dcce5f3a306.zip
gdb-9544c605b634aa6fd72e24537c327dcce5f3a306.tar.gz
gdb-9544c605b634aa6fd72e24537c327dcce5f3a306.tar.bz2
* utils.c (string_to_core_addr): If the executable format
indicates that addresses should be sign-extended and there are only 8 hex digits in the address, then do so. * Makefile.in (utils.o): Depend on $(gdbcore_h).
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/Makefile.in2
-rw-r--r--gdb/utils.c15
3 files changed, 24 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af73198..b5ba6da 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-17 Nigel Stephens <nigel@mips.com>
+ Maciej W. Rozycki <macro@mips.com>
+
+ * utils.c (string_to_core_addr): If the executable format
+ indicates that addresses should be sign-extended and there are
+ only 8 hex digits in the address, then do so.
+ * Makefile.in (utils.o): Depend on $(gdbcore_h).
+
2007-12-17 Chris Dearman <chris@mips.com>
* symfile.c (init_filename_language_table): Recognise .sx as
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 961b730..a46c9d4 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2903,7 +2903,7 @@ utils.o: utils.c $(defs_h) $(gdb_assert_h) $(gdb_string_h) $(event_top_h) \
$(exceptions_h) $(tui_h) $(gdbcmd_h) $(serial_h) $(bfd_h) \
$(target_h) $(demangle_h) $(expression_h) $(language_h) $(charset_h) \
$(annotate_h) $(filenames_h) $(symfile_h) $(inferior_h) $(top_h) \
- $(gdb_curses_h) $(readline_h) $(gdb_obstack_h)
+ $(gdb_curses_h) $(readline_h) $(gdb_obstack_h) $(gdbcore_h)
v850-tdep.o: v850-tdep.c $(defs_h) $(frame_h) $(frame_base_h) $(trad_frame_h) \
$(frame_unwind_h) $(dwarf2_frame_h) $(gdbtypes_h) $(inferior_h) \
$(gdb_string_h) $(gdb_assert_h) $(gdbcore_h) $(arch_utils_h) \
diff --git a/gdb/utils.c b/gdb/utils.c
index 3be084e..9e79626 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -52,6 +52,7 @@
#include "filenames.h"
#include "symfile.h"
#include "gdb_obstack.h"
+#include "gdbcore.h"
#include "top.h"
#include "inferior.h" /* for signed_pointer_to_address */
@@ -2824,7 +2825,9 @@ core_addr_to_string_nz (const CORE_ADDR addr)
CORE_ADDR
string_to_core_addr (const char *my_string)
{
+ int addr_bit = gdbarch_addr_bit (current_gdbarch);
CORE_ADDR addr = 0;
+
if (my_string[0] == '0' && tolower (my_string[1]) == 'x')
{
/* Assume that it is in hex. */
@@ -2838,6 +2841,17 @@ string_to_core_addr (const char *my_string)
else
error (_("invalid hex \"%s\""), my_string);
}
+
+ /* Not very modular, but if the executable format expects
+ addresses to be sign-extended, then do so if the address was
+ specified with only 32 significant bits. Really this should
+ be determined by the target architecture, not by the object
+ file. */
+ if (i - 2 == addr_bit / 4
+ && exec_bfd
+ && bfd_get_sign_extend_vma (exec_bfd))
+ addr = (addr ^ ((CORE_ADDR) 1 << (addr_bit - 1)))
+ - ((CORE_ADDR) 1 << (addr_bit - 1));
}
else
{
@@ -2851,6 +2865,7 @@ string_to_core_addr (const char *my_string)
error (_("invalid decimal \"%s\""), my_string);
}
}
+
return addr;
}