From 0fd705062ee0bb570ac7a1201d6f3cc2ed96f95d Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 8 May 2024 17:02:15 +0200 Subject: [PATCH] [gdb/testsuite] Add gdb.tui/reread.exp Add a regression test for commit d68f983f88c ("Fix heap-use-after-free because all_objfiles_removed triggers tui_display_main"). When building with address sanitizer, and reverting the commit it triggers the heap-use-after-free. Tested on aarch64-linux. PR symtab/31697 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31697 --- gdb/testsuite/gdb.tui/reread.exp | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 gdb/testsuite/gdb.tui/reread.exp diff --git a/gdb/testsuite/gdb.tui/reread.exp b/gdb/testsuite/gdb.tui/reread.exp new file mode 100644 index 00000000000..9f16bee9f67 --- /dev/null +++ b/gdb/testsuite/gdb.tui/reread.exp @@ -0,0 +1,39 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that rereading the exec while in TUI doesn't cause trouble. +# Used to trigger an AddressSanitizer heap-use-after-free, PR31697. + +tuiterm_env + +# Use main-one-line.c to get the line info at a predictable location without +# resorting to a dwarf assembly test-case. +standard_testfile main-one-line.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $testfile + +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + +remote_exec build sleep 1 +gdb_touch_execfile $binfile + +Term::command "start" -- 2.39.5