[PATCH v8 6/6] gdb/infrun: handle already-exited threads when attempting to stop

Pedro Alves palves@redhat.com
Thu May 14 11:16:54 GMT 2020


>>
>> +/* Return true if INF only has one non-exited thread.  */
>> +
>> +static bool
>> +single_non_exited_thread_p (inferior *inf)
> Given that the return type is bool and not int, can the '_p' in the name be
> discarded and a question phrase, like 'has_single_non_exited_thread', be
> used?

Using "_p" (for predicate) is a common idiom in GDB/GCC code,
but I don't mind.

> Similar to what you did in multi-kill.exp, to eliminate code duplication,
> this 'with_test_prefix' code block can be removed, and the start_inferior
> procedure can be used for inferior 1, too, by ...
> 
>> +
>> +# Start inferior NUM.
>> +
>> +proc start_inferior {num} {
>> +    global srcfile binfile
>> +
>> +    gdb_test "add-inferior" "Added inferior $num.*" \
>> +	"add empty inferior $num"
>> +    gdb_test "inferior $num" "Switching to inferior $num.*" \
>> +	"switch to inferior $num"
> ... guarding the statements above with 'if {$num != 1}'.  And then ...
> 
>> +
>> +    with_test_prefix "inf $num" {
>> +	gdb_load $binfile
>> +
>> +	if {[gdb_start_cmd] < 0} {
>> +	    fail "could not start"
>> +	    return -1
>> +	}
>> +	gdb_test "" ".*reakpoint .*, main .*${srcfile}.*" "start"
>> +    }
>> +
>> +    return 0
>> +}
>> +
>> +# Sufficient inferiors to make sure that at least some other inferior
>> +# exits while we're handling a process exit event.
>> +set NUM_INFS 10
>> +
>> +for {set i 2} {$i <= $NUM_INFS} {incr i} {
> ... this loop could start from 1.
> 

Indeed.  In your update, you just missed putting the add-inferior/inferior
commands under with_test_prefix as well (and then remove the inferior
number from the test message), like I had done on multi-kill.exp.  I.e.,:

diff --git a/gdb/testsuite/gdb.multi/multi-exit.exp b/gdb/testsuite/gdb.multi/multi-exit.exp
index 2e3ed39a268..393093b3784 100644
--- a/gdb/testsuite/gdb.multi/multi-exit.exp
+++ b/gdb/testsuite/gdb.multi/multi-exit.exp
@@ -42,16 +42,16 @@ save_vars { GDBFLAGS } {
 # Start inferior NUM.
 
 proc start_inferior {num} {
-    global srcfile binfile
-
-    if {$num != 1} {
-	gdb_test "add-inferior" "Added inferior $num.*" \
-	    "add empty inferior $num"
-	gdb_test "inferior $num" "Switching to inferior $num.*" \
-	    "switch to inferior $num"
-    }
+    with_test_prefix "start_inferior $num" {
+	global srcfile binfile
+
+	if {$num != 1} {
+	    gdb_test "add-inferior" "Added inferior $num.*" \
+		"add empty inferior"
+	    gdb_test "inferior $num" "Switching to inferior $num.*" \
+		"switch to inferior"
+	}
 
-    with_test_prefix "inf $num" {
 	gdb_load $binfile
 
 	if {[gdb_start_cmd] < 0} {

Thanks,
Pedro Alves



More information about the Gdb-patches mailing list