From patchwork Fri Jun 13 19:07:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 1496 Received: (qmail 28997 invoked by alias); 13 Jun 2014 19:07:18 -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 28987 invoked by uid 89); 13 Jun 2014 19:07:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jun 2014 19:07:16 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5DJ7EKW009289 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 13 Jun 2014 15:07:15 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5DJ7ET6004300 for ; Fri, 13 Jun 2014 15:07:14 -0400 From: Keith Seitz To: gdb-patches@sourceware.org Subject: [RFA] Fix for PR mi/15863 Date: Fri, 13 Jun 2014 12:07:14 -0700 Message-Id: <1402686434-21260-1-git-send-email-keiths@redhat.com> X-IsSubscribed: yes If an MI client creates a varobj and attempts to update the root /before/ the inferior is started, gdb will throw an internal error: (gdb) -var-create * - batch_flag ^done,name="var1",numchild="0",value="0",type="int",has_more="0" (gdb) -var-update var1 ^done,changelist=[] (gdb) -var-update * ~"../../src/gdb/thread.c:628: internal-error: is_thread_state: Assertion `tp' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? " ~"(y or n) " The function that handles the varobj update in the failing case, mi_cmd_var_udpate_iter, checks if the thread/inferior is stopped before attempting to update the varobj. It calls is_stopped (inferior_ptid) which calls is_thread_state: tp = find_thread_ptid (ptid); gdb_assert (tp); When there is no inferior, ptid is null_ptid, and find_thread_ptid (null_ptid) returns NULL and the assertion is triggered. This patch changes mi_cmd_var_update_iter to behave the same way "-var-update var1" does: by calling the thread "stopped" if there is no inferior (and thereby calling varobj_update_one). ChangeLog 2014-06-13 Keith Seitz PR mi/15863 * mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt to update the varobj if inferior_ptid is null_ptid. testsuite/ChangeLog 2014-06-13 Keith Seitz PR mi/15863 * gdb.mi/mi-var-cmd.exp: Add test for -var-update before the inferior is started. --- gdb/mi/mi-cmd-var.c | 4 +++- gdb/testsuite/gdb.mi/mi-var-cmd.exp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 9059616..08a87bf 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -642,7 +642,9 @@ mi_cmd_var_update_iter (struct varobj *var, void *data_pointer) thread_id = varobj_get_thread_id (var); - if (thread_id == -1 && is_stopped (inferior_ptid)) + if (thread_id == -1 + && (ptid_equal (inferior_ptid, null_ptid) + || is_stopped (inferior_ptid))) thread_stopped = 1; else { diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp index 46a4e9e..03e1b4c 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp @@ -50,6 +50,12 @@ mi_gdb_load ${binfile} mi_create_varobj "global_simple" "global_simple" "create global variable" +# PR mi/15863 +# Attempt to update the varobj before running the inferior. +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update varobj before running inferior" + # Test: c_variable-1.2 # Desc: Create non-existent variable