Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Klee Dienes <klee@apple.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Use read_memory_unsigned_integer when reading to CORE_ADDR
Date: Sat, 05 Oct 2002 19:48:00 -0000	[thread overview]
Message-ID: <1BE45412-D8D6-11D6-9DA9-00039396EEB8@apple.com> (raw)

The following patch converts several instances of read_memory_integer  
to read_memory_unsigned_integer.
In all cases except one, the value is being read into a CORE_ADDR,  
which will cause sign-extension lossage if read_memory_integer is used  
with a 64-bit bfd (the final case is reading into an unsigned int, but  
I believe the change is still correct).

2002-10-05  Klee Dienes  <kdienes@apple.com>

         * blockframe.c (sigtramp_saved_pc): Use
         read_memory_unsigned_integer to read a value destined for a
         CORE_ADDR, not read_memory_integer.
         * f-valprint.c (f77_get_dynamic_upperbound): Ditto.
         (f77_get_dynamic_lowerbound): Ditto.
         * symfile.c (simple_read_overlay_region_table): Ditto (this
         function is reading to an unsigned int, not a CORE_ADDR, and is
         commented out, but I believe reading as unsigned is still
         correct).

diff -ru --exclude=Makefile.in --exclude=configure.in  
--exclude=configure --exclude=aclocal.m4 --exclude=config.in  
--exclude=gconfig.in --exclude=config.h.in --exclude=Make-in  
--exclude=CVS  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
blockframe.c ./blockframe.c
---  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
blockframe.c	Sun Sep 22 12:47:43 2002
+++ ./blockframe.c	Sat Oct  5 21:05:32 2002
@@ -1035,14 +1035,14 @@
    buf = alloca (ptrbytes);
    /* Get sigcontext address, it is the third parameter on the stack.   
*/
    if (frame->next)
-    sigcontext_addr = read_memory_integer (FRAME_ARGS_ADDRESS  
(frame->next)
-					   + FRAME_ARGS_SKIP
-					   + sigcontext_offs,
-					   ptrbytes);
+    sigcontext_addr = read_memory_unsigned_integer (FRAME_ARGS_ADDRESS  
(frame->next)
+						    + FRAME_ARGS_SKIP
+						    + sigcontext_offs,
+						    ptrbytes);
    else
-    sigcontext_addr = read_memory_integer (read_register (SP_REGNUM)
-					   + sigcontext_offs,
-					   ptrbytes);
+    sigcontext_addr = read_memory_unsigned_integer (read_register  
(SP_REGNUM)
+						    + sigcontext_offs,
+						    ptrbytes);

    /* Don't cause a memory_error when accessing sigcontext in case the  
stack
       layout has changed or the stack is corrupt.  */
diff -ru --exclude=Makefile.in --exclude=configure.in  
--exclude=configure --exclude=aclocal.m4 --exclude=config.in  
--exclude=gconfig.in --exclude=config.h.in --exclude=Make-in  
--exclude=CVS  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
f-valprint.c ./f-valprint.c
---  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
f-valprint.c	Mon Aug  5 17:39:21 2002
+++ ./f-valprint.c	Sat Oct  5 20:24:29 2002
@@ -77,10 +77,8 @@
        current_frame_addr = selected_frame->frame;
        if (current_frame_addr > 0)
  	{
-	  *lower_bound =
-	    read_memory_integer (current_frame_addr +
-				 TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-				 4);
+	  *lower_bound = read_memory_unsigned_integer
+	    (current_frame_addr + TYPE_ARRAY_LOWER_BOUND_VALUE (type), 4);
  	}
        else
  	{
@@ -101,11 +99,9 @@
        current_frame_addr = selected_frame->frame;
        if (current_frame_addr > 0)
  	{
-	  ptr_to_lower_bound =
-	    read_memory_integer (current_frame_addr +
-				 TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-				 4);
-	  *lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
+	  ptr_to_lower_bound = read_memory_unsigned_integer
+	    (current_frame_addr + TYPE_ARRAY_LOWER_BOUND_VALUE (type), 4);
+	  *lower_bound = read_memory_unsigned_integer (ptr_to_lower_bound, 4);
  	}
        else
  	{
@@ -135,10 +131,8 @@
        current_frame_addr = selected_frame->frame;
        if (current_frame_addr > 0)
  	{
-	  *upper_bound =
-	    read_memory_integer (current_frame_addr +
-				 TYPE_ARRAY_UPPER_BOUND_VALUE (type),
-				 4);
+	  *upper_bound = read_memory_unsigned_integer
+	    (current_frame_addr + TYPE_ARRAY_UPPER_BOUND_VALUE (type), 4);
  	}
        else
  	{
@@ -164,11 +158,9 @@
        current_frame_addr = selected_frame->frame;
        if (current_frame_addr > 0)
  	{
-	  ptr_to_upper_bound =
-	    read_memory_integer (current_frame_addr +
-				 TYPE_ARRAY_UPPER_BOUND_VALUE (type),
-				 4);
-	  *upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
+	  ptr_to_upper_bound = read_memory_unsigned_integer
+	    (current_frame_addr + TYPE_ARRAY_UPPER_BOUND_VALUE (type), 4);
+	  *upper_bound = read_memory_unsigned_integer (ptr_to_upper_bound, 4);
  	}
        else
  	{
diff -ru --exclude=Makefile.in --exclude=configure.in  
--exclude=configure --exclude=aclocal.m4 --exclude=config.in  
--exclude=gconfig.in --exclude=config.h.in --exclude=Make-in  
--exclude=CVS  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
symfile.c ./symfile.c
---  
/Volumes/Storage/Users/kdienes/source/cygnus.pristine-current/src/gdb/ 
symfile.c	Sun Sep 22 12:47:51 2002
+++ ./symfile.c	Sun Sep 29 02:09:10 2002
@@ -3137,7 +3377,7 @@
    simple_free_overlay_region_table ();
    msym = lookup_minimal_symbol ("_novly_regions", NULL, NULL);
    if (msym != NULL)
-    cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS  
(msym), 4);
+    cache_novly_regions = read_memory_unsigned_integer  
(SYMBOL_VALUE_ADDRESS (msym), 4);
    else
      return 0;			/* failure */
    cache_ovly_region_table = (void *) xmalloc (cache_novly_regions *  
12);


             reply	other threads:[~2002-10-06  2:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-05 19:48 Klee Dienes [this message]
2002-10-05 19:56 ` Daniel Jacobowitz
2002-10-05 23:52   ` Klee Dienes
2002-10-06  8:09     ` Daniel Jacobowitz
2002-10-06  9:41       ` Klee Dienes
2002-10-06  9:51         ` Daniel Jacobowitz
2002-10-07 14:19         ` Jim Blandy
2002-10-21 12:08         ` Andrew Cagney
2002-11-04 19:45           ` Klee Dienes
2002-11-06 14:37             ` Andrew Cagney
2002-10-21 12:08     ` Andrew Cagney
2002-10-07 14:14   ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1BE45412-D8D6-11D6-9DA9-00039396EEB8@apple.com \
    --to=klee@apple.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox