diff options
author | Tom de Vries <tdevries@suse.de> | 2025-01-28 21:00:40 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-01-28 21:00:40 +0100 |
commit | 1c525b0e037b895f6d21deaf32dd922dfdd9c822 (patch) | |
tree | 4039ff9478a50c1b6b50c84b638067420ebb72da /gdb/tui | |
parent | 852cbc7ffadf9daf173e13ea56caff49d52733af (diff) | |
download | gdb-1c525b0e037b895f6d21deaf32dd922dfdd9c822.zip gdb-1c525b0e037b895f6d21deaf32dd922dfdd9c822.tar.gz gdb-1c525b0e037b895f6d21deaf32dd922dfdd9c822.tar.bz2 |
[gdb/tui] Fix assert in tui_source_window_base::refresh_window
Say we use the executable of test-case gdb.tui/tui-missing-src.exp like this:
...
$ gdb.sh -q -tui outputs/gdb.tui/tui-missing-src/tui-missing-src \
-ex "b f2"\
-ex run
...
(from a directory not containing a file called main.c to make sure that the
missing source stays missing) and then issue finish:
...
(gdb) finish
Run till exit from #0 f2 (x=4)
at f2.c:5
0x0000000000400570 in main ()
at main.c:7
Value returned is $1 = 13
(gdb)
...
and use control-<minus> to decrease the font size (IOW increase the $LINES and
$COLUMNS) on the terminal, we get:
...
gdb/tui/tui-winsource.c:340: internal-error: refresh_window: \
Assertion `pad_x + view_width <= pad_width || m_pad.get () == nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...
The tui_source_window_base class has variable m_pad which keeps track of a
curses pad that is used to display the source code or disassembly efficiently.
The assert in tui_source_window_base::refresh_window triggers while preparing
to display part of the pad.
The problem is that the window is in a state in which the pad is not used,
because m_content.empty () == true. Instead, it simply shows
"[ No Source Available ]".
Fix this by bailing out of tui_source_window_base::refresh_window before
accessing the m_pad variable, if m_content.empty () == true.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR tui/32592
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32592
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-winsource.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index a313e44..a5d0c59 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -314,6 +314,9 @@ tui_source_window_base::refresh_window () the screen, potentially creating a flicker. */ wnoutrefresh (handle.get ()); + if (m_content.empty ()) + return; + int pad_width = getmaxx (m_pad.get ()); int left_margin = this->left_margin (); int view_width = this->view_width (); |