Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- linux-user/main.c | 21 +++++++++++++++++++++ linux-user/syscall.c | 4 ++++ 2 files changed, 25 insertions(+)
diff --git a/linux-user/main.c b/linux-user/main.c index 03666ef657..ac5c30c1fb 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -36,6 +36,7 @@ #include "exec/log.h" #include "trace/control.h" #include "glib-compat.h" +#include "instrument/cmdline.h" char *exec_path; @@ -4017,6 +4018,17 @@ static void handle_arg_trace(const char *arg) trace_file = trace_opt_parse(arg); } +static char *instrument_path; +static int instrument_argc; +static const char **instrument_argv; +#if defined(CONFIG_INSTRUMENT) +static void handle_arg_instrument(const char *arg) +{ + instr_opt_parse(arg, &instrument_path, + &instrument_argc, &instrument_argv); +} +#endif + struct qemu_argument { const char *argv; const char *env; @@ -4066,6 +4078,10 @@ static const struct qemu_argument arg_table[] = { "", "Seed for pseudo-random number generator"}, {"trace", "QEMU_TRACE", true, handle_arg_trace, "", "[[enable=]<pattern>][,events=<file>][,file=<file>]"}, +#if defined(CONFIG_INSTRUMENT) + {"instr", "QEMU_INSTR", true, handle_arg_instrument, + "", "[file=]<file>[,arg=<string>]"}, +#endif {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, {NULL, NULL, false, NULL, NULL, NULL} @@ -4257,6 +4273,9 @@ int main(int argc, char **argv, char **envp) srand(time(NULL)); qemu_add_opts(&qemu_trace_opts); +#if defined(CONFIG_INSTRUMENT) + qemu_add_opts(&qemu_instr_opts); +#endif optind = parse_args(argc, argv); @@ -4265,6 +4284,8 @@ int main(int argc, char **argv, char **envp) } trace_init_file(trace_file); + instr_init(instrument_path, instrument_argc, instrument_argv); + /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..e73a07fa6f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -115,6 +115,8 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include "uname.h" #include "qemu.h" +#include "instrument/cmdline.h" + #ifndef CLONE_IO #define CLONE_IO 0x80000000 /* Clone io context */ @@ -7765,6 +7767,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + instr_fini(); _exit(arg1); ret = 0; /* avoid warning */ break; @@ -9821,6 +9824,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + instr_fini(); ret = get_errno(exit_group(arg1)); break; #endif