def type_is_pointer(t):
basic_type = gdb.types.get_basic_type(t)
- return basic_type.code == gdb.TYPE_CODE_PTR
+ return basic_type.code == gdb.TYPE_CODE_PTR or basic_type.code == gdb.TYPE_CODE_REF
def find_outgoing_pointers(value):
"""Finds all outgoing pointers from a value, traversing each non-pointer member of a composite type
(e.g. struct members inside structs) and also each member in every base class, recursively.
Returns a dict of {field_name:address} where field_name is a string, and address is a gdb.Value."""
- if type_is_pointer(value.dynamic_type):
+ try:
+ valuetype = value.dynamic_type
+ except gdb.error:
+ valuetype = value.type
+ if type_is_pointer(valuetype):
return {"*": value}
- elif type_has_fields(value.dynamic_type):
+ elif type_has_fields(valuetype):
result = {}
for f in value.type.fields():
if f.is_base_class:
for (child_name, child_value) in children.iteritems():
# compute child "tree" dimensions (layout is always tree-like even if there are edges that make this a generic graph)
if child_value != 0:
- child_width, child_height = visit_values(node_dict, child_value.dereference(), children_x, children_y, recursion_level - 1)
+ child_width, child_height = visit_values(node_dict, child_value.referenced_value(), children_x, children_y, recursion_level - 1)
children_y += child_height
children_height += child_height
width = max(width, NODE_SPACING + child_width)
<h2> Custom commands (2/3) </h2>
<p>A more complex example, from PpluX's <a href="http://code.google.com/p/slb/source/browse/extra/lua_utils.gdb?name=default">SLB repo</a></p>
-<pre>
-define luastack
+<pre><code>define luastack
set $top = lua_gettop($arg0)
set $i = 1
while $i <= $top
end
set $i = $i + 1
end
-</pre>
+</code></pre>
</section>
(gdb) python print "Hello, World!"
Hello, World!
</pre>
+ <p class="fragment">Ok, now what?</p>
+ </section>
+
+ <section>
+ <h2>Pretty printing</h2>
+ <ul>
+ <li>
+ Friendly representation of your data structures
+ </li>
+ <li>
+ Up-to-date libc versions have pretty printers for STL containers. You don't need to do
+ anything to benefit from this RIGHT NOW. <br>
+ <img class="fragment" src="its-free.jpg">
+
+ </li>
+ </ul>
+
</section>
<section>
<h2>Custom commands (python version)</h2>
-<pre><code contenteditable>
+<pre><code>
class DoNothingCommand(gdb.Command):
"""This command does nothing.""" # docstring
def __init__(self):