scripts: Adopted better input file handling in result scripts

- Error on no/insufficient files.

  Instead of just returning no results. This is more useful when
  debugging complicated bash scripts.

- Use elf magic to allow any file order in perfbd.py/stack.py.

  This was already implemented in stack.py, now also adopted in
  perfbd.py.

  Elf files always start with the magic string "\x7fELF", so we can use
  this to figure out the types of input files without needing to rely on
  argument order.

  This is just one less thing to worry about when invoking these
  scripts.
This commit is contained in:
Christopher Haster
2024-12-10 14:45:46 -06:00
parent 4325a06277
commit 3e03c2ee7f
9 changed files with 117 additions and 11 deletions

View File

@@ -1015,7 +1015,15 @@ def main(obj_paths, *,
**args):
# find sizes
if not args.get('use', None):
# not enough info?
if not obj_paths:
print("error: no *.o files?",
file=sys.stderr)
sys.exit(1)
# collect info
results = collect(obj_paths, **args)
else:
results = []
with openio(args['use']) as f: