From: Tom Tromey Date: Sat, 1 Feb 2025 23:51:42 +0000 (-0700) Subject: Avoid "text file busy" in dw2-using-debug-str.exp X-Git-Tag: binutils-2_45~1768 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ec54fab7b67961cd9b47157ea66811ad38de1af;p=thirdparty%2Fbinutils-gdb.git Avoid "text file busy" in dw2-using-debug-str.exp When I run: runtest dw2-using-debug-str.exp ... if I examine the gdb.log, I see: objcopy: unable to copy file '[...]/dw2-using-debug-str'; reason: Text file busy This happens because the inferior is still running, and objcopy -- despite the invocation seemingly not needing this -- tries to open it for writing. This patch works around the objcopy oddity by having gdb exit (killing the inferior) before the invocation. Fixing this points out that the test does not work in the --target_board=cc-with-gdb-index case. This patch also arranges to issue an "untested" here. --- diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp index 762ff02ea55..c45d63102a3 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp @@ -98,6 +98,18 @@ if ![runto_main] { # field names, all of which are stored in the .debug_str section. gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}" +# If we have a .gdb_index already, this test isn't going to work, +# because the .gdb_index reader doesn't check for .debug_str. +if {[get_index_type $testfile] == "gdb"} { + untested ".gdb_index does not handle this case" + return +} + +# objcopy, even with --dump-section, will try to open the executable +# for writing. To avoid "text file busy", exit gdb here, stopping the +# inferior as a side effect. +gdb_exit + set host_binfile [gdb_remote_download host $binfile] # Verify that the executable actually contains a .debug_str section, before