Re: [RFC][patch 0/9] Python support in GDB

Vladimir Prus
2008-05-02T18:07:15Z

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

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 #2: 0001-Refactor-varobj_update-interface.patch --]
[-- Type: application/mbox, Size: 12073 bytes --]

[-- Attachment #3: 0002-Implement-Python-based-computation-of-varobj-childre.patch --]
[-- Type: application/mbox, Size: 29338 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: .gdbinit --]
[-- Type: text/x-java; name=".gdbinit", Size: 740 bytes --]

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"