Add an rbpf-cli option to dump the program execution trace (#29289)
This commit is contained in:
parent
ff8bb5362c
commit
acb7eb226b
|
@ -157,6 +157,14 @@ before execting it in the virtual machine.",
|
|||
.takes_value(true)
|
||||
.possible_values(["json", "json-compact"]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("trace")
|
||||
.help("Output instruction trace")
|
||||
.short('t')
|
||||
.long("trace")
|
||||
.takes_value(true)
|
||||
.value_name("FILE"),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let loader_id = bpf_loader::id();
|
||||
|
@ -297,6 +305,23 @@ before execting it in the virtual machine.",
|
|||
}
|
||||
let (instruction_count, result) = vm.execute_program(matches.value_of("use").unwrap() != "jit");
|
||||
let duration = Instant::now() - start_time;
|
||||
if matches.occurrences_of("trace") > 0 {
|
||||
let trace_log = vm.env.context_object_pointer.trace_log.as_slice();
|
||||
if matches.value_of("trace").unwrap() == "stdout" {
|
||||
analysis
|
||||
.analyze()
|
||||
.disassemble_trace_log(&mut std::io::stdout(), trace_log)
|
||||
.unwrap();
|
||||
} else {
|
||||
analysis
|
||||
.analyze()
|
||||
.disassemble_trace_log(
|
||||
&mut File::create(matches.value_of("trace").unwrap()).unwrap(),
|
||||
trace_log,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
drop(vm);
|
||||
|
||||
let output = Output {
|
||||
|
|
Loading…
Reference in New Issue