Skip to content

Commit 0ac7668

Browse files
committed
[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 (cherry picked from commit 1c525b0)
1 parent 4144c2f commit 0ac7668

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

gdb/testsuite/gdb.tui/tui-missing-src.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ Term::command "finish"
101101
Term::check_box_contents "check source box is empty after return" \
102102
0 0 80 15 "No Source Available"
103103
Term::check_contents "Back in main" "Value returned is .* 13"
104+
105+
Term::resize 30 100
106+
Term::check_box "source box after resize" 0 0 100 19

gdb/tui/tui-winsource.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ tui_source_window_base::refresh_window ()
314314
the screen, potentially creating a flicker. */
315315
wnoutrefresh (handle.get ());
316316

317+
if (m_content.empty ())
318+
return;
319+
317320
int pad_width = getmaxx (m_pad.get ());
318321
int left_margin = this->left_margin ();
319322
int view_width = this->view_width ();

0 commit comments

Comments
 (0)