From 5f601589e1e0dad6276d458d25c818ff6458b3f3 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sun, 2 Feb 2003 18:53:22 +0000 Subject: [PATCH] 2003-02-02 Andrew Cagney * frame.h: Note that namelen can be negative. * frame.c (frame_map_name_to_regnum): When LEN is negative, use NAME's length. * NEWS: Mention that the d10v's `regs' command is deprecated. * d10v-tdep.c (d10v_gdbarch_init): Set print_registers_info. (d10v_print_registers_info): New function. (show_regs): Call d10v_print_registers_info. (_initialize_d10v_tdep): Mark "show regs" command as deprecated. --- gdb/ChangeLog | 12 +++++ gdb/NEWS | 5 ++ gdb/d10v-tdep.c | 124 +++++++++++++++++++++++++++++------------------- gdb/frame.c | 3 ++ gdb/frame.h | 5 +- 5 files changed, 99 insertions(+), 50 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 30fdf7e4ad1..b819c67933a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2003-02-02 Andrew Cagney + + * frame.h: Note that namelen can be negative. + * frame.c (frame_map_name_to_regnum): When LEN is negative, use + NAME's length. + + * NEWS: Mention that the d10v's `regs' command is deprecated. + * d10v-tdep.c (d10v_gdbarch_init): Set print_registers_info. + (d10v_print_registers_info): New function. + (show_regs): Call d10v_print_registers_info. + (_initialize_d10v_tdep): Mark "show regs" command as deprecated. + 2003-02-02 Mark Kettenis * stack.c (print_frame_info): Restore call to annotate_frame_begin diff --git a/gdb/NEWS b/gdb/NEWS index a59e99b2d45..6bb45081ee8 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,11 @@ *** Changes since GDB 5.3: +* d10v `regs' command deprecated + +The `info registers' command has been updated so that it displays the +registers using a format identical to the old `regs' command. + * Profiling support A new command, "maint set profile on/off", has been added. This command can diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index 4cd3c6300f3..05bf475a427 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -819,65 +819,90 @@ d10v_frame_unwind_cache (struct frame_info *fi, } static void -show_regs (char *args, int from_tty) +d10v_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, + struct frame_info *frame, int regnum, int all) { - int a; - printf_filtered ("PC=%04lx (0x%lx) PSW=%04lx RPT_S=%04lx RPT_E=%04lx RPT_C=%04lx\n", - (long) read_register (PC_REGNUM), - (long) d10v_make_iaddr (read_register (PC_REGNUM)), - (long) read_register (PSW_REGNUM), - (long) read_register (24), - (long) read_register (25), - (long) read_register (23)); - printf_filtered ("R0-R7 %04lx %04lx %04lx %04lx %04lx %04lx %04lx %04lx\n", - (long) read_register (0), - (long) read_register (1), - (long) read_register (2), - (long) read_register (3), - (long) read_register (4), - (long) read_register (5), - (long) read_register (6), - (long) read_register (7)); - printf_filtered ("R8-R15 %04lx %04lx %04lx %04lx %04lx %04lx %04lx %04lx\n", - (long) read_register (8), - (long) read_register (9), - (long) read_register (10), - (long) read_register (11), - (long) read_register (12), - (long) read_register (13), - (long) read_register (14), - (long) read_register (15)); - for (a = 0; a < NR_IMAP_REGS; a++) + if (regnum >= 0) { - if (a > 0) - printf_filtered (" "); - printf_filtered ("IMAP%d %04lx", a, d10v_imap_register (a)); - } - if (NR_DMAP_REGS == 1) - printf_filtered (" DMAP %04lx\n", d10v_dmap_register (2)); - else - { - for (a = 0; a < NR_DMAP_REGS; a++) - { - printf_filtered (" DMAP%d %04lx", a, d10v_dmap_register (a)); - } - printf_filtered ("\n"); + default_print_registers_info (gdbarch, file, frame, regnum, all); + return; } - printf_filtered ("A0-A%d", NR_A_REGS - 1); + + { + ULONGEST pc, psw, rpt_s, rpt_e, rpt_c; + frame_read_unsigned_register (frame, PC_REGNUM, &pc); + frame_read_unsigned_register (frame, PSW_REGNUM, &psw); + frame_read_unsigned_register (frame, frame_map_name_to_regnum ("rpt_s", -1), &rpt_s); + frame_read_unsigned_register (frame, frame_map_name_to_regnum ("rpt_e", -1), &rpt_e); + frame_read_unsigned_register (frame, frame_map_name_to_regnum ("rpt_c", -1), &rpt_c); + fprintf_filtered (file, "PC=%04lx (0x%lx) PSW=%04lx RPT_S=%04lx RPT_E=%04lx RPT_C=%04lx\n", + (long) pc, (long) d10v_make_iaddr (pc), (long) psw, + (long) rpt_s, (long) rpt_e, (long) rpt_c); + } + + { + int group; + for (group = 0; group < 16; group += 8) + { + int r; + fprintf_filtered (file, "R%d-R%-2d", group, group + 7); + for (r = group; r < group + 8; r++) + { + ULONGEST tmp; + frame_read_unsigned_register (frame, r, &tmp); + fprintf_filtered (file, " %04lx", (long) tmp); + } + fprintf_filtered (file, "\n"); + } + } + + /* Note: The IMAP/DMAP registers don't participate in function + calls. Don't bother trying to unwind them. */ + { - char *num = alloca (max_register_size (current_gdbarch)); + int a; + for (a = 0; a < NR_IMAP_REGS; a++) + { + if (a > 0) + fprintf_filtered (file, " "); + fprintf_filtered (file, "IMAP%d %04lx", a, d10v_imap_register (a)); + } + if (NR_DMAP_REGS == 1) + /* Registers DMAP0 and DMAP1 are constant. Just return dmap2. */ + fprintf_filtered (file, " DMAP %04lx\n", d10v_dmap_register (2)); + else + { + for (a = 0; a < NR_DMAP_REGS; a++) + { + fprintf_filtered (file, " DMAP%d %04lx", a, d10v_dmap_register (a)); + } + fprintf_filtered (file, "\n"); + } + } + + { + char *num = alloca (max_register_size (gdbarch)); + int a; + fprintf_filtered (file, "A0-A%d", NR_A_REGS - 1); for (a = A0_REGNUM; a < A0_REGNUM + NR_A_REGS; a++) { int i; - printf_filtered (" "); - deprecated_read_register_gen (a, (char *) &num); + fprintf_filtered (file, " "); + frame_register_read (frame, a, num); for (i = 0; i < MAX_REGISTER_RAW_SIZE; i++) { - printf_filtered ("%02x", (num[i] & 0xff)); + fprintf_filtered (file, "%02x", (num[i] & 0xff)); } } } - printf_filtered ("\n"); + fprintf_filtered (file, "\n"); +} + +static void +show_regs (char *args, int from_tty) +{ + d10v_print_registers_info (current_gdbarch, gdb_stdout, + get_current_frame (), -1, 1); } static CORE_ADDR @@ -1701,6 +1726,8 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_register_sim_regno (gdbarch, d10v_register_sim_regno); set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); + set_gdbarch_print_registers_info (gdbarch, d10v_print_registers_info); + frame_unwind_append_predicate (gdbarch, d10v_frame_p); return gdbarch; @@ -1720,7 +1747,8 @@ _initialize_d10v_tdep (void) target_resume_hook = d10v_eva_prepare_to_trace; target_wait_loop_hook = d10v_eva_get_trace_data; - add_com ("regs", class_vars, show_regs, "Print all registers"); + deprecate_cmd (add_com ("regs", class_vars, show_regs, "Print all registers"), + "info registers"); add_com ("itrace", class_support, trace_command, "Enable tracing of instruction execution."); diff --git a/gdb/frame.c b/gdb/frame.c index e4adf7d7c51..f5d40bdf537 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -385,6 +385,9 @@ frame_map_name_to_regnum (const char *name, int len) { int i; + if (len < 0) + len = strlen (name); + /* Search register name space. */ for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++) if (REGISTER_NAME (i) && len == strlen (REGISTER_NAME (i)) diff --git a/gdb/frame.h b/gdb/frame.h index 8e0da6df364..dc90e0af275 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -291,9 +291,10 @@ extern void frame_read_unsigned_register (struct frame_info *frame, /* 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. */ + includes builtin registers. If NAMELEN is negative, use the NAME's + length when doing the comparison. */ -extern int frame_map_name_to_regnum (const char *name, int strlen); +extern int frame_map_name_to_regnum (const char *name, int namelen); extern const char *frame_map_regnum_to_name (int regnum); /* Unwind the PC. Strictly speaking return the resume address of the -- 2.30.2