From: Andrew Burgess Date: Fri, 10 Aug 2018 09:16:32 +0000 (+0100) Subject: gdb: Fix instability in thread groups test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67943c005fafa4397535766787b4fbda338ac07d;p=binutils-gdb.git gdb: Fix instability in thread groups test 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="",type="process",description="", user="",cores=["","",...]} All the fields after 'id' and 'type' are optional, and the 'cores' list can contain 1 or more "" 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. I've only adjusted the cores regexp for the occasion when we have GDB read information about all processes, its only in this case that we might encounter an exiting process. When we read information about two known PIDs, that we know will not exit for the duration of the test, we require that the core list be non-empty. gdb/testsuite/ChangeLog: * gdb.mi/list-thread-groups-available.exp: Update test regexp. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bd3c3bfec5f..33749aa6763 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-08-14 Andrew Burgess + + * gdb.mi/list-thread-groups-available.exp: Update test regexp. + 2018-08-09 Andrew Burgess * gdb.base/vla-optimized-out.exp: Add new test. diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp index c4dab2a2c34..34066a8f8b3 100644 --- a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp +++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp @@ -45,7 +45,11 @@ 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\")*\\\]" + +# The CORES_RE regexp allows a process to be running on zero or more +# cores. The former can happen if a process exits while GDB is +# reading information out of /proc. +set cores_re "cores=\\\[(\"$decimal\"(,\"$decimal\")*)?\\\]" # List all available processes. set process_entry_re "{${id_re},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" @@ -64,6 +68,12 @@ set spawn_id_2 [remote_spawn target $binfile] set pid_2 [spawn_id_get_pid $spawn_id_2] set id_re_2 "id=\"$pid_2\"" +# Unlike the earlier CORES_RE this list must contain at least one +# core. Given that we know these processes will not exit while GDB is +# reading their information from /proc we can expect at least one core +# for each process. +set cores_re "cores=\\\[\"$decimal\"(,\"$decimal\")*\\\]" + set process_entry_re_1 "{${id_re_1},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" set process_entry_re_2 "{${id_re_2},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}"