[RFA/MI testsuite] Add pthreads tests

Keith Seitz keiths@redhat.com
Wed Sep 25 09:08:00 GMT 2002


On Wed, 25 Sep 2002, Fernando Nasser wrote:

> Can you please fix this by mimicking gdb.threads?

It already does this. The real problem is that expect doesn't initialize 
expect_out when it starts up, so any accesses of this variable will cause 
a tcl error until any match is made. Dejagnu doesn't help by initializing 
it, either, so when suppressing files, it never gets set, and we have the 
behavior you observed. (This has always been a bug that I've worked around 
in my own mini-dejagnu implementations.)

I've committed the following workarounds for these problems, which will 
cause an ERROR (when the executable fails to load) and the tests will 
FAIL.

Keith

ChangeLog
2002-09-25  Keith Seitz  <keiths@redhat.com>

        * mi-pthreads.exp (get_mi_thread_list): Check if expect_out
        exists before using it.
        (check_mi_and_console_threads): Likewise.
        * gdb669.exp (get_mi_thread_list): Likewise.
        (check_mi_and_console_threads): Likewise.

Patch
Index: testsuite/gdb.mi/gdb669.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb669.exp,v
retrieving revision 1.1
diff -p -r1.1 gdb669.exp
*** testsuite/gdb.mi/gdb669.exp	24 Sep 2002 19:36:06 -0000	1.1
--- testsuite/gdb.mi/gdb669.exp	25 Sep 2002 16:06:42 -0000
*************** proc get_mi_thread_list {name} {
*** 49,56 ****
      {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \
      "-thread_list_ids ($name)"
  
    set thread_list {}
!   if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $expect_out(buffer) threads]} {
      fail "finding threads in MI output ($name)"
    } else {
      pass "finding threads in MI output ($name)"
--- 49,60 ----
      {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \
      "-thread_list_ids ($name)"
  
+   set output {}
+   if {[info exists expect_out(buffer)]} {
+     set output $expect_out(buffer)
+   }
    set thread_list {}
!   if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} {
      fail "finding threads in MI output ($name)"
    } else {
      pass "finding threads in MI output ($name)"
*************** proc check_mi_and_console_threads {name}
*** 77,83 ****
    mi_gdb_test "-thread-list-ids" \
      {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \
      "-thread-list-ids ($name)"
!   set mi_output $expect_out(buffer)
  
    # GDB will return a list of thread ids and some more info:
    #
--- 81,90 ----
    mi_gdb_test "-thread-list-ids" \
      {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \
      "-thread-list-ids ($name)"
!   set mi_output {}
!   if {[info exists expect_out(buffer)]} {
!     set mi_output $expect_out(buffer)
!   }
  
    # GDB will return a list of thread ids and some more info:
    #
*************** proc check_mi_and_console_threads {name}
*** 91,97 ****
    mi_gdb_test "info threads" \
      {.*(~".*"[\r\n]*)+.*} \
      "info threads ($name)"
!   set console_output $expect_out(buffer)
  
    # Make a list of all known threads to console (gdb's thread IDs)
    set console_thread_list {}
--- 98,107 ----
    mi_gdb_test "info threads" \
      {.*(~".*"[\r\n]*)+.*} \
      "info threads ($name)"
!   set console_output {}
!   if {[info exists expect_out(buffer)]} {
!     set console_output $expect_out(buffer)
!   }
  
    # Make a list of all known threads to console (gdb's thread IDs)
    set console_thread_list {}
Index: testsuite/gdb.mi/mi-pthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-pthreads.exp,v
retrieving revision 1.2
diff -p -r1.2 mi-pthreads.exp
*** testsuite/gdb.mi/mi-pthreads.exp	24 Sep 2002 19:36:06 -0000	1.2
--- testsuite/gdb.mi/mi-pthreads.exp	25 Sep 2002 16:06:51 -0000
*************** proc get_mi_thread_list {name} {
*** 52,59 ****
      {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \
      "-thread_list_ids ($name)"
  
    set thread_list {}
!   if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $expect_out(buffer) threads]} {
      fail "finding threads in MI output ($name)"
    } else {
      pass "finding threads in MI output ($name)"
--- 52,64 ----
      {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \
      "-thread_list_ids ($name)"
  
+   set output {}
+   if {[info exists expect_out(buffer)]} {
+     set output $expect_out(buffer)
+   }
+ 
    set thread_list {}
!   if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} {
      fail "finding threads in MI output ($name)"
    } else {
      pass "finding threads in MI output ($name)"
*************** proc check_mi_and_console_threads {name}
*** 80,86 ****
    mi_gdb_test "-thread-list-ids" \
      {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \
      "-thread-list-ids ($name)"
!   set mi_output $expect_out(buffer)
  
    # GDB will return a list of thread ids and some more info:
    #
--- 85,94 ----
    mi_gdb_test "-thread-list-ids" \
      {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \
      "-thread-list-ids ($name)"
!   set mi_output {}
!   if {[info exists expect_out(buffer)]} {
!     set mi_output $expect_out(buffer)
!   }
  
    # GDB will return a list of thread ids and some more info:
    #
*************** proc check_mi_and_console_threads {name}
*** 94,100 ****
    mi_gdb_test "info threads" \
      {.*(~".*"[\r\n]*)+.*} \
      "info threads ($name)"
!   set console_output $expect_out(buffer)
  
    # Make a list of all known threads to console (gdb's thread IDs)
    set console_thread_list {}
--- 102,111 ----
    mi_gdb_test "info threads" \
      {.*(~".*"[\r\n]*)+.*} \
      "info threads ($name)"
!   set console_output {}
!   if {[info exists $expect_out(buffer)]} {
!     set console_output $expect_out(buffer)
!   }
  
    # Make a list of all known threads to console (gdb's thread IDs)
    set console_thread_list {}



More information about the Gdb-patches mailing list