From d6ea11561793c96cf1eb9f3f013089724c9c923d Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Thu, 6 Dec 2012 14:15:54 +0800 Subject: [PATCH 5/5] * tilegx-tdep.c (tilera_print_registers_info): new support tilegx private register info hook to show registers in columns. --- gdb/tilegx-tdep.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 1e967fe..bf00983 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -946,6 +946,66 @@ tilegx_cannot_reference_register (struct gdbarch *gdbarch, int regno) return 1; } + +/* Tilera private register printer. */ +#define MAX_COLUMNS 3 +static void +tilera_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, + struct frame_info *frame, + int regnum, int print_all) +{ + int i; + int j; + int k; + gdb_byte buffer[MAX_REGISTER_SIZE]; + + if (regnum != -1) + { + default_print_registers_info (gdbarch, file, frame, regnum, print_all); + return; + } + + for (i = 0; i < TILEGX_NUM_EASY_REGS / MAX_COLUMNS + 1; ++i) + { + for (j = i; + j < TILEGX_NUM_EASY_REGS + 1; + j += TILEGX_NUM_EASY_REGS / MAX_COLUMNS + 1) + { + /* Some registers are never available. Skip them and print PC. */ + if (j > TILEGX_LR_REGNUM) + j = TILEGX_PC_REGNUM; + + if (j > i) + fprintf_filtered (file, " "); + + fputs_filtered (gdbarch_register_name (gdbarch, j), file); + print_spaces_filtered (5 - strlen (gdbarch_register_name + (gdbarch, j)), file); + + /* Get the data in raw format. */ + if (! deprecated_frame_register_read (frame, j, buffer)) + { + fprintf_filtered (file, " *** no value *** "); + } + else + { + fprintf_filtered (file, "0x"); + for (k = 0; k < tilegx_reg_size; k++) + { + int idx; + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + idx = k; + else + idx = tilegx_reg_size - 1 - k; + fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]); + } + } + } + + fprintf_filtered (file, "\n"); + } +} + static struct gdbarch * tilegx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { @@ -1006,6 +1066,9 @@ tilegx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Stack grows down. */ set_gdbarch_inner_than (gdbarch, core_addr_lessthan); + /* Tilera private register printer */ + set_gdbarch_print_registers_info (gdbarch, tilera_print_registers_info); + /* Frame Info. */ set_gdbarch_unwind_sp (gdbarch, tilegx_unwind_sp); set_gdbarch_unwind_pc (gdbarch, tilegx_unwind_pc); -- 1.7.10.4