public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Duane Ellis <duane_ellis@franklin.com>
To: mckennad@esatclear.ie
Cc: insight@sources.redhat.com
Subject: Re: Adding Registers
Date: Tue, 12 Feb 2002 07:17:00 -0000	[thread overview]
Message-ID: <200202121516.KAA17821@mercury.franklin.com> (raw)
In-Reply-To: <3c92000a.32bb.0@esatclear.ie> (mckennad@esatclear.ie)


dave> Is it possible to add extra registers to gdb that link to a memory address,
      eg R0 links to 0x00h ?

Not directly with out of the box prebuilt stuff. but if you want to
modify/tweak GDB sources to do something like this.... you can do it.

I know you can do that... I've done things like that on a few custom
ports I've done. :->

Basically you need to look at the CPU definition file for the machine
you want want to use.

For instance: Our custom cpu has 3 banks of 16 registers, 32bits each,
plus a few spares. We actually tell GDB there are 4 banks, plus the
extra ones. The "Current bank" and bank 0,1 and 2. The current bank
ends up being a ghost of what ever happens to be the current bank.

Example:

In the various "tm-CPUNAME.h" files (tm-arm.h, tm-m68k.h, etc) Look
for 'NUM_REGS', increase this number.  There are a number of other
macros that need tweaking.

Things like: "REGISTER_BYTES" and "REGISTER_BYTE()" macros,
and the register names to name a few.

In some of the target machine descriptions you'll notice that they
talk about "phony" registers, that's basically what you are doing.

You'll want to look at the functions (really macros) in target.h

       target_fetch_registers()
       target_store_registers()

and work through how they are called.

Basically, when GDB needs a register value, it will
call the function:

	   target_fetch_register( MY_FUNKY_REGISTER )

You'll need to modify whatever that eventually resolves to in the
target machine code (typically the "CPUNAME-tdep.c" file) so that it
does something like this:

void
my_target_fetch_register( int id )
{
	if( (id >= MY_FIRST_FUNKY_REGISTER) && 
	    (id <= MY_LAST_FUNKY_REGISTER) ){
		do_that_special_thing(id);
	} else {
	        call_existing_code(id);
	}
}

There are caviats to this:

GDB will seemingly periodically randomly call and ask for registers
when you least expect it, you quitely must just supply something or
have GDB go wacky on you. [Certian registers are only readable in
certian modes (ie: supervisor or user), or if the hardware is
configured a certian way.]

Another problem is if you are using a graphical front end, like
insight the display register window can get really huge and darn right
ugly.

In the specific example you give, if you modify memory via other means
(ie: Peek/Poke bytes some how) the values in the static register
display will be out of sync with what is in memory.

Doing things like this can be viewed like this: 

      You give a somebody a knife.
      You remind them they can cut themself. 
      They walk away, only to return bleeding and confused. 
      Do you really want to give them the knife?
      Is the knife really that important?

I find that many times you must give them the knife. You just wish
some of the others never found the knife. There are those people who
just don't, won't, or refuse to understand the danger of the knife.

-Duane.

  reply	other threads:[~2002-02-12 15:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-12  6:27 David Mc Kenna
2002-02-12  7:17 ` Duane Ellis [this message]
2002-02-12  8:58   ` Keith Seitz
2002-02-12 19:26     ` Andrew Cagney
2002-02-13  3:40 David Mc Kenna
2002-02-13  6:49 ` Duane Ellis
2002-02-13 10:05 ` Andrew Cagney
2002-02-14  4:32 David Mc Kenna
2002-02-14  7:03 ` Duane Ellis
2002-02-14  7:39   ` Andrew Cagney

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=200202121516.KAA17821@mercury.franklin.com \
    --to=duane_ellis@franklin.com \
    --cc=insight@sources.redhat.com \
    --cc=mckennad@esatclear.ie \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).