From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com
Subject: Re: [rfc] expose gdb values to python
Date: Tue, 30 Sep 2008 04:07:00 -0000 [thread overview]
Message-ID: <1222747562.8567.87.camel@localhost.localdomain> (raw)
In-Reply-To: <20080929165930.GA19283@caradoc.them.org>
El lun, 29-09-2008 a las 12:59 -0400, Daniel Jacobowitz escribió:
> On Mon, Sep 29, 2008 at 01:15:05PM -0300, Thiago Jung Bauermann wrote:
> > +/* Python's float type corresponds to native C's double type (which is
> > + assumed to use IEEE double format). */
> > +#define builtin_type_pyfloat builtin_type_ieee_double
> > +
> > +/* Python's long type corresponds to native C's long long type (which is
> > + assumed to be int64_t). */
> > +#define builtin_type_pylong builtin_type_int64
> > +
> > +/* The current language may not have a boolean type, so always use an
> > + integer as boolean type. Hopefully any language can deal with integers
> > + as boolean values. */
> > +#define builtin_type_pybool builtin_type_int32
>
> Can't you get an architecture to use when you need these? I'm scared
> the double change, in particular, will break any non-ieee target.
> This is supposed to be target arithmetic, we should use the target
> formats.
I did it this way having in mind the case when a value needs to be
created at a moment when no file is loaded (and thus an
architecture/target is not yet determined). This is the same problem
faced by the expression evaluator, when the user types (say):
(gdb) print 1.2
Right after starting GDB, before any file has been loaded. It uses
current_gdbarch for now.
I had a look again at the places where builtin_type_* are used, and I
found out in several cases that we can find a gdbarch when needed, but
sometimes I can't see how to do that, and then we'd have to resort to
something like the above.
Some of the uses of builtin_type_* are in convert_value_from_python, it
has two callers: the gdb.Value constructor and gdb.Function, which
registers a Python function that can be called from the GDB expression
evaluator. The constructor can be removed as the user won't need to
create new gdb.Value objects himself. I kept it because it was very
convenient for the testsuite. I'll rewrite it to use the
get_value_from_history trick. For gdb.Function, I think it's possible to
get gdbarch from the expression where it appears. I'll have to dig more
into this, but since that code is not in this patch, I can just remove
convert_value_from_python for now, and resubmit it later.
The other uses of builtin_type_* are in valpy_binop and
valpy_richcompare. They have a struct value handy, which is the second
argument to the binary operation. From its type->main_type->objfile I
can get a gdbarch. Sometimes a type will not have an objfile though (if
it is a builtin_type itself), and in those cases I'd have to resort to
some generic builtin_type. I thought this could happen if a gdb.Function
was called before an architecture is determined, but now that I wrote
all this, I believe since it would get its gdbarch from the expression,
I guess we can just punt if value->type->main_type->objfile is NULL.
Or should I expect types which are not associated with any objfile?
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
next prev parent reply other threads:[~2008-09-30 4:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-12 6:05 Thiago Jung Bauermann
2008-09-20 21:29 ` Tom Tromey
2008-09-21 4:27 ` Daniel Jacobowitz
2008-09-25 4:33 ` Thiago Jung Bauermann
2008-09-25 11:47 ` Daniel Jacobowitz
2008-09-26 2:00 ` Thiago Jung Bauermann
2008-09-26 9:30 ` Eli Zaretskii
2008-09-28 1:19 ` Thiago Jung Bauermann
2008-09-28 18:19 ` Eli Zaretskii
2008-09-29 16:16 ` Thiago Jung Bauermann
2008-09-29 17:00 ` Daniel Jacobowitz
2008-09-30 4:07 ` Thiago Jung Bauermann [this message]
2008-09-30 12:41 ` Daniel Jacobowitz
2008-10-01 3:18 ` Thiago Jung Bauermann
2008-10-01 11:40 ` Daniel Jacobowitz
2008-09-29 18:52 ` Eli Zaretskii
2008-09-26 20:57 ` Daniel Jacobowitz
2008-10-01 5:39 ` Joel Brobecker
2008-10-04 22:14 ` Thiago Jung Bauermann
2008-09-25 4:49 ` Thiago Jung Bauermann
2008-09-26 23:08 ` Tom Tromey
2008-10-01 5:48 ` Joel Brobecker
2008-10-01 15:12 ` Tom Tromey
2008-10-01 16:04 ` Joel Brobecker
2008-10-04 22:21 ` Daniel Jacobowitz
2008-10-05 0:00 ` Tom Tromey
2008-10-06 18:49 ` Joel Brobecker
2008-10-06 21:15 ` Daniel Jacobowitz
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=1222747562.8567.87.camel@localhost.localdomain \
--to=bauerman@br.ibm.com \
--cc=drow@false.org \
--cc=eliz@gnu.org \
--cc=gdb-patches@sources.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