From patchwork Wed Sep 13 10:13:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 9950891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0303D6024A for ; Wed, 13 Sep 2017 10:14:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E848828F8E for ; Wed, 13 Sep 2017 10:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD23A28FB6; Wed, 13 Sep 2017 10:14:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 41E1A28F8E for ; Wed, 13 Sep 2017 10:14:42 +0000 (UTC) Received: from localhost ([::1]:41335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds4gr-0008Ar-A7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Sep 2017 06:14:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds4gJ-000889-PN for qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:14:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds4gF-0006bs-Kj for qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:14:07 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:59537) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds4gF-0006bK-98 for qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:14:03 -0400 Received: from correu-2.ac.upc.es (correu-2.ac.upc.es [147.83.30.92]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8DADx4E008276; Wed, 13 Sep 2017 12:13:59 +0200 Received: from localhost (unknown [132.68.137.204]) by correu-2.ac.upc.es (Postfix) with ESMTPSA id 2649739C; Wed, 13 Sep 2017 12:13:54 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 13:13:53 +0300 Message-Id: <150529763287.10902.10736733334663967708.stgit@frigg.lan> X-Mailer: git-send-email 2.14.1 In-Reply-To: <150529642278.10902.18234057937634437857.stgit@frigg.lan> References: <150529642278.10902.18234057937634437857.stgit@frigg.lan> User-Agent: StGit/0.18 MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id v8DADx4E008276 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v6 05/22] instrument: [bsd-user] Add command line library loader X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Emilio G. Cota" , Markus Armbruster , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: LluĂ­s Vilanova --- bsd-user/main.c | 17 +++++++++++++++++ bsd-user/syscall.c | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 8a6706a1c8..104844edfc 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -33,6 +33,7 @@ #include "exec/log.h" #include "trace/control.h" #include "glib-compat.h" +#include "instrument/cmdline.h" int singlestep; unsigned long mmap_min_addr; @@ -667,6 +668,11 @@ static void usage(void) "-B address set guest_base address to address\n" "-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n" "\n" +#if defined(CONFIG_INSTRUMENT) + "-instr [file=][,arg=]\n" + " load an instrumentation library\n" + "\n" +#endif "Debug options:\n" "-d item1[,...] enable logging of specified items\n" " (use '-d help' for a list of log items)\n" @@ -738,6 +744,9 @@ int main(int argc, char **argv) envlist_t *envlist = NULL; char *trace_file = NULL; bsd_type = target_openbsd; + char *instrument_path = NULL; + int instrument_argc = 0; + const char **instrument_argv = NULL; if (argc <= 1) usage(); @@ -756,6 +765,9 @@ int main(int argc, char **argv) cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); +#if defined(CONFIG_INSTRUMENT) + qemu_add_opts(&qemu_instr_opts); +#endif optind = 1; for (;;) { @@ -843,6 +855,9 @@ int main(int argc, char **argv) } else if (!strcmp(r, "trace")) { g_free(trace_file); trace_file = trace_opt_parse(optarg); + } else if (!strcmp(r, "instr")) { + instr_opt_parse(optarg, &instrument_path, + &instrument_argc, &instrument_argv); } else { usage(); } @@ -872,6 +887,8 @@ int main(int argc, char **argv) } 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/bsd-user/syscall.c b/bsd-user/syscall.c index 66492aaf5d..3230f722f3 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -26,6 +26,8 @@ #include "qemu.h" #include "qemu-common.h" +#include "instrument/cmdline.h" + //#define DEBUG @@ -332,6 +334,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + instr_fini(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ @@ -430,6 +433,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + instr_fini(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ @@ -505,6 +509,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + instr_fini(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */