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][patch 0/9] Python support in GDB


Thiago Jung Bauermann wrote:

> Hi everybody,
> 
> This patch series adds Python scripting support to GDB, and exposes
> some of its subsystems hopefully in a "pythonic" way. These patches
> correspond to the contents of the git repository at gitorious.org,
> rebased to apply cleanly on top of CVS HEAD as of 04/27.

The attached two patches are rebased MI ones. The first is cleanup,
and I'll commit it shortly. The second one is the real one. Since both
patches touch just MI code, this is RFC, not RFA. The second patch
has a couple fixmes that I'll address later, and needs doc that I'll
also write as the other Python patches are in.

Here's an example session:

(gdb)
-var-set-type-visualizer std::vector.* VectorVisualizer
^done
....
~"11\t  std::vector<int> v;\n"
....
~"12\t  v.push_back (7);\n"
^done
(gdb)
-var-create V * v
^done,name="V",numchild="1",value="{...}",type="std::vector<int,std::allocator<int> >",thread-id="1"
(gdb)
-var-list-children V
^done,numchild="0"
(gdb)
next
&"next\n"
~"13\t  v[0] = 11;\n"
^done
(gdb)
-var-update --all-values V
^done,changelist=[{name="V",value="{...}",in_scope="true",type_changed="false",children=[{name="V.0",exp="0",numchild="0",value="7",type="int",thread-id="1"}]}]
(gdb)

The .gdbinit I use is also attached.

- Volodya

Attachment: 0001-Refactor-varobj_update-interface.patch
Description: application/mbox

Attachment: 0002-Implement-Python-based-computation-of-varobj-childre.patch
Description: application/mbox

python
class StringVisualizer:
    def to_string (self, v):
        # FIXME: catch any exceptions accessing bogus memory
        data = v.get_element ("_M_dataplus")
        return str (data.get_element ("_M_p"))
class VectorVisualizer:
    def children (self, v):
        result = []
        impl = v.get_element ('_M_impl')
        start = impl.get_element ('_M_start')
        finish = impl.get_element ('_M_finish')
        current = start
        index = 0
        while not current.equals(finish):
            result.append((str(index), current.dereference()))
            current = current.increment(1)
            index = index + 1
        return result
end
#interpreter-exec mi2 "-var-set-type-visualizer string StringVisualizer"


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