This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[18/19] string_to_core_addr


Hello,

this patch is an updated version of a patch I posted last year as part
of the Cell multi-arch debugger patches:
http://sourceware.org/ml/gdb-patches/2008-09/msg00139.html

I'm including this patch in this series because it eliminates
a reference to current_gdbarch in string_to_core_addr.

Bye,
Ulrich


ChangeLog:

	* printcmd.c (print_scalar_formatted): Always truncate
	unsigned data types.

	* cli-dump.c (struct callback_data): Change type of load_offset
	to CORE_ADDR.
	(restore_binary_file): Update type casts.
	(restore_command): Parse load_offset as address, not long.

	* utils.c (string_to_core_addr): Do not sign-extend value.
	* varobj.c (find_frame_addr_in_frame_chain): Truncate frame_base
	before comparing against requested frame address.

testsuite/ChangeLog:

	* gdb.base/dump.exp: Handle SPU like 64-bit platforms.


Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -407,7 +407,7 @@ print_scalar_formatted (const void *vala
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
-  if (options->format != 'd')
+  if (options->format != 'd' || TYPE_UNSIGNED (type))
     {
       if (len < sizeof (LONGEST))
 	val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
Index: gdb-head/gdb/cli/cli-dump.c
===================================================================
--- gdb-head.orig/gdb/cli/cli-dump.c
+++ gdb-head/gdb/cli/cli-dump.c
@@ -428,7 +428,7 @@ add_dump_command (char *name, void (*fun
 
 /* Opaque data for restore_section_callback. */
 struct callback_data {
-  long load_offset;
+  CORE_ADDR load_offset;
   CORE_ADDR load_start;
   CORE_ADDR load_end;
 };
@@ -533,8 +533,8 @@ restore_binary_file (char *filename, str
   printf_filtered 
     ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", 
      filename, 
-     (unsigned long) data->load_start + data->load_offset, 
-     (unsigned long) data->load_start + data->load_offset + len);
+     (unsigned long) (data->load_start + data->load_offset),
+     (unsigned long) (data->load_start + data->load_offset + len));
 
   /* Now set the file pos to the requested load start pos.  */
   if (fseek (file, data->load_start, SEEK_SET) != 0)
@@ -584,7 +584,7 @@ restore_command (char *args, int from_tt
       /* Parse offset (optional). */
       if (args != NULL && *args != '\0')
       data.load_offset = 
-	parse_and_eval_long (scan_expression_with_cleanup (&args, NULL));
+	parse_and_eval_address (scan_expression_with_cleanup (&args, NULL));
       if (args != NULL && *args != '\0')
 	{
 	  /* Parse start address (optional). */
Index: gdb-head/gdb/utils.c
===================================================================
--- gdb-head.orig/gdb/utils.c
+++ gdb-head/gdb/utils.c
@@ -3154,7 +3154,6 @@ core_addr_to_string_nz (const CORE_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')
@@ -3170,17 +3169,6 @@ string_to_core_addr (const char *my_stri
 	  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
     {
Index: gdb-head/gdb/varobj.c
===================================================================
--- gdb-head.orig/gdb/varobj.c
+++ gdb-head/gdb/varobj.c
@@ -462,7 +462,16 @@ find_frame_addr_in_frame_chain (CORE_ADD
        frame != NULL;
        frame = get_prev_frame (frame))
     {
-      if (get_frame_base_address (frame) == frame_addr)
+      /* The CORE_ADDR we get as argument was parsed from a string GDB
+	 output as $fp.  This output got truncated to gdbarch_addr_bit.
+	 Truncate the frame base address in the same manner before
+	 comparing it against our argument.  */
+      CORE_ADDR frame_base = get_frame_base_address (frame);
+      int addr_bit = gdbarch_addr_bit (get_frame_arch (frame));
+      if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+	frame_base &= ((CORE_ADDR) 1 << addr_bit) - 1;
+
+      if (frame_base == frame_addr)
 	return frame;
     }
 
Index: gdb-head/gdb/testsuite/gdb.base/dump.exp
===================================================================
--- gdb-head.orig/gdb/testsuite/gdb.base/dump.exp
+++ gdb-head/gdb/testsuite/gdb.base/dump.exp
@@ -42,6 +42,12 @@ if {[istarget "ia64*-*-*"] || [istarget 
     set is64bitonly "yes"
 }
 
+if {[istarget "spu*-*-*"]} then {
+    # The internal address format used for the combined Cell/B.E.
+    # debugger requires 64-bit.
+    set is64bitonly "yes"
+}
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
      untested dump.exp
      return -1
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]