From: Jorge Gorbe Date: Thu, 8 Nov 2012 17:50:15 +0000 (+0100) Subject: Changes X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=50b015bd1887d8237df51ea5ee0f2e9e89525f92;p=resacon2012.git Changes --- diff --git a/samples/view.py b/samples/view.py index 70f9a63..49cfffb 100644 --- a/samples/view.py +++ b/samples/view.py @@ -19,15 +19,19 @@ def type_has_fields(t): 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: @@ -388,7 +392,7 @@ def visit_values(node_dict, value, x, y, recursion_level): 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) diff --git a/slides/index.html b/slides/index.html index 510d5ce..968388b 100644 --- a/slides/index.html +++ b/slides/index.html @@ -126,8 +126,7 @@ End with a line saying just "end".

Custom commands (2/3)

A more complex example, from PpluX's SLB repo

-
-define luastack
+
define luastack
     set $top = lua_gettop($arg0)
     set $i = 1
     while $i <= $top
@@ -146,7 +145,7 @@ define luastack
         end
         set $i = $i + 1
     end
-
+
@@ -174,11 +173,28 @@ define luastack (gdb) python print "Hello, World!" Hello, World! +

Ok, now what?

+ + +
+

Pretty printing

+ +

Custom commands (python version)

-

+

 class DoNothingCommand(gdb.Command):
     """This command does nothing."""  # docstring
     def __init__(self):
diff --git a/slides/its-free.jpg b/slides/its-free.jpg
new file mode 100644
index 0000000..c6289ec
Binary files /dev/null and b/slides/its-free.jpg differ