From patchwork Fri Aug 10 09:57:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 28836 Received: (qmail 36642 invoked by alias); 10 Aug 2018 09:58:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 36520 invoked by uid 89); 10 Aug 2018 09:58:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Running X-HELO: mail-wm0-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Aug 2018 09:58:01 +0000 Received: by mail-wm0-f68.google.com with SMTP id r24-v6so1025266wmh.0 for ; Fri, 10 Aug 2018 02:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=bwf311PBiW6PTZvqJpKGU6+1Teoll+trjXw6N+cpefg=; b=H2B0VawBxv9aEoY5JJ5MnRecd2yifBCIh/HNIevgk3QaHqYGDWuAT+ngm9XLFOL8Wj nPZ6loSpoi4u3faM4Hqr7CLQ5XR8Dg8UkidgNw+MH/QzxXzqKEEx4wSehnqjg1Rb8zpp dDmAPeCEhWyqJ6pqb6aTIYgda4+lBGoPjtJ2PL/jJdcUghEfuasiymDHrlbiMtFAVYKo f+GArjk2PzqFbQulc6qMDTBDu1NU5pr/FjVJ6GDoTzGDv8BOibypj5z/5AstZX3fchPP 49kql4grJpHGWkWC+qDs+kdVw7KcjVuHuZqRzjkKJUpGL0BMv+L3i4vKybzK+ZnlaIfL I8JA== Return-Path: Received: from localhost (host81-140-215-41.range81-140.btcentralplus.com. [81.140.215.41]) by smtp.gmail.com with ESMTPSA id h83-v6sm1138768wmf.46.2018.08.10.02.57.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Aug 2018 02:57:58 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: Fix instability in thread groups test Date: Fri, 10 Aug 2018 10:57:50 +0100 Message-Id: <20180810095750.13017-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes 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. 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)?}"