This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFA: fix PR python/13351
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 31 Jan 2012 14:59:46 -0700
- Subject: RFA: fix PR python/13351
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 <tromey@redhat.com>
PR python/13351:
* python/py-symbol.c (gdbpy_lookup_symbol): Work even when there
is no frame.
2012-01-31 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Symbols In Python): lookup_symbol works even
without a current frame.
2012-01-31 Tom Tromey <tromey@redhat.com>
* gdb.python/py-symbol.exp: Add test for frame-less
lookup_symbol.
>From 29e3b00fe4b2593af94ed37f3f6c29d2a218ecbd Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
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