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

Add support for 64-bit addresses #51

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
4 changes: 2 additions & 2 deletions puncover/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def add_symbol(self, name, address, size=None, file=None, line=None, assembly_li
return sym

# 00000550 00000034 T main /Users/behrens/Documents/projects/pebble/puncover/puncover/build/../src/puncover.c:25
parse_size_line_re = re.compile(r"^([\da-f]{8})\s+([\da-f]{8})\s+(.)\s+(\w+)(\s+([^:]+):(\d+))?")
parse_size_line_re = re.compile(r"^([\da-f]{8,16})\s+([\da-f]{8,16})\s+(.)\s+(\w+)(\s+([^:]+):(\d+))?")

def parse_size_line(self, line):
# print(line)
Expand All @@ -145,7 +145,7 @@ def parse_size_line(self, line):

# 00000098 <pbl_table_addr>:
# 00000098 <pbl_table_addr.constprop.0>:
parse_assembly_text_function_start_pattern = re.compile(r"^([\da-f]{8})\s+<(\.?\w+)(\..*)?>:")
parse_assembly_text_function_start_pattern = re.compile(r"^([\da-f]{8,16})\s+<(\.?\w+)(\..*)?>:")

# /Users/behrens/Documents/projects/pebble/puncover/pebble/build/../src/puncover.c:8
parse_assembly_text_c_reference_pattern = re.compile(r"^(/[^:]+)(:(\d+))?")
Expand Down
23 changes: 23 additions & 0 deletions tests/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def test_parses_function_line(self):
self.assertTrue(c.parse_size_line(line))
self.assertDictEqual(c.symbols, {0x00000550: {'name': 'main', 'base_file': 'puncover.c', 'path': '/Users/behrens/Documents/projects/pebble/puncover/puncover/build/../src/puncover.c', 'address': '00000550', 'line': 25, 'size': 52, 'type': 'function'}})

def test_parses_64bit_function_line(self):
c = Collector(None)
line = "1000000000000550 1000000000000034 T main /Users/behrens/Documents/projects/pebble/puncover/puncover/build/../src/puncover.c:25"
self.assertTrue(c.parse_size_line(line))
self.assertDictEqual(c.symbols, {0x1000000000000550: {'name': 'main', 'base_file': 'puncover.c', 'path': '/Users/behrens/Documents/projects/pebble/puncover/puncover/build/../src/puncover.c', 'address': '1000000000000550', 'line': 25, 'size': 1152921504606847028, 'type': 'function'}})

def test_parses_variable_line_from_initialized_data_section(self):
c = Collector(None)
line = "00000968 000000c8 D foo /Users/behrens/Documents/projects/pebble/puncover/pebble/build/puncover.c:15"
Expand Down Expand Up @@ -76,6 +82,23 @@ def test_parses_assembly2(self):
self.assertTrue(0x00000098 in c.symbols)
self.assertEqual(c.symbols[0x00000098]["name"], "pbl_table_addr")

def test_parses_64bit_assembly(self):
assembly = """
1000000000000098 <pbl_table_addr>:
pbl_table_addr():
98: a8a8a8a8 .word 0xa8a8a8a8

100000000000009c <__aeabi_dmul>:
__aeabi_dmul():
9c: b570 push {r4, r5, r6, lr}
"""
c = Collector(None)
self.assertEqual(2, c.parse_assembly_text(assembly))
self.assertTrue(0x100000000000009c in c.symbols)
self.assertEqual(c.symbols[0x100000000000009c]["name"], "__aeabi_dmul")
self.assertTrue(0x1000000000000098 in c.symbols)
self.assertEqual(c.symbols[0x1000000000000098]["name"], "pbl_table_addr")

def test_parses_assembly_and_ignores_c(self):
assembly = """
00000098 <pbl_table_addr>:
Expand Down