From: Jeff Mahoney <jeffm@suse.com>
To: Phil Muldoon <pmuldoon@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/7] py-symbol: Require a frame for lookup_symbol only when necessary
Date: Fri, 05 Feb 2016 16:08:00 -0000 [thread overview]
Message-ID: <56B4C8DB.1010808@suse.com> (raw)
In-Reply-To: <56B492DC.6090402@redhat.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2/5/16 7:17 AM, Phil Muldoon wrote:
> On 04/02/16 17:29, jeffm@suse.com wrote:
>> From: Jeff Mahoney <jeffm@suse.com> > > gdbpy_lookup_symbol
>> requires a frame prior to doing the symbol lookup but > a frame
>> isn't necessary for many symbol types. Calling >
>> symbol_read_needs_frame will tell us if it's necessary but we
>> need to > have already looked up the symbol to use it. This
>> patch puts the > lookup first and then only resolves the frame if
>> one is required. > > This allows us to lookup static symbols
>> directly from python rather > than using gdb.eval_and_parse.
>
> Please add documentation and further tests for new functionality.
>
>> --- > gdb/python/py-symbol.c | 31
>> +++++++++++++++++-------------- > 1 file changed, 17
>> insertions(+), 14 deletions(-) > > diff --git
>> a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c > index
>> cbbc9e2..c7f0ff8 100644 > --- a/gdb/python/py-symbol.c > +++
>> b/gdb/python/py-symbol.c > @@ -382,14 +382,28 @@
>> gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject
>> *kw) > > if (block_obj) > block = block_object_to_block
>> (block_obj); > - else > + > + TRY > + { > + symbol =
>> lookup_symbol (name, block, (domain_enum) domain, > +
>> &is_a_field_of_this).symbol; > + } > + CATCH (except,
>> RETURN_MASK_ALL) > + { > + GDB_PY_HANDLE_EXCEPTION
>> (except); > + } > + END_CATCH > + > + if (symbol && !block)
>> > { > struct frame_info *selected_frame; > >
>> TRY > { > - selected_frame = get_selected_frame (_("No
>> frame selected.")); > - block = get_frame_block
>> (selected_frame, NULL); > + if
> (symbol_read_needs_frame(symbol)) {
>
> Formatting nit, space after function name and before (.
>
>> + selected_frame = get_selected_frame (_("No frame
>> selected.")); > + block = get_frame_block (selected_frame,
>> NULL); > + } > } > CATCH (except,
>> RETURN_MASK_ALL) > { > @@ -398,17 +412,6 @@
>> gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject
>> *kw) > END_CATCH > }
>
> My only concern here is (and the context is not meaningful enough
> to see), is that you've removed an "else" above which is an
> unconditional branch, and replaced it with an IF instead. What
> happens when both IFs can fail?
This patch is broken. It works for my need to look up static symbols
but it fails the py-symbol testsuite. We look up the block and never
use it, so it's no wonder it's failing.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
Comment: GPGTools - http://gpgtools.org
iQIcBAEBAgAGBQJWtMjbAAoJEB57S2MheeWyJhcQALzkE3DaXUyTHxaSovnUbe6+
bFleikXDjbL4UKYwT/0iJfVoaH8weoWMiFfrYVXJgCqXIUEX9mtUPfMXq5NHyJ71
0FgQa9pRVCK2sS/4jpPjMwL40AU4DI4XYOHbSowZfm9kn28yY+uP6UkbiWsv5dDn
egNkSzjyrX4MzMHSzZIDqNBGqPdp03nLBKyrjl8iLtgUK6HZwBponk2Y50l8d+gy
M6FP4xXMUqKgW0JBW+P1V/S6YowW+RCaHgBrmwISe9QU79M3s3Jpi+VD+WxEO8HY
rUrlOXzJhMm/IcF9r4ROmYGXFdQdOjlMyTQtOkyCe8+VYlwOsc107GzipNnQ2mRf
Rd2+2UZNs+430pcpivq+h+wDlcM5Cu6QWDFa9/TIHw97n776YeQ6bZHcSCXFOvd2
FrWsOqQoM2zNTKTjuxCJyr2lfgHxFTiSggVrX1Glmw2sVdwks5DvoGXNa8lnq1fp
PGII0edxMPg1neOhZZ24j/k2dB1dZmAOMuzUg6OggSiVSj31R+ZmarE/xRHfXqPk
kTfuJHX45dpBTZQ+X6VgWkYzG6OHhRV2ilWHky7PETM3LTpTVFNGqOxEEYZach0/
C5SV6Zykp+wjkZTVLL/q3YgPRHJj+SUKRRBEj7qfG4PcyeI0ybsDVfQ8ZEh6JANI
WWRyy3/zyUbONSV77I/R
=eJFa
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2016-02-05 16:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 17:29 [PATCH 0/7] Python extension patchset jeffm
2016-02-04 17:29 ` [PATCH 1/7] check_types_equal: short circuit check if identical pointers are used jeffm
2016-02-04 17:29 ` [PATCH 4/7] py-symbol: Require a frame for lookup_symbol only when necessary jeffm
2016-02-05 12:17 ` Phil Muldoon
2016-02-05 16:08 ` Jeff Mahoney [this message]
2016-02-05 16:35 ` Phil Muldoon
2016-02-04 17:29 ` [PATCH 3/7] py-symbol: use Py_RETURN_NONE instead of open coding it jeffm
2016-02-04 17:29 ` [PATCH 7/7] py-regcache: Add interface to regcache jeffm
2016-02-04 17:29 ` [PATCH 6/7] py-minsymbol: Add interface to access minimal_symbols jeffm
2016-02-05 12:25 ` Phil Muldoon
2016-02-05 16:43 ` Phil Muldoon
2016-02-08 15:51 ` Jeff Mahoney
2016-02-04 17:43 ` [PATCH 2/7] py-value: properly handle unsigned and pointer types jeffm
2016-02-05 12:12 ` Phil Muldoon
2016-02-05 12:29 ` Phil Muldoon
2016-02-04 17:43 ` [PATCH 5/7] py-symbol: export section name jeffm
2016-02-05 12:18 ` Phil Muldoon
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=56B4C8DB.1010808@suse.com \
--to=jeffm@suse.com \
--cc=gdb-patches@sourceware.org \
--cc=pmuldoon@redhat.com \
/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