Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: Klee Dienes <klee@apple.com>
Cc: Daniel Jacobowitz <drow@mvista.com>, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Use read_memory_unsigned_integer when reading to CORE_ADDR
Date: Mon, 07 Oct 2002 14:19:00 -0000	[thread overview]
Message-ID: <vt24rby7yj5.fsf@zenia.red-bean.com> (raw)
In-Reply-To: <7E7F8836-D94A-11D6-9563-00039396EEB8@apple.com>


This patch looks good to me, too.  I think it's fine to commit it.

Klee Dienes <klee@apple.com> writes:

> On Sunday, October 6, 2002, at 11:09 AM, Daniel Jacobowitz wrote:
> 
> >
> > Might want to use alloca (TYPE_LENGTH (builtin_type_void_data_ptr)).
> 
> Love to; I had been under the (apparently mistaken) impression that
> alloca was deprecated for new code.
> 
> >> Aside from the intimidating comments in findvar.c, this would seem a
> >> good candidate for extract_address ... though a similar modification
> >> would have to be made to it to handle the sign-extension as well.
> >>
> >> Or alternately, I could just leave well-enough alone, and be
> >> careful to
> >> truncate CORE_ADDRs to 32 bits in our target xfer_memory code (or the
> >> MIPS code could sign-extend it in the same place).
> >
> > Well, I think a general read_memory_typed_address (returning CORE_ADDR,
> > and honoroing POINTER_TO_ADDRESS) would be the way to go here.
> 
> That sounds good to me; how about the following?  I removed the patch
> to symfile.c, as it's commented out anyway, and probably not worth the
> effort.  My one concern is that I don't currently have a good system
> to test the part of the patch that affects blockframe.c.
> 
> 2002-10-06  Klee Dienes  <kdienes@apple.com>
> 
>          * findvar.c (read_memory_typed_address): New function.
>          * gdbcore.h (read_memory_typed_address): Add prototype.
>          * blockframe.c (sigtramp_saved_pc): Use
>          read_memory_typed_address 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.
> 
> diff -u /home/klee/source/cygnus.cygnus/gdb/gdbcore.h ./gdbcore.h
> --- /home/klee/source/cygnus.cygnus/gdb/gdbcore.h	Wed Dec 19
> 15:54:26 2001
> +++ ./gdbcore.h	Sun Oct  6 09:18:11 2002
> @@ -64,8 +64,15 @@
> 
>   /* Read a null-terminated string from the debuggee's memory, given
> address,
>    * a buffer into which to place the string, and the maximum
> available space */
> +
>   extern void read_memory_string (CORE_ADDR, char *, int);
> 
> +/* Read the pointer of type TYPE at BUF, and return the address it
> +   represents. */
> +
> +CORE_ADDR
> +read_memory_typed_address (CORE_ADDR addr, struct type *type);
> +
>   /* This takes a char *, not void *.  This is probably right, because
>      passing in an int * or whatever is wrong with respect to
>      byteswapping, alignment, different sizes for host vs. target types,
> diff -u /home/klee/source/cygnus.cygnus/gdb/corefile.c ./corefile.c
> --- /home/klee/source/cygnus.cygnus/gdb/corefile.c	Thu May 30
> 15:41:24 2002
> +++ ./corefile.c	Sun Oct  6 09:18:11 2002
> @@ -356,6 +356,14 @@
>       }
>   }
> 
> +CORE_ADDR
> +read_memory_typed_address (CORE_ADDR addr, struct type *type)
> +{
> +  char *buf = alloca (TYPE_LENGTH (type));
> +  read_memory (addr, buf, TYPE_LENGTH (type));
> +  return extract_typed_address (buf, type);
> +}
> +
>   /* Same as target_write_memory, but report an error if can't write.  */
>   void
>   write_memory (CORE_ADDR memaddr, char *myaddr, int len)
> diff -u /home/klee/source/cygnus.cygnus/gdb/blockframe.c ./blockframe.c
> --- /home/klee/source/cygnus.cygnus/gdb/blockframe.c	Mon Sep 30
> 18:24:01 2002
> +++ ./blockframe.c	Sun Oct  6 09:35:42 2002
> @@ -1035,19 +1035,17 @@
>     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_typed_address
> +      (FRAME_ARGS_ADDRESS (frame->next) + FRAME_ARGS_SKIP +
> sigcontext_offs,
> +       builtin_type_void_data_ptr);
>     else
> -    sigcontext_addr = read_memory_integer (read_register (SP_REGNUM)
> -					   + sigcontext_offs,
> -					   ptrbytes);
> +    sigcontext_addr = read_memory_typed_address
> +      (read_register (SP_REGNUM) + sigcontext_offs,
> builtin_type_void_data_ptr);
> 
>     /* Don't cause a memory_error when accessing sigcontext in case
> the stack
>        layout has changed or the stack is corrupt.  */
>     target_read_memory (sigcontext_addr + SIGCONTEXT_PC_OFFSET, buf,
> ptrbytes);
> -  return extract_unsigned_integer (buf, ptrbytes);
> +  return extract_typed_address (buf, builtin_type_void_data_ptr);
>   }
>   #endif /* SIGCONTEXT_PC_OFFSET */
> 
> diff -u /home/klee/source/cygnus.cygnus/gdb/f-valprint.c ./f-valprint.c
> --- /home/klee/source/cygnus.cygnus/gdb/f-valprint.c	Tue Mar  6
> 18:57:08 2001
> +++ ./f-valprint.c	Sun Oct  6 09:18:11 2002
> @@ -102,9 +102,9 @@
>         if (current_frame_addr > 0)
>   	{
>   	  ptr_to_lower_bound =
> -	    read_memory_integer (current_frame_addr +
> -				 TYPE_ARRAY_LOWER_BOUND_VALUE (type),
> -				 4);
> +	    read_memory_typed_address (current_frame_addr +
> +				       TYPE_ARRAY_LOWER_BOUND_VALUE (type),
> +				       builtin_type_void_data_ptr);
>   	  *lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
>   	}
>         else
> @@ -165,9 +165,9 @@
>         if (current_frame_addr > 0)
>   	{
>   	  ptr_to_upper_bound =
> -	    read_memory_integer (current_frame_addr +
> -				 TYPE_ARRAY_UPPER_BOUND_VALUE (type),
> -				 4);
> +	    read_memory_typed_address (current_frame_addr +
> +				       TYPE_ARRAY_UPPER_BOUND_VALUE (type),
> +				       builtin_type_void_data_ptr);
>   	  *upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
>   	}
>         else


  parent reply	other threads:[~2002-10-07 21:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-05 19:48 Klee Dienes
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 [this message]
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=vt24rby7yj5.fsf@zenia.red-bean.com \
    --to=jimb@redhat.com \
    --cc=drow@mvista.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=klee@apple.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