On openSUSE tumbleweed I'm running into a cluster of tui fails: ... FAIL: gdb.tui/basic.exp: asm window shows main ERROR: invalid command name "_csi_L" FAIL: gdb.tui/basic.exp: source box in split layout (ll corner) FAIL: gdb.tui/basic.exp: asm box in split layout (ul corner) FAIL: gdb.tui/list.exp: asm window shows main ERROR: invalid command name "_csi_L" ERROR: invalid command name "_csi_L" FAIL: gdb.tui/list.exp: source is still visible FAIL: gdb.tui/new-layout.exp: example layout shows assembly ERROR: invalid command name "_csi_L" FAIL: gdb.tui/new-layout.exp: right window box (ul corner) FAIL: gdb.tui/new-layout.exp: horizontal display ERROR: invalid command name "_csi_L" FAIL: gdb.tui/new-layout.exp: right window box after shrink (ul corner) ERROR: invalid command name "_csi_L" FAIL: gdb.tui/new-layout.exp: right window box after grow (ul corner) FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents ERROR: invalid command name "_csi_L" ERROR: invalid command name "_csi_L" FAIL: gdb.tui/tui-layout-asm.exp: check asm box contents ... The first FAIL happens after we hit: ... +++ Inserted string '+', cursor: (14, 79) -> (15, 0) +++ wait_for: _csi_G <<<80>>> +++ Cursor Horizontal Absolute (80), cursor: (15, 0) -> (15, 79) +++ wait_for: _csi_m <<<39>>> +++ Select Graphic Rendition (39), cursor: (15, 79) -> (15, 79) +++ wait_for: _csi_m <<<0;10>>> +++ Select Graphic Rendition (0, 10), cursor: (15, 79) -> (15, 79) ^[[H^[[0;10;1m^[[36m+-^[[77b+|^[[80G||^[[80G||^[[80G||^[[80G||^[[80G||^[[80G||^[[80G||^[\ [80G||^[[80G||^[[80G||^[[80G||^[[80G||^[[80G|+-^[[77b+^[[B^[[39m^[[0;10m^[[19d/data/gdb_versions/devel/src/gdb/ui-style.c:243: internal-error: bool ui_file_style::parse(const char*, size_t*): Assertion `match == 0' failed.^M^[[BA problem internal to GDB has been detected,^M^[[Bfurther debugging may prove unreliable.^M^[[BQuit this debugging session? (y or n) +++ wait_for: _csi_H <<<>>> +++ Cursor Position (1, 1), cursor: (15, 79) -> (0, 0) +++ wait_for: _csi_m <<<0;10;1>>> +++ Select Graphic Rendition (0, 10, 1), cursor: (0, 0) -> (0, 0) +++ wait_for: _csi_m <<<36>>> ...
Created attachment 13339 [details] gdb.sum
Created attachment 13340 [details] gdb.log
To reproduce: ... $ gdb -q outputs/gdb.tui/basic/basic -ex "tui enable" -ex "layout asm" <CLEAR> ┌───────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ │ │ │ │ │ │ │ │ [ No Assembly Available ] │ │ │ │ │ │ │ │ │ │ │ └───────────────────────────────────────────────────────────────────────────────────────┘ exec No process In: L?? PC: ?? /data/gdb_versions/devel/src/gdb/ui-style.c:243: internal-error: bool ui_file_style::pars e(const char*, size_t*): Assertion `match == 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ...
Backtrace ... #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49 #1 0x00007ffff7331864 in __GI_abort () at abort.c:79 #2 0x0000000000b1684d in dump_core () at /data/gdb_versions/devel/src/gdb/utils.c:204 #3 0x0000000000b16d5e in internal_vproblem(internal_problem *, const char *, int, const char *, typedef __va_list_tag __va_list_tag *) ( problem=0x14db6c0 <internal_error_problem>, file=0xf8fdc8 "/data/gdb_versions/devel/src/gdb/ui-style.c", line=243, fmt=0xf8fc88 "%s: Assertion `%s' failed.", ap=0x7fffffffce18) at /data/gdb_versions/devel/src/gdb/utils.c:414 #4 0x0000000000b16e22 in internal_verror ( file=0xf8fdc8 "/data/gdb_versions/devel/src/gdb/ui-style.c", line=243, fmt=0xf8fc88 "%s: Assertion `%s' failed.", ap=0x7fffffffce18) at /data/gdb_versions/devel/src/gdb/utils.c:439 #5 0x0000000000deaa37 in internal_error ( file=0xf8fdc8 "/data/gdb_versions/devel/src/gdb/ui-style.c", line=243, fmt=0xf8fc88 "%s: Assertion `%s' failed.") at /data/gdb_versions/devel/src/gdbsupport/errors.cc:55 #6 0x0000000000aeb749 in ui_file_style::parse (this=0x7fffffffcff0, buf=0x19770a1 "[34m0x4010f6\033[m <\033[33mmain\033[m>", n_read=0x7fffffffcfe8) at /data/gdb_versions/devel/src/gdb/ui-style.c:243 #7 0x0000000000abbb84 in len_without_escapes (str=...) at /data/gdb_versions/devel/src/gdb/tui/tui-disasm.c:70 #8 0x0000000000abbd3e in tui_disassemble (gdbarch=0x18ef660, asm_lines=..., pc=4198647, count=11, addr_size=0x7fffffffd188) at /data/gdb_versions/devel/src/gdb/tui/tui-disasm.c:144 #9 0x0000000000abc546 in tui_disasm_window::set_contents (this=0x195c9c0, arch=0x18ef660, sal=...) at /data/gdb_versions/devel/src/gdb/tui/tui-disasm.c:342 #10 0x0000000000adf26d in tui_source_window_base::update_source_window_as_is ( this=0x195c9c0, gdbarch=0x18ef660, sal=...) at /data/gdb_versions/devel/src/gdb/tui/tui-winsource.c:167 #11 0x0000000000adf232 in tui_source_window_base::update_source_window (this=0x195c9c0, gdbarch=0x18ef660, sal=...) at /data/gdb_versions/devel/src/gdb/tui/tui-winsource.c:156 #12 0x0000000000adf42b in tui_update_source_windows_with_addr (gdbarch=0x18ef660, addr=4198646) at /data/gdb_versions/devel/src/gdb/tui/tui-winsource.c:190 #13 0x0000000000acc2d1 in tui_apply_current_layout () at /data/gdb_versions/devel/src/gdb/tui/tui-layout.c:113 #14 0x0000000000acc3b9 in tui_set_layout (layout=0x16eca40) at /data/gdb_versions/devel/src/gdb/tui/tui-layout.c:131 #15 0x0000000000acc580 in tui_apply_layout (command=0x16ecc50, args=0x0, from_tty=1) at /data/gdb_versions/devel/src/gdb/tui/tui-layout.c:180 #16 0x0000000000589bd5 in cmd_func (cmd=0x16ecc50, args=0x0, from_tty=1) at /data/gdb_versions/devel/src/gdb/cli/cli-decode.c:2181 #17 0x0000000000a9ae89 in execute_command (p=0x7fffffffe1c3 "", from_tty=1) at /data/gdb_versions/devel/src/gdb/top.c:670 #18 0x0000000000806a16 in catch_command_errors ( command=0xa9a918 <execute_command(char const*, int)>, arg=0x7fffffffe1b9 "layout asm", from_tty=1, do_bp_actions=true) at /data/gdb_versions/devel/src/gdb/main.c:450 #19 0x0000000000806beb in execute_cmdargs (cmdarg_vec=0x7fffffffd8e0, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd8bc) at /data/gdb_versions/devel/src/gdb/main.c:539 #20 0x0000000000807e4f in captured_main_1 (context=0x7fffffffdae0) at /data/gdb_versions/devel/src/gdb/main.c:1211 #21 0x0000000000808036 in captured_main (data=0x7fffffffdae0) at /data/gdb_versions/devel/src/gdb/main.c:1232 #22 0x00000000008080a1 in gdb_main (args=0x7fffffffdae0) at /data/gdb_versions/devel/src/gdb/main.c:1257 #23 0x000000000041781d in main (argc=14, argv=0x7fffffffdbf8) at /data/gdb_versions/devel/src/gdb/gdb.c:32 ...
Actual value of match: ... (gdb) p match $1 = 17 ...
Tentative patch: ... diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 65b300cb008..13763eb82a1 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -67,7 +67,7 @@ len_without_escapes (const std::string &str) { ui_file_style style; size_t n_read; - if (style.parse (ptr, &n_read)) + if (style.parse (ptr - 1, &n_read)) ptr += n_read; else { ... Fixes all fails.
The code in the loop isn't expecting the ++ in the loop header. The else clause also has this same bug: else { /* Shouldn't happen, but just skip the ESC if it somehow does. */ ++ptr; }
(In reply to Tom Tromey from comment #7) > The code in the loop isn't expecting the ++ in the loop header. > The else clause also has this same bug: > > else > { > /* Shouldn't happen, but just skip the ESC if it somehow > does. */ > ++ptr; > } OK, then: ... diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 65b300cb008..163552aede4 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -61,7 +61,7 @@ len_without_escapes (const std::string &str) const char *ptr = str.c_str (); char c; - while ((c = *ptr++) != '\0') + while ((c = *ptr) != '\0') { if (c == '\033') { @@ -77,7 +77,10 @@ len_without_escapes (const std::string &str) } } else - ++len; + { + ++len; + ++ptr; + } } return len; } ...
Looks good to me. Thank you.
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d811a7cf74fa8523f67a13c0527b27f4954e9ae1 commit d811a7cf74fa8523f67a13c0527b27f4954e9ae1 Author: Tom de Vries <tdevries@suse.de> Date: Tue Apr 6 10:40:11 2021 +0200 [gdb/tui] Fix len_without_escapes in tui-disasm.c On openSUSE Tumbleweed I run into: ... FAIL: gdb.tui/basic.exp: asm window shows main ERROR: invalid command name "_csi_L" ... Using a minimal example, we get: ... $ gdb -q outputs/gdb.tui/basic/basic -ex "tui enable" -ex "layout asm" <TUI output> src/gdb/ui-style.c:243: internal-error: bool \ ui_file_style::parse(const char*, size_t*): Assertion `match == 0' failed. ... The problem is in len_without_escapes, where we detect the start of an escape sequence, but then pass ptr to style.parse while ptr no longer points to the escape due to the ptr++ in the while condition: ... while ((c = *ptr++) != '\0') { if (c == '\033') { ui_file_style style; size_t n_read; if (style.parse (ptr, &n_read)) ... Fix this by removing the ++ in the while condition, and adding ptr++ in the loop body where appropriate. Tested on x86_64-linux. gdb/ChangeLog: 2021-04-06 Tom de Vries <tdevries@suse.de> PR tui/27680 * tui/tui-disasm.c (len_without_escapes): Pass ptr pointing at escape to style.parse.
Patch committed, marking resolved-fixed.
@Tom - any chance you can land this in TW, or at least devel:gcc? Thanks.
(In reply to Stefan Brüns from comment #12) > @Tom - any chance you can land this in TW, or at least devel:gcc? Thanks. Committed to devel:gcc @ revision 274, will submit request for TW.
(In reply to Tom de Vries from comment #13) > (In reply to Stefan Brüns from comment #12) > > @Tom - any chance you can land this in TW, or at least devel:gcc? Thanks. > > Committed to devel:gcc @ revision 274, will submit request for TW. https://build.opensuse.org/request/show/890032
(In reply to Tom de Vries from comment #14) > (In reply to Tom de Vries from comment #13) > > (In reply to Stefan Brüns from comment #12) > > > @Tom - any chance you can land this in TW, or at least devel:gcc? Thanks. > > > > Committed to devel:gcc @ revision 274, will submit request for TW. > > https://build.opensuse.org/request/show/890032 Now available in TW.