From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyfAN-0000Pr-Qe for qemu-devel@nongnu.org; Wed, 31 Aug 2011 03:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QyfAM-0003It-S4 for qemu-devel@nongnu.org; Wed, 31 Aug 2011 03:24:55 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:61309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyfAM-0003Ij-NA for qemu-devel@nongnu.org; Wed, 31 Aug 2011 03:24:54 -0400 Received: by yih10 with SMTP id 10so407992yih.4 for ; Wed, 31 Aug 2011 00:24:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 31 Aug 2011 08:24:53 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH, RFC] trace: implement guest tracepoint passthrough List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: =?ISO-8859-1?Q?Llu=EDs?= , Dhaval Giani , Stefan Hajnoczi , qemu-devel On Tue, Aug 30, 2011 at 7:43 PM, Blue Swirl wrote: > On Mon, Aug 29, 2011 at 12:17 PM, Stefan Hajnoczi wr= ote: >> On Fri, Aug 26, 2011 at 8:06 PM, Blue Swirl wrote= : >>> Let guests inject tracepoint data via fw_cfg device. >>> >>> Signed-off-by: Blue Swirl >>> --- >>> The patch is used like this: >>> ../configure --with-guest-trace-file=3D/src/openbios-devel/trace-events >>> make >>> sparc64-softmmu/qemu-system-sparc64 -trace file=3Dfoo >>> # ugly hack to combine the file, but my laziness^Wpython-fu is too >>> weak to add handling of "--guest-trace-file >>> /src/openbios-devel/trace-events" to simpletrace.py >>> cat ../trace-events /src/openbios-devel/trace-events >/tmp/trace-events >>> # examine trace file with OpenBIOS trace data with simpletrace.py >>> ../scripts/simpletrace.py /tmp/trace-events foo >>> ob_ide_read_blocks 0.000 dest=3D0xfff0bed0 blk=3D0x0 n=3D0x1 >>> ob_ide_read_blocks 6491.806 dest=3D0xfff0bed0 blk=3D0x0 n=3D0x1 >>> >>> An example of a generated guest-trace.c file: >>> /* This file is autogenerated by tracetool, do not edit. */ >>> #include "trace.h" >>> #include "guest-trace.h" >>> >>> void guest_trace(uint64_t event_id, uint64_t arg1, uint64_t arg2, >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint64_t arg3, uint64_t arg4, uint64_t = arg5, uint64_t arg6) >>> >>> { >>> =A0 =A0switch (event_id) { >>> >>> =A0 =A0case 0: >>> =A0 =A0 =A0 =A0trace_esp_do_command(arg1, arg2, arg3); >>> =A0 =A0 =A0 =A0break; >>> >>> =A0 =A0case 1: >>> =A0 =A0 =A0 =A0trace_ob_ide_pio_insw(arg1); >>> =A0 =A0 =A0 =A0break; >>> >>> =A0 =A0case 2: >>> =A0 =A0 =A0 =A0trace_ob_ide_read_blocks(arg1, arg2, arg3); >>> =A0 =A0 =A0 =A0break; >>> >>> =A0 =A0default: >>> =A0 =A0 =A0 =A0break; >>> =A0 } >>> } >>> >>> --- >>> =A0Makefile.objs =A0 =A0 | =A0 15 +++++++++++- >>> =A0configure =A0 =A0 =A0 =A0 | =A0 =A09 +++++++- >>> =A0guest-trace.h =A0 =A0 | =A0 =A03 ++ >>> =A0hw/fw_cfg.c =A0 =A0 =A0 | =A0 31 +++++++++++++++++++++++++++ >>> =A0hw/fw_cfg.h =A0 =A0 =A0 | =A0 10 ++++++-- >>> =A0scripts/tracetool | =A0 60 +++++++++++++++++++++++++++++++++++++++++= ++++++++++- >>> =A06 files changed, 120 insertions(+), 8 deletions(-) >>> =A0create mode 100644 guest-trace.h >> >> The ability to trace from the guest can be handy, so I think we should >> have this feature. =A0Please add documentation on how to hook it up >> (e.g. how people would use this for other firmware/guest code and/or >> other architectures). > > OK. The format should be the same as raw simpletrace data, but words > always in little endian like used elsewhere with fw_cfg. BTW, > currently simpletrace file format depends on host endianness, is that > intentional? Yes, it is intentional. The rationale is that we want to stream trace events to disk as quickly as possible without any overhead. Since there is a magic number in the first trace record, the post-processing tool can in theory determine the endianness and do the byteswapping at that time. The current simpletrace.py script does not do this. Stefan