This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
[PATCH] Limit register display len to preserve multiple TUI columns
- From: Bogdan Harjoc <harjoc at gmail dot com>
- To: gdb at sourceware dot org
- Date: Fri, 24 May 2019 15:08:26 +0300
- Subject: [PATCH] Limit register display len to preserve multiple TUI columns
When TUI layout is regs+asm+cmd, if a register value can be resolved
to a symbol with a long name, the register window becomes
single-column. That makes it hard to look at registers since you have
to scroll down in the regs window.
I couldn't figure out how to make use of gdb print settings to limit
the display length, so I wrote a patch to get the max-reg-len from the
environment (attached). I could change it to make the max-len a gdb
setting, or guess it somehow if someone suggests how.
Regards,
Bogdan
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 7059b02..bf2c998 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -311,9 +311,13 @@ tui_display_registers_from (int start_element_no)
{
int i = start_element_no;
int j, item_win_width, cur_y;
+ int len_env = 0;
+ const char *env = getenv("GDB_MAX_REG_LEN");
+
+ if (env) len_env = atoi(env);
int max_len = 0;
- for (i = 0; i < display_info->regs_content_count; i++)
+ for (; i < display_info->regs_content_count; i++)
{
struct tui_data_element *data;
struct tui_gen_win_info *data_item_win;
@@ -326,17 +330,26 @@ tui_display_registers_from (int start_element_no)
len = 0;
p = data->content;
if (p != 0)
- while (*p)
- {
- if (*p++ == '\t')
- len = 8 * ((len / 8) + 1);
- else
- len++;
- }
+ {
+ while (*p)
+ {
+ if (*p++ == '\t')
+ len = 8 * ((len / 8) + 1);
+ else
+ len++;
+ }
+
+ if (len_env && len > len_env)
+ {
+ len = len_env;
+ data->content[len] = 0;
+ }
+ }
if (len > max_len)
max_len = len;
}
+
item_win_width = max_len + 1;
i = start_element_no;