From: Phil Muldoon <pmuldoon@redhat.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [patch] PR 11417
Date: Tue, 30 Mar 2010 14:46:00 -0000 [thread overview]
Message-ID: <4BB20EC0.10500@redhat.com> (raw)
http://sourceware.org/bugzilla/show_bug.cgi?id=11417
The OP of that bug posts an interesting issue. If the address of a
value in the inferior is 0x0, should the user still be able to create
a Python lazy string from that value? My first reaction was no --
purely for the reason that anything with an address of 0x0 can ever be
lazily fetched. But the problem here is compatibility with
Value.string, and the enormous pain in the neck it would be to check
for NULL on every value before a lazy string could be created. Maybe
we should just handle lazy strings with no address? And when printing
occurs print nothing (or in this case, with GDB, print ""). I created a
patch to do that and have attached it. While this is technically
incorrect, I think it will make life a little easier. One of the side
effects of this change is that if you want to convert a lazy string
back into a value, GDB will raise an exception with address 0x0. I
gated that one side effect by raising an exception.
Tested on x86_64 with no regressions
What do you think?
Cheers,
Phil
--
2010-03-30 Phil Muldoon <pmuldoon@redhat.com>
PR python/11417
* python/py-lazy-string.c (stpy_convert_to_value): Check for
a NULL address.
(gdbpy_create_lazy_string_object): Allow strings with a NULL
address.
--
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 8309527..a7a4046 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -94,6 +94,13 @@ stpy_convert_to_value (PyObject *self, PyObject *args)
lazy_string_object *self_string = (lazy_string_object *) self;
struct value *val;
+ if (self_string->address == 0)
+ {
+ PyErr_SetString (PyExc_MemoryError,
+ "Cannot create a value from NULL");
+ return NULL;
+ }
+
val = value_at_lazy (self_string->type, self_string->address);
return value_to_value_object (val);
}
@@ -111,13 +118,6 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
{
lazy_string_object *str_obj = NULL;
- if (address == 0)
- {
- PyErr_SetString (PyExc_MemoryError,
- "Cannot create a lazy string from a GDB-side string.");
- return NULL;
- }
-
if (!type)
{
PyErr_SetString (PyExc_RuntimeError,
next reply other threads:[~2010-03-30 14:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-30 14:46 Phil Muldoon [this message]
2010-03-30 18:05 ` Tom Tromey
2010-03-31 10:07 ` Phil Muldoon
2010-04-07 20:58 ` Tom Tromey
2010-04-08 12:38 ` 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=4BB20EC0.10500@redhat.com \
--to=pmuldoon@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