]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid "text file busy" in dw2-using-debug-str.exp
authorTom Tromey <tom@tromey.com>
Sat, 1 Feb 2025 23:51:42 +0000 (16:51 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 2 Feb 2025 17:44:17 +0000 (10:44 -0700)
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.

gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp

index 762ff02ea55c7e0e75d7b2cfccfe48e8dddf75c4..c45d63102a37a2efd1f46b4fe51039d06437f50d 100644 (file)
@@ -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