tools: fix parsetrace.py output
- 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 <alejandro.aguirre@midokura.com>
This commit is contained in:
parent
e75ac114c1
commit
d762427ec9
1 changed files with 8 additions and 9 deletions
|
@ -258,13 +258,11 @@ class Trace(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def dump_trace(self, output="trace.systrace"):
|
def dump_trace(self):
|
||||||
formatted = ["# tracer: nop", "#"]
|
formatted = ["# tracer: nop", "#"]
|
||||||
for trace in self.all_trace:
|
for trace in self.all_trace:
|
||||||
formatted.append(trace.dump_one_trace())
|
formatted.append(trace.dump_one_trace())
|
||||||
with open(output, "w") as fp:
|
return formatted
|
||||||
fp.writelines("\n".join(formatted))
|
|
||||||
return output
|
|
||||||
|
|
||||||
|
|
||||||
class ParseBinaryLogTool:
|
class ParseBinaryLogTool:
|
||||||
|
@ -637,7 +635,7 @@ def parse_arguments():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = parse_arguments()
|
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)
|
logger.setLevel(logging.DEBUG if args.verbose else logging.INFO)
|
||||||
|
|
||||||
if args.trace is None and args.device is None:
|
if args.trace is None and args.device is None:
|
||||||
|
@ -666,9 +664,10 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
|
|
||||||
lines = trace.dump_trace()
|
lines = trace.dump_trace()
|
||||||
with open(args.out, "w") as out:
|
with open(out_path, "w") as out:
|
||||||
out.writelines("\n".join(lines))
|
out.write("\n".join(lines))
|
||||||
print(os.path.abspath(args.out))
|
out.write("\n")
|
||||||
|
print(os.path.abspath(out_path))
|
||||||
else:
|
else:
|
||||||
print("trace log type is binary")
|
print("trace log type is binary")
|
||||||
if args.elf:
|
if args.elf:
|
||||||
|
@ -676,7 +675,7 @@ if __name__ == "__main__":
|
||||||
"parse_binary_log, default config, size_long=4, config_endian_big=False, config_smp=0"
|
"parse_binary_log, default config, size_long=4, config_endian_big=False, config_smp=0"
|
||||||
)
|
)
|
||||||
parse_binary_log_tool = ParseBinaryLogTool(
|
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.symbol_tables.parse_symbol()
|
||||||
parse_binary_log_tool.parse_binary_log()
|
parse_binary_log_tool.parse_binary_log()
|
||||||
|
|
Loading…
Reference in a new issue