From 7faf367052958a5fbbdfd8545494329761f98597 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 25 Sep 2002 20:30:38 +0000 Subject: 2002-09-25 Andrew Cagney * frame.c: Include "gdb_string.h" and "builtin-regs.h". (frame_map_regnum_to_name): New function. (frame_map_name_to_regnum): New function. * frame.h (frame_map_name_to_regnum): Declare. (frame_map_regnum_to_name): Declare. * builtin-regs.c (builtin_reg_map_regnum_to_name): New function. * builtin-regs.h (builtin_reg_map_regnum_to_name): Declare. * parse.c: Do not include "builtin-regs.h". (target_map_name_to_register): Delete function. (write_dollar_variable): Use frame_map_name_to_regnum. * parser-defs.h (target_map_name_to_register): Delete declaration. * expprint.c: Include "frame.h". (print_subexp): Use frame_map_regnum_to_name. * eval.c (evaluate_subexp_standard): Use frame_map_regnum_to_name. * infcmd.c (registers_info): Use frame_map_name_to_regnum. 2002-09-25 Andrew Cagney * gdb.base/pc-fp.exp, gdb.base/pc-fp.c: New test. --- gdb/frame.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'gdb/frame.c') diff --git a/gdb/frame.c b/gdb/frame.c index 82754ef1ce5..1ad3b09f3bd 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -27,6 +27,8 @@ #include "inferior.h" /* for inferior_ptid */ #include "regcache.h" #include "gdb_assert.h" +#include "gdb_string.h" +#include "builtin-regs.h" /* Return a frame uniq ID that can be used to, later re-find the frame. */ @@ -233,3 +235,44 @@ frame_register_read (struct frame_info *frame, int regnum, void *myaddr) return !optim; } + + +/* Map between a frame register number and its name. A frame register + space is a superset of the cooked register space --- it also + includes builtin registers. */ + +int +frame_map_name_to_regnum (const char *name, int len) +{ + int i; + + /* Search register name space. */ + for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++) + if (REGISTER_NAME (i) && len == strlen (REGISTER_NAME (i)) + && strncmp (name, REGISTER_NAME (i), len) == 0) + { + return i; + } + + /* Try builtin registers. */ + i = builtin_reg_map_name_to_regnum (name, len); + if (i >= 0) + { + /* A builtin register doesn't fall into the architecture's + register range. */ + gdb_assert (i >= NUM_REGS + NUM_PSEUDO_REGS); + return i; + } + + return -1; +} + +const char * +frame_map_regnum_to_name (int regnum) +{ + if (regnum < 0) + return NULL; + if (regnum < NUM_REGS + NUM_PSEUDO_REGS) + return REGISTER_NAME (regnum); + return builtin_reg_map_regnum_to_name (regnum); +} -- cgit v1.2.1