From: Andrew Cagney Date: Thu, 10 Dec 1998 06:10:03 +0000 (+0000) Subject: CARP: X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ddf9aa9be045961f83eacd457a959acb32df2fe;p=binutils-gdb.git CARP: Rename REGISTER_NAMES{} -> REGISTER_NAME(). --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 685f0d19f4d..a25bc0df8d3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +Thu Dec 10 07:14:56 1998 Andrew Cagney + + * config/arm/tm-arm.h, arm-tdep.c: Replace REGISTER_NAMES with + REGISTER_NAME. + * mn10300-tdep.c, config/mn10300/tm-mn10300.h: Ditto. + * sh-tdep.c, config/sh/tm-sh.h: Ditto. + + * defs.h (REGISTER_NAME): Provide default for old targets. + * defs.h, infcmd.c: Rename reg_names to gdb_register_names. + + * tracepoint.c, target.c, parse.c, infcmd.c, remote-udi.c, + expprint.c, infcmd.c, printcmd.c, eval.c, stack.c, findvar.c, + remote-udi.c, config/alpha/tm-alpha.h, remote-sim.c, d30v-tdep.c, + config/mips/tm-mips.h, config/mips/tm-txvu.h, txvu-tdep.c, + hppa-tdep.c: Use REGISTER_NAME. + 1998-12-08 James E Wilson * config/i960/mon960.mt (SIM_OBJS, SIM): Define. diff --git a/gdb/config/alpha/tm-alpha.h b/gdb/config/alpha/tm-alpha.h index 8aaefb43d59..fced3f4f80f 100644 --- a/gdb/config/alpha/tm-alpha.h +++ b/gdb/config/alpha/tm-alpha.h @@ -77,7 +77,7 @@ alpha_saved_pc_after_call PARAMS ((struct frame_info *)); /* Stack grows downward. */ -#define INNER_THAN < +#define INNER_THAN(lhs,rhs) ((lhs) < (rhs)) #define BREAKPOINT {0x80, 0, 0, 0} /* call_pal bpt */ @@ -409,7 +409,7 @@ init_extra_frame_info PARAMS ((struct frame_info *)); { \ if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \ printf_filtered (" frame pointer is at %s+%d\n", \ - reg_names[fi->proc_desc->pdr.framereg], \ + REGISTER_NAME (fi->proc_desc->pdr.framereg), \ fi->proc_desc->pdr.frameoffset); \ } diff --git a/gdb/config/mips/tm-mips.h b/gdb/config/mips/tm-mips.h index 8b80f96e9e9..fac4e144a47 100644 --- a/gdb/config/mips/tm-mips.h +++ b/gdb/config/mips/tm-mips.h @@ -465,7 +465,7 @@ extern void init_extra_frame_info PARAMS ((struct frame_info *)); { \ if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \ printf_filtered (" frame pointer is at %s+%d\n", \ - reg_names[fi->proc_desc->pdr.framereg], \ + REGISTER_NAME (fi->proc_desc->pdr.framereg), \ fi->proc_desc->pdr.frameoffset); \ } diff --git a/gdb/config/mn10300/tm-mn10300.h b/gdb/config/mn10300/tm-mn10300.h index 6108f2abf3c..94582bab52f 100644 --- a/gdb/config/mn10300/tm-mn10300.h +++ b/gdb/config/mn10300/tm-mn10300.h @@ -37,11 +37,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define REGISTER_BYTES (NUM_REGS * REGISTER_SIZE) -#define REGISTER_NAMES \ -{ "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3", \ - "sp", "pc", "mdr", "psw", "lir", "lar", "", "", \ - "", "", "", "", "", "", "", "", \ - "", "", "", "", "", "", "", "fp" } +extern char **mn10300_register_names; +#define REGISTER_NAME(i) mn10300_register_names[i] #define D2_REGNUM 2 #define D3_REGNUM 3 diff --git a/gdb/config/sh/tm-sh.h b/gdb/config/sh/tm-sh.h index a65461caec5..22e60a81237 100644 --- a/gdb/config/sh/tm-sh.h +++ b/gdb/config/sh/tm-sh.h @@ -111,17 +111,8 @@ extern CORE_ADDR sh_skip_prologue (); /* Initializer for an array of names of registers. Entries beyond the first NUM_REGS are ignored. */ -#define REGISTER_NAMES \ - { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ - "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", \ - "fpul", "fpscr", \ - "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \ - "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \ - "ssr", "spc", \ - "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0", \ - "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1", \ - } +extern char **sh_register_names; +#define REGISTER_NAME(i) sh_register_names[i] #define NUM_REGS 59 diff --git a/gdb/d30v-tdep.c b/gdb/d30v-tdep.c index 2cdb25d2c96..588e1def707 100644 --- a/gdb/d30v-tdep.c +++ b/gdb/d30v-tdep.c @@ -791,10 +791,10 @@ d30v_do_registers_info (regnum, fpregs) if (regnum != -1) { - if (reg_names[0] == NULL || reg_names[0][0] == '\000') + if (REGISTER_NAME (0) == NULL || REGISTER_NAME (0)[0] == '\000') return; - printf_filtered ("%s ", reg_names[regnum]); + printf_filtered ("%s ", REGISTER_NAME (regnum)); d30v_print_register (regnum, 0); printf_filtered ("\n"); diff --git a/gdb/defs.h b/gdb/defs.h index 8b7f9a46a53..831a083377d 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -629,7 +629,11 @@ extern PTR xmrealloc PARAMS ((PTR, PTR, long)); extern int parse_escape PARAMS ((char **)); -extern char *reg_names[]; +/* compat - handle old targets that just define REGISTER_NAMES */ +#ifndef REGISTER_NAME +extern char *gdb_register_names[]; +#define REGISTER_NAME(i) gdb_register_names[i] +#endif /* Message to be printed before the error message, when an error occurs. */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 807d99fbeab..f86edac6565 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +Wed Dec 9 21:13:57 1998 Andrew Cagney + + * gdbint.texinfo (REGISTER_NAME): Replace REGISTER_NAMES. + 1998-12-03 J.T. Conklin * remote.texi: Changed wording that implied that the GDB remote diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index ff099dd58bb..c5fc4b7169f 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -556,8 +556,10 @@ code, initialized data, and uninitialized data, respectively. The @file{a.out} format is so simple that it doesn't have any reserved place for debugging information. (Hey, the original Unix hackers used @file{adb}, which is a machine-language debugger.) The only debugging -format for @file{a.out} is stabs, which for this format are encoded as -symbols with distinctive properties. +format for @file{a.out} is stabs, which is encoded as a set of normal +symbols with distinctive attributes. + +The basic @file{a.out} reader is in @file{dbxread.c}. @subsection COFF @@ -570,8 +572,15 @@ was a step forward, the debugging information was woefully limited. For instance, it was not possible to represent code that came from an included file. +The COFF reader is in @file{coffread.c}. + @subsection ECOFF +ECOFF is an extended COFF originally introduced for Mips and Alpha +workstations. + +The basic ECOFF reader is in @file{mipsread.c}. + @subsection XCOFF The IBM RS/6000 running AIX uses an object file format called XCOFF. @@ -580,8 +589,8 @@ symbols are dbx-style stabs whose strings are located in the @samp{.debug} section (rather than the string table). For more information, see @xref{Top,,,stabs,The Stabs Debugging Format}. -The shared library scheme has a nice clean interface for figuring out -what shared libraries are in use, but the catch is that everything which +The shared library scheme has a clean interface for figuring out what +shared libraries are in use, but the catch is that everything which refers to addresses (symbol tables and breakpoints at least) needs to be relocated for both shared libraries and the main executable. At least using the standard mechanism this can only be done once the program has @@ -590,7 +599,10 @@ been run (or the core file has been read). @subsection PE Windows 95 and NT use the PE (Portable Executable) format for their -executables. PE is basically COFF with an additional header or two. +executables. PE is basically COFF with additional headers. + +While BFD includes special PE support, GDB needs only the basic +COFF reader. @subsection ELF @@ -598,20 +610,70 @@ The ELF format came with System V Release 4 (SVR4) Unix. ELF is similar to COFF in being organized into a number of sections, but it removes many of COFF's limitations. +The basic ELF reader is in @file{elfread.c}. + @subsection SOM +SOM is HP's object file and debug format (not to be confused with IBM's +SOM, which is a cross-language ABI). + +The SOM reader is in @file{hpread.c}. + +@subsection Other File Formats + +Other file formats that have been supported by GDB include Netware +Loadable Modules (@file{nlmread.c}. + @section Debugging File Formats +This section describes characteristics of debugging information that +are independent of the object file format. + @subsection stabs +@code{stabs} started out as special symbols within the @code{a.out} +format. Since then, it has been encapsulated into other file +formats, such as COFF and ELF. + +While @file{dbxread.c} does some of the basic stab processing, +including for encapsulated versions, @file{stabsread.c} does +the real work. + @subsection COFF +The basic COFF definition includes debugging information. The level +of support is minimal and non-extensible, and is not often used. + +@subsection Mips debug (Third Eye) + +ECOFF includes a definition of a special debug format. + +The file @file{mdebugread.c} implements reading for this format. + @subsection DWARF 1 +DWARF 1 is a debugging format that was originally designed to be +used with ELF in SVR4 systems. + +@c CHILL_PRODUCER +@c GCC_PRODUCER +@c GPLUS_PRODUCER +@c LCC_PRODUCER +@c If defined, these are the producer strings in a DWARF 1 file. All of +@c these have reasonable defaults already. + +The DWARF 1 reader is in @file{dwarfread.c}. + @subsection DWARF 2 +DWARF 2 is an improved but incompatible version of DWARF 1. + +The DWARF 2 reader is in @file{dwarf2read.c}. + @subsection SOM +Like COFF, the SOM definition includes debugging information. + @section Adding a New Symbol Reader to GDB If you are using an existing object file format (a.out, COFF, ELF, etc), @@ -1071,7 +1133,7 @@ GDB does not have a magical way to match up with the compiler's idea of which registers are which; however, it is critical that they do match up accurately. The only way to make this work is to get accurate information about the order that the compiler uses, and to reflect that -in the @code{REGISTER_NAMES} and related macros. +in the @code{REGISTER_NAME} and related macros. GDB can handle big-endian, little-endian, and bi-endian architectures. @@ -1178,13 +1240,6 @@ written to the target. This is often the case for program counters, status words, and other special registers. If this is not defined, GDB will assume that all registers may be written. -@item CHILL_PRODUCER -@item GCC_PRODUCER -@item GPLUS_PRODUCER -@item LCC_PRODUCER -If defined, these are the producer strings in a DWARF 1 file. All of -these have reasonable defaults already. - @item DO_DEFERRED_STORES @item CLEAR_DEFERRED_STORES Define this to execute any deferred stores of registers into the inferior, @@ -1360,22 +1415,20 @@ given @var{pc}. On machines where the address is just a compile time constant, the macro expansion will typically just ignore the supplied @var{pc}. -@item IN_SOLIB_TRAMPOLINE pc name +@item IN_SOLIB_CALL_TRAMPOLINE pc name Define this to evaluate to nonzero if the program is stopped in the trampoline that connects to a shared library. +@item IN_SOLIB_RETURN_TRAMPOLINE pc name +Define this to evaluate to nonzero if the program is stopped in the +trampoline that returns from a shared library. + @item IS_TRAPPED_INTERNALVAR (name) This is an ugly hook to allow the specification of special actions that should occur as a side-effect of setting the value of a variable internal to GDB. Currently only used by the h8500. Note that this could be either a host or target conditional. -@item KERNEL_DEBUGGING -tm-ultra3.h - -@item MIPSEL -mips-tdep.c - @item NEED_TEXT_START_END Define this if GDB should determine the start and end addresses of the text section. (Seems dubious.) @@ -1447,9 +1500,9 @@ Used in @samp{call_function_by_hand} to create an artificial stack frame. The total amount of space needed to store GDB's copy of the machine's register state. -@item REGISTER_NAMES -Define this to expand into an initializer of an array of strings. Each -string is the name of a register. +@item REGISTER_NAME(i) +Return the name of register @var{i} as a string. May return @var{NULL} +or @var{NUL} to indicate that register @var{i} is not valid. @item REG_STRUCT_HAS_ADDR (gcc_p, type) Define this to return 1 if the given type will be passed by pointer diff --git a/gdb/findvar.c b/gdb/findvar.c index 9c3d58097c8..298abf7d631 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -577,7 +577,7 @@ value_of_register (regnum) REGISTER_RAW_SIZE (regnum)); else fatal ("Register \"%s\" (%d) has conflicting raw (%d) and virtual (%d) size", - reg_names [regnum], regnum, + REGISTER_NAME (regnum), regnum, REGISTER_RAW_SIZE (regnum), REGISTER_VIRTUAL_SIZE (regnum)); VALUE_LVAL (reg_val) = lval; VALUE_ADDRESS (reg_val) = addr; @@ -686,7 +686,7 @@ read_register_bytes (inregbyte, myaddr, inlen) if (register_valid[regno]) continue; - if (reg_names[regno] == NULL || *reg_names[regno] == '\0') + if (REGISTER_NAME (regno) == NULL || *REGISTER_NAME (regno) == '\0') continue; regstart = REGISTER_BYTE (regno); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 03215cedc34..e09c220fda1 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1839,7 +1839,7 @@ pa_do_registers_info (regnum, fpregs) if (regnum == -1) pa_print_registers (raw_regs, regnum, fpregs); else if (regnum < FP0_REGNUM) - printf_unfiltered ("%s %x\n", reg_names[regnum], *(long *)(raw_regs + + printf_unfiltered ("%s %x\n", REGISTER_NAME (regnum), *(long *)(raw_regs + REGISTER_BYTE (regnum))); else pa_print_fp_reg (regnum); @@ -1860,7 +1860,7 @@ pa_print_registers (raw_regs, regnum, fpregs) { val = extract_signed_integer (raw_regs + REGISTER_BYTE (i+(j*18)), 4); - printf_unfiltered ("%8.8s: %8x ", reg_names[i+(j*18)], val); + printf_unfiltered ("%8.8s: %8x ", REGISTER_NAME (i+(j*18)), val); } printf_unfiltered ("\n"); } @@ -1883,8 +1883,8 @@ pa_print_fp_reg (i) /* Put it in the buffer. No conversions are ever necessary. */ memcpy (virtual_buffer, raw_buffer, REGISTER_RAW_SIZE (i)); - fputs_filtered (reg_names[i], gdb_stdout); - print_spaces_filtered (8 - strlen (reg_names[i]), gdb_stdout); + fputs_filtered (REGISTER_NAME (i), gdb_stdout); + print_spaces_filtered (8 - strlen (REGISTER_NAME (i)), gdb_stdout); fputs_filtered ("(single precision) ", gdb_stdout); val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, gdb_stdout, 0, @@ -1903,8 +1903,8 @@ pa_print_fp_reg (i) REGISTER_RAW_SIZE (i)); /* Dump it as a double. */ - fputs_filtered (reg_names[i], gdb_stdout); - print_spaces_filtered (8 - strlen (reg_names[i]), gdb_stdout); + fputs_filtered (REGISTER_NAME (i), gdb_stdout); + print_spaces_filtered (8 - strlen (REGISTER_NAME (i)), gdb_stdout); fputs_filtered ("(double precision) ", gdb_stdout); val_print (builtin_type_double, virtual_buffer, 0, gdb_stdout, 0, diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 3a916ba7a08..6280f2c8d51 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1102,12 +1102,32 @@ set_reg_offset (regno, offset) } +/* Test whether the PC points to the return instruction at the + end of a function. */ + +static int +mips_about_to_return (pc) + CORE_ADDR pc; +{ + if (pc_is_mips16 (pc)) + /* This mips16 case isn't necessarily reliable. Sometimes the compiler + generates a "jr $ra"; other times it generates code to load + the return address from the stack to an accessible register (such + as $a3), then a "jr" using that register. This second case + is almost impossible to distinguish from an indirect jump + used for switch statements, so we don't even try. */ + return mips_fetch_instruction (pc) == 0xe820; /* jr $ra */ + else + return mips_fetch_instruction (pc) == 0x3e00008; /* jr $ra */ +} + + /* This fencepost looks highly suspicious to me. Removing it also seems suspicious as it could affect remote debugging across serial lines. */ static CORE_ADDR -heuristic_proc_start(pc) +heuristic_proc_start (pc) CORE_ADDR pc; { CORE_ADDR start_pc; @@ -1181,7 +1201,7 @@ Otherwise, you told GDB there was a function where there isn't one, or\n\ else seen_adjsp = 0; } - else if (ABOUT_TO_RETURN(start_pc)) + else if (mips_about_to_return (start_pc)) { start_pc += 2 * MIPS_INSTLEN; /* skip return, and its delay slot */ break; @@ -2136,7 +2156,7 @@ mips_print_register (regnum, all) /* Get the data in raw format. */ if (read_relative_register_raw_bytes (regnum, raw_buffer)) { - printf_filtered ("%s: [Invalid]", reg_names[regnum]); + printf_filtered ("%s: [Invalid]", REGISTER_NAME (regnum)); return; } @@ -2156,7 +2176,7 @@ mips_print_register (regnum, all) gdb_stdout, 0, 1, 0, Val_pretty_default); printf_filtered ("); "); } - fputs_filtered (reg_names[regnum], gdb_stdout); + fputs_filtered (REGISTER_NAME (regnum), gdb_stdout); /* The problem with printing numeric register names (r26, etc.) is that the user can't use them on input. Probably the best solution is to @@ -2210,14 +2230,14 @@ do_fp_register_row (regnum) /* Get the data in raw format. */ if (read_relative_register_raw_bytes (regnum, raw_buffer[HI])) - error ("can't read register %d (%s)", regnum, reg_names[regnum]); + error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum)); if (REGISTER_RAW_SIZE(regnum) == 4) { /* 4-byte registers: we can fit two registers per row. */ /* Also print every pair of 4-byte regs as an 8-byte double. */ if (read_relative_register_raw_bytes (regnum + 1, raw_buffer[LO])) error ("can't read register %d (%s)", - regnum + 1, reg_names[regnum + 1]); + regnum + 1, REGISTER_NAME (regnum + 1)); /* copy the two floats into one double, and unpack both */ memcpy (dbl_buffer, raw_buffer, sizeof(dbl_buffer)); @@ -2226,9 +2246,9 @@ do_fp_register_row (regnum) doub = unpack_double (builtin_type_double, dbl_buffer, &inv3); printf_filtered (inv1 ? " %-5s: " : - " %-5s%-17.9g", reg_names[regnum], flt1); + " %-5s%-17.9g", REGISTER_NAME (regnum), flt1); printf_filtered (inv2 ? " %-5s: " : - " %-5s%-17.9g", reg_names[regnum + 1], flt2); + " %-5s%-17.9g", REGISTER_NAME (regnum + 1), flt2); printf_filtered (inv3 ? " dbl: \n" : " dbl: %-24.17g\n", doub); /* may want to do hex display here (future enhancement) */ @@ -2244,7 +2264,7 @@ do_fp_register_row (regnum) doub = unpack_double (builtin_type_double, dbl_buffer, &inv3); printf_filtered (inv1 ? " %-5s: " : - " %-5s flt: %-17.9g", reg_names[regnum], flt1); + " %-5s flt: %-17.9g", REGISTER_NAME (regnum), flt1); printf_filtered (inv3 ? " dbl: \n" : " dbl: %-24.17g\n", doub); /* may want to do hex display here (future enhancement) */ @@ -2276,12 +2296,12 @@ do_gp_register_row (regnum) printf_filtered (" "); for (col = 0; col < ncols && regnum < numregs; regnum++) { - if (*reg_names[regnum] == '\0') + if (*REGISTER_NAME (regnum) == '\0') continue; /* unused register */ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT) break; /* end the row: reached FP register */ printf_filtered (MIPS_REGSIZE == 8 ? "%17s" : "%9s", - reg_names[regnum]); + REGISTER_NAME (regnum)); col++; } printf_filtered (start_regnum < MIPS_NUMREGS ? "\n R%-4d" : "\n ", @@ -2291,13 +2311,13 @@ do_gp_register_row (regnum) /* now print the values in hex, 4 or 8 to the row */ for (col = 0; col < ncols && regnum < numregs; regnum++) { - if (*reg_names[regnum] == '\0') + if (*REGISTER_NAME (regnum) == '\0') continue; /* unused register */ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT) break; /* end row: reached FP register */ /* OK: get the data in raw format. */ if (read_relative_register_raw_bytes (regnum, raw_buffer)) - error ("can't read register %d (%s)", regnum, reg_names[regnum]); + error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum)); /* pad small registers */ for (byte = 0; byte < (MIPS_REGSIZE - REGISTER_RAW_SIZE (regnum)); byte++) printf_filtered (" "); @@ -2326,7 +2346,7 @@ mips_do_registers_info (regnum, fpregs) { if (regnum != -1) /* do one specified register */ { - if (*(reg_names[regnum]) == '\0') + if (*(REGISTER_NAME (regnum)) == '\0') error ("Not a valid register for the current processor type"); mips_print_register (regnum, 0); @@ -2825,7 +2845,8 @@ mips_set_processor_type (str) mips_processor_type = str; for (j = 0; j < NUM_REGS; ++j) - reg_names[j] = mips_processor_type_table[i].regnames[j]; + /* FIXME - MIPS should be defining REGISTER_NAME() instead */ + gdb_register_names[j] = mips_processor_type_table[i].regnames[j]; return 1; @@ -2898,6 +2919,19 @@ gdb_print_insn_mips (memaddr, info) return print_insn_little_mips (memaddr, info); } +/* Old-style breakpoint macros. + The IDT board uses an unusual breakpoint value, and sometimes gets + confused when it sees the usual MIPS breakpoint instruction. */ + +#define BIG_BREAKPOINT {0, 0x5, 0, 0xd} +#define LITTLE_BREAKPOINT {0xd, 0, 0x5, 0} +#define PMON_BIG_BREAKPOINT {0, 0, 0, 0xd} +#define PMON_LITTLE_BREAKPOINT {0xd, 0, 0, 0} +#define IDT_BIG_BREAKPOINT {0, 0, 0x0a, 0xd} +#define IDT_LITTLE_BREAKPOINT {0xd, 0x0a, 0, 0} +#define MIPS16_BIG_BREAKPOINT {0xe8, 0xa5} +#define MIPS16_LITTLE_BREAKPOINT {0xa5, 0xe8} + /* This function implements the BREAKPOINT_FROM_PC macro. It uses the program counter value to determine whether a 16- or 32-bit breakpoint should be used. It returns a pointer to a string of bytes that encode a breakpoint @@ -2965,26 +2999,6 @@ unsigned char *mips_breakpoint_from_pc (pcptr, lenptr) } } -/* Test whether the PC points to the return instruction at the - end of a function. This implements the ABOUT_TO_RETURN macro. */ - -int -mips_about_to_return (pc) - CORE_ADDR pc; -{ - if (pc_is_mips16 (pc)) - /* This mips16 case isn't necessarily reliable. Sometimes the compiler - generates a "jr $ra"; other times it generates code to load - the return address from the stack to an accessible register (such - as $a3), then a "jr" using that register. This second case - is almost impossible to distinguish from an indirect jump - used for switch statements, so we don't even try. */ - return mips_fetch_instruction (pc) == 0xe820; /* jr $ra */ - else - return mips_fetch_instruction (pc) == 0x3e00008; /* jr $ra */ -} - - /* If PC is in a mips16 call or return stub, return the address of the target PC, which is either the callee or the caller. There are several cases which must be handled: diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 44e9f6b0263..eb2426ff59a 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -28,15 +28,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gdbcore.h" #include "symfile.h" -char *mn10300_generic_register_names[] = REGISTER_NAMES; +static char *mn10300_generic_register_names[] = +{ "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3", + "sp", "pc", "mdr", "psw", "lir", "lar", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "fp" }; +char **mn10300_register_names = mn10300_generic_register_names; /* start-sanitize-am33 */ -char *am33_register_names [] = +static char *am33_register_names [] = { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3", "sp", "pc", "mdr", "psw", "lir", "lar", "", "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ssp", "msp", "usp", "mcrh", "mcrl", "mcvf", "", "", ""}; -int am33_mode; +static int am33_mode; /* end-sanitize-am33 */ static CORE_ADDR mn10300_analyze_prologue PARAMS ((struct frame_info *fi, @@ -739,6 +744,41 @@ mn10300_init_extra_frame_info (fi) mn10300_analyze_prologue (fi, 0); } +/* Function: mn10300_virtual_frame_pointer + Return the register that the function uses for a frame pointer, + plus any necessary offset to be applied to the register before + any frame pointer offsets. */ + +void +mn10300_virtual_frame_pointer (pc, reg, offset) + CORE_ADDR pc; + long *reg; + long *offset; +{ + struct frame_info fi; + + /* Set up a dummy frame_info. */ + fi.next = NULL; + fi.prev = NULL; + fi.frame = 0; + fi.pc = pc; + + /* Analyze the prolog and fill in the extra info. */ + mn10300_init_extra_frame_info (&fi); + + /* Results will tell us which type of frame it uses. */ + if (fi.status & MY_FRAME_IN_SP) + { + *reg = SP_REGNUM; + *offset = -(fi.stack_size); + } + else + { + *reg = A3_REGNUM; + *offset = 0; + } +} + /* This can be made more generic later. */ static void set_machine_hook (filename) @@ -749,16 +789,15 @@ set_machine_hook (filename) if (bfd_get_mach (exec_bfd) == bfd_mach_mn10300 || bfd_get_mach (exec_bfd) == 0) { - for (i = 0; i < NUM_REGS; i++) - reg_names[i] = mn10300_generic_register_names[i]; + mn10300_register_names = mn10300_generic_register_names; } /* start-sanitize-am33 */ am33_mode = 0; if (bfd_get_mach (exec_bfd) == bfd_mach_am33) { - for (i = 0; i < NUM_REGS; i++) - reg_names[i] = am33_register_names[i]; + + mn10300_register_names = am33_register_names; am33_mode = 1; } /* end-sanitize-am33 */ diff --git a/gdb/parse.c b/gdb/parse.c index 2d4a629a772..bd74ecde065 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -129,8 +129,8 @@ target_map_name_to_register (str, len) /* Search architectural register name space. */ for (i = 0; i < NUM_REGS; i++) - if (reg_names[i] && len == strlen (reg_names[i]) - && STREQN (str, reg_names[i], len)) + if (REGISTER_NAME (i) && len == strlen (REGISTER_NAME (i)) + && STREQN (str, REGISTER_NAME (i), len)) { return i; } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 6d475c9dada..ecde3eb5aba 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -121,12 +121,13 @@ static int display_number; int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *)); disassemble_info tm_print_insn_info; -/* Functions exported for general use: */ +/* Prototypes for exported functions. */ void output_command PARAMS ((char *, int)); +void _initialize_printcmd PARAMS ((void)); -/* Prototypes for local functions. */ +/* Prototypes for local functions. */ static void delete_display PARAMS ((int)); @@ -1106,7 +1107,7 @@ address_info (exp, from_tty) break; case LOC_REGISTER: - printf_filtered ("a variable in register %s", reg_names[val]); + printf_filtered ("a variable in register %s", REGISTER_NAME (val)); break; case LOC_STATIC: @@ -1123,11 +1124,11 @@ address_info (exp, from_tty) break; case LOC_REGPARM: - printf_filtered ("an argument in register %s", reg_names[val]); + printf_filtered ("an argument in register %s", REGISTER_NAME (val)); break; case LOC_REGPARM_ADDR: - printf_filtered ("address of an argument in register %s", reg_names[val]); + printf_filtered ("address of an argument in register %s", REGISTER_NAME (val)); break; case LOC_ARG: @@ -1148,12 +1149,12 @@ address_info (exp, from_tty) case LOC_BASEREG: printf_filtered ("a variable at offset %ld from register %s", - val, reg_names[basereg]); + val, REGISTER_NAME (basereg)); break; case LOC_BASEREG_ARG: printf_filtered ("an argument at offset %ld from register %s", - val, reg_names[basereg]); + val, REGISTER_NAME (basereg)); break; case LOC_TYPEDEF: @@ -1921,9 +1922,9 @@ printf_command (arg, from_tty) char *arg; int from_tty; { - register char *f; + register char *f = NULL; register char *s = arg; - char *string; + char *string = NULL; value_ptr *val_args; char *substrings; char *current_substring; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index f76375335ac..aaa225230f1 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -345,7 +345,7 @@ gdbsim_fetch_register (regno) for (regno = 0; regno < NUM_REGS; regno++) gdbsim_fetch_register (regno); } - else if (reg_names[regno] != NULL && *reg_names[regno] != '\0') + else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0') { char buf[MAX_REGISTER_RAW_SIZE]; int nr_bytes = sim_fetch_register (gdbsim_desc, regno, buf, REGISTER_RAW_SIZE (regno)); @@ -356,7 +356,7 @@ gdbsim_fetch_register (regno) && warn_user) { printf_unfiltered ("Size of register %s (%d) incorrect (%d instead of %d))", - reg_names [regno], regno, + REGISTER_NAME (regno), regno, nr_bytes, REGISTER_RAW_SIZE (regno)); warn_user = 0; } @@ -380,7 +380,7 @@ gdbsim_store_register (regno) for (regno = 0; regno < NUM_REGS; regno++) gdbsim_store_register (regno); } - else if (reg_names[regno] != NULL && *reg_names[regno] != '\0') + else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0') { char tmp[MAX_REGISTER_RAW_SIZE]; int nr_bytes; diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index 324a7df4ab3..5b5ca5ccfaa 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -1450,7 +1450,7 @@ fetch_register (regno) supply_register(regno, (char *) &To); if (remote_debug) - printf_unfiltered("Fetching register %s = 0x%x\n", reg_names[regno], To); + printf_unfiltered("Fetching register %s = 0x%x\n", REGISTER_NAME (regno), To); } /*****************************************************************************/ /* Store a single register indicated by 'regno'. @@ -1471,7 +1471,7 @@ store_register (regno) From = read_register (regno); /* get data value */ if (remote_debug) - printf_unfiltered("Storing register %s = 0x%x\n", reg_names[regno], From); + printf_unfiltered("Storing register %s = 0x%x\n", REGISTER_NAME (regno), From); if (regno == GR1_REGNUM) { diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index e5245098672..55fef8995c2 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -38,9 +38,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* A set of original names, to be used when restoring back to generic registers from a specific set. */ -char *sh_generic_reg_names[] = REGISTER_NAMES; +static char *sh_generic_reg_names[] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", + "fpul", "fpscr", + "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", + "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", + "ssr", "spc", + "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0", + "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1", +}; -char *sh_reg_names[] = { +static char *sh_reg_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -52,7 +62,7 @@ char *sh_reg_names[] = { "", "", "", "", "", "", "", "", }; -char *sh3_reg_names[] = { +static char *sh3_reg_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -64,7 +74,7 @@ char *sh3_reg_names[] = { "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1" }; -char *sh3e_reg_names[] = { +static char *sh3e_reg_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -76,6 +86,9 @@ char *sh3e_reg_names[] = { "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1", }; +char **sh_register_names = sh_generic_reg_names; + + struct { char **regnames; int mach; @@ -598,9 +611,7 @@ sh_target_architecture_hook (ap) { if (sh_processor_type_table[i].mach == ap->mach) { - for (j = 0; j < NUM_REGS; ++j) - reg_names[j] = sh_processor_type_table[i].regnames[j]; - return 1; + sh_register_names = sh_processor_type_table[i].regnames; } } diff --git a/gdb/stack.c b/gdb/stack.c index 06fd83d4b03..53389385ab0 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1,5 +1,5 @@ /* Print and select stack frames for GDB, the GNU debugger. - Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995 + Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 1998 Free Software Foundation, Inc. This file is part of GDB. @@ -34,6 +34,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "demangle.h" #include "inferior.h" #include "annotate.h" +#include "symfile.h" +#include "objfiles.h" + +/* Prototypes for exported functions. */ + +void args_info PARAMS ((char *, int)); + +void locals_info PARAMS ((char *, int)); + +void (*selected_frame_level_changed_hook) PARAMS ((int)); + +void _initialize_stack PARAMS ((void)); + +/* Prototypes for local functions. */ static void return_command PARAMS ((char *, int)); @@ -49,14 +63,10 @@ static void frame_command PARAMS ((char *, int)); static void select_frame_command PARAMS ((char *, int)); -static void args_info PARAMS ((char *, int)); - static void print_frame_arg_vars PARAMS ((struct frame_info *, GDB_FILE *)); static void catch_info PARAMS ((char *, int)); -static void locals_info PARAMS ((char *, int)); - static void print_frame_label_vars PARAMS ((struct frame_info *, int, GDB_FILE *)); @@ -142,7 +152,7 @@ print_stack_frame (fi, level, source) args.source = source; args.args = 1; - catch_errors (print_stack_frame_stub, (char *)&args, "", RETURN_MASK_ERROR); + catch_errors (print_stack_frame_stub, (char *)&args, "", RETURN_MASK_ALL); } struct print_args_args { @@ -284,7 +294,7 @@ print_frame_info (fi, level, source, args) } else { - register struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); + struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); if (msymbol != NULL) { funname = SYMBOL_NAME (msymbol); @@ -317,7 +327,8 @@ print_frame_info (fi, level, source, args) struct print_args_args args; args.fi = fi; args.func = func; - catch_errors (print_args_stub, (char *)&args, "", RETURN_MASK_ERROR); + catch_errors (print_args_stub, (char *)&args, "", RETURN_MASK_ALL); + QUIT; } printf_filtered (")"); if (sal.symtab && sal.symtab->filename) @@ -564,7 +575,7 @@ frame_info (addr_exp, from_tty) print_address_numeric (fi->frame, 1, gdb_stdout); printf_filtered (":\n"); } - printf_filtered (" %s = ", reg_names[PC_REGNUM]); + printf_filtered (" %s = ", REGISTER_NAME (PC_REGNUM)); print_address_numeric (fi->pc, 1, gdb_stdout); wrap_here (" "); @@ -579,7 +590,7 @@ frame_info (addr_exp, from_tty) printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line); puts_filtered ("; "); wrap_here (" "); - printf_filtered ("saved %s ", reg_names[PC_REGNUM]); + printf_filtered ("saved %s ", REGISTER_NAME (PC_REGNUM)); print_address_numeric (FRAME_SAVED_PC (fi), 1, gdb_stdout); printf_filtered ("\n"); @@ -672,7 +683,7 @@ frame_info (addr_exp, from_tty) else puts_filtered (","); wrap_here (" "); - printf_filtered (" %s at ", reg_names[i]); + printf_filtered (" %s at ", REGISTER_NAME (i)); print_address_numeric (fsr.regs[i], 1, gdb_stdout); count++; } @@ -1006,7 +1017,7 @@ print_frame_label_vars (fi, this_level_only, stream) } /* ARGSUSED */ -static void +void locals_info (args, from_tty) char *args; int from_tty; @@ -1091,7 +1102,7 @@ print_frame_arg_vars (fi, stream) } } -static void +void args_info (ignore, from_tty) char *ignore; int from_tty; @@ -1100,6 +1111,7 @@ args_info (ignore, from_tty) error ("No frame selected."); print_frame_arg_vars (selected_frame, gdb_stdout); } + /* Select frame FI, and note that its stack level is LEVEL. LEVEL may be -1 if an actual level number is not known. */ @@ -1113,6 +1125,8 @@ select_frame (fi, level) selected_frame = fi; selected_frame_level = level; + if (selected_frame_level_changed_hook) + selected_frame_level_changed_hook (level); /* Ensure that symbols for this frame are read in. Also, determine the source language of this frame, and switch to it if desired. */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index ff475a1b591..7f17fab0d3e 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2363,7 +2363,7 @@ scope_info (args, from_tty) break; case LOC_REGISTER: printf_filtered ("a local variable in register $%s", - reg_names [SYMBOL_VALUE (sym)]); + REGISTER_NAME (SYMBOL_VALUE (sym))); break; case LOC_ARG: case LOC_LOCAL_ARG: @@ -2380,11 +2380,11 @@ scope_info (args, from_tty) break; case LOC_REGPARM: printf_filtered ("an argument in register $%s", - reg_names[SYMBOL_VALUE (sym)]); + REGISTER_NAME (SYMBOL_VALUE (sym))); break; case LOC_REGPARM_ADDR: printf_filtered ("the address of an argument, in register $%s", - reg_names[SYMBOL_VALUE (sym)]); + REGISTER_NAME (SYMBOL_VALUE (sym))); break; case LOC_TYPEDEF: printf_filtered ("a typedef.\n"); @@ -2401,12 +2401,12 @@ scope_info (args, from_tty) case LOC_BASEREG: printf_filtered ("a variable at offset %d from register $%s", SYMBOL_VALUE (sym), - reg_names [SYMBOL_BASEREG (sym)]); + REGISTER_NAME (SYMBOL_BASEREG (sym))); break; case LOC_BASEREG_ARG: printf_filtered ("an argument at offset %d from register $%s", SYMBOL_VALUE (sym), - reg_names [SYMBOL_BASEREG (sym)]); + REGISTER_NAME (SYMBOL_BASEREG (sym))); break; case LOC_UNRESOLVED: msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);