Patchwork [v2,23/23] trace: Do not use the word 'new' in event arguments

login
register
mail settings
Submitter Lluís Vilanova
Date April 16, 2013, 1:52 p.m.
Message ID <20130416135201.21588.77757.stgit@fimbulvetr.bsc.es>
Download mbox | patch
Permalink /patch/236995/
State New
Headers show

Comments

Lluís Vilanova - April 16, 2013, 1:52 p.m.
This lets instrumentation clients in C++ use the auto-generated headers.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 scripts/tracetool/__init__.py |   16 +++++++++++++++-
 trace-events                  |    8 ++++----
 2 files changed, 19 insertions(+), 5 deletions(-)

Patch

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 7624982..851be4d 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -40,6 +40,14 @@  def out(*lines, **kwargs):
     sys.stdout.writelines("\n".join(lines) + "\n")
 
 
+FORBIDDEN = [ "new" ]
+
+class ForbiddenArgumentError (Exception):
+    def __init__ (self, name):
+        self.name = name
+    def __str__ (self):
+        return "Cannot use forbidden argument name: %s" % self.name
+
 class Arguments:
     """Event arguments description."""
 
@@ -74,6 +82,9 @@  class Arguments:
             else:
                 arg_type, identifier = arg.rsplit(None, 1)
 
+            if identifier in FORBIDDEN:
+                raise ForbiddenArgumentError(identifier)
+
             res.append((arg_type, identifier))
         return Arguments(res)
 
@@ -165,7 +176,10 @@  class Event(object):
         name = groups["name"]
         props = groups["props"].split()
         fmt = groups["fmt"]
-        args = Arguments.build(groups["args"])
+        try:
+            args = Arguments.build(groups["args"])
+        except ForbiddenArgumentError as e:
+            error("Error: event '%s' uses forbidden argument name '%s'" % (name, e.name))
 
         return Event(name, props, fmt, args)
 
diff --git a/trace-events b/trace-events
index 412f7e4..eb7dd93 100644
--- a/trace-events
+++ b/trace-events
@@ -187,7 +187,7 @@  hd_geometry_guess(void *bs, uint32_t cyls, uint32_t heads, uint32_t secs, int tr
 
 # hw/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"
+jazz_led_write(uint64_t addr, uint8_t new_) "write addr=0x%"PRIx64": 0x%x"
 
 # hw/lance.c
 lance_mem_readw(uint64_t addr, uint32_t ret) "addr=%"PRIx64"val=0x%04x"
@@ -285,10 +285,10 @@  usb_port_release(int bus, const char *port) "bus %d, port %s"
 usb_ehci_reset(void) "=== RESET ==="
 usb_ehci_opreg_read(uint32_t addr, const char *str, uint32_t val) "rd mmio %04x [%s] = %x"
 usb_ehci_opreg_write(uint32_t addr, const char *str, uint32_t val) "wr mmio %04x [%s] = %x"
-usb_ehci_opreg_change(uint32_t addr, const char *str, uint32_t new, uint32_t old) "ch mmio %04x [%s] = %x (old: %x)"
+usb_ehci_opreg_change(uint32_t addr, const char *str, uint32_t new_, uint32_t old) "ch mmio %04x [%s] = %x (old: %x)"
 usb_ehci_portsc_read(uint32_t addr, uint32_t port, uint32_t val) "rd mmio %04x [port %d] = %x"
 usb_ehci_portsc_write(uint32_t addr, uint32_t port, uint32_t val) "wr mmio %04x [port %d] = %x"
-usb_ehci_portsc_change(uint32_t addr, uint32_t port, uint32_t new, uint32_t old) "ch mmio %04x [port %d] = %x (old: %x)"
+usb_ehci_portsc_change(uint32_t addr, uint32_t port, uint32_t new_, uint32_t old) "ch mmio %04x [port %d] = %x (old: %x)"
 usb_ehci_usbsts(const char *sts, int state) "usbsts %s %d"
 usb_ehci_state(const char *schedule, const char *state) "%s schedule %s"
 usb_ehci_qh_ptrs(void *q, uint32_t addr, uint32_t nxt, uint32_t c_qtd, uint32_t n_qtd, uint32_t a_qtd) "q %p - QH @ %08x: next %08x qtds %08x,%08x,%08x"
@@ -530,7 +530,7 @@  qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
 
 # hw/g364fb.c
 g364fb_read(uint64_t addr, uint32_t val) "read addr=0x%"PRIx64": 0x%x"
-g364fb_write(uint64_t addr, uint32_t new) "write addr=0x%"PRIx64": 0x%x"
+g364fb_write(uint64_t addr, uint32_t val) "write addr=0x%"PRIx64": 0x%x"
 
 # hw/grlib_gptimer.c
 grlib_gptimer_enable(int id, uint32_t count) "timer:%d set count 0x%x and run"