From ce902e7a8696c73fefc43dd9109bf4783e9c41bc Mon Sep 17 00:00:00 2001 From: florijan Date: Fri, 18 Aug 2017 14:52:18 +0200 Subject: [PATCH] GDB operator tree plugin improvement suggestion Summary: The previous version didn't seemt to be able to print the operator tree below the `Expand` operator. It seems it was unable to reach the `input_` field because it's a member of the `ExpandCommon` super-type. The proposed fix handles that. @teon, please test, verify, modify, whatever, just ensure printing works below `Expand` operators. Reviewers: teon.banek, buda Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D679 --- tools/gdb-plugins/operator_tree.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/gdb-plugins/operator_tree.py b/tools/gdb-plugins/operator_tree.py index 650a6b030..f394a22d6 100644 --- a/tools/gdb-plugins/operator_tree.py +++ b/tools/gdb-plugins/operator_tree.py @@ -37,11 +37,17 @@ def _smart_ptr_pointee(smart_ptr): def _get_operator_input(operator): '''Returns the input operator of given operator, if it has any.''' - if 'input_' not in [f.name for f in operator.type.fields()]: + types_to_process = [operator.type] + all_fields = [] + while types_to_process: + for field in types_to_process.pop().fields(): + if field.is_base_class: + types_to_process.append(field.type) + else: + all_fields.append(field) + if "input_" not in [f.name for f in all_fields]: return None input_addr = _smart_ptr_pointee(operator['input_']) - if input_addr == 0: - return None pointer_type = _logical_operator_type().pointer() input_op = gdb.Value(input_addr).cast(pointer_type).dereference() return input_op.cast(input_op.dynamic_type)