Received: from eggs.gnu.org ([2001:4830:134:3::10]:57372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPGaW-00060w-6z for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPGaQ-0005g8-Ln for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPGaQ-0005fv-EM for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:26 -0400 From: Stefan Hajnoczi Date: Mon, 18 Jul 2016 23:00:12 +0100 Message-Id: <1468879219-24500-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1468879219-24500-1-git-send-email-stefanha@redhat.com> References: <1468879219-24500-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 2/9] trace: [bsd-user] Commandline arguments to control tracing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi From: Llu=C3=ADs Vilanova [Changed const char *trace_file to char *trace_file since it's a heap-allocated string that needs to be freed. This type is also returned by trace_opt_parse() and used in vl.c. Also fixed coding style on for(;;) and else statement as suggested by Eric Blake since the patch modifies these lines or close enough. --Stefan] Signed-off-by: Llu=C3=ADs Vilanova Message-id: 146860252322.30668.18276041739086338328.stgit@fimbulvetr.bsc.= es Signed-off-by: Stefan Hajnoczi --- bsd-user/main.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 4819b9e..6d6e3e3 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -21,6 +21,7 @@ =20 #include "qapi/error.h" #include "qemu.h" +#include "qemu/config-file.h" #include "qemu/path.h" #include "qemu/help_option.h" /* For tb_lock */ @@ -30,6 +31,8 @@ #include "qemu/timer.h" #include "qemu/envlist.h" #include "exec/log.h" +#include "trace/control.h" +#include "glib-compat.h" =20 int singlestep; unsigned long mmap_min_addr; @@ -687,6 +690,8 @@ static void usage(void) "-p pagesize set the host page size to 'pagesize'\n" "-singlestep always run in singlestep mode\n" "-strace log system calls\n" + "-trace [[enable=3D]][,events=3D][,= file=3D]\n" + " specify tracing options\n" "\n" "Environment variables:\n" "QEMU_STRACE Print system calls and arguments similar t= o the\n" @@ -735,6 +740,7 @@ int main(int argc, char **argv) int gdbstub_port =3D 0; char **target_environ, **wrk; envlist_t *envlist =3D NULL; + char *trace_file =3D NULL; bsd_type =3D target_openbsd; =20 if (argc <=3D 1) @@ -754,8 +760,10 @@ int main(int argc, char **argv) =20 cpu_model =3D NULL; =20 + qemu_add_opts(&qemu_trace_opts); + optind =3D 1; - for(;;) { + for (;;) { if (optind >=3D argc) break; r =3D argv[optind]; @@ -840,8 +848,10 @@ int main(int argc, char **argv) singlestep =3D 1; } else if (!strcmp(r, "strace")) { do_strace =3D 1; - } else - { + } else if (!strcmp(r, "trace")) { + g_free(trace_file); + trace_file =3D trace_opt_parse(optarg); + } else { usage(); } } @@ -865,6 +875,11 @@ int main(int argc, char **argv) } filename =3D argv[optind]; =20 + if (!trace_init_backends()) { + exit(1); + } + trace_init_file(trace_file); + /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); =20 --=20 2.7.4