Read the pointer and if not 0 create a function to parse it and call it. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- python_modules/dissector.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/python_modules/dissector.py b/python_modules/dissector.py index 3d822cc..d623576 100644 --- a/python_modules/dissector.py +++ b/python_modules/dissector.py @@ -357,9 +357,58 @@ def write_array(writer, container, member, nelements, array, dest, scope): assert(element_type.is_struct()) write_struct(writer, member, element_type, index, dest, scope) + +def write_ptr_function(writer, target_type, container, member, dest, scope): + nelements = '' + if target_type.is_array(): + parse_function = "parse_array_%s" % target_type.element_type.primitive_type() + nelements = ', guint32 nelements' + else: + parse_function = "parse_struct_%s" % target_type.c_type() + if writer.is_generated("parser", parse_function): + return '%s(glb, %s, offset)' % (parse_function, dest.level.tree) + + writer.set_is_generated("parser", parse_function) + + writer = writer.function_helper() + scope = writer.function(parse_function, "guint32", "GlobalInfo *glb _U_, proto_tree *tree _U_%s, guint32 offset" % nelements, True) + + writer.newline() + + dest = RootDestination(scope) + dest.is_helper = True + if target_type.is_array(): + write_array(writer, None, None, "nelements", target_type, dest, scope) + else: + write_container_parser(writer, target_type, dest) + + writer.statement("return offset") + + writer.end_block() + + return '%s(glb, %s, offset)' % (parse_function, dest.level.tree) + +def read_ptr(writer, t): + writer.assign('ptr', '%s(glb->tvb, offset)' % primitive_read_func(t)) + writer.increment('offset', str(t.get_fixed_nw_size())) + def write_pointer(writer, container, member, t, dest, scope): assert(t.is_pointer()) + if not scope.variable_defined('ptr'): + scope.variable_def('guint32', 'ptr') + read_ptr(writer, t) + with writer.if_block('ptr'): + writer.variable_def('guint32', 'save_offset = offset') + writer.assign('offset', 'ptr + glb->message_offset') + if t.target_type.is_array(): + nelements = read_array_len(writer, member.name, t.target_type, dest, scope, True) + write_array(writer, container, member, nelements, t.target_type, dest, scope) + else: + stmt = write_ptr_function(writer, t.target_type, container, member, dest, scope) + writer.statement(stmt) + writer.assign('offset', 'save_offset') + def write_struct_func(writer, t, func_name, index): func_name = 'dissect_spice_struct_' + t.name -- 2.1.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel