diff --git a/main.py b/main.py index b149bda..42c915c 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,7 @@ SCRIPT_VERSION = '0.1.0' configuration = { 'include_file_name': False, 'print_debug_info': False, + 'all_members': False, } supported_types = [ @@ -194,6 +195,9 @@ class Bear(): child_offset = 0 child_offset_bit = 0 for child_die in die_type._children: + if child_die.tag != 'DW_TAG_member' and not configuration['all_members']: + continue + if 'DW_AT_type' in child_die.attributes: typ_die = child_die.get_DIE_from_attribute('DW_AT_type') elif child_die.tag in supported_types: @@ -230,6 +234,9 @@ class Bear(): load_children(die_type) child_entries = [] for child_die in die_type._children: + if child_die.tag != 'DW_TAG_member' and not configuration['all_members']: + continue + if 'DW_AT_type' in child_die.attributes: typ_die = child_die.get_DIE_from_attribute('DW_AT_type') elif child_die.tag in supported_types: @@ -351,6 +358,8 @@ def main(): help='Display filename at the beginning') parser.add_argument('--print-debug-info', dest='print_debug_info', action='store_true', help='Print debug infor when parsing DWARF') + parser.add_argument('--all-members', dest='all_members', action='store_true', + help='Print information of all children') parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=SCRIPT_VERSION)) @@ -358,6 +367,7 @@ def main(): configuration['include_file_name'] = args.include_file_name configuration['print_debug_info'] = args.print_debug_info + configuration['all_members'] = args.all_members if not args.elf_file: parser.print_help()