From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21532 invoked by alias); 16 Nov 2010 20:17:40 -0000 Received: (qmail 21523 invoked by uid 22791); 16 Nov 2010 20:17:37 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Nov 2010 20:17:30 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAGKHSlm001744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Nov 2010 15:17:28 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAGKHRVK032269; Tue, 16 Nov 2010 15:17:27 -0500 From: Phil Muldoon To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: PR Python/12212 References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 16 Nov 2010 20:17:00 -0000 In-Reply-To: (Tom Tromey's message of "Tue, 16 Nov 2010 12:00:56 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00212.txt.bz2 Tom Tromey writes: >>>>>> "Phil" == Phil Muldoon writes: > > Phil> Oops I did not notice that the documentation. In that case the only > Phil> change is to py-inferior.c, and I can delete the changes to > Phil> py-infthread.c. Do you want me to generate a new patch, or should I > Phil> just go ahead check that change in? > > It would be nice to have a regression test for the crash. I adjusted the regression test in the previous patch I sent to account for this. Patch included. Cheers, Phil -- diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index b1ddb168..6382dab 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -130,6 +130,9 @@ find_thread_object (ptid_t ptid) PyObject *inf_obj; pid = PIDGET (ptid); + if (pid == 0) + return NULL; + inf_obj = find_inferior_object (pid); if (inf_obj) diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index dd9175a..e6080d1 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -146,6 +146,11 @@ gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect hel gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "verify help to uiout" +# Test PR 12212, using InfThread.selected_thread() when no inferior is +# loaded. +gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1 +gdb_test "python print nothread == None" "True" "Ensure that no threads are returned" + # Start with a fresh gdb. clean_restart ${testfile}