scripts: Added -i/--internal to ctx.py/structs.py, re-limiting structs.py
This adds -i/--internal to ctx.py and structs.py, which has proven useful for introspection/debugging. Being able to view the ctx/args of internal functions is nice, even if they don't actually contribute to the high-level cost. This also reverts structs.py to limit to .h files by default, to match ctx.py, once again relying on dwarf file info. This has been a bit unreliable in the past, but there's not much else that determines if a struct is part of the "public interface" in C. But that's what ctx.py is for. --- Also fixed an issue where structs appearing in multiple files would have their sizes added together, which ends up with some pretty confusing results (sizeof(uint32_t) => 8?).
This commit is contained in:
+8
-1
@@ -457,6 +457,7 @@ def collect_dwarf_info(obj_path, tags=None, *,
|
||||
return DwarfInfo(info)
|
||||
|
||||
def collect_ctx(obj_paths, *,
|
||||
internal=False,
|
||||
everything=False,
|
||||
no_strip=False,
|
||||
depth=1,
|
||||
@@ -466,7 +467,8 @@ def collect_ctx(obj_paths, *,
|
||||
# find global symbols
|
||||
syms = collect_syms(obj_path,
|
||||
sections=['.text'],
|
||||
global_=not everything,
|
||||
# only include internal symbols if explicitly requested
|
||||
global_=not internal and not everything,
|
||||
**args)
|
||||
|
||||
# find dwarf info
|
||||
@@ -1509,6 +1511,11 @@ if __name__ == "__main__":
|
||||
'--prefix',
|
||||
help="Prefix to use for fields in CSV/JSON output. Defaults "
|
||||
"to %r." % ("%s_" % CtxResult._prefix))
|
||||
parser.add_argument(
|
||||
'-i', '--internal',
|
||||
action='store_true',
|
||||
help="Include internal symbols. Useful for introspection, but "
|
||||
"usually you don't care about these.")
|
||||
parser.add_argument(
|
||||
'--everything',
|
||||
action='store_true',
|
||||
|
||||
Reference in New Issue
Block a user