This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC - GDB Python API] New gdb.Architecture class


Fixed all of Tom's nits in the attached patch. Also, added doc and
NEWS entries in this patch.

On Mon, Jan 21, 2013 at 9:09 AM, Tom Tromey <tromey@redhat.com> wrote:
> One other question is whether we care about object identity.
> gdbarch_to_arch_object returns a new object each time.
> Either way is fine depending on circumstances -- we do both already in
> gdb -- but it ought to be an explicit choice.

In the attached patch, I have made it such a way that if a Python
architecture object exists, then a new reference is returned instead
of a new object. To be frank, the class is so simple that I am not
really sure which is the right approach. But I modified because I
think (as gdbarch pointers do not change) references instead of whole
objects might be more efficient memory wise(?).

Siva> +gdbpy_current_arch (PyObject *self, PyObject *args) {

> Do we need this function?  The "current arch" is kind of a problematic
> feature.  It is semi-exposed to Python right now, but I think we're
> mostly agreed that this was an early mistake.

The only reason I added this function is because I can have something
to add as tests for the new class! I have removed it now and only have
tests for the new method gdb.Frame.architecture(). Will raise my
questions about get_current_arch() and python_gdbarch in a separate
thread.

2013-01-22  Siva Chandra Reddy  <sivachandra@google.com>

        Add a new class gdb.Architecture which exposes GDB's
        internal representation of architecture via GDB Python API.

        * Makefile.in: Add entries corresponding to the new file
        python/py-arch.c.
        * python/py-arch.c: Implement gdb.Architecture class.
        * python/py-frame.c (frapy_arch): Implement the method
        gdb.Frame.architecture().
        (frame_object_methods): Add 'architecture' to the method table.
        * python/python-internal.h: Add declarations of new utility
        functions.
        * python/python.c (_initialize_python): Initialize
        gdb.Architecture class.

doc/

        * gdb.texinfo (Architectures In Python): New sub-sub-section
        describing the gdb.Architecture class.
        (Frames In Python): Add description about the new method
        Frame.architecture().

testsuite/

        * gdb.python/frame.exp: Add a test for Frame.architecture()
        method.

Thanks,
Siva Chandra

Attachment: gdb_arch_patch_v2.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]