forked from Imagelibrary/littlefs
scripts: Strip compiler suffixes in result scripts
This can be explicitly disabled with -x/--no-strip in the relevant scripts, but stripping by default seems to be more useful for composing results in higher-level scripts. It's better for the result names to be consistent, even if they don't match the .o symbols exactly. Note some scripts are unaffected: - cov.py - gcov doesn't seem to have an option for getting the unstripped symbols, so we only output the stripped names. - structs.py - structs.py deals with struct names, which are notably not symbols.
This commit is contained in:
@@ -453,6 +453,7 @@ def collect_dwarf_info(obj_path, tags=None, *,
|
|||||||
|
|
||||||
def collect_code(obj_paths, *,
|
def collect_code(obj_paths, *,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
**args):
|
**args):
|
||||||
results = []
|
results = []
|
||||||
for obj_path in obj_paths:
|
for obj_path in obj_paths:
|
||||||
@@ -493,7 +494,12 @@ def collect_code(obj_paths, *,
|
|||||||
if not everything and sym.name.startswith('__'):
|
if not everything and sym.name.startswith('__'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results.append(CodeResult(file, sym.name, sym.size))
|
# strip compiler suffixes
|
||||||
|
name = sym.name
|
||||||
|
if not no_strip:
|
||||||
|
name = name.split('.', 1)[0]
|
||||||
|
|
||||||
|
results.append(CodeResult(file, name, sym.size))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -1188,6 +1194,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--objdump-path',
|
'--objdump-path',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
|||||||
@@ -458,6 +458,7 @@ def collect_dwarf_info(obj_path, tags=None, *,
|
|||||||
|
|
||||||
def collect_ctx(obj_paths, *,
|
def collect_ctx(obj_paths, *,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
depth=1,
|
depth=1,
|
||||||
**args):
|
**args):
|
||||||
results = []
|
results = []
|
||||||
@@ -693,9 +694,14 @@ def collect_ctx(obj_paths, *,
|
|||||||
children=children_,
|
children=children_,
|
||||||
notes=notes_))
|
notes=notes_))
|
||||||
|
|
||||||
|
# strip compiler suffixes
|
||||||
|
name = sym.name
|
||||||
|
if not no_strip:
|
||||||
|
name = name.split('.', 1)[0]
|
||||||
|
|
||||||
# context = sum of params
|
# context = sum of params
|
||||||
name = entry.name
|
|
||||||
size = sum((param.size for param in params), start=RInt(0))
|
size = sum((param.size for param in params), start=RInt(0))
|
||||||
|
|
||||||
results.append(CtxResult(
|
results.append(CtxResult(
|
||||||
0, 0, file, name, 0, size,
|
0, 0, file, name, 0, size,
|
||||||
children=params))
|
children=params))
|
||||||
@@ -1507,6 +1513,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--objdump-path',
|
'--objdump-path',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
|||||||
@@ -453,6 +453,7 @@ def collect_dwarf_info(obj_path, tags=None, *,
|
|||||||
|
|
||||||
def collect_data(obj_paths, *,
|
def collect_data(obj_paths, *,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
**args):
|
**args):
|
||||||
results = []
|
results = []
|
||||||
for obj_path in obj_paths:
|
for obj_path in obj_paths:
|
||||||
@@ -493,7 +494,12 @@ def collect_data(obj_paths, *,
|
|||||||
if not everything and sym.name.startswith('__'):
|
if not everything and sym.name.startswith('__'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results.append(DataResult(file, sym.name, sym.size))
|
# strip compiler suffixes
|
||||||
|
name = sym.name
|
||||||
|
if not no_strip:
|
||||||
|
name = name.split('.', 1)[0]
|
||||||
|
|
||||||
|
results.append(DataResult(file, name, sym.size))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -1188,6 +1194,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--objdump-path',
|
'--objdump-path',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ def collect_decompressed(path, *,
|
|||||||
perf_path=PERF_PATH,
|
perf_path=PERF_PATH,
|
||||||
sources=None,
|
sources=None,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
propagate=0,
|
propagate=0,
|
||||||
depth=1,
|
depth=1,
|
||||||
**args):
|
**args):
|
||||||
@@ -742,6 +743,10 @@ def collect_decompressed(path, *,
|
|||||||
else:
|
else:
|
||||||
file, line = re.sub('(\.o)?$', '.c', dso, 1), 0
|
file, line = re.sub('(\.o)?$', '.c', dso, 1), 0
|
||||||
|
|
||||||
|
# strip compiler suffixes
|
||||||
|
if not no_strip:
|
||||||
|
sym = sym.split('.', 1)[0]
|
||||||
|
|
||||||
last_stack.append((file, sym, line))
|
last_stack.append((file, sym, line))
|
||||||
|
|
||||||
# stop propogating?
|
# stop propogating?
|
||||||
@@ -1766,6 +1771,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--branches',
|
'--branches',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|||||||
@@ -485,6 +485,7 @@ def collect_dwarf_lines(obj_path, *,
|
|||||||
def collect_job(path, start, stop, syms, lines, *,
|
def collect_job(path, start, stop, syms, lines, *,
|
||||||
sources=None,
|
sources=None,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
propagate=0,
|
propagate=0,
|
||||||
depth=1,
|
depth=1,
|
||||||
**args):
|
**args):
|
||||||
@@ -551,6 +552,10 @@ def collect_job(path, start, stop, syms, lines, *,
|
|||||||
else:
|
else:
|
||||||
file = os.path.abspath(file)
|
file = os.path.abspath(file)
|
||||||
|
|
||||||
|
# strip compiler suffixes
|
||||||
|
if not no_strip:
|
||||||
|
sym = sym.split('.', 1)[0]
|
||||||
|
|
||||||
results[(file, sym, line)] = (
|
results[(file, sym, line)] = (
|
||||||
last_readed,
|
last_readed,
|
||||||
last_proged,
|
last_proged,
|
||||||
@@ -705,6 +710,10 @@ def collect_job(path, start, stop, syms, lines, *,
|
|||||||
|
|
||||||
at_cache[addr] = file, sym, line
|
at_cache[addr] = file, sym, line
|
||||||
|
|
||||||
|
# strip compiler suffixes
|
||||||
|
if not no_strip:
|
||||||
|
sym = sym.split('.', 1)[0]
|
||||||
|
|
||||||
last_stack.append((file, sym, line))
|
last_stack.append((file, sym, line))
|
||||||
|
|
||||||
# stop propagating?
|
# stop propagating?
|
||||||
@@ -1763,6 +1772,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-A', '--annotate',
|
'-A', '--annotate',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ def collect_callgraph(ci_path,
|
|||||||
|
|
||||||
def collect_stack(ci_paths, *,
|
def collect_stack(ci_paths, *,
|
||||||
everything=False,
|
everything=False,
|
||||||
|
no_strip=False,
|
||||||
depth=1,
|
depth=1,
|
||||||
**args):
|
**args):
|
||||||
# parse the callgraphs
|
# parse the callgraphs
|
||||||
@@ -351,6 +352,10 @@ def collect_stack(ci_paths, *,
|
|||||||
else:
|
else:
|
||||||
file = os.path.abspath(file)
|
file = os.path.abspath(file)
|
||||||
|
|
||||||
|
# strip compiler suffixes
|
||||||
|
if not no_strip:
|
||||||
|
name = name.split('.', 1)[0]
|
||||||
|
|
||||||
nameof.cache[node.name] = name, file
|
nameof.cache[node.name] = name, file
|
||||||
return name, file
|
return name, file
|
||||||
|
|
||||||
@@ -1254,6 +1259,10 @@ if __name__ == "__main__":
|
|||||||
'--everything',
|
'--everything',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Include builtin and libc specific symbols.")
|
help="Include builtin and libc specific symbols.")
|
||||||
|
parser.add_argument(
|
||||||
|
'-x', '--no-strip',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't strip compiler optimization suffixes from symbols.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-e', '--error-on-recursion',
|
'-e', '--error-on-recursion',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|||||||
Reference in New Issue
Block a user