Skip to content

Commit

Permalink
Replace calls to get_view_of_file with load
Browse files Browse the repository at this point in the history
  • Loading branch information
ElykDeer committed Jul 10, 2023
1 parent 88474db commit f2e004f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/python/debuggercontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class DebuggerController:
Most operations of the debugger are performed on this class. For example, we can launch the debugger as follows::
>>> bv = BinaryViewType.get_view_of_file("test/binaries/helloworld")
>>> bv = load("test/binaries/helloworld")
>>> dbg = DebuggerController(bv)
>>> dbg.launch()
True
Expand Down
26 changes: 13 additions & 13 deletions test/debugger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import subprocess
import unittest

from binaryninja import BinaryView, BinaryViewType, LowLevelILOperation, mainthread, Settings
from binaryninja import load
try:
from debugger import DebuggerController, DebugStopReason
except:
Expand Down Expand Up @@ -52,7 +52,7 @@ def setUp(self) -> None:

def test_repeated_use(self):
fpath = name_to_fpath('helloworld', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)

def run_once():
dbg = DebuggerController(bv)
Expand All @@ -78,7 +78,7 @@ def run_once():
def test_return_code(self):
# return code tests
fpath = name_to_fpath('exitcode', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)

# some systems return byte, or low byte of 32-bit code and others return 32-bit code
testvals = [('-11', [245, 4294967285]),
Expand Down Expand Up @@ -107,7 +107,7 @@ def expect_segfault(self, reason):

def test_exception_segfault(self):
fpath = name_to_fpath('do_exception', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)

dbg.cmd_line = 'segfault'
Expand All @@ -120,7 +120,7 @@ def test_exception_segfault(self):
# # This would not work until we fix the test binary
# def test_exception_illegalinstr(self):
# fpath = name_to_fpath('do_exception', self.arch)
# bv = BinaryViewType.get_view_of_file(fpath)
# bv = load(fpath)
# dbg = DebuggerController(bv)
# dbg.cmd_line = 'illegalinstr'
# self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])
Expand All @@ -142,7 +142,7 @@ def expect_divide_by_zero(self, reason):

def test_exception_divzero(self):
fpath = name_to_fpath('do_exception', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
if not self.arch == 'arm64':
dbg.cmd_line = 'divzero'
Expand All @@ -153,7 +153,7 @@ def test_exception_divzero(self):

def test_step_into(self):
fpath = name_to_fpath('helloworld', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
dbg.cmd_line = 'foobar'
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])
Expand All @@ -166,7 +166,7 @@ def test_step_into(self):

def test_breakpoint(self):
fpath = name_to_fpath('helloworld', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])
# TODO: right now we are not returning whether the operation succeeds, so we cannot use assertTrue/assertFalse
Expand All @@ -184,7 +184,7 @@ def test_breakpoint(self):

def test_register_read_write(self):
fpath = name_to_fpath('helloworld', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])

Expand Down Expand Up @@ -216,7 +216,7 @@ def test_register_read_write(self):

def test_memory_read_write(self):
fpath = name_to_fpath('helloworld', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])

Expand All @@ -237,7 +237,7 @@ def test_memory_read_write(self):
# @unittest.skip
def test_thread(self):
fpath = name_to_fpath('helloworld_thread', self.arch)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])

Expand All @@ -262,7 +262,7 @@ def test_thread(self):
def test_assembly_code(self):
if self.arch == 'x86_64':
fpath = name_to_fpath('asmtest', 'x86_64')
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError])
entry = dbg.data.entry_point
Expand Down Expand Up @@ -304,7 +304,7 @@ def test_attach(self):
print('attaching test not yet implemented on %s' % platform.system())

self.assertIsNotNone(pid)
bv = BinaryViewType.get_view_of_file(fpath)
bv = load(fpath)
dbg = DebuggerController(bv)
dbg.pid_attach = pid
self.assertTrue(dbg.attach_and_wait())
Expand Down

0 comments on commit f2e004f

Please sign in to comment.