Commit aa0a3247 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf tool fixes from Ingo Molnar:
 "Misc tooling fixes: python3 related fixes, gcc8 fix, bashism fixes and
  some other smaller fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf tools: Use python-config --includes rather than --cflags
  perf script python: Fix dict reference counting
  perf stat: Fix --interval_clear option
  perf tools: Fix compilation errors on gcc8
  perf test shell: Prevent temporary editor files from being considered test scripts
  perf llvm-utils: Remove bashism from kernel include fetch script
  perf test shell: Make perf's inet_pton test more portable
  perf test shell: Replace '|&' with '2>&1 |' to work with more shells
  perf scripts python: Add Python 3 support to EventClass.py
  perf scripts python: Add Python 3 support to sched-migration.py
  perf scripts python: Add Python 3 support to Util.py
  perf scripts python: Add Python 3 support to SchedGui.py
  perf scripts python: Add Python 3 support to Core.py
  perf tools: Generate a Python script compatible with Python 2 and 3
parents 75adbd13 6e1d33b2
...@@ -207,8 +207,7 @@ ifdef PYTHON_CONFIG ...@@ -207,8 +207,7 @@ ifdef PYTHON_CONFIG
PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS))
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
endif endif
......
...@@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op) ...@@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
else if (rm[2].rm_so != rm[2].rm_eo) else if (rm[2].rm_so != rm[2].rm_eo)
prefix[0] = '+'; prefix[0] = '+';
else else
strncpy(prefix, "+0", 2); scnprintf(prefix, sizeof(prefix), "+0");
} }
/* Rename register */ /* Rename register */
......
...@@ -1742,7 +1742,7 @@ static void print_interval(char *prefix, struct timespec *ts) ...@@ -1742,7 +1742,7 @@ static void print_interval(char *prefix, struct timespec *ts)
} }
} }
if ((num_print_interval == 0 && metric_only) || interval_clear) if ((num_print_interval == 0 || interval_clear) && metric_only)
print_metric_headers(" ", true); print_metric_headers(" ", true);
if (++num_print_interval == 25) if (++num_print_interval == 25)
num_print_interval = 0; num_print_interval = 0;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <syscall.h> /* for gettid() */ #include <syscall.h> /* for gettid() */
#include <err.h> #include <err.h>
#include <linux/kernel.h>
#include "jvmti_agent.h" #include "jvmti_agent.h"
#include "../util/jitdump.h" #include "../util/jitdump.h"
...@@ -249,7 +250,7 @@ void *jvmti_open(void) ...@@ -249,7 +250,7 @@ void *jvmti_open(void)
/* /*
* jitdump file name * jitdump file name
*/ */
snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid()); scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666); fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666);
if (fd == -1) if (fd == -1)
......
...@@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value): ...@@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value):
string = "" string = ""
if flag_fields[event_name][field_name]: if flag_fields[event_name][field_name]:
print_delim = 0 print_delim = 0
keys = flag_fields[event_name][field_name]['values'].keys() for idx in sorted(flag_fields[event_name][field_name]['values']):
keys.sort()
for idx in keys:
if not value and not idx: if not value and not idx:
string += flag_fields[event_name][field_name]['values'][idx] string += flag_fields[event_name][field_name]['values'][idx]
break break
...@@ -51,14 +49,12 @@ def symbol_str(event_name, field_name, value): ...@@ -51,14 +49,12 @@ def symbol_str(event_name, field_name, value):
string = "" string = ""
if symbolic_fields[event_name][field_name]: if symbolic_fields[event_name][field_name]:
keys = symbolic_fields[event_name][field_name]['values'].keys() for idx in sorted(symbolic_fields[event_name][field_name]['values']):
keys.sort()
for idx in keys:
if not value and not idx: if not value and not idx:
string = symbolic_fields[event_name][field_name]['values'][idx] string = symbolic_fields[event_name][field_name]['values'][idx]
break break
if (value == idx): if (value == idx):
string = symbolic_fields[event_name][field_name]['values'][idx] string = symbolic_fields[event_name][field_name]['values'][idx]
break break
return string return string
...@@ -74,19 +70,17 @@ def trace_flag_str(value): ...@@ -74,19 +70,17 @@ def trace_flag_str(value):
string = "" string = ""
print_delim = 0 print_delim = 0
keys = trace_flags.keys() for idx in trace_flags:
if not value and not idx:
for idx in keys: string += "NONE"
if not value and not idx: break
string += "NONE"
break if idx and (value & idx) == idx:
if print_delim:
if idx and (value & idx) == idx: string += " | ";
if print_delim: string += trace_flags[idx]
string += " | "; print_delim = 1
string += trace_flags[idx] value &= ~idx
print_delim = 1
value &= ~idx
return string return string
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# PerfEvent is the base class for all perf event sample, PebsEvent # PerfEvent is the base class for all perf event sample, PebsEvent
# is a HW base Intel x86 PEBS event, and user could add more SW/HW # is a HW base Intel x86 PEBS event, and user could add more SW/HW
# event classes based on requirements. # event classes based on requirements.
from __future__ import print_function
import struct import struct
...@@ -44,7 +45,8 @@ class PerfEvent(object): ...@@ -44,7 +45,8 @@ class PerfEvent(object):
PerfEvent.event_num += 1 PerfEvent.event_num += 1
def show(self): def show(self):
print "PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % (self.name, self.symbol, self.comm, self.dso) print("PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" %
(self.name, self.symbol, self.comm, self.dso))
# #
# Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer # Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
try: try:
import wx import wx
except ImportError: except ImportError:
raise ImportError, "You need to install the wxpython lib for this script" raise ImportError("You need to install the wxpython lib for this script")
class RootFrame(wx.Frame): class RootFrame(wx.Frame):
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# This software may be distributed under the terms of the GNU General # This software may be distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software # Public License ("GPL") version 2 as published by the Free Software
# Foundation. # Foundation.
from __future__ import print_function
import errno, os import errno, os
...@@ -33,7 +34,7 @@ def nsecs_str(nsecs): ...@@ -33,7 +34,7 @@ def nsecs_str(nsecs):
return str return str
def add_stats(dict, key, value): def add_stats(dict, key, value):
if not dict.has_key(key): if key not in dict:
dict[key] = (value, value, value, 1) dict[key] = (value, value, value, 1)
else: else:
min, max, avg, count = dict[key] min, max, avg, count = dict[key]
...@@ -72,10 +73,10 @@ try: ...@@ -72,10 +73,10 @@ try:
except: except:
if not audit_package_warned: if not audit_package_warned:
audit_package_warned = True audit_package_warned = True
print "Install the audit-libs-python package to get syscall names.\n" \ print("Install the audit-libs-python package to get syscall names.\n"
"For example:\n # apt-get install python-audit (Ubuntu)" \ "For example:\n # apt-get install python-audit (Ubuntu)"
"\n # yum install audit-libs-python (Fedora)" \ "\n # yum install audit-libs-python (Fedora)"
"\n etc.\n" "\n etc.\n")
def syscall_name(id): def syscall_name(id):
try: try:
......
...@@ -9,13 +9,17 @@ ...@@ -9,13 +9,17 @@
# This software is distributed under the terms of the GNU General # This software is distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software # Public License ("GPL") version 2 as published by the Free Software
# Foundation. # Foundation.
from __future__ import print_function
import os import os
import sys import sys
from collections import defaultdict from collections import defaultdict
from UserList import UserList try:
from UserList import UserList
except ImportError:
# Python 3: UserList moved to the collections package
from collections import UserList
sys.path.append(os.environ['PERF_EXEC_PATH'] + \ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace') '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
...@@ -300,7 +304,7 @@ class TimeSliceList(UserList): ...@@ -300,7 +304,7 @@ class TimeSliceList(UserList):
if i == -1: if i == -1:
return return
for i in xrange(i, len(self.data)): for i in range(i, len(self.data)):
timeslice = self.data[i] timeslice = self.data[i]
if timeslice.start > end: if timeslice.start > end:
return return
...@@ -336,8 +340,8 @@ class SchedEventProxy: ...@@ -336,8 +340,8 @@ class SchedEventProxy:
on_cpu_task = self.current_tsk[headers.cpu] on_cpu_task = self.current_tsk[headers.cpu]
if on_cpu_task != -1 and on_cpu_task != prev_pid: if on_cpu_task != -1 and on_cpu_task != prev_pid:
print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ print("Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
(headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
threads[prev_pid] = prev_comm threads[prev_pid] = prev_comm
threads[next_pid] = next_comm threads[next_pid] = next_comm
......
...@@ -422,7 +422,7 @@ static const char *shell_test__description(char *description, size_t size, ...@@ -422,7 +422,7 @@ static const char *shell_test__description(char *description, size_t size,
#define for_each_shell_test(dir, base, ent) \ #define for_each_shell_test(dir, base, ent) \
while ((ent = readdir(dir)) != NULL) \ while ((ent = readdir(dir)) != NULL) \
if (!is_directory(base, ent)) if (!is_directory(base, ent) && ent->d_name[0] != '.')
static const char *shell_tests__dir(char *path, size_t size) static const char *shell_tests__dir(char *path, size_t size)
{ {
......
...@@ -14,35 +14,40 @@ libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1 ...@@ -14,35 +14,40 @@ libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1
nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254 nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
trace_libc_inet_pton_backtrace() { trace_libc_inet_pton_backtrace() {
idx=0
expected[0]="ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" expected=`mktemp -u /tmp/expected.XXX`
expected[1]=".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
echo "ping[][0-9 \.:]+probe_libc:inet_pton: \([[:xdigit:]]+\)" > $expected
echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
case "$(uname -m)" in case "$(uname -m)" in
s390x) s390x)
eventattr='call-graph=dwarf,max-stack=4' eventattr='call-graph=dwarf,max-stack=4'
expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
;; ;;
*) *)
eventattr='max-stack=3' eventattr='max-stack=3'
expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected
expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
;; ;;
esac esac
file=`mktemp -u /tmp/perf.data.XXX` perf_data=`mktemp -u /tmp/perf.data.XXX`
perf_script=`mktemp -u /tmp/perf.script.XXX`
perf record -e probe_libc:inet_pton/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
perf script -i $perf_data > $perf_script
perf record -e probe_libc:inet_pton/$eventattr/ -o $file ping -6 -c 1 ::1 > /dev/null 2>&1 exec 3<$perf_script
perf script -i $file | while read line ; do exec 4<$expected
while read line <&3 && read -r pattern <&4; do
[ -z "$pattern" ] && break
echo $line echo $line
echo "$line" | egrep -q "${expected[$idx]}" echo "$line" | egrep -q "$pattern"
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
printf "FAIL: expected backtrace entry %d \"%s\" got \"%s\"\n" $idx "${expected[$idx]}" "$line" printf "FAIL: expected backtrace entry \"%s\" got \"%s\"\n" "$pattern" "$line"
exit 1 exit 1
fi fi
let idx+=1
[ -z "${expected[$idx]}" ] && break
done done
# If any statements are executed from this point onwards, # If any statements are executed from this point onwards,
...@@ -58,6 +63,6 @@ skip_if_no_perf_probe && \ ...@@ -58,6 +63,6 @@ skip_if_no_perf_probe && \
perf probe -q $libc inet_pton && \ perf probe -q $libc inet_pton && \
trace_libc_inet_pton_backtrace trace_libc_inet_pton_backtrace
err=$? err=$?
rm -f ${file} rm -f ${perf_data} ${perf_script} ${expected}
perf probe -q -d probe_libc:inet_pton perf probe -q -d probe_libc:inet_pton
exit $err exit $err
...@@ -17,7 +17,7 @@ skip_if_no_perf_probe || exit 2 ...@@ -17,7 +17,7 @@ skip_if_no_perf_probe || exit 2
file=$(mktemp /tmp/temporary_file.XXXXX) file=$(mktemp /tmp/temporary_file.XXXXX)
trace_open_vfs_getname() { trace_open_vfs_getname() {
evts=$(echo $(perf list syscalls:sys_enter_open* |& egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
perf trace -e $evts touch $file 2>&1 | \ perf trace -e $evts touch $file 2>&1 | \
egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
} }
......
...@@ -266,16 +266,16 @@ static const char *kinc_fetch_script = ...@@ -266,16 +266,16 @@ static const char *kinc_fetch_script =
"#!/usr/bin/env sh\n" "#!/usr/bin/env sh\n"
"if ! test -d \"$KBUILD_DIR\"\n" "if ! test -d \"$KBUILD_DIR\"\n"
"then\n" "then\n"
" exit -1\n" " exit 1\n"
"fi\n" "fi\n"
"if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n" "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
"then\n" "then\n"
" exit -1\n" " exit 1\n"
"fi\n" "fi\n"
"TMPDIR=`mktemp -d`\n" "TMPDIR=`mktemp -d`\n"
"if test -z \"$TMPDIR\"\n" "if test -z \"$TMPDIR\"\n"
"then\n" "then\n"
" exit -1\n" " exit 1\n"
"fi\n" "fi\n"
"cat << EOF > $TMPDIR/Makefile\n" "cat << EOF > $TMPDIR/Makefile\n"
"obj-y := dummy.o\n" "obj-y := dummy.o\n"
......
...@@ -908,14 +908,11 @@ static void python_process_tracepoint(struct perf_sample *sample, ...@@ -908,14 +908,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
if (_PyTuple_Resize(&t, n) == -1) if (_PyTuple_Resize(&t, n) == -1)
Py_FatalError("error resizing Python tuple"); Py_FatalError("error resizing Python tuple");
if (!dict) { if (!dict)
call_object(handler, t, handler_name); call_object(handler, t, handler_name);
} else { else
call_object(handler, t, default_handler_name); call_object(handler, t, default_handler_name);
Py_DECREF(dict);
}
Py_XDECREF(all_entries_dict);
Py_DECREF(t); Py_DECREF(t);
} }
...@@ -1235,7 +1232,6 @@ static void python_process_general_event(struct perf_sample *sample, ...@@ -1235,7 +1232,6 @@ static void python_process_general_event(struct perf_sample *sample,
call_object(handler, t, handler_name); call_object(handler, t, handler_name);
Py_DECREF(dict);
Py_DECREF(t); Py_DECREF(t);
} }
...@@ -1627,6 +1623,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) ...@@ -1627,6 +1623,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
fprintf(ofp, "# See the perf-script-python Documentation for the list " fprintf(ofp, "# See the perf-script-python Documentation for the list "
"of available functions.\n\n"); "of available functions.\n\n");
fprintf(ofp, "from __future__ import print_function\n\n");
fprintf(ofp, "import os\n"); fprintf(ofp, "import os\n");
fprintf(ofp, "import sys\n\n"); fprintf(ofp, "import sys\n\n");
...@@ -1636,10 +1633,10 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) ...@@ -1636,10 +1633,10 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
fprintf(ofp, "from Core import *\n\n\n"); fprintf(ofp, "from Core import *\n\n\n");
fprintf(ofp, "def trace_begin():\n"); fprintf(ofp, "def trace_begin():\n");
fprintf(ofp, "\tprint \"in trace_begin\"\n\n"); fprintf(ofp, "\tprint(\"in trace_begin\")\n\n");
fprintf(ofp, "def trace_end():\n"); fprintf(ofp, "def trace_end():\n");
fprintf(ofp, "\tprint \"in trace_end\"\n\n"); fprintf(ofp, "\tprint(\"in trace_end\")\n\n");
while ((event = trace_find_next_event(pevent, event))) { while ((event = trace_find_next_event(pevent, event))) {
fprintf(ofp, "def %s__%s(", event->system, event->name); fprintf(ofp, "def %s__%s(", event->system, event->name);
...@@ -1675,7 +1672,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) ...@@ -1675,7 +1672,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
"common_secs, common_nsecs,\n\t\t\t" "common_secs, common_nsecs,\n\t\t\t"
"common_pid, common_comm)\n\n"); "common_pid, common_comm)\n\n");
fprintf(ofp, "\t\tprint \""); fprintf(ofp, "\t\tprint(\"");
not_first = 0; not_first = 0;
count = 0; count = 0;
...@@ -1736,31 +1733,31 @@ static int python_generate_script(struct pevent *pevent, const char *outfile) ...@@ -1736,31 +1733,31 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
fprintf(ofp, "%s", f->name); fprintf(ofp, "%s", f->name);
} }
fprintf(ofp, ")\n\n"); fprintf(ofp, "))\n\n");
fprintf(ofp, "\t\tprint 'Sample: {'+" fprintf(ofp, "\t\tprint('Sample: {'+"
"get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n");
fprintf(ofp, "\t\tfor node in common_callchain:"); fprintf(ofp, "\t\tfor node in common_callchain:");
fprintf(ofp, "\n\t\t\tif 'sym' in node:"); fprintf(ofp, "\n\t\t\tif 'sym' in node:");
fprintf(ofp, "\n\t\t\t\tprint \"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name'])"); fprintf(ofp, "\n\t\t\t\tprint(\"\\t[%%x] %%s\" %% (node['ip'], node['sym']['name']))");
fprintf(ofp, "\n\t\t\telse:"); fprintf(ofp, "\n\t\t\telse:");
fprintf(ofp, "\n\t\t\t\tprint \"\t[%%x]\" %% (node['ip'])\n\n"); fprintf(ofp, "\n\t\t\t\tprint(\"\t[%%x]\" %% (node['ip']))\n\n");
fprintf(ofp, "\t\tprint \"\\n\"\n\n"); fprintf(ofp, "\t\tprint()\n\n");
} }
fprintf(ofp, "def trace_unhandled(event_name, context, " fprintf(ofp, "def trace_unhandled(event_name, context, "
"event_fields_dict, perf_sample_dict):\n"); "event_fields_dict, perf_sample_dict):\n");
fprintf(ofp, "\t\tprint get_dict_as_string(event_fields_dict)\n"); fprintf(ofp, "\t\tprint(get_dict_as_string(event_fields_dict))\n");
fprintf(ofp, "\t\tprint 'Sample: {'+" fprintf(ofp, "\t\tprint('Sample: {'+"
"get_dict_as_string(perf_sample_dict['sample'], ', ')+'}'\n\n"); "get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')\n\n");
fprintf(ofp, "def print_header(" fprintf(ofp, "def print_header("
"event_name, cpu, secs, nsecs, pid, comm):\n" "event_name, cpu, secs, nsecs, pid, comm):\n"
"\tprint \"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t" "\tprint(\"%%-20s %%5u %%05u.%%09u %%8u %%-20s \" %% \\\n\t"
"(event_name, cpu, secs, nsecs, pid, comm),\n\n"); "(event_name, cpu, secs, nsecs, pid, comm), end=\"\")\n\n");
fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n" fprintf(ofp, "def get_dict_as_string(a_dict, delimiter=' '):\n"
"\treturn delimiter.join" "\treturn delimiter.join"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment