aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-08-15 14:29:03 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-08-15 14:29:03 +0100
commit81a6a2d48a6c7543a03265bcc5c5bbb0d929d894 (patch)
treef83c09c7048ce12ad4dc5bfb3f8f95be95536110
parentc4a6a8887c1b2a669e35ff9da9530824300bdce4 (diff)
parent840d8351774664d01c328d31ed33b0e2d85c866e (diff)
downloadqemu-81a6a2d48a6c7543a03265bcc5c5bbb0d929d894.zip
qemu-81a6a2d48a6c7543a03265bcc5c5bbb0d929d894.tar.gz
qemu-81a6a2d48a6c7543a03265bcc5c5bbb0d929d894.tar.bz2
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
# gpg: Signature made Tue 15 Aug 2017 14:27:34 BST # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/tracing-pull-request: simpletrace: fix flight recorder --no-header option trace: use static event ID mapping in simpletrace.stp Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rwxr-xr-xscripts/simpletrace.py24
-rw-r--r--scripts/tracetool/format/simpletrace_stap.py31
2 files changed, 20 insertions, 35 deletions
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py
index 2a977e2..a3a6315 100755
--- a/scripts/simpletrace.py
+++ b/scripts/simpletrace.py
@@ -97,11 +97,17 @@ def read_trace_header(fobj):
raise ValueError('Log format %d not supported with this QEMU release!'
% log_version)
-def read_trace_records(edict, fobj):
- """Deserialize trace records from a file, yielding record tuples (event_num, timestamp, pid, arg1, ..., arg6)."""
- idtoname = {
- dropped_event_id: "dropped"
- }
+def read_trace_records(edict, idtoname, fobj):
+ """Deserialize trace records from a file, yielding record tuples (event_num, timestamp, pid, arg1, ..., arg6).
+
+ Note that `idtoname` is modified if the file contains mapping records.
+
+ Args:
+ edict (str -> Event): events dict, indexed by name
+ idtoname (int -> str): event names dict, indexed by event ID
+ fobj (file): input file
+
+ """
while True:
t = fobj.read(8)
if len(t) == 0:
@@ -171,10 +177,16 @@ def process(events, log, analyzer, read_header=True):
dropped_event = Event.build("Dropped_Event(uint64_t num_events_dropped)")
edict = {"dropped": dropped_event}
+ idtoname = {dropped_event_id: "dropped"}
for event in events:
edict[event.name] = event
+ # If there is no header assume event ID mapping matches events list
+ if not read_header:
+ for event_id, event in enumerate(events):
+ idtoname[event_id] = event.name
+
def build_fn(analyzer, event):
if isinstance(event, str):
return analyzer.catchall
@@ -197,7 +209,7 @@ def process(events, log, analyzer, read_header=True):
analyzer.begin()
fn_cache = {}
- for rec in read_trace_records(edict, log):
+ for rec in read_trace_records(edict, idtoname, log):
event_num = rec[0]
event = edict[event_num]
if event_num not in fn_cache:
diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py
index 144b704..e7e4484 100644
--- a/scripts/tracetool/format/simpletrace_stap.py
+++ b/scripts/tracetool/format/simpletrace_stap.py
@@ -22,33 +22,8 @@ def global_var_name(name):
return probeprefix().replace(".", "_") + "_" + name
def generate(events, backend, group):
- id_map = global_var_name("event_name_to_id_map")
- next_id = global_var_name("event_next_id")
- map_func = global_var_name("simple_trace_map_event")
out('/* This file is autogenerated by tracetool, do not edit. */',
- '',
- 'global %(id_map)s',
- 'global %(next_id)s',
- 'function %(map_func)s(name)',
- '',
- '{',
- ' if (!([name] in %(id_map)s)) {',
- ' %(id_map)s[name] = %(next_id)s',
- ' name_len = strlen(name)',
- ' printf("%%8b%%8b%%4b%%.*s", 0, ',
- ' %(next_id)s, name_len, name_len, name)',
- ' %(next_id)s = %(next_id)s + 1',
- ' }',
- ' return %(id_map)s[name]',
- '}',
- 'probe begin',
- '{',
- ' printf("%%8b%%8b%%8b", 0xffffffffffffffff, 0xf2b177cb0aa429b4, 4)',
- '}',
- '',
- id_map=id_map,
- next_id=next_id,
- map_func=map_func)
+ '')
for event_id, e in enumerate(events):
if 'disable' in e.properties:
@@ -56,9 +31,7 @@ def generate(events, backend, group):
out('probe %(probeprefix)s.simpletrace.%(name)s = %(probeprefix)s.%(name)s ?',
'{',
- ' id = %(map_func)s("%(name)s")',
probeprefix=probeprefix(),
- map_func=map_func,
name=e.name)
# Calculate record size
@@ -77,7 +50,7 @@ def generate(events, backend, group):
sizestr = ' + '.join(sizes)
# Generate format string and value pairs for record header and arguments
- fields = [('8b', 'id'),
+ fields = [('8b', str(event_id)),
('8b', 'gettimeofday_ns()'),
('4b', sizestr),
('4b', 'pid()')]