* [PATCH] Limit register display len to preserve multiple TUI columns
@ 2019-05-24 16:24 Bogdan Harjoc
0 siblings, 0 replies; only message in thread
From: Bogdan Harjoc @ 2019-05-24 16:24 UTC (permalink / raw)
To: gdb
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
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
[-- Attachment #2: gdb-8.2-max-reg-len.patch --]
[-- Type: text/x-patch, Size: 1349 bytes --]
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-24 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 16:24 [PATCH] Limit register display len to preserve multiple TUI columns Bogdan Harjoc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).