MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / DebugInfo

Class DebugInfo

python/debuginfo.py:280–545  ·  view source on GitHub ↗

``class DebugInfo`` provides an interface to both provide and query debug info. The DebugInfo object is used internally by the binary view to which it is applied to determine the attributes of functions, types, and variables that would otherwise be costly to deduce. DebugInfo objects themselve

Source from the content-addressed store, hash-verified

278
279
280class DebugInfo(object):
281 """
282 ``class DebugInfo`` provides an interface to both provide and query debug info. The DebugInfo object is used
283 internally by the binary view to which it is applied to determine the attributes of functions, types, and variables
284 that would otherwise be costly to deduce.
285
286 DebugInfo objects themselves are independent of binary views; their data can be sourced from any arbitrary binary
287 views and be applied to any other arbitrary binary view. A DebugInfo object can also contain debug info from multiple
288 DebugInfoParsers. This makes it possible to gather debug info that may be distributed across several different
289 formats and files.
290
291 DebugInfo cannot be instantiated by the user, instead you must get it from either the binary view (see ``'binaryview.BinaryView'.debug_info``)
292 or a debug-info parser (see ``debuginfo.DebugInfoParser.parse_debug_info``).
293
294 .. note:: Please note that calling one of ``add_*`` functions will not work outside of a debuginfo plugin.
295 """
296 def __init__(self, handle: core.BNDebugInfo) -> None:
297 self.handle = core.handle_of_type(handle, core.BNDebugInfo)
298
299 def __del__(self) -> None:
300 core.BNFreeDebugInfoReference(self.handle)
301
302 @property
303 def parsers(self) -> Iterator[str]:
304 count = ctypes.c_ulonglong()
305 parsers = core.BNGetDebugParserNames(self.handle, count)
306 try:
307 assert parsers is not None, "core.BNGetDebugParserNames returned None"
308 for i in range(0, count.value):
309 yield parsers[i].decode("utf-8")
310 finally:
311 core.BNFreeStringList(parsers, count.value)
312
313 def get_type_container(self, parser_name: str) -> 'typecontainer.TypeContainer':
314 """
315 Type Container for all types in the DebugInfo that resulted from the parse of
316 the given parser.
317
318 :param parser_name: Name of parser
319 :return: Type Container for types from that parser
320 """
321 return typecontainer.TypeContainer(core.BNGetDebugInfoTypeContainer(self.handle, parser_name))
322
323 def types_from_parser(self, name: Optional[str] = None) -> Iterator[Tuple[str, _types.Type]]:
324 """Returns a generator of all types provided by a named DebugInfoParser"""
325 count = ctypes.c_ulonglong(0)
326 name_and_types = core.BNGetDebugTypes(self.handle, name, count)
327 try:
328 assert name_and_types is not None, "core.BNGetDebugTypes returned None"
329 for i in range(0, count.value):
330 yield (name_and_types[i].name, _types.Type.create(core.BNNewTypeReference(name_and_types[i].type)))
331 finally:
332 core.BNFreeDebugTypes(name_and_types, count.value)
333
334 @property
335 def types(self) -> Iterator[Tuple[str, _types.Type]]:
336 """A generator of all types provided by DebugInfoParsers"""
337 return self.types_from_parser()

Callers 2

_parse_infoMethod · 0.70
parse_debug_infoMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected