Skip to content

Commit 3202c04

Browse files
committed
move enhance_call_tree_pattern to gcc_tools, and teach gcc_tools how to pick up call trees for RISC-V
1 parent 9e5f178 commit 3202c04

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

puncover/collector.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,11 @@ def add_function_call(self, caller, callee):
386386
if callee_file and caller_file and callee_file != caller_file:
387387
callee["called_from_other_file"] = True
388388

389-
# 934: f7ff bba8 b.w 88 <jump_to_pbl_function>
390-
# 8e4: f000 f824 bl 930 <app_log>
391-
#
392-
# but not:
393-
# 805bbac: 2471 0805 b64b 0804 b3c9 0804 b459 0804 q$..K.......Y...
394-
enhance_call_tree_pattern = re.compile(r"^\s*[\da-f]+:\s+[\d\sa-f]{9}\s+BL?(EQ|NE|CS|HS|CC|LO|MI|PL|VS|VC|HI|LS|GE|LT|GT|LE|AL)?(\.W|\.N)?\s+([\d\sa-f]+)", re.IGNORECASE)
395-
396389
def enhance_call_tree_from_assembly_line(self, function, line):
397390
if "<" not in line:
398391
return False
399392

400-
match = self.enhance_call_tree_pattern.match(line)
393+
match = self.gcc_tools.enhance_call_tree_pattern.match(line)
401394

402395
if match:
403396
callee = self.symbol_by_addr(match.group(3))

puncover/gcc_tools.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import subprocess
3+
import re
34

45
import itertools
56

@@ -12,6 +13,16 @@ def __init__(self, gcc_base_filename):
1213

1314
self.gcc_base_filename = gcc_base_filename
1415

16+
if 'riscv' in gcc_base_filename:
17+
self.enhance_call_tree_pattern = re.compile(r"^\s*[\da-f]+:\s+[\d\sa-f]{9}\s+(J|JAL|JR|JALR|BEQZ|BNEZ|BEQ|BNE|NLT|BGE|BLTU|BGEU)()\s+([\d\sa-f]+)", re.IGNORECASE)
18+
else: # ARM
19+
# 934: f7ff bba8 b.w 88 <jump_to_pbl_function>
20+
# 8e4: f000 f824 bl 930 <app_log>
21+
#
22+
# but not:
23+
# 805bbac: 2471 0805 b64b 0804 b3c9 0804 b459 0804 q$..K.......Y...
24+
self.enhance_call_tree_pattern = re.compile(r"^\s*[\da-f]+:\s+[\d\sa-f]{9}\s+BL?(EQ|NE|CS|HS|CC|LO|MI|PL|VS|VC|HI|LS|GE|LT|GT|LE|AL)?(\.W|\.N)?\s+([\d\sa-f]+)", re.IGNORECASE)
25+
1526
def gcc_tool_path(self, name):
1627
path = self.gcc_base_filename + name
1728
if os.name == 'nt':

0 commit comments

Comments
 (0)