From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX91a-0006bB-6v for qemu-devel@nongnu.org; Tue, 09 Aug 2016 11:33:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bX91S-0005ib-CB for qemu-devel@nongnu.org; Tue, 09 Aug 2016 11:33:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX91S-0005iW-0x for qemu-devel@nongnu.org; Tue, 09 Aug 2016 11:32:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FA77C0C1121 for ; Tue, 9 Aug 2016 15:32:53 +0000 (UTC) From: "Daniel P. Berrange" Date: Tue, 9 Aug 2016 16:31:44 +0100 Message-Id: <1470756748-18933-17-git-send-email-berrange@redhat.com> In-Reply-To: <1470756748-18933-1-git-send-email-berrange@redhat.com> References: <1470756748-18933-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH for-2.8 v1 16/60] trace: introduce ID range offsets per trace-events file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Daniel P. Berrange" For simpletrace we need to be able to form a globally unique ID value for trace records. Since the individual events no longer have globally unique ID values, we define an event ID offset per trace-events file. The simpletrace records will now use (id_offset << 16) | event_id for the ID value in trace records. Signed-off-by: Daniel P. Berrange --- audio/trace-events | 2 ++ block/trace-events | 2 ++ crypto/trace-events | 2 ++ hw/9pfs/trace-events | 2 ++ hw/acpi/trace-events | 2 ++ hw/alpha/trace-events | 2 ++ hw/arm/trace-events | 2 ++ hw/audio/trace-events | 2 ++ hw/block/trace-events | 2 ++ hw/char/trace-events | 2 ++ hw/display/trace-events | 2 ++ hw/dma/trace-events | 2 ++ hw/i386/trace-events | 2 ++ hw/input/trace-events | 2 ++ hw/intc/trace-events | 2 ++ hw/isa/trace-events | 2 ++ hw/mem/trace-events | 2 ++ hw/misc/trace-events | 2 ++ hw/net/trace-events | 2 ++ hw/nvram/trace-events | 2 ++ hw/pci/trace-events | 2 ++ hw/ppc/trace-events | 2 ++ hw/s390x/trace-events | 2 ++ hw/scsi/trace-events | 2 ++ hw/sd/trace-events | 2 ++ hw/sparc/trace-events | 2 ++ hw/timer/trace-events | 2 ++ hw/usb/trace-events | 2 ++ hw/vfio/trace-events | 2 ++ hw/virtio/trace-events | 2 ++ io/trace-events | 2 ++ linux-user/trace-events | 2 ++ migration/trace-events | 2 ++ net/trace-events | 2 ++ qom/trace-events | 2 ++ scripts/simpletrace.py | 7 ++-- scripts/tracetool/__init__.py | 49 +++++++++++++++++++++++----- scripts/tracetool/backend/simple.py | 3 +- scripts/tracetool/format/simpletrace_stap.py | 2 +- target-i386/trace-events | 2 ++ target-ppc/trace-events | 2 ++ target-s390x/trace-events | 2 ++ target-sparc/trace-events | 2 ++ trace-events | 2 ++ ui/trace-events | 2 ++ util/trace-events | 2 ++ 46 files changed, 131 insertions(+), 14 deletions(-) diff --git a/audio/trace-events b/audio/trace-events index 5638ea1..5630465 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(512) + # audio/alsaaudio.c alsa_revents(int revents) "revents = %d" alsa_pollout(int i, int fd) "i = %d fd = %d" diff --git a/block/trace-events b/block/trace-events index 978ef4f..8286458 100644 --- a/block/trace-events +++ b/block/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(25) + # block.c bdrv_open_common(void *bs, const char *filename, int flags, const char *format_name) "bs %p filename \"%s\" flags %#x format_name \"%s\"" bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" diff --git a/crypto/trace-events b/crypto/trace-events index 71f1d99..9850d0d 100644 --- a/crypto/trace-events +++ b/crypto/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(32) + # crypto/tlscreds.c qcrypto_tls_creds_load_dh(void *creds, const char *filename) "TLS creds load DH creds=%p filename=%s" qcrypto_tls_creds_get_path(void *creds, const char *filename, const char *path) "TLS creds path creds=%p filename=%s path=%s" diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events index 63efa27..84275da 100644 --- a/hw/9pfs/trace-events +++ b/hw/9pfs/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(196) + # hw/9pfs/virtio-9p.c v9fs_rerror(uint16_t tag, uint8_t id, int err) "tag %d id %d err %d" v9fs_version(uint16_t tag, uint8_t id, int32_t msize, char* version) "tag %d id %d msize %d version %s" diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events index 5aa3ba6..840928e 100644 --- a/hw/acpi/trace-events +++ b/hw/acpi/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(225) + # hw/acpi/memory_hotplug.c mhp_acpi_invalid_slot_selected(uint32_t slot) "0x%"PRIx32 mhp_acpi_ejecting_invalid_slot(uint32_t slot) "0x%"PRIx32 diff --git a/hw/alpha/trace-events b/hw/alpha/trace-events index 7d52b5d..7963ee4 100644 --- a/hw/alpha/trace-events +++ b/hw/alpha/trace-events @@ -1,4 +1,6 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(169) + # hw/alpha/pci.c alpha_pci_iack_write(void) "" diff --git a/hw/arm/trace-events b/hw/arm/trace-events index d0dad16..e1f9d5c 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -1,4 +1,6 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(324) + # hw/arm/virt-acpi-build.c virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 796f4a1..0610b63 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(243) + # hw/audio/cs4231.c cs4231_mem_readl_dreg(uint32_t reg, uint32_t ret) "read dreg %d: 0x%02x" cs4231_mem_readl_reg(uint32_t reg, uint32_t ret) "read reg %d: 0x%08x" diff --git a/hw/block/trace-events b/hw/block/trace-events index 31df44b..4c79bc0 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(49) + # hw/block/virtio-blk.c virtio_blk_req_complete(void *req, int status) "req %p status %d" virtio_blk_rw_complete(void *req, int ret) "req %p ret %d" diff --git a/hw/char/trace-events b/hw/char/trace-events index 005fcd8..fec6fc3 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(288) + # hw/char/virtio-serial-bus.c virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t value) "port %u, event %u, value %u" virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, throttle %d" diff --git a/hw/display/trace-events b/hw/display/trace-events index 78f0465..4dd88aa 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(100) + # hw/display/jazz_led.c jazz_led_read(uint64_t addr, uint8_t val) "read addr=0x%"PRIx64": 0x%x" jazz_led_write(uint64_t addr, uint8_t new) "write addr=0x%"PRIx64": 0x%x" diff --git a/hw/dma/trace-events b/hw/dma/trace-events index d8a5674..685460d 100644 --- a/hw/dma/trace-events +++ b/hw/dma/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(72) + # hw/dma/rc4030.c jazzio_read(uint64_t addr, uint32_t ret) "read reg[0x%"PRIx64"] = 0x%x" jazzio_write(uint64_t addr, uint32_t val) "write reg[0x%"PRIx64"] = 0x%x" diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 507f753..6ee0130 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(392) + # hw/i386/xen/xen_platform.c xen_platform_log(char *s) "xen platform: %s" diff --git a/hw/input/trace-events b/hw/input/trace-events index f24dff2..c78af6c 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(432) + # hw/input/ps2.c ps2_put_keycode(void *opaque, int keycode) "%p keycode %d" ps2_read_data(void *opaque) "%p" diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 376dd18..ee46617 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(144) + # hw/intc/apic_common.c cpu_set_apic_base(uint64_t val) "%016"PRIx64 cpu_get_apic_base(uint64_t val) "%016"PRIx64 diff --git a/hw/isa/trace-events b/hw/isa/trace-events index 686282f..b6b8ba6 100644 --- a/hw/isa/trace-events +++ b/hw/isa/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(400) + # hw/isa/pc87312.c pc87312_io_read(uint32_t addr, uint32_t val) "read addr=%x val=%x" pc87312_io_write(uint32_t addr, uint32_t val) "write addr=%x val=%x" diff --git a/hw/mem/trace-events b/hw/mem/trace-events index 3a49215..4b67bba 100644 --- a/hw/mem/trace-events +++ b/hw/mem/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(36) + # hw/mem/pc-dimm.c mhp_pc_dimm_assigned_slot(int slot) "0x%d" mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64 diff --git a/hw/misc/trace-events b/hw/misc/trace-events index ea52a14..31db6a7 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(361) + # hw/misc/eccmemctl.c ecc_mem_writel_mer(uint32_t val) "Write memory enable %08x" ecc_mem_writel_mdr(uint32_t val) "Write memory delay %08x" diff --git a/hw/net/trace-events b/hw/net/trace-events index aaa905f..a78e8c6 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(289) + # hw/net/lance.c lance_mem_readw(uint64_t addr, uint32_t ret) "addr=%"PRIx64"val=0x%04x" lance_mem_writew(uint64_t addr, uint32_t val) "addr=%"PRIx64"val=0x%04x" diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events index 325447d..f026896 100644 --- a/hw/nvram/trace-events +++ b/hw/nvram/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(256) + # hw/nvram/ds1225y.c nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x" nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x -> 0x%02x" diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 285338a..7803590 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(121) + # hw/pci/pci.c pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,%#"PRIx64"+%#"PRIx64 pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,%#"PRIx64"+%#"PRIx64 diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 900679b..d372099 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(125) + # hw/ppc/spapr_pci.c spapr_pci_msi(const char *msg, uint32_t ca) "%s (cfg=%x)" spapr_pci_msi_setup(const char *name, unsigned vector, uint64_t addr) "dev\"%s\" vector %u, addr=%"PRIx64 diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events index 72c4549..59305ca 100644 --- a/hw/s390x/trace-events +++ b/hw/s390x/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(64) + # hw/s390x/css.c css_enable_facility(const char *facility) "CSS: enable %s" css_crw(uint8_t rsc, uint8_t erc, uint16_t rsid, const char *chained) "CSS: queueing crw: rsc=%x, erc=%x, rsid=%x %s" diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index 5f19e32..42e699e 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(200) + # hw/scsi/scsi-bus.c scsi_req_alloc(int target, int lun, int tag) "target %d lun %d tag %d" scsi_req_cancel(int target, int lun, int tag) "target %d lun %d tag %d" diff --git a/hw/sd/trace-events b/hw/sd/trace-events index b580a0f..7e5a87a 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(441) + # hw/sd/milkymist-memcard.c milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" diff --git a/hw/sparc/trace-events b/hw/sparc/trace-events index ab677a3..3701222 100644 --- a/hw/sparc/trace-events +++ b/hw/sparc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(81) + # hw/sparc/sun4m.c sun4m_cpu_interrupt(unsigned int level) "Set CPU IRQ %d" sun4m_cpu_reset_interrupt(unsigned int level) "Reset CPU IRQ %d" diff --git a/hw/timer/trace-events b/hw/timer/trace-events index 19db4bf..884cce6 100644 --- a/hw/timer/trace-events +++ b/hw/timer/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(484) + # hw/timer/slavio_timer.c slavio_timer_get_out(uint64_t limit, uint32_t counthigh, uint32_t count) "limit %"PRIx64" count %x%08x" slavio_timer_irq(uint32_t counthigh, uint32_t count) "callback: count %x%08x" diff --git a/hw/usb/trace-events b/hw/usb/trace-events index ac2d951..c913c99 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(343) + # hw/usb/core.c usb_packet_state_change(int bus, const char *port, int ep, void *p, const char *o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s -> %s" usb_packet_state_fault(int bus, const char *port, int ep, void *p, const char *o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s, expected %s" diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 4bb7690..b3898d7 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(108) + # hw/vfio/pci.c vfio_intx_interrupt(const char *name, char line) " (%s) Pin %c" vfio_intx_eoi(const char *name) " (%s) EOI" diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 6849a44..e5350c6 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(500) + # hw/virtio/virtio.c virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) "vq %p elem %p len %u idx %u" virtqueue_flush(void *vq, unsigned int count) "vq %p count %u" diff --git a/io/trace-events b/io/trace-events index 8d84eda..910c9b9 100644 --- a/io/trace-events +++ b/io/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(529) + # io/task.c qio_task_new(void *task, void *source, void *func, void *opaque) "Task new task=%p source=%p func=%p opaque=%p" qio_task_complete(void *task) "Task complete task=%p" diff --git a/linux-user/trace-events b/linux-user/trace-events index 80a2e07..e8d4229 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(4) + # linux-user/signal.c user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64 user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64 diff --git a/migration/trace-events b/migration/trace-events index 8568dab..43ce7f7 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(9) + # migration/savevm.c qemu_loadvm_state_section(unsigned int section_type) "%d" qemu_loadvm_state_section_command(int ret) "%d" diff --git a/net/trace-events b/net/trace-events index 32a0a8a..49b0174 100644 --- a/net/trace-events +++ b/net/trace-events @@ -1,4 +1,6 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(625) + # net/vhost-user.c vhost_user_event(const char *chr, int event) "chr: %s got event: %d" diff --git a/qom/trace-events b/qom/trace-events index 350fc1f..4c76f43 100644 --- a/qom/trace-events +++ b/qom/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(675) + # qom/object.c object_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)" object_class_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)" diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index 3916c6d..0f4d020 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -114,11 +114,12 @@ def process(events, log, analyzer, read_header=True): if read_header: read_trace_header(log) - dropped_event = Event.build("Dropped_Event(uint64_t num_events_dropped)") + dropped_event = Event.build("Dropped_Event(uint64_t num_events_dropped)", + dropped_event_id, 0) edict = {dropped_event_id: dropped_event} - for num, event in enumerate(events): - edict[num] = event + for event in events: + edict[event.global_id] = event def build_fn(analyzer, event): if isinstance(event, str): diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index aebabaf..00d1c89 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -145,6 +145,12 @@ class Event(object): ---------- name : str The event name. + local_id: int + ID of event within the group + id_offset: int + Offset for event ID + global_id: int + ID of event globally unique fmt : str The event format string. properties : set(str) @@ -163,13 +169,17 @@ class Event(object): _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec", "vcpu"]) - def __init__(self, name, props, fmt, args, orig=None, + def __init__(self, name, local_id, id_offset, props, fmt, args, orig=None, event_trans=None, event_exec=None): """ Parameters ---------- name : string Event name. + local_id: int + ID of event within the group + id_offset: int + Offset for event ID props : list of str Property names. fmt : str, list of str @@ -185,6 +195,9 @@ class Event(object): """ self.name = name + self.local_id = local_id + self.id_offset = id_offset + self.global_id = (self.id_offset << 16) | self.local_id self.properties = props self.fmt = fmt self.args = args @@ -204,11 +217,11 @@ class Event(object): def copy(self): """Create a new copy.""" - return Event(self.name, list(self.properties), self.fmt, + return Event(self.name, self.local_id, self.id_offset, list(self.properties), self.fmt, self.args.copy(), self, self.event_trans, self.event_exec) @staticmethod - def build(line_str): + def build(line_str, local_id, id_offset): """Build an Event instance from a string. Parameters @@ -237,7 +250,7 @@ class Event(object): if "tcg" in props and isinstance(fmt, str): raise ValueError("Events with 'tcg' property must have two formats") - event = Event(name, props, fmt, args) + event = Event(name, local_id, id_offset, props, fmt, args) # add implicit arguments when using the 'vcpu' property import tracetool.vcpu @@ -251,10 +264,13 @@ class Event(object): fmt = self.fmt else: fmt = "%s, %s" % (self.fmt[0], self.fmt[1]) - return "Event('%s %s(%s) %s')" % (" ".join(self.properties), - self.name, - self.args, - fmt) + return "Event('%s %s:%d:%d(%s) %s')" % ( + " ".join(self.properties), + self.name, + self.local_id, + self.id_offset, + self.args, + fmt) _FMT = re.compile("(%[\d\.]*\w+|%.*PRI\S+)") @@ -274,6 +290,8 @@ class Event(object): def transform(self, *trans): """Return a new Event with transformed Arguments.""" return Event(self.name, + self.local_id, + self.id_offset, list(self.properties), self.fmt, self.args.transform(*trans), @@ -282,13 +300,26 @@ class Event(object): def _read_events(fobj): events = [] + id_offset = 0 + local_id = 0 + all_id_offsets = [] for line in fobj: if not line.strip(): continue if line.lstrip().startswith('#'): continue - event = Event.build(line) + if line.startswith("@id_offset("): + id_offset = int(line[11:-2]) + + if id_offset in all_id_offsets: + raise TracetoolError("ID offset %d already used" % id_offset) + all_id_offsets.append(id_offset) + local_id = 0 + continue + + event = Event.build(line, local_id, id_offset) + local_id += 1 # transform TCG-enabled events if "tcg" not in event.properties: diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py index 8c27b68..b4f6ea4 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -80,11 +80,12 @@ def generate_c(event, group): ' return;', ' }', '', - ' if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {', + ' if (trace_record_start(&rec, (%(id_offset)d << 16) | %(event_id)s, %(size_str)s)) {', ' return; /* Trace Buffer Full, Event Dropped ! */', ' }', cond=cond, event_id=event_id, + id_offset=event.id_offset, size_str=sizestr) if len(event.args) > 0: diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py index c8b3850..9ec107c 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -48,7 +48,7 @@ def generate(events, backend, group): sizestr = ' + '.join(sizes) # Generate format string and value pairs for record header and arguments - fields = [('8b', str(event_id)), + fields = [('8b', str((e.id_offset << 16) | event_id)), ('8b', 'gettimeofday_ns()'), ('4b', sizestr), ('4b', 'pid()')] diff --git a/target-i386/trace-events b/target-i386/trace-events index ccc49e3..6882f35 100644 --- a/target-i386/trace-events +++ b/target-i386/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(8) + # target-i386/kvm.c kvm_x86_fixup_msi_error(uint32_t gsi) "VT-d failed to remap interrupt for GSI %" PRIu32 kvm_x86_add_msi_route(int virq) "Adding route entry for virq %d" diff --git a/target-ppc/trace-events b/target-ppc/trace-events index d37da2b..a81d2e7 100644 --- a/target-ppc/trace-events +++ b/target-ppc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(676) + # target-ppc/kvm.c kvm_failed_spr_set(int str, const char *msg) "Warning: Unable to set SPR %d to KVM: %s" kvm_failed_spr_get(int str, const char *msg) "Warning: Unable to retrieve SPR %d from KVM: %s" diff --git a/target-s390x/trace-events b/target-s390x/trace-events index 9589b16..ac2b6ec 100644 --- a/target-s390x/trace-events +++ b/target-s390x/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(16) + # target-s390x/mmu_helper.c get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d" set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d" diff --git a/target-sparc/trace-events b/target-sparc/trace-events index c75faf9..0022c45 100644 --- a/target-sparc/trace-events +++ b/target-sparc/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(576) + # target-sparc/mmu_helper.c mmu_helper_dfault(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) "DFAULT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d" mmu_helper_dprot(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) "DPROT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d" diff --git a/trace-events b/trace-events index 1de7e99..08c0b1e 100644 --- a/trace-events +++ b/trace-events @@ -25,6 +25,8 @@ # # The should be a sprintf()-compatible format string. +@id_offset(1) + # thread-pool.c thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p opaque %p" thread_pool_complete(void *pool, void *req, void *opaque, int ret) "pool %p req %p opaque %p ret %d" diff --git a/ui/trace-events b/ui/trace-events index d36dbbb..1649aa1 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(27) + # ui/console.c console_gfx_new(void) "" console_putchar_csi(int esc_param0, int esc_param1, int ch, int nb_esc_params) "escape sequence CSI%d;%d%c, %d parameters" diff --git a/util/trace-events b/util/trace-events index 111e1de..f83fbde 100644 --- a/util/trace-events +++ b/util/trace-events @@ -1,5 +1,7 @@ # See docs/trace-events.txt for syntax documentation. +@id_offset(648) + # util/buffer.c buffer_resize(const char *buf, size_t olen, size_t len) "%s: old %zd, new %zd" buffer_move_empty(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s" -- 2.7.4