Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Steven Johnson <sjohnson@neurizon.net>
To: Steven Johnson <sjohnson@neurizon.net>
Cc: gdb@sources.redhat.com
Subject: Re: GDB and ARM Frame Pointer strangeness
Date: Tue, 08 Jun 2004 04:25:00 -0000	[thread overview]
Message-ID: <40C53F70.8030101@neurizon.net> (raw)
In-Reply-To: <40C42C75.5020208@neurizon.net>

I have tracked the root cause of GDB reading invalid memory at its whim, 
but am at the moment confused as to the way to solve this problem.

The problem resides in the function: value_assign in valops.c

struct value *
value_assign (struct value *toval, struct value *fromval)
{

  [snip]

  /* Since modifying a register can trash the frame chain, and modifying 
memory
     can trash the frame cache, we save the old frame and then restore 
the new
     frame afterwards.  */
  old_frame = get_frame_id (deprecated_selected_frame);

This is all well and good, but at the beginning of the world, when the 
target is not yet properly initialised, the frame is corrupt.  
Dereferencing R11 (on an ARM) and then looking at that Memory is BAD.  
R11 at the beginning of the world doesnt contain anything valid.

This seems to be a worse problem (to me) than the one supposedly solved 
by the piece of code here.  I would have thought it would only need to 
do this if:
1.  The frame was valid. AND
2. You modify a frame register OR
3. You modify any memory within the current Frame.

Otherwise the operation is un needed. (As far as I can tell).  Is there 
any way to determine if the frame is valid, so that at least that check 
can be added to this code, to prevent GDB illegally accessing invalid 
memory?

Steven Johnson

Steven Johnson wrote:

> Hi all,
>
> I have compiled GDB 6.1 for ARM Cross Debugging. Hosted on X86 Linux.  
> Ive been doing this for a while with PowerPC, so im no stranger to 
> it.  Well, now I have an ARM target and I am writing an ARM remote 
> interface to my target communicating using the Remote Protocol over 
> TCP/IP.  The strange thing is, right after startup, if I try and write 
> an absolute memory location GDB insists on dereferencing the Frame 
> Pointer (R11) and reading the address stored there.  It then does 
> something with the result and dereferences that.
>
> The problem is, I havent got a program loaded yet. And the Registers 
> are just in any old state, a program not having been loaded and run.  
> Dereferencing the FP (R11) is causing the target to crash, becasue the 
> memory it is trying to access is a random address (being the default 
> garbage in the register) and this is causing the target to get a 
> memory exception and die.
>
> Not Good.
>
> Why is GDB insisting on de-referencing the FP when all I asked it to 
> do is write to an absolute memory location. I have not told it to do 
> anything that is frame pointer relative.  The last thing I expect to 
> see is 2 memory read packets when i execute:
>
> set (unsigned int)0x0 0x12345
>
> all i should see is the memory write packet.  The single memory write 
> packet is all i ever saw with my PowerPC target, it never dereferenced 
> the FP on a memory write operation????
>
> Is there a way to turn this undesirable operation off?
>
> Any help would be appreciated.
>
> Also, as an aside, 2 other strange things ive noticed with the ARM GDB:
>
> it seems "set architecture" causes GDB to crash for ARM targets.  eg 
> set architecture armv4t followed by the write indicated above crashes 
> GDB.  Leaving it on Auto does not.
>
> and, set osabi does not work with ARM for anything other than "none" 
> or "auto" I was trying to set an ABI to an embedded ABI, that 
> theoretically doesnt use an FP, but the command doesnt work. Eg,
> (gdb) set osabi ARM EABI v1
> Ambiguous item "ARM EABI v1 ".
>
> same goes for "ARM EABI v2" and "ARM APCS"
>
> only "none" "default" and "auto" works.
>
> Also, this is a raw GDB, meaning I havent loaded any application.  Im 
> just trying to get GDB to talk to my target, so am not interested in 
> debugging an actual application yet.  Reading and writing 
> registers/memory and disassembling are the big ticket items at the 
> moment.
>
> Steven Johnson
>
>


  reply	other threads:[~2004-06-08  4:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-07  8:50 Steven Johnson
2004-06-08  4:25 ` Steven Johnson [this message]
2004-06-08  4:29   ` Daniel Jacobowitz
2004-06-08  5:02     ` Steven Johnson
2004-06-08 12:26       ` Mark Salter
2004-06-08 23:47         ` Steven Johnson
2004-06-09 15:14           ` Andrew Cagney
2004-06-10  0:06             ` Steven Johnson
2004-06-10  2:20               ` Ian Lance Taylor
2004-06-10  4:37                 ` Steven Johnson
2004-06-10  5:10                   ` Ian Lance Taylor
2004-06-10  7:16                     ` Steven Johnson
2004-06-10 21:32                       ` Andrew Cagney
2004-06-11  0:46                         ` Steven Johnson
2004-06-11 15:33                           ` Andrew Cagney
2004-06-10  9:03                   ` Richard Earnshaw

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=40C53F70.8030101@neurizon.net \
    --to=sjohnson@neurizon.net \
    --cc=gdb@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