From 54d595170437c2f367bf659c15362aedfcebf44b Mon Sep 17 00:00:00 2001 From: Antonio Castelli Date: Sun, 6 Jun 2021 17:46:18 -0700 Subject: [PATCH] Updated get_symbol.py to use dkr.map --- tools/python/get_symbol.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/python/get_symbol.py b/tools/python/get_symbol.py index eebab15b..78c99edd 100644 --- a/tools/python/get_symbol.py +++ b/tools/python/get_symbol.py @@ -3,27 +3,32 @@ import re from file_util import FileUtil -SYMBOLS_TEXT_FILENAME = 'undefined_syms.txt' +SYMBOLS_TEXT_FILENAME = 'build/us_1.0/dkr.map' -symbol_define_regex = r'([_0-9A-Za-z]*)\s*=\s*([_0-9A-Za-z]*)\s*;' +symbol_define_regex = r'\s*(0x[0-9a-f]{16})\s*([_0-9A-Za-z]*)' def main(): + FileUtil.set_working_dir_to_project_base() if len(sys.argv) != 2: show_help() return print_symbol(int(sys.argv[1], 16)) def print_symbol(ramAddress): - lines = FileUtil.get_text_from_file(SYMBOLS_TEXT_FILENAME).split('\n') + try: + lines = FileUtil.get_text_from_file(SYMBOLS_TEXT_FILENAME).split('\n') + except: + print('Couldn\'t open file ' + SYMBOLS_TEXT_FILENAME) + return foundSymbol = False for line in lines: matches = re.match(symbol_define_regex, line) if matches is None: continue - address = int(matches[2], 16) + address = int(matches[1], 16) if address == ramAddress: - symbol = matches[1] - print(matches[2] + ' = ' + matches[1]) + symbol = matches[2] + print('0x%08X = %s' % (address, symbol)) foundSymbol = True break if not foundSymbol: