summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2021-09-28 14:19:23 +0800
committerXusheng <xusheng@vector35.com>2022-04-29 11:21:47 +0800
commit87a8a04db5c0a80c06819ec6caf1568b7202cf51 (patch)
tree8850056e2ade5dd60262b20a76e035658136b965 /python
parentdbb5c9d47b3db0a478aab57b9ef43d0dd3f6d4b5 (diff)
Check in the debugger
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py16
-rw-r--r--python/scriptingprovider.py12
2 files changed, 26 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 625a22a4..cdda228f 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -900,7 +900,7 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
if available.name == "Universal":
universal_bvt = available
continue
- if bvt is None and available.name != "Raw":
+ if bvt is None and available.name not in ["Raw", "Debugger"]:
bvt = available
if bvt is None:
@@ -1935,6 +1935,7 @@ class BinaryView:
cls._registered_cb.create = cls._registered_cb.create.__class__(cls._create)
cls._registered_cb.parse = cls._registered_cb.parse.__class__(cls._parse)
cls._registered_cb.isValidForData = cls._registered_cb.isValidForData.__class__(cls._is_valid_for_data)
+ cls._registered_cb.isDeprecated = cls._registered_cb.isDeprecated.__class__(cls._is_deprecated)
cls._registered_cb.getLoadSettingsForData = cls._registered_cb.getLoadSettingsForData.__class__(
cls._get_load_settings_for_data
)
@@ -1991,6 +1992,19 @@ class BinaryView:
return False
@classmethod
+ def _is_deprecated(cls, ctxt):
+ # Since the is_deprecated() method is newly added, existing code may not have it at all
+ # So here we do not consider it as an error
+ if not callable(getattr(cls, 'is_deprecated', None)):
+ return False
+
+ try:
+ return cls.is_deprecated() # type: ignore
+ except:
+ log_error(traceback.format_exc())
+ return False
+
+ @classmethod
def _get_load_settings_for_data(cls, ctxt, data):
try:
attr = getattr(cls, "get_load_settings_for_data", None)
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py
index 8dfe3553..11707240 100644
--- a/python/scriptingprovider.py
+++ b/python/scriptingprovider.py
@@ -43,6 +43,7 @@ from . import function
from .log import log_info, log_error, is_output_redirected_to_log
from .pluginmanager import RepositoryManager
from .enums import ScriptingProviderExecuteResult, ScriptingProviderInputReadyState
+from .debugger import *
class _ThreadActionContext:
@@ -585,7 +586,7 @@ class PythonScriptingInstance(ScriptingInstance):
# Note: "current_address" and "here" are interactive auto-variables (i.e. can be set by user and programmatically)
blacklisted_vars = {
"current_view", "bv", "current_function", "current_basic_block", "current_selection", "current_llil",
- "current_mlil", "current_hlil"
+ "current_mlil", "current_hlil", "dbg"
}
self.locals = BlacklistedDict(
blacklisted_vars, {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]}
@@ -601,6 +602,7 @@ class PythonScriptingInstance(ScriptingInstance):
self.current_addr = 0
self.current_selection_begin = 0
self.current_selection_end = 0
+ self.current_dbg = None
# Selections that were current as of last issued command
self.active_view = None
@@ -609,6 +611,7 @@ class PythonScriptingInstance(ScriptingInstance):
self.active_addr = 0
self.active_selection_begin = 0
self.active_selection_end = 0
+ self.active_dbg = None
self.locals["get_selected_data"] = self.get_selected_data
self.locals["write_at_cursor"] = self.write_at_cursor
@@ -724,6 +727,7 @@ from binaryninja import *
self.active_addr = self.current_addr
self.active_selection_begin = self.current_selection_begin
self.active_selection_end = self.current_selection_end
+ self.active_dbg = self.current_dbg
self.locals.blacklist_enabled = False
self.locals["current_thread"] = self.interpreter
@@ -734,6 +738,7 @@ from binaryninja import *
self.locals["current_address"] = self.active_addr
self.locals["here"] = self.active_addr
self.locals["current_selection"] = (self.active_selection_begin, self.active_selection_end)
+ self.locals["dbg"] = self.active_dbg
if self.active_func is None:
self.locals["current_llil"] = None
self.locals["current_mlil"] = None
@@ -812,6 +817,11 @@ from binaryninja import *
@abc.abstractmethod
def perform_set_current_binary_view(self, view):
self.interpreter.current_view = view
+ if settings.Settings().get_bool('corePlugins.debugger'):
+ if view is not None:
+ self.interpreter.current_dbg = DebuggerController(view)
+ else:
+ self.interpreter.current_dbg = None
@abc.abstractmethod
def perform_set_current_function(self, func):