From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55729 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ogaex-0003bu-VV for qemu-devel@nongnu.org; Wed, 04 Aug 2010 05:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ogaet-0003yO-DU for qemu-devel@nongnu.org; Wed, 04 Aug 2010 05:53:15 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:50774) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ogaet-0003yK-BM for qemu-devel@nongnu.org; Wed, 04 Aug 2010 05:53:11 -0400 Received: by vws19 with SMTP id 19so4083239vws.4 for ; Wed, 04 Aug 2010 02:53:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4C5933FC.2090902@linux.vnet.ibm.com> References: <20100803110700.75d7c3b0@zephyr> <4C5933FC.2090902@linux.vnet.ibm.com> Date: Wed, 4 Aug 2010 10:53:10 +0100 Message-ID: Subject: Re: [Qemu-devel] [Tracing][PATCH] Add options to specify trace file name at startup and runtime. From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Prerna Saxena Cc: Ananth Narayan , qemu-devel , Stefan Hajnoczi On Wed, Aug 4, 2010 at 10:33 AM, Prerna Saxena wrote: > On 08/03/2010 07:45 PM, Stefan Hajnoczi wrote: >> On Tue, Aug 3, 2010 at 6:37 AM, Prerna Saxena >> =A0wrote: >>> @@ -2590,6 +2597,12 @@ int main(int argc, char **argv, char **envp) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xen_mode =3D XEN_ATTACH; >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >>> +#ifdef CONFIG_SIMPLE_TRACE >>> + =A0 =A0 =A0 =A0 =A0 =A0case QEMU_OPTION_trace: >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0trace_file =3D (char *) qemu_malloc(st= rlen(optarg) + 1); >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strcpy(trace_file, optarg); >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >>> +#endif >> >> Malloc isn't necessary, just hold the optarg pointer like gdbstub_dev >> and other string options do. > > It wouldnt be corect to use optarg directly here. If this optional argume= nt > is not specified, st_set_file_name() is called with a NULL argument, and = the > filename defaults to config-specified name. > (This is how gdbstub_dev works too. The optional argument is copied to > gdbstub_dev if provided.) const char *trace_file =3D NULL; ... switch (...) { case QEMU_OPTION_trace: trace_file =3D optarg; break; } ... st_set_trace_file(trace_file); There is no need to malloc/strcpy/free. Stefan