]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest/gdb_backtrace: avoid printing backtrace twice with 1 thread
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 7 Mar 2024 10:13:56 +0000 (23:13 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 20 Mar 2024 23:42:34 +0000 (23:42 +0000)
We call 'thread apply all bt full' in case there are interesting
things going on in other threads, but often there are no other threads
and it only serves to repeat the original trace (and very slowly, for
some reason).

The $_inferior_thread_count convenience variable is new in gdb 13.1
(2022-ish) so we init-if-undefined it to default to the old behaviour.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/gdb_backtrace

index 7ab50f3138c329b9f97456e03d9b4d739b7e5704..b97766c2e188e2524a09875a03ec52923527844c 100755 (executable)
@@ -132,7 +132,10 @@ gdb)
        cat <<EOF >${BATCHFILE_MAIN}
 set height 0
 bt full
-thread apply all bt full
+init-if-undefined \$_inferior_thread_count = 0
+if \$_inferior_thread_count != 1
+  thread apply all bt full
+end
 info locals
 if PyList_New
   echo \\n### Python traceback\\n\\n