From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: fix PR python/13351
Date: Tue, 31 Jan 2012 22:02:00 -0000 [thread overview]
Message-ID: <m339avednx.fsf@fleche.redhat.com> (raw)
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
next reply other threads:[~2012-01-31 22:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 22:02 Tom Tromey [this message]
2012-01-31 23:23 ` Doug Evans
2012-02-01 11:52 ` Phil Muldoon
2012-02-01 16:03 ` Tom Tromey
2012-02-01 16:02 ` Tom Tromey
2012-02-01 19:21 ` Doug Evans
2012-02-01 10:41 ` Pedro Alves
2012-02-01 16:05 ` Tom Tromey
2012-02-01 16:12 ` Pedro Alves
2012-02-01 16:17 ` Tom Tromey
2012-02-07 18:05 ` Tom Tromey
2012-02-07 18:49 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m339avednx.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox