Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright (C) 2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GCC; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>.
# Helpers to parse and check DWARF in object files. # # The purpose of these is to make it easy to write "smart" tests on DWARF # information: pattern matching on DIEs and their attributes, check links # between DIEs, etc. Doing these checks using abstract representations of DIEs # is far easier than scanning the generated assembly!
# Fetch the DWARF parsing function that correspond to the DWARF dump tool to # use.
'objdump': dwarfutils.objdump.parse_dwarf, } except KeyError: # no-coverage raise RuntimeError('Unhandled DWARF dump tool: {}'.format( DWARF_DUMP_TOOL_KIND ))
def parse_dwarf(object_file=None, single_cu=True): # no-coverage """ Fetch and decode DWARF compilation units in `object_file`.
If `single_cu` is true, make sure there is exactly one compilation unit and return it. Otherwise, return compilation units as a list.
:param str|None object_file: Name of the object file to process. If left to None, `sys.argv[1]` is used instead.
:rtype: dwarfutils.data.CompilationUnit |list[dwarfutils.data.CompilationUnit] """ script_args = testutils.parse_args() result = dwarf_parser(script_args.object_file)
if single_cu: if not result: return None if len(result) > 1: raise ValueError('Multiple compilation units found') return result[0] else: return result |