public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: Fix instability in thread groups test
@ 2018-08-10  9:58 Andrew Burgess
  2018-08-10 21:26 ` Simon Marchi
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Burgess @ 2018-08-10  9:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

In the test script gdb.mi/list-thread-groups-available.exp we ask GDB
to list all thread groups, and match the output against a
regexp. Occasionally, I would see this test fail.

The expected output is a list of entries, each entry looking roughly
like this:

  {id="<DECIMAL>",type="process",description="<STRING>",
   user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}

All the fields after 'id' and 'type' are optional, and the 'cores'
list can contain 1 or more "<DECIMAL>" entries.

On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64)
usually the 'description' is a non-empty string, and the 'cores' list
has at least one entry in it.  But sometimes, very rarely, I'll see an
entry in the process group list where the 'description' is an empty
string, the 'user' is the string "?", and the 'cores' list is empty.
Such an entry looks like this:

   {id="19863",type="process",description="",user="?",cores=[]}

I believe that this is caused by the process exiting while GDB is
scanning /proc for process information.  The current code in
gdb/nat/linux-osdata.c is not (I think) resilient against exiting
processes.

This commit adjusts the regex that matches the 'cores' list so that an
empty list is acceptable, with this patch in place the test script
gdb.mi/list-thread-groups-available.exp never fails for me now.

gdb/testsuite/ChangeLog:

	* gdb.mi/list-thread-groups-available.exp: Update test regexp.
---
 gdb/testsuite/ChangeLog                               | 4 ++++
 gdb/testsuite/gdb.mi/list-thread-groups-available.exp | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
index c4dab2a2c34..88f9ee9b63d 100644
--- a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
+++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
@@ -45,7 +45,7 @@ set id_re "id=\"$decimal\""
 set type_re "type=\"process\""
 set description_re "description=\"$string_re\""
 set user_re "user=\"$string_re\""
-set cores_re "cores=\\\[\"$decimal\"(,\"$decimal\")*\\\]"
+set cores_re "cores=\\\[(\"$decimal\"(,\"$decimal\")*)?\\\]"
 
 # List all available processes.
 set process_entry_re "{${id_re},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}"
-- 
2.14.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-08-14 11:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10  9:58 [PATCH] gdb: Fix instability in thread groups test Andrew Burgess
2018-08-10 21:26 ` Simon Marchi
2018-08-13  9:51   ` Pedro Alves
2018-08-13 11:41     ` Andrew Burgess
2018-08-13 12:03       ` Pedro Alves
2018-08-13 13:01         ` Andrew Burgess
2018-08-13 13:38           ` Pedro Alves
2018-08-13 21:45             ` [PATCHv2] " Andrew Burgess
2018-08-14 11:37               ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).