summaryrefslogtreecommitdiff
path: root/diff.py
diff options
context:
space:
mode:
authorJonathan Wase <jonathan@familjenwase.se>2021-01-07 02:45:55 +0100
committerGitHub <noreply@github.com>2021-01-06 20:45:55 -0500
commit85f6906ba0ac002af41aa653466c52047c13f6d8 (patch)
treedf9f88fae2641b4b9cf39fcd346b29cdbe2622f5 /diff.py
parent6f2c187418477d5f10d766f23857afdc3f2f2e54 (diff)
diff.py --select-occurrence (#74)
* --select-occurrence * print address of function Co-authored-by: Julgodis <> Co-authored-by: Pheenoh <pheenoh@gmail.com>
Diffstat (limited to 'diff.py')
-rw-r--r--diff.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/diff.py b/diff.py
index ca44578a4e..4fccef9581 100644
--- a/diff.py
+++ b/diff.py
@@ -244,6 +244,13 @@ parser.add_argument(
metavar="SYMBOL",
help="override symbol name on lhs when using -o"
)
+parser.add_argument(
+ "--select-occurence",
+ dest="select_occurence",
+ type=int,
+ default=0,
+ help="If multiple occurence of the same symbol is found, use this to select the correct ocurrance."
+)
# Project-specific flags, e.g. different versions/make arguments.
add_custom_arguments_fn = getattr(diff_settings, "add_custom_arguments", None)
@@ -498,8 +505,15 @@ def search_map_file(fn_name: str, mapfile: Optional[str] = None, build_dir: Opti
# ram elf rom object name
find = re.findall(re.compile(r' \S+ \S+ (\S+) (\S+) . ' + fn_name + r'(?: \(entry of \.(?:init|text)\))? \t(\S+)'), contents)
if len(find) > 1:
- fail(f"Found multiple occurrences of function {fn_name} in map file.")
+ if args.select_occurence > 0:
+ find = [find[args.select_occurence - 1]]
+ else:
+ print(f"Found multiple occurrences of function {fn_name} in map file:", file=sys.stderr)
+ for i,location in enumerate(find):
+ print(f" {i+1}: {location[0]} {location[1]} {str(location[2]).ljust(40, ' ')}", file=sys.stderr)
+ fail(f"Use --select-occurence to select the right occurrence.")
if len(find) == 1:
+ print(find)
rom = int(find[0][1],16)
objname = find[0][2]
# The metrowerks linker map format does not contain the full object path, so we must complete it manually.