Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug for aarch64 in android #285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Vagrant.configure(2) do |config|
v.linked_clone = true
end

config.vm.network "forwarded_port", guest: 5555, host: 5556
config.vm.network "forwarded_port", guest: 22222, host: 5556

config.vm.synced_folder "../", "/voltron"
config.vm.synced_folder "~/shared", "/shared"
Expand Down
28 changes: 14 additions & 14 deletions tests/http_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setup():
voltron.setup_env()
voltron.config['server'] = {
"listen": {
"tcp": ["127.0.0.1", 5555]
"tcp": ["127.0.0.1", 22222]
}
}
pm = PluginManager()
Expand All @@ -76,88 +76,88 @@ def teardown():


def test_disassemble():
data = requests.get('http://localhost:5555/api/disassemble?count=16').text
data = requests.get('http://localhost:22222/api/disassemble?count=16').text
res = APIResponse(data=data)
assert res.is_success
assert res.disassembly == disassemble_response


def test_command():
data = requests.get('http://localhost:5555/api/command?command=reg%20read').text
data = requests.get('http://localhost:22222/api/command?command=reg%20read').text
res = APIResponse(data=data)
assert res.is_success
assert res.output == command_response


def test_targets():
data = requests.get('http://localhost:5555/api/targets').text
data = requests.get('http://localhost:22222/api/targets').text
res = api_response('targets', data=data)
assert res.is_success
assert res.targets == targets_response


def test_memory():
data = requests.get('http://localhost:5555/api/registers').text
data = requests.get('http://localhost:22222/api/registers').text
res = api_response('registers', data=data)
url = 'http://localhost:5555/api/memory?address={}&length=64'.format(res.registers['rip'])
url = 'http://localhost:22222/api/memory?address={}&length=64'.format(res.registers['rip'])
data = requests.get(url).text
res = api_response('memory', data=data)
assert res.is_success
assert res.memory == memory_response


def test_registers():
data = requests.get('http://localhost:5555/api/registers').text
data = requests.get('http://localhost:22222/api/registers').text
res = api_response('registers', data=data)
assert res.is_success
assert res.registers == registers_response


def test_stack_length_missing():
data = requests.get('http://localhost:5555/api/stack').text
data = requests.get('http://localhost:22222/api/stack').text
res = APIErrorResponse(data=data)
assert res.is_error
assert res.message == 'length'


def test_stack():
data = requests.get('http://localhost:5555/api/stack?length=64').text
data = requests.get('http://localhost:22222/api/stack?length=64').text
res = api_response('stack', data=data)
assert res.is_success
assert res.memory == stack_response


def test_state():
data = requests.get('http://localhost:5555/api/state').text
data = requests.get('http://localhost:22222/api/state').text
res = api_response('state', data=data)
assert res.is_success
assert res.state == state_response


def test_version():
data = requests.get('http://localhost:5555/api/version').text
data = requests.get('http://localhost:22222/api/version').text
res = api_response('version', data=data)
assert res.is_success
assert res.api_version == 1.1
assert res.host_version == 'lldb-something'


def test_bad_json():
data = requests.post('http://localhost:5555/api/request', data='xxx').text
data = requests.post('http://localhost:22222/api/request', data='xxx').text
res = APIResponse(data=data)
assert res.is_error
assert res.code == 0x1001


def test_bad_request():
data = requests.post('http://localhost:5555/api/request', data='{"type":"request","request":"no_such_request"}').text
data = requests.post('http://localhost:22222/api/request', data='{"type":"request","request":"no_such_request"}').text
res = APIResponse(data=data)
assert res.is_error
assert res.code == 0x1002


def test_breakpoints():
data = requests.get('http://localhost:5555/api/breakpoints').text
data = requests.get('http://localhost:22222/api/breakpoints').text
res = api_response('breakpoints', data=data)
assert res.is_success
assert res.breakpoints == breakpoints_response
4 changes: 2 additions & 2 deletions voltron/config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ server:
domain: "~/.voltron/sock"
tcp:
- 127.0.0.1
- 5555
- 22222
view:
#api_url: "http+unix://~%2f.voltron%2fsock/api/request",
api_url: http://localhost:5555/api/request
api_url: http://localhost:22222/api/request
reconnect: true
all_views:
clear: true
Expand Down
2 changes: 1 addition & 1 deletion voltron/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class Client(object):
"""
Used by a client (ie. a view) to communicate with the server.
"""
def __init__(self, host='127.0.0.1', port=5555, sockfile=None, url=None,
def __init__(self, host='127.0.0.1', port=22222, sockfile=None, url=None,
build_requests=None, callback=None, supports_blocking=True):
"""
Initialise a new client
Expand Down
43 changes: 26 additions & 17 deletions voltron/dbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def validate_target(func, *args, **kwargs):

Raises a NoSuchTargetException if the target does not exist.
"""

def inner(self, *args, **kwargs):
# find the target param
target_id = None
Expand All @@ -38,6 +39,7 @@ def inner(self, *args, **kwargs):

# call the function
return func(self, *args, **kwargs)

return inner


Expand All @@ -50,6 +52,7 @@ def validate_busy(func, *args, **kwargs):

Raises a TargetBusyException if the target does not exist.
"""

def inner(self, *args, **kwargs):
# find the target param
target_id = None
Expand All @@ -64,6 +67,7 @@ def inner(self, *args, **kwargs):

# call the function
return func(self, *args, **kwargs)

return inner


Expand All @@ -72,6 +76,7 @@ def lock_host(func, *args, **kwargs):
A decorator that acquires a lock before accessing the debugger to
avoid API locking related errors with the debugger host.
"""

def inner(self, *args, **kwargs):
self.host_lock.acquire()
try:
Expand All @@ -81,6 +86,7 @@ def inner(self, *args, **kwargs):
self.host_lock.release()
raise e
return res

return inner


Expand All @@ -91,26 +97,28 @@ class DebuggerAdaptor(object):
"""

reg_names = {
"x86": {"pc": "eip", "sp": "esp"},
"x86_64": {"pc": "rip", "sp": "rsp"},
"arm": {"pc": "pc", "sp": "sp"},
"armv6": {"pc": "pc", "sp": "sp"},
"armv7": {"pc": "pc", "sp": "sp"},
"armv7s": {"pc": "pc", "sp": "sp"},
"arm64": {"pc": "pc", "sp": "sp"},
"powerpc": {"pc": "pc", "sp": "r1"},
"x86": {"pc": "eip", "sp": "esp"},
"x86_64": {"pc": "rip", "sp": "rsp"},
"arm": {"pc": "pc", "sp": "sp"},
"armv6": {"pc": "pc", "sp": "sp"},
"armv7": {"pc": "pc", "sp": "sp"},
"armv7s": {"pc": "pc", "sp": "sp"},
"arm64": {"pc": "pc", "sp": "sp"},
"aarch64": {"pc": "pc", "sp": "sp"},
"powerpc": {"pc": "pc", "sp": "r1"},
}
cs_archs = {}
if capstone:
cs_archs = {
"x86": (capstone.CS_ARCH_X86, capstone.CS_MODE_32),
"x86_64": (capstone.CS_ARCH_X86, capstone.CS_MODE_64),
"arm": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv6": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv7": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv7s": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"arm64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM),
"powerpc": (capstone.CS_ARCH_PPC, capstone.CS_MODE_32),
"x86": (capstone.CS_ARCH_X86, capstone.CS_MODE_32),
"x86_64": (capstone.CS_ARCH_X86, capstone.CS_MODE_64),
"arm": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv6": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv7": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"armv7s": (capstone.CS_ARCH_ARM, capstone.CS_MODE_ARM),
"arm64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM),
"aarch64": (capstone.CS_ARCH_ARM64, capstone.CS_MODE_ARM),
"powerpc": (capstone.CS_ARCH_PPC, capstone.CS_MODE_32),
}

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -220,10 +228,11 @@ def disassemble_capstone(self, target_id=0, address=None, count=None):
return '\n'.join(output)


class DebuggerCommand (object):
class DebuggerCommand(object):
"""
The `voltron` command in the debugger.
"""

def __init__(self, *args, **kwargs):
super(DebuggerCommand, self).__init__(*args, **kwargs)
self.adaptor = voltron.debugger
Expand Down
11 changes: 6 additions & 5 deletions voltron/plugins/view/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class RegisterView (TerminalView):
}
],
}
FORMAT_INFO['aarch64'] = FORMAT_INFO['arm64']
TEMPLATES = {
'x86_64': {
'horizontal': {
Expand Down Expand Up @@ -389,6 +390,7 @@ class RegisterView (TerminalView):
}
}
}
TEMPLATES['aarch64'] = TEMPLATES['arm64']
FLAG_BITS = {'c': 0, 'p': 2, 'a': 4, 'z': 6, 's': 7, 't': 8, 'i': 9, 'd': 10, 'o': 11}
FLAG_TEMPLATE = "{o} {d} {i} {t} {s} {z} {a} {p} {c}"
XMM_INDENT = 7
Expand Down Expand Up @@ -442,18 +444,17 @@ def build_requests(self):
]

def render(self, results):
error = None
t_res, d_res, r_res = results
formatter = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter,
style=self.config.format.pygments_style)

def format(tok, tik=None):
if tik:
tok = (tok, tik)
if isinstance(tok, tuple):
return pygments.format([tok], formatter)
else:
return pygments.format(tok, formatter)
error = None
t_res, d_res, r_res = results
formatter = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter,
style=self.config.format.pygments_style)
self.f = format

if t_res and t_res.is_error:
Expand Down