Skip to content

Commit

Permalink
tools: fix parsetrace.py output
Browse files Browse the repository at this point in the history
- Fix usage of non-existing variable `args.out`.
- Fix dump trace not writing to the output file.
- Fix path provided through `-o` getting ignored.

Signed-off-by: Alejandro Aguirre <[email protected]>
  • Loading branch information
alexguirre authored and xiaoxiang781216 committed Oct 18, 2024
1 parent e75ac11 commit d762427
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tools/parsetrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,11 @@ def parse(self):
except Exception:
continue

def dump_trace(self, output="trace.systrace"):
def dump_trace(self):
formatted = ["# tracer: nop", "#"]
for trace in self.all_trace:
formatted.append(trace.dump_one_trace())
with open(output, "w") as fp:
fp.writelines("\n".join(formatted))
return output
return formatted


class ParseBinaryLogTool:
Expand Down Expand Up @@ -637,7 +635,7 @@ def parse_arguments():

if __name__ == "__main__":
args = parse_arguments()
out = args.output if not args.output else "trace.systrace"
out_path = args.output if args.output else "trace.systrace"
logger.setLevel(logging.DEBUG if args.verbose else logging.INFO)

if args.trace is None and args.device is None:
Expand Down Expand Up @@ -666,17 +664,18 @@ def parse_arguments():
)

lines = trace.dump_trace()
with open(args.out, "w") as out:
out.writelines("\n".join(lines))
print(os.path.abspath(args.out))
with open(out_path, "w") as out:
out.write("\n".join(lines))
out.write("\n")
print(os.path.abspath(out_path))
else:
print("trace log type is binary")
if args.elf:
print(
"parse_binary_log, default config, size_long=4, config_endian_big=False, config_smp=0"
)
parse_binary_log_tool = ParseBinaryLogTool(
args.trace, args.elf, args.out
args.trace, args.elf, out_path
)
parse_binary_log_tool.symbol_tables.parse_symbol()
parse_binary_log_tool.parse_binary_log()
Expand Down

0 comments on commit d762427

Please sign in to comment.