diff options
| author | KyleMiles <krm504@nyu.edu> | 2021-05-19 20:40:24 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2021-07-07 23:27:29 -0400 |
| commit | d19f5e85ee26c3d6604798d30ab821d15731cada (patch) | |
| tree | 9851b7f6bf5589df69508d4489c11148515cb550 /python/binaryview.py | |
| parent | 0f58b0742e3010eee6bbd2e15f4dd4930ec0d822 (diff) | |
DebugInfo - plugable debug information importers - C++, Rust, and Python APIs
Diffstat (limited to 'python/binaryview.py')
| -rw-r--r-- | python/binaryview.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 30b763a0..ae88b4c0 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -28,6 +28,7 @@ import abc import numbers import json import inspect +from typing import Union from collections import defaultdict, OrderedDict @@ -500,6 +501,15 @@ class DataVariable(object): self._view = value +class DataVariableAndName(DataVariable): + def __init__(self, addr: int, var_type: types.Type, var_name: str, auto_discovered: bool, view: "BinaryView" = None) -> None: + super(DataVariableAndName, self).__init__(addr, var_type, auto_discovered, view) + self.name = var_name + + def __repr__(self) -> str: + return "<var 0x%x: %s %s>" % (self.address, str(self.type), self.name) + + class BinaryDataNotificationCallbacks(object): def __init__(self, view, notify): self._view = view @@ -1483,7 +1493,6 @@ class BinaryView(object): finally: core.BNFreeFunctionList(funcs, count.value) - def __getitem__(self, i): if isinstance(i, tuple): result = bytes() @@ -6251,6 +6260,24 @@ class BinaryView(object): """ core.BNSetGlobalCommentForAddress(self.handle, addr, comment) + @property + def debug_info(self) -> "binaryninja.debuginfo.DebugInfo": + """The current debug info object for this binary view""" + return binaryninja.debuginfo.DebugInfo(core.BNNewDebugInfoReference(core.BNGetDebugInfo(self.handle))) + + @debug_info.setter + def debug_info(self, value: "binaryninja.debuginfo.DebugInfo") -> Union[None, 'NotImplemented']: + """Sets the debug info for the current binary view""" + if not isinstance(value, binaryninja.debuginfo.DebugInfo): + return NotImplemented + core.BNSetDebugInfo(self.handle, value.handle) + + def apply_debug_info(self, value: "binaryninja.debuginfo.DebugInfo") -> Union[None, 'NotImplemented']: + """Sets the debug info and applies its contents to the current binary view""" + if not isinstance(value, binaryninja.debuginfo.DebugInfo): + return NotImplemented + core.BNApplyDebugInfo(self.handle, value.handle) + def query_metadata(self, key): """ `query_metadata` retrieves a metadata associated with the given key stored in the current BinaryView. |
