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] Debug Operators with GDB Python


On Mon, Dec 10, 2012 at 2:30 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Fri, Dec 7, 2012 at 4:59 PM, Doug Evans <dje@google.com> wrote:
>> IWBN if the user didn't have to deal with this, and it all just fell
>> out from gdb's existing support that it already has to get right if it
>> hand-called the inferior's operator implementation.
>
> I spent the weekend thinking through a way on how to add 'debug
> methods' for C++ alone. When I consider C++ alone, lot of
> arguments/points that you have made make a lot more sense to me. I
> have started putting together a patch which adds the ability to define
> 'debug methods' in Python for C++. I hope to have a working version by
> the end of this week. We can probably compare with the first patch I
> sent out and debate further.

It turned out to be much more involved than I had expected and took me
much longer than I had expected. And, I am still a long way away from
a complete patch in many ways. The patch as I have it today is
attached. I am sending it out to get early feedback before I head too
much in the direction I have in mind. Few points about the patch.

1. Though the design enables to add/replace any non-static and
non-virtual methods of a class, only operator methods implemented in
Python will be functional. The complete patch will remove this
restriction.
2. Dynamic types are not yet handled. However, support for overload
resolution over the methods defined for the 'static' type of an object
is complete. The complete patch will also take the dynamic type of the
object, on which the method is being invoked, into consideration.
3. I have not reg tested the patch yet. I have only tested with a few
toy programs.
4. I have not yet bothered myself with looking into differences
between Python versions.
5. As I mentioned previously, this patch is for C++ alone.
6. The changelog (which is also very raw) is as follows:

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

        * Makefile.in: Add entries for new files
        * data-directory/Makefile.in: Add entery for new Python file
        * eval.c: Use new 'find_overload_match' signature.
        * ext-function.c: Support for working with functions/methods
        defined in an extension language.
        * ext-function.h: Support for working with functions/methods
        defined in an extension language.
        * python/lib/gdb/debugmethods.py: Python side of the support
        for debug methods in Python.
        * python/py-debugmethods.c: C side of the support for debug
        methods in Python.
        * python/py-objfile.c: Add 'debug_methods' attribute to
        gdb.Objfile.
        * python/python-internal.h: Add new function
        gdb.enable_debug_methods to the Python module 'gdb'.
        * python/python.c: Add new function gdb.enable_debug_methods to
        the Python module 'gdb'.
        * python/python.h: Add declarations of new functions.
        * valarith.c: Use methods defined in extension languages.
        * valops.c: Use methods defined in extension languages.
        * value.h: New signature for 'find_overload_match'.

Also attached are the toy program I used and the associated auto load script.

Thanks and regards,
Siva Chandra

Attachment: dm_patch.txt
Description: Text document

Attachment: dm.cc
Description: Binary data

Attachment: dm-gdb.py
Description: Binary data


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