This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] fix spurious FAIL in py-inferior.exp (x86-solaris)


The inferior is single-threaded, but on x86-solaris, GDB says
that the program has two entries in the thread list:

    (gdb) info threads
      Id   Target Id         Frame
    * 2    Thread 1 (LWP 1)  f2 (a=1) at /[...]/py-inferior.c:20
      1    LWP    1          f2 (a=1) at /[...]/py-inferior.c:20

As a result, the test that prints the list of threads trips
because the expected output assumes only one thread.

The regular expression I used to match is a little complicated because
of the case where there is only one element -vs- the case where there
is more than one.  In the first case, the last element is followed by
a comma.  In the second case, it's not.  I tried to make it easier
to read by using a variable that factorizes the expression matching
a thread object, as well as makes it shorter and easier to read.

gdb/testsuite/ChangeLog:

        * gdb.python/py-inferior.exp: Adjust expected output of
        test printing the list of threads as seen by Python, to
        allow the list to contain more than 1 thread.

Tested on x86-solaris and x86_64-linux.

---
 gdb/testsuite/gdb.python/py-inferior.exp |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 138c0fb..07c7801 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -64,7 +64,12 @@ gdb_test "python print 'result =', i0 == inferiors\[0\]" " = True" "test equalit
 gdb_test "python print 'result =', i0.num" " = \[0-9\]+" "test Inferior.num"
 gdb_test "python print 'result =', i0.pid" " = \[0-9\]+" "test Inferior.pid"
 gdb_test "python print 'result =', i0.was_attached" " = False" "test Inferior.was_attached"
-gdb_test "python print i0.threads ()" "\\(<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>,\\)" "test Inferior.threads"
+# Print the list of threads in inferior 0.  Althought this inferior
+# does not use threads, the list of threads may in fact show more
+# than 1 thread.  We've seen this on x86-solaris where "info threads"
+# shows 1 thread and 1 LWP.
+set thread_re "<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>"
+gdb_test "python print i0.threads ()" "\\(${thread_re}((, ${thread_re})*|,)\\)" "test Inferior.threads"
 
 # Test memory read and write operations.
 
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]