From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22374 invoked by alias); 12 Feb 2002 15:17:01 -0000 Mailing-List: contact insight-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sources.redhat.com Received: (qmail 22282 invoked from network); 12 Feb 2002 15:16:55 -0000 Received: from unknown (HELO earth-out.franklin.com) (63.88.59.82) by sources.redhat.com with SMTP; 12 Feb 2002 15:16:55 -0000 Received: from saturn.franklin.com (IDENT:root@saturn.franklin.com [192.9.200.2]) by earth-out.franklin.com (8.9.3/8.9.3) with ESMTP id KAA31129; Tue, 12 Feb 2002 10:16:41 -0500 Received: from mercury.franklin.com (IDENT:root@mercury.franklin.com [192.9.200.250]) by saturn.franklin.com (8.9.3/8.9.3) with ESMTP id KAA19798; Tue, 12 Feb 2002 10:16:41 -0500 Received: (from duane@localhost) by mercury.franklin.com (8.9.3/8.9.3) id KAA17821; Tue, 12 Feb 2002 10:16:43 -0500 Date: Tue, 12 Feb 2002 07:17:00 -0000 Message-Id: <200202121516.KAA17821@mercury.franklin.com> From: Duane Ellis To: mckennad@esatclear.ie CC: insight@sources.redhat.com In-reply-to: <3c92000a.32bb.0@esatclear.ie> (mckennad@esatclear.ie) Subject: Re: Adding Registers Reply-to: duane_ellis@franklin.com References: <3c92000a.32bb.0@esatclear.ie> X-SW-Source: 2002-q1/txt/msg00106.txt.bz2 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.