]> Git Repo - linux.git/blobdiff - tools/perf/scripts/python/export-to-sqlite.py
Merge branch 'fixes' into arm/soc
[linux.git] / tools / perf / scripts / python / export-to-sqlite.py
index eb63e6c7107fdb29ea7fee0d6606794186c543f9..bf271fbc3a885f509d78ee60fbb0138fd12df53f 100644 (file)
@@ -10,6 +10,8 @@
 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 # more details.
 
+from __future__ import print_function
+
 import os
 import sys
 import struct
@@ -60,11 +62,17 @@ perf_db_export_mode = True
 perf_db_export_calls = False
 perf_db_export_callchains = False
 
+def printerr(*args, **keyword_args):
+       print(*args, file=sys.stderr, **keyword_args)
+
+def printdate(*args, **kw_args):
+        print(datetime.datetime.today(), *args, sep=' ', **kw_args)
+
 def usage():
-       print >> sys.stderr, "Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]"
-       print >> sys.stderr, "where:    columns         'all' or 'branches'"
-       print >> sys.stderr, "          calls           'calls' => create calls and call_paths table"
-       print >> sys.stderr, "          callchains      'callchains' => create call_paths table"
+       printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]");
+       printerr("where:        columns         'all' or 'branches'");
+       printerr("              calls           'calls' => create calls and call_paths table");
+       printerr("              callchains      'callchains' => create call_paths table");
        raise Exception("Too few arguments")
 
 if (len(sys.argv) < 2):
@@ -100,7 +108,7 @@ def do_query_(q):
                return
        raise Exception("Query failed: " + q.lastError().text())
 
-print datetime.datetime.today(), "Creating database..."
+printdate("Creating database ...")
 
 db_exists = False
 try:
@@ -323,7 +331,7 @@ if perf_db_export_calls:
                        'return_id,'
                        'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE flags END AS flags,'
                        'parent_call_path_id,'
-                       'parent_id'
+                       'calls.parent_id'
                ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
 
 do_query(query, 'CREATE VIEW samples_view AS '
@@ -378,7 +386,7 @@ if perf_db_export_calls:
        call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
 
 def trace_begin():
-       print datetime.datetime.today(), "Writing records..."
+       printdate("Writing records...")
        do_query(query, 'BEGIN TRANSACTION')
        # id == 0 means unknown.  It is easier to create records for them than replace the zeroes with NULLs
        evsel_table(0, "unknown")
@@ -397,14 +405,14 @@ unhandled_count = 0
 def trace_end():
        do_query(query, 'END TRANSACTION')
 
-       print datetime.datetime.today(), "Adding indexes"
+       printdate("Adding indexes")
        if perf_db_export_calls:
                do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)')
                do_query(query, 'CREATE INDEX pid_idx ON calls (parent_id)')
 
        if (unhandled_count):
-               print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events"
-       print datetime.datetime.today(), "Done"
+               printdate("Warning: ", unhandled_count, " unhandled events")
+       printdate("Done")
 
 def trace_unhandled(event_name, context, event_fields_dict):
        global unhandled_count
This page took 0.060409 seconds and 4 git commands to generate.