From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21162 invoked by alias); 31 Jan 2012 22:00:11 -0000 Received: (qmail 21118 invoked by uid 22791); 31 Jan 2012 22:00:08 -0000 X-SWARE-Spam-Status: No, hits=-7.0 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, 31 Jan 2012 21:59:49 +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 q0VLxmxS029955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 31 Jan 2012 16:59:49 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0VLxmEp025540; Tue, 31 Jan 2012 16:59:48 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0VLxkZG014477; Tue, 31 Jan 2012 16:59:47 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFA: fix PR python/13351 Date: Tue, 31 Jan 2012 22:02:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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: 2012-01/txt/msg01020.txt.bz2 This fixes PR python/13351. The bug is that gdb.lookup_symbol required a current frame, but this restriction doesn't really make sense. It is ok to look up global symbols without a current frame. This patch just lifts the restriction. This requires a doc review. Built and regtested on x86-64 Fedora 15. Tom 2012-01-31 Tom Tromey PR python/13351: * python/py-symbol.c (gdbpy_lookup_symbol): Work even when there is no frame. 2012-01-31 Tom Tromey * gdb.texinfo (Symbols In Python): lookup_symbol works even without a current frame. 2012-01-31 Tom Tromey * gdb.python/py-symbol.exp: Add test for frame-less lookup_symbol. >From 29e3b00fe4b2593af94ed37f3f6c29d2a218ecbd Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 31 Jan 2012 13:53:35 -0700 Subject: [PATCH 1/3] fix for PR 13351 - let lookup_symbol work without a frame --- gdb/ChangeLog | 6 ++++++ gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 3 ++- gdb/python/py-symbol.c | 5 +++-- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.python/py-symbol.exp | 3 +++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5738d14..86fa88f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -23924,7 +23924,8 @@ arguments. optional @var{block} argument restricts the search to symbols visible in that @var{block}. The @var{block} argument must be a @code{gdb.Block} object. If omitted, the block for the current frame -is used. The optional @var{domain} argument restricts +is used; if there is no current frame, then file-scoped and global +symbols are searched. The optional @var{domain} argument restricts the search to the domain type. The @var{domain} argument must be a domain constant defined in the @code{gdb} module and described later in this chapter. diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 9d32a71..f93a35a 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -292,8 +292,9 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) TRY_CATCH (except, RETURN_MASK_ALL) { - selected_frame = get_selected_frame (_("No frame selected.")); - block = get_frame_block (selected_frame, NULL); + selected_frame = get_selected_frame_if_set (); + if (selected_frame) + block = get_frame_block (selected_frame, NULL); } GDB_PY_HANDLE_EXCEPTION (except); } diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp index b0e73c3..91bfd51 100644 --- a/gdb/testsuite/gdb.python/py-symbol.exp +++ b/gdb/testsuite/gdb.python/py-symbol.exp @@ -42,6 +42,9 @@ gdb_py_test_silent_cmd "python main_func = gdb.lookup_global_symbol(\"main\")" " gdb_test "python print main_func.is_function" "True" "Test main_func.is_function" gdb_test "python print gdb.lookup_global_symbol(\"junk\")" "None" "Test lookup_global_symbol(\"junk\")" +gdb_test "python print gdb.lookup_symbol('main')\[0\].is_function" "True" \ + "Lookup main using lookup_symbol" + if ![runto_main] then { fail "Can't run to main" return 0 -- 1.7.6.5