[binutils-gdb] Adjust gdb.python/py-events.exp for Cygwin/MinGW, thread IDs

Pedro Alves via Gdb-cvs <[email protected]> Fri, 12 Jun 2026 13:59:35 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ab20bdf8efc3e8607e6aa68464901bb109b544db

commit ab20bdf8efc3e8607e6aa68464901bb109b544db
Author: Pedro Alves <[email protected]>
Date:   Wed May 20 11:22:56 2026 +0100

    Adjust gdb.python/py-events.exp for Cygwin/MinGW, thread IDs
    
    This commit fixes a couple issues in gdb.python/py-events.exp for
    Cygwin and MinGW:
    
    1) - GDB prints Windows thread IDs in hex:
    
     (gdb) thread
     [Current thread is 1 (Thread 9528.0xa9c)]
    
    The current code assumes decimal, so we only (incorrectly) extract the
    "0" after the dot.
    
    2) - Thread and process ID number spaces are different.
    
    The current code assumes that the extracted thread ID is the same
    number as the extracted process ID, which is not true on Windows.
    
    Also tested on x86_64-unknown-linux-gnu.
    
    Change-Id: Iebcc07c3ad0845b548334c0d5177b3ab9e9350cf

Diff:
---
 gdb/testsuite/gdb.python/py-events.exp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index 16a290c31c2..b07eb2ec9b0 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -76,17 +76,23 @@ delete_breakpoints
 # Test inferior call events
 
 set process_id "invalid"
+set thread_id "invalid"
 gdb_test_multiple "thread" "get current thread" {
     -re -wrap "process ($decimal).*" {
 	set process_id $expect_out(1,string)
+	set thread_id $process_id
 	pass $gdb_test_name
     }
     -re -wrap "Thread $hex \\(LWP ($decimal)\\).*" {
 	set process_id $expect_out(1,string)
+	set thread_id $process_id
 	pass $gdb_test_name
     }
-    -re -wrap "Thread $decimal\.($decimal).*" {
+    -re -wrap "Thread ($decimal)\.($hex|$decimal).*" {
 	set process_id $expect_out(1,string)
+	set thread_id $expect_out(2,string)
+	# Convert from hex to decimal.
+	set thread_id [expr {$thread_id}]
 	pass $gdb_test_name
     }
 }
@@ -99,9 +105,9 @@ gdb_test_multiple "print do_nothing" "get address of do_nothing" {
 }
 
 set expected [list "event type: pre-call"]
-lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr"
+lappend expected "ptid: \\($process_id, $thread_id, 0\\)" "address: $addr"
 lappend expected "event type: post-call"
-lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr"
+lappend expected "ptid: \\($process_id, $thread_id, 0\\)" "address: $addr"
 gdb_test_sequence "call do_nothing()" "" $expected
 
 # Test register changed event