public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress
@ 2023-04-07 9:10 vries at gcc dot gnu.org
2023-04-07 9:13 ` [Bug tui/30325] " vries at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-07 9:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
Bug ID: 30325
Summary: [gdb/tui] Stray '[' before insn adddress
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: tui
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
When running test-case gdb.tui/tui-layout-asm.exp with tui_asm_window_width set
to 60, I get:
...
Box Dump (60 x 15) @ (0, 0):
0 +----------------------------------------------------------+
1 | 0x4004a7 <main> push %rbp |
2 | 0x4004a8 <main+1> mov %rsp,%rbp |
3 | 0x4004ab <main+4> mov $0x0,%eax |
4 | 0x4004b0 <main+9> pop %rbp |
5 | 0x4004b1 <main+10> ret |
6 | 0x4004b2 cs nopw 0x0(%rax,%rax,1) |
7 | [0x4004bc nopl 0x0(%rax) |
8 | 0x4004c0 nop |
9 | 0x4004c1 nop |
10 | 0x4004c2 nop |
11 | 0x4004c3 nop |
12 | 0x4004c4 nop |
13 | 0x4004c5 nop |
14 +----------------------------------------------------------+
...
There seems to be a stray '[' at line 7.
I reproduced it on an actual terminal, after setting cols/rows to 24/60:
...
$ ( export TERM=ansi; gdb tui-layout-asm -ex "maint set tui-resize-message on"
-ex "set tui border-kind ascii" -ex "tui enable" -ex "layout asm" )
...
and got:
...
+----------------------------------------------------------+
| 0x4004a7 <main> push %rbp |
| 0x4004a8 <main+1> mov %rsp,%rbp |
| 0x4004ab <main+4> mov $0x0,%eax |
| 0x4004b0 <main+9> pop %rbp |
| 0x4004b1 <main+10> ret |
| 0x4004b2 cs nopw 0x0(%rax,%rax,1) |
| [0x4004bc nopl 0x0(%rax) |
| 0x4004c0 nop |
| 0x4004c1 nop |
| 0x4004c2 nop |
| 0x4004c3 nop |
| 0x4004c4 nop |
| 0x4004c5 nop |
+----------------------------------------------------------+
...
So, this isn't related to the tuienv terminal emulator.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
@ 2023-04-07 9:13 ` vries at gcc dot gnu.org
2023-04-07 9:55 ` vries at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-07 9:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> When running test-case gdb.tui/tui-layout-asm.exp with tui_asm_window_width
> set to 60, I get:
> ...
> Box Dump (60 x 15) @ (0, 0):
> 0 +----------------------------------------------------------+
> 1 | 0x4004a7 <main> push %rbp |
> 2 | 0x4004a8 <main+1> mov %rsp,%rbp |
> 3 | 0x4004ab <main+4> mov $0x0,%eax |
> 4 | 0x4004b0 <main+9> pop %rbp |
> 5 | 0x4004b1 <main+10> ret |
> 6 | 0x4004b2 cs nopw 0x0(%rax,%rax,1) |
> 7 | [0x4004bc nopl 0x0(%rax) |
> 8 | 0x4004c0 nop |
> 9 | 0x4004c1 nop |
> 10 | 0x4004c2 nop |
> 11 | 0x4004c3 nop |
> 12 | 0x4004c4 nop |
> 13 | 0x4004c5 nop |
> 14 +----------------------------------------------------------+
> ...
>
In contrast, with tui_asm_window_width == 65:
...
0 +---------------------------------------------------------------+
1 | 0x4004a7 <main> push %rbp |
2 | 0x4004a8 <main+1> mov %rsp,%rbp |
3 | 0x4004ab <main+4> mov $0x0,%eax |
4 | 0x4004b0 <main+9> pop %rbp |
5 | 0x4004b1 <main+10> ret |
6 | 0x4004b2 cs nopw 0x0(%rax,%rax,1) |
7 | 0x4004bc nopl 0x0(%rax) |
8 | 0x4004c0 nop |
9 | 0x4004c1 nop |
10 | 0x4004c2 nop |
11 | 0x4004c3 nop |
12 | 0x4004c4 nop |
13 | 0x4004c5 nop |
14 +---------------------------------------------------------------+
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
2023-04-07 9:13 ` [Bug tui/30325] " vries at gcc dot gnu.org
@ 2023-04-07 9:55 ` vries at gcc dot gnu.org
2023-04-07 12:27 ` tromey at sourceware dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-07 9:55 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Also happens when build with gdb's readline instead of system readline.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
2023-04-07 9:13 ` [Bug tui/30325] " vries at gcc dot gnu.org
2023-04-07 9:55 ` vries at gcc dot gnu.org
@ 2023-04-07 12:27 ` tromey at sourceware dot org
2023-04-07 14:25 ` vries at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at sourceware dot org @ 2023-04-07 12:27 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (2 preceding siblings ...)
2023-04-07 12:27 ` tromey at sourceware dot org
@ 2023-04-07 14:25 ` vries at gcc dot gnu.org
2023-04-07 16:13 ` vries at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-07 14:25 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 52a0f7af00f..16badd6dbe4 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -666,7 +666,8 @@ tui_source_window_base::update_exec_info (bool refresh_p)
for (int i = 0; i < m_content.size (); i++)
{
struct tui_source_element *src_element = &m_content[i];
- char element[TUI_EXECINFO_SIZE] = " ";
+ /* Add 1 for terminating '\0'. Init to TUI_EXECINFO_SIZE spaces. */
+ char element[TUI_EXECINFO_SIZE + 1] = " ";
/* Now update the exec info content based upon the state
of each line as indicated by the source content. */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 7370ae95d8b..bce9097ee41 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -58,6 +58,7 @@ DEF_ENUM_FLAGS_TYPE (enum tui_bp_flag, tui_bp_flags);
#define TUI_BP_HIT_POS 0
#define TUI_BP_BREAK_POS 1
#define TUI_EXEC_POS 2
+#define TUI_SPACE_POS 3
#define TUI_EXECINFO_SIZE 4
/* Elements in the Source/Disassembly Window. */
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (3 preceding siblings ...)
2023-04-07 14:25 ` vries at gcc dot gnu.org
@ 2023-04-07 16:13 ` vries at gcc dot gnu.org
2023-04-11 8:24 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-07 16:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
So, I finally figured out what we're looking at.
It's the '[' in "[ No Assembly Available ]":
...
0 +----------------------------------------------------------+
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | [ No Assembly Available ] |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 +----------------------------------------------------------+
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (4 preceding siblings ...)
2023-04-07 16:13 ` vries at gcc dot gnu.org
@ 2023-04-11 8:24 ` vries at gcc dot gnu.org
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-11 8:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch submitted at
https://sourceware.org/pipermail/gdb-patches/2023-April/198780.html .
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (5 preceding siblings ...)
2023-04-11 8:24 ` vries at gcc dot gnu.org
@ 2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
2023-04-12 22:19 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-12 22:18 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=58b77c6af2ed391b263460ef37285ee5cfebc69f
commit 58b77c6af2ed391b263460ef37285ee5cfebc69f
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Apr 13 00:18:12 2023 +0200
[gdb/tui] Add maint set/show tui-left-margin-verbose
The TUI has two types of windows derived from tui_source_window_base:
- tui_source_window (the source window), and
- tui_disasm_window (the disassembly window).
The two windows share a common concept: the left margin.
With a hello world a.out, we can see the source window:
...
ââ/home/vries/hello.cââââââââââââââââââââââââââââââââââââââââ
â 5 { â
âB+> 6 printf ("hello\n"); â
â 7 return 0; â
â 8 } â
â 9 â
â
...
where the left margin is the part holding "B+>" and the line number, and
the
disassembly window:
...
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â 0x555555555149 <main> endbr64 â
â 0x55555555514d <main+4> push %rbp â
â 0x55555555514e <main+5> mov %rsp,%rbp â
âB+> 0x555555555151 <main+8> lea 0xeac(%rip),%raxâ
â 0x555555555158 <main+15> mov %rax,%rdi â
...
where the left margin is just the bit holding "B+>".
Because the left margin contains some spaces, it's not clear where it
starts
and ends, making it harder to observe problems related to it.
Add a new maintenance command "maint set tui-left-margin-verbose", that
when
set to on replaces the spaces in the left margin with either '_' or '0',
giving us this for the source window:
...
ââ/home/vries/hello.cââââââââââââââââââââââââââââââââââââââââ
â___000005__{ â
âB+>000006__ printf ("hello\n"); â
â___000007__ return 0; â
â___000008__} â
...
and this for the disassembly window:
...
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â___ 0x555555555149 <main> endbr64 â
â___ 0x55555555514d <main+4> push %rbp â
â___ 0x55555555514e <main+5> mov %rsp,%rbp â
âB+> 0x555555555151 <main+8> lea 0xeac(%rip),%raxâ
â___ 0x555555555158 <main+15> mov %rax,%rdi â
...
Note the space between "B+>" and 0x555555555151. The space shows that a
bit
of the left margin is not written, a problem reported as PR tui/30325.
Specifically, PR tui/30325 is about the fact that the '[' character from
the
string "[ No Assembly Available ]" ends up in that same spot:
...
âB+>[0x555555555151 <main+8> lea 0xeac(%rip),%raxâ
...
which only happens for certain window widths.
The new command allows us to spot the problem with any window width.
Likewise, when we revert the fix from commit 1b6d4bb2232 ("Redraw both
spaces
between line numbers and source code"), we have:
...
ââ/home/vries/hello.cââââââââââââââââââââââââââââââââââââââââ
â___000005_ { â
âB+>000006_ printf ("hello\n"); â
â___000007_ return 0; â
â___000008_ } â
...
showing a similar problem at the space between '_' and '{'.
Tested on x86_64-linux.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (6 preceding siblings ...)
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
@ 2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
2023-04-12 22:19 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-12 22:18 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5479c4c7c9e7179d95c6520cdef98ae175874cab
commit 5479c4c7c9e7179d95c6520cdef98ae175874cab
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Apr 13 00:18:12 2023 +0200
[gdb/tui] Fix left margin in disassembly window
With a hello world a.out, and maint set tui-left-margin-verbose on, we have
this disassembly window:
...
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â___ 0x555555555149 <main> endbr64 â
â___ 0x55555555514d <main+4> push %rbp â
â___ 0x55555555514e <main+5> mov %rsp,%rbp â
âB+> 0x555555555151 <main+8> lea 0xeac(%rip),%raxâ
â___ 0x555555555158 <main+15> mov %rax,%rdi â
...
Note the space between "B+>" and 0x555555555151. The space shows that a
bit
of the left margin is not written, which is a problem because that location
is
showing a character previously written, which happens to be a space, but
also
may be something else, for instance a '[' as reported in PR tui/30325.
The problem is caused by confusion about the meaning of:
...
#define TUI_EXECINFO_SIZE 4
...
There's the meaning of defining the size of this zero-terminated char
array:
...
char element[TUI_EXECINFO_SIZE];
...
which is used to print the "B+>" bit, which is 3 chars wide.
And there's the meaning of defining part of the size of the left margin:
...
int left_margin () const
{ return 1 + TUI_EXECINFO_SIZE + extra_margin (); }
...
where it represents 4 chars.
The discrepancy between the two causes the space between "B+>" and
"0x555555555151".
Fix this by redefining TUI_EXECINFO_SIZE to 3, and using:
...
char element[TUI_EXECINFO_SIZE + 1];
...
such that we have:
...
|B+>0x555555555151 <main+8> lea 0xeac(%rip),%rax â
...
This changes the layout of the disassembly window back to what it was
before
commit 9e820dec13e ("Use a curses pad for source and disassembly windows"),
the commit that introduced the PR30325 regression.
This also changes the source window from:
...
â___000005__{ |
...
to:
...
â___000005_{ |
...
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30325
Approved-By: Tom Tromey <tom@tromey.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tui/30325] [gdb/tui] Stray '[' before insn adddress
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
` (7 preceding siblings ...)
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
@ 2023-04-12 22:19 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-12 22:19 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=30325
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|--- |14.1
Resolution|--- |FIXED
--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-04-12 22:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07 9:10 [Bug tui/30325] New: [gdb/tui] Stray '[' before insn adddress vries at gcc dot gnu.org
2023-04-07 9:13 ` [Bug tui/30325] " vries at gcc dot gnu.org
2023-04-07 9:55 ` vries at gcc dot gnu.org
2023-04-07 12:27 ` tromey at sourceware dot org
2023-04-07 14:25 ` vries at gcc dot gnu.org
2023-04-07 16:13 ` vries at gcc dot gnu.org
2023-04-11 8:24 ` vries at gcc dot gnu.org
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
2023-04-12 22:18 ` cvs-commit at gcc dot gnu.org
2023-04-12 22:19 ` vries at gcc dot gnu.org
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).