From a1c8d76ef8cc1ddf20b43fe5660ba67a93339808 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Tue, 24 Aug 1993 21:38:24 +0000 Subject: [PATCH] * frame.h, symtab.h, findvar.c (read_var_value): Change basereg support to use LOC_BASEREG rather than SYMBOL_BASEREG_VALID. * dwarfread.c: Use LOC_BASEREG where appropriate. * Various: Support LOC_BASEREG and LOC_BASEREG_ARG. --- gdb/ChangeLog | 2 +- gdb/c-exp.y | 2 ++ gdb/ch-exp.y | 2 ++ gdb/dwarfread.c | 39 +++++++++++++++++--------------------- gdb/m2-exp.y | 4 ++++ gdb/printcmd.c | 50 +++++++++++++++++++------------------------------ gdb/symtab.c | 3 ++- gdb/symtab.h | 44 +++++++++++++++++++------------------------ 8 files changed, 66 insertions(+), 80 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3c95ef20a4a..7f42e8cbabe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -4,7 +4,7 @@ Tue Aug 24 00:36:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com) * frame.h, symtab.h, findvar.c (read_var_value): Change basereg support to use LOC_BASEREG rather than SYMBOL_BASEREG_VALID. - * dwarfread: Use LOC_BASEREG where appropriate. + * dwarfread.c: Use LOC_BASEREG where appropriate. * Various: Support LOC_BASEREG and LOC_BASEREG_ARG. * coffread.c (init_lineno, init_stringtab): Don't check whether diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 42e482b357d..0b19ed5f163 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -667,6 +667,8 @@ variable: name_not_typename case LOC_REGPARM: case LOC_LOCAL: case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: if (innermost_block == 0 || contained_in (block_found, innermost_block)) diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y index 58b82ead562..895113329e3 100644 --- a/gdb/ch-exp.y +++ b/gdb/ch-exp.y @@ -1931,6 +1931,8 @@ yylex () case LOC_REGPARM: case LOC_LOCAL: case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: if (innermost_block == NULL || contained_in (block_found, innermost_block)) { diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index ba00cd2f2e1..076f1759908 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -21,9 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* -FIXME: Figure out how to get the frame pointer register number in the -execution environment of the target. Remove R_FP kludge - FIXME: Do we need to generate dependencies in partial symtabs? (Perhaps we don't need to). @@ -180,10 +177,6 @@ struct complaint not_row_major = "DIE @ 0x%x \"%s\", array not row major; not handled correctly", 0, 0 }; -#ifndef R_FP /* FIXME */ -#define R_FP 14 /* Kludge to get frame pointer register number */ -#endif - typedef unsigned int DIE_REF; /* Reference to a DIE */ #ifndef GCC_PRODUCER @@ -332,7 +325,11 @@ static int dbsize; /* Size of dwarf info in bytes */ static int dbroff; /* Relative offset from start of .debug section */ static char *lnbase; /* Base pointer to line section */ static int isreg; /* Kludge to identify register variables */ -static int offreg; /* Kludge to identify basereg references */ +/* Kludge to identify basereg references. Nonzero if we have an offset + relative to a basereg. */ +static int offreg; +/* Which base register is it relative to? */ +static int basereg; /* This value is added to each symbol value. FIXME: Generalize to the section_offsets structure used by dbxread (once this is done, @@ -2207,21 +2204,13 @@ locval (loc) break; case OP_BASEREG: /* push value of register (number) */ - /* Actually, we compute the value as if register has 0 */ + /* Actually, we compute the value as if register has 0, so the + value ends up being the offset from that register. */ offreg = 1; - regno = target_to_host (loc, loc_value_size, GET_UNSIGNED, - current_objfile); + basereg = target_to_host (loc, loc_value_size, GET_UNSIGNED, + current_objfile); loc += loc_value_size; - if (regno == R_FP) - { - stack[++stacki] = 0; - } - else - { - stack[++stacki] = 0; - - complain (&basereg_not_handled, DIE_ID, DIE_NAME, regno); - } + stack[++stacki] = 0; break; case OP_ADDR: /* push address (relocated address) */ @@ -2988,7 +2977,8 @@ new_symbol (dip, objfile) } else if (offreg) { - SYMBOL_CLASS (sym) = LOC_LOCAL; + SYMBOL_CLASS (sym) = LOC_BASEREG; + SYMBOL_BASEREG (sym) = basereg; } else { @@ -3007,6 +2997,11 @@ new_symbol (dip, objfile) { SYMBOL_CLASS (sym) = LOC_REGPARM; } + else if (offreg) + { + SYMBOL_CLASS (sym) = LOC_BASEREG_ARG; + SYMBOL_BASEREG (sym) = basereg; + } else { SYMBOL_CLASS (sym) = LOC_ARG; diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index b00af97d503..1d7e80116f8 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -607,6 +607,8 @@ variable: NAME case LOC_REF_ARG: case LOC_REGPARM: case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: if (innermost_block == 0 || contained_in (block_found, innermost_block)) @@ -1119,6 +1121,8 @@ yylex () case LOC_REGPARM: case LOC_LOCAL: case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: case LOC_CONST: case LOC_CONST_BYTES: return NAME; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 79d136c1046..7409b3a3e4b 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -927,50 +927,36 @@ address_info (exp, from_tty) printf ("an argument in register %s", reg_names[val]); break; - case LOC_REGPARM_ADDR: - printf ("address of an argument in register %s", reg_names[val]); - break; - + case LOC_REGPARM_ADDR: + printf ("address of an argument in register %s", reg_names[val]); + break; + case LOC_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { - printf ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { - printf ("an argument at offset %ld", val); - } + printf ("an argument at offset %ld", val); break; case LOC_LOCAL_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { - printf ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { - printf ("an argument at frame offset %ld", val); - } + printf ("an argument at frame offset %ld", val); break; case LOC_LOCAL: - if (SYMBOL_BASEREG_VALID (sym)) - { - printf ("a local variable at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { - printf ("a local variable at frame offset %ld", val); - } + printf ("a local variable at frame offset %ld", val); break; case LOC_REF_ARG: printf ("a reference argument at offset %ld", val); break; + case LOC_BASEREG: + printf ("a variable at offset %ld from register %s", + val, reg_names[basereg]); + break; + + case LOC_BASEREG_ARG: + printf ("an argument at offset %ld from register %s", + val, reg_names[basereg]); + break; + case LOC_TYPEDEF: printf ("a typedef"); break; @@ -1494,6 +1480,8 @@ print_frame_args (func, fi, num, stream) case LOC_REGPARM: case LOC_REGPARM_ADDR: case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: break; /* Other types of symbols we just skip over. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 38675d13ba9..745b74c7048 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -899,7 +899,8 @@ lookup_block_symbol (block, name, namespace) SYMBOL_CLASS (sym) != LOC_LOCAL_ARG && SYMBOL_CLASS (sym) != LOC_REF_ARG && SYMBOL_CLASS (sym) != LOC_REGPARM && - SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR) + SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR && + SYMBOL_CLASS (sym) != LOC_BASEREG_ARG) { break; } diff --git a/gdb/symtab.h b/gdb/symtab.h index 34bc099530a..8ac697277f5 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -515,6 +515,22 @@ enum address_class LOC_LOCAL_ARG, + /* Value is at SYMBOL_VALUE offset from the current value of + register number SYMBOL_BASEREG. This exists mainly for the same + things that LOC_LOCAL and LOC_ARG do; but we need to do this + instead because on 88k DWARF gives us the offset from the + frame/stack pointer, rather than the offset from the "canonical + frame address" used by COFF, stabs, etc., and we don't know how + to convert between these until we start examining prologues. + + Note that LOC_BASEREG is much less general than a DWARF expression. */ + + LOC_BASEREG, + + /* Same as LOC_BASEREG but it is an argument. */ + + LOC_BASEREG_ARG, + /* The variable does not actually exist in the program. The value is ignored. */ @@ -551,12 +567,8 @@ struct symbol union { - /* for OP_BASEREG in DWARF location specs */ - struct - { - short regno_valid; /* 0 == regno invalid; !0 == regno valid */ - short regno; /* base register number {0, 1, 2, ...} */ - } basereg; + /* Used by LOC_BASEREG and LOC_BASEREG_ARG. */ + short basereg; } aux_value; @@ -566,25 +578,7 @@ struct symbol #define SYMBOL_CLASS(symbol) (symbol)->class #define SYMBOL_TYPE(symbol) (symbol)->type #define SYMBOL_LINE(symbol) (symbol)->line -#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg.regno - -/* If we want to do baseregs using this approach we should have a - LOC_BASEREG (and LOC_BASEREG_ARG) rather than changing the meaning - of LOC_LOCAL, LOC_ARG, etc. based on SYMBOL_BASEREG_VALID. But - this approach provides just a small fraction of the expressiveness - of a DWARF location, so it does less than we might want. On the - other hand, it may do more than we need; FRAME_LOCALS_ADDRESS, - LOC_REGPARM_ADDR, and similar things seem to handle most of the - cases which actually come up. */ - -#if 0 -/* This currently fails because some symbols are not being initialized - to zero on allocation, and no code is currently setting this value. */ -#define SYMBOL_BASEREG_VALID(symbol) (symbol)->aux_value.basereg.regno_valid -#else -#define SYMBOL_BASEREG_VALID(symbol) 0 -#endif - +#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg /* A partial_symbol records the name, namespace, and address class of symbols whose types we have not parsed yet. For functions, it also -- 2.30.2