Ñò •˜¦_c@sÉddkZddkZddkZddkZddkTddkTedƒZeiZe e_ ei Z ei Z ei Z e e _ eiZeiZe e ege_eiZe e ge_eiieiddƒeZeZd„Zeeiƒdjo eƒneidZeeiƒd joeidZnd ZedFjo eƒned jZeeiƒd jo)eid d jo eZq°eƒnei ƒdedZ!ei"e!ƒd„Z#eii$ƒGdGHe%i&dƒZ'e(e'ƒZ)e'i*dƒe'i+ƒye#e)deƒWnei,e!ƒ‚nXe)i-ƒe)i.ƒe'i/ƒe'i*eƒe'i+ƒe(e'ƒZ)e#e)dƒe#e)dƒe#e)dƒe#e)dƒe#e)dƒe#e)dƒe#e)dƒe#e)dƒe#e)dƒeoe#e)dƒne#e)dƒeoe#e)d ƒe#e)d!ƒne#e)d"ƒei0d#d$d%d%ƒZ1d&Z2d'„Z3d(„Z4d)„Z5d*„Z6d+„Z7e3d,ƒZ8e3d-ƒZ9e3d.ƒZ:e3d/ƒZ;e3d0ƒZ<e3d1ƒZ=e3d2ƒZ>e3d3ƒZ?e3d4ƒZ@eoe3d5ƒZAe3d6ƒZBnd7„ZCd%aDd8„ZEd9„ZFd:„ZGd;„ZHd<„ZId=„ZJd>„ZKd?„ZLd@„ZMdA„ZNdB„ZOdC„ZPdD„ZQdE„ZRdS(GiÿÿÿÿN(t*s libpq.so.5tPERF_EXEC_PATHs./scripts/python/Perf-Trace-Util/lib/Perf/TracecCs7tidIJtidIJtidIJtdƒ‚dS(NsGUsage is: export-to-postgresql.py [] []s#where: columns 'all' or 'branches's& calls 'calls' => create calls tablesToo few arguments(tsyststderrt Exception(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytusage-s   iiitalltbranchesitcallst/s -perf-datacCs5|i|ƒodStd|iƒiƒƒ‚dS(NsQuery failed: (texec_Rt lastErrorttext(tqts((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytdo_queryKssCreating database...tQPSQLtpostgressCREATE DATABASE s"SET client_min_messages TO WARNINGsECREATE TABLE selected_events (id bigint NOT NULL,name varchar(80))sQCREATE TABLE machines (id bigint NOT NULL,pid integer,root_dir varchar(4096))siCREATE TABLE threads (id bigint NOT NULL,machine_id bigint,process_id bigint,pid integer,tid integer)s;CREATE TABLE comms (id bigint NOT NULL,comm varchar(16))sPCREATE TABLE comm_threads (id bigint NOT NULL,comm_id bigint,thread_id bigint)sCREATE TABLE dsos (id bigint NOT NULL,machine_id bigint,short_name varchar(256),long_name varchar(4096),build_id varchar(64))s~CREATE TABLE symbols (id bigint NOT NULL,dso_id bigint,sym_start bigint,sym_end bigint,binding integer,name varchar(2048))sCCREATE TABLE branch_types (id integer NOT NULL,name varchar(80))s/CREATE TABLE samples (id bigint NOT NULL,evsel_id bigint,machine_id bigint,thread_id bigint,comm_id bigint,dso_id bigint,symbol_id bigint,sym_offset bigint,ip bigint,time bigint,cpu integer,to_dso_id bigint,to_symbol_id bigint,to_sym_offset bigint,to_ip bigint,branch_type integer,in_tx boolean)spCREATE TABLE samples (id bigint NOT NULL,evsel_id bigint,machine_id bigint,thread_id bigint,comm_id bigint,dso_id bigint,symbol_id bigint,sym_offset bigint,ip bigint,time bigint,cpu integer,to_dso_id bigint,to_symbol_id bigint,to_sym_offset bigint,to_ip bigint,period bigint,weight bigint,transaction bigint,data_src bigint,branch_type integer,in_tx boolean)s[CREATE TABLE call_paths (id bigint NOT NULL,parent_id bigint,symbol_id bigint,ip bigint)sßCREATE TABLE calls (id bigint NOT NULL,thread_id bigint,comm_id bigint,call_path_id bigint,call_time bigint,return_time bigint,branch_count bigint,call_id bigint,return_id bigint,parent_call_path_id bigint,flags integer)s¼CREATE VIEW samples_view AS SELECT id,time,cpu,(SELECT pid FROM threads WHERE id = thread_id) AS pid,(SELECT tid FROM threads WHERE id = thread_id) AS tid,(SELECT comm FROM comms WHERE id = comm_id) AS command,(SELECT name FROM selected_events WHERE id = evsel_id) AS event,to_hex(ip) AS ip_hex,(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,sym_offset,(SELECT short_name FROM dsos WHERE id = dso_id) AS dso_short_name,to_hex(to_ip) AS to_ip_hex,(SELECT name FROM symbols WHERE id = to_symbol_id) AS to_symbol,to_sym_offset,(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,in_tx FROM sampless!11siis PGCOPY ÿ isÿÿcCs.td|}t|dƒ}|itƒ|S(NR sw+(toutput_dir_nametopentwritet file_header(t file_namet path_nametfile((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytopen_output_fileás cCs|itƒ|iƒdS(N(Rt file_trailertclose(R((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytclose_output_fileçs cCs4t|ƒd|d|id}tt|ƒdS(NsCOPY s FROM 's' (FORMAT 'binary')(RtnameRtquery(Rt table_nametsql((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcopy_output_file_directës cCs=tdtƒ}t|ƒotdƒ‚n|itƒ|idƒd|d}t||ƒ}t|ƒdjotdƒ‚n|i dƒ}x`t |ƒoRt ||t |ƒƒ}|d jotd t |ƒƒ‚n|i dƒ}q™Wt |dƒ}|d jotd t |ƒƒ‚nt|ƒdS( Ns dbname = s"COPY FROM STDIN PQconnectdb failedisCOPY s FROM STDIN (FORMAT 'binary')isCOPY FROM STDIN PQexec failediis,COPY FROM STDIN PQputCopyData failed, error s+COPY FROM STDIN PQputCopyEnd failed, error (t PQconnectdbtdbnametPQstatusRRRtseektPQexectPQresultStatustreadtlent PQputCopyDatatstrt PQputCopyEndtNonetPQfinish(RRtconnR trestdatatret((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcopy_output_fileñs(      cCs$|i}|iƒti|ƒdS(N(RRtostunlink(RR((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytremove_output_files  sevsel_table.binsmachine_table.binsthread_table.binscomm_table.binscomm_thread_table.bins dso_table.binssymbol_table.binsbranch_type_table.binssample_table.binscall_path_table.binscall_table.bincCsétiiƒGdGHtddƒtdddƒtdddddƒtddƒtdddddƒtddddddƒtdddddddddddddddddddddƒt ot ddddƒndS(Ns Writing to intermediate files...itunknowniÿÿÿÿt( tdatetimettodayt evsel_tablet machine_tablet thread_tablet comm_tablet dso_tablet symbol_tablet sample_tabletperf_db_export_callstcall_path_table(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyt trace_begins  FcCs°tiiƒGdGHttdƒttdƒttdƒttdƒttdƒttdƒtt dƒtt d ƒtt d ƒt ott d ƒttd ƒntiiƒGd GHttƒttƒttƒttƒttƒttƒtt ƒtt ƒtt ƒt ott ƒttƒntitƒtiiƒGdGHttdƒttdƒttdƒttdƒttdƒttdƒttdƒttdƒttdƒt ottdƒttdƒntiiƒGdGHttdƒttdƒttdƒttdƒttdƒt o+ttd ƒttd!ƒttd"ƒntotiiƒGd#GtGd$GHntiiƒGd%GHdS(&NsCopying to database...tselected_eventstmachinestthreadstcommst comm_threadstdsostsymbolst branch_typestsamplest call_pathsRsRemoving intermediate files...sAdding primary keyss0ALTER TABLE selected_events ADD PRIMARY KEY (id)s0ALTER TABLE machines ADD PRIMARY KEY (id)s0ALTER TABLE threads ADD PRIMARY KEY (id)s0ALTER TABLE comms ADD PRIMARY KEY (id)s0ALTER TABLE comm_threads ADD PRIMARY KEY (id)s0ALTER TABLE dsos ADD PRIMARY KEY (id)s0ALTER TABLE symbols ADD PRIMARY KEY (id)s0ALTER TABLE branch_types ADD PRIMARY KEY (id)s0ALTER TABLE samples ADD PRIMARY KEY (id)s0ALTER TABLE call_paths ADD PRIMARY KEY (id)s0ALTER TABLE calls ADD PRIMARY KEY (id)sAdding foreign keyss³ALTER TABLE threads ADD CONSTRAINT machinefk FOREIGN KEY (machine_id) REFERENCES machines (id),ADD CONSTRAINT processfk FOREIGN KEY (process_id) REFERENCES threads (id)s¸ALTER TABLE comm_threads ADD CONSTRAINT commfk FOREIGN KEY (comm_id) REFERENCES comms (id),ADD CONSTRAINT threadfk FOREIGN KEY (thread_id) REFERENCES threads (id)s`ALTER TABLE dsos ADD CONSTRAINT machinefk FOREIGN KEY (machine_id) REFERENCES machines (id)scALTER TABLE symbols ADD CONSTRAINT dsofk FOREIGN KEY (dso_id) REFERENCES dsos (id)s˜ALTER TABLE samples ADD CONSTRAINT evselfk FOREIGN KEY (evsel_id) REFERENCES selected_events (id),ADD CONSTRAINT machinefk FOREIGN KEY (machine_id) REFERENCES machines (id),ADD CONSTRAINT threadfk FOREIGN KEY (thread_id) REFERENCES threads (id),ADD CONSTRAINT commfk FOREIGN KEY (comm_id) REFERENCES comms (id),ADD CONSTRAINT dsofk FOREIGN KEY (dso_id) REFERENCES dsos (id),ADD CONSTRAINT symbolfk FOREIGN KEY (symbol_id) REFERENCES symbols (id),ADD CONSTRAINT todsofk FOREIGN KEY (to_dso_id) REFERENCES dsos (id),ADD CONSTRAINT tosymbolfk FOREIGN KEY (to_symbol_id) REFERENCES symbols (id)s¸ALTER TABLE call_paths ADD CONSTRAINT parentfk FOREIGN KEY (parent_id) REFERENCES call_paths (id),ADD CONSTRAINT symbolfk FOREIGN KEY (symbol_id) REFERENCES symbols (id)sALTER TABLE calls ADD CONSTRAINT threadfk FOREIGN KEY (thread_id) REFERENCES threads (id),ADD CONSTRAINT commfk FOREIGN KEY (comm_id) REFERENCES comms (id),ADD CONSTRAINT call_pathfk FOREIGN KEY (call_path_id) REFERENCES call_paths (id),ADD CONSTRAINT callfk FOREIGN KEY (call_id) REFERENCES samples (id),ADD CONSTRAINT returnfk FOREIGN KEY (return_id) REFERENCES samples (id),ADD CONSTRAINT parent_call_pathfk FOREIGN KEY (parent_call_path_id) REFERENCES call_paths (id)s5CREATE INDEX pcpid_idx ON calls (parent_call_path_id)s Warning: s unhandled eventstDone(R9R:R3t evsel_filet machine_filet thread_filet comm_filetcomm_thread_filetdso_filet symbol_filetbranch_type_filet sample_fileRBtcall_path_filet call_fileR6R4trmdirRRRtunhandled_count(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyt trace_end'sj                                      cCstd7adS(Ni(R\(t event_nametcontexttevent_fields_dict((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyttrace_unhandledwscGsdS(N((tx((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytsched__sched_switch{scGsOt|ƒ}dt|ƒd}ti|dd|||ƒ}ti|ƒdS(Ns!hiqiRii(R)R+tstructtpackRPR(tevsel_idt evsel_nameRbtntfmttvalue((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR;~s c GsUt|ƒ}dt|ƒd}ti|dd|d|||ƒ}ti|ƒdS(Ns!hiqiiiRiii(R)R+RdReRQR(t machine_idtpidtroot_dirRbRhRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR<„s $c GsAtiddd|d|d|d|d|ƒ }ti|ƒdS(Ns !hiqiqiqiiiiiii(RdReRRR(t thread_idRkt process_idRlttidRbRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR=Šs0cGsOt|ƒ}dt|ƒd}ti|dd|||ƒ}ti|ƒdS(Ns!hiqiRii(R)R+RdReRSR(tcomm_idtcomm_strRbRhRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR>Žs c Gs;d}ti|dd|d|d|ƒ}ti|ƒdS(Ns!hiqiqiqii(RdReRTR(tcomm_thread_idRqRnRbRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcomm_thread_table”s$c Gs•t|ƒ}t|ƒ}t|ƒ}dt|ƒdt|ƒdt|ƒd} ti| dd|d|||||||ƒ } ti| ƒdS(Ns!hiqiqitsiRii(R)R+RdReRUR( tdso_idRkt short_namet long_nametbuild_idRbtn1tn2tn3RiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR?™s    00c Gsgt|ƒ}dt|ƒd}ti|dd|d|d|d|d|||ƒ} ti| ƒdS(Ns !hiqiqiqiqiiiRiii(R)R+RdReRVR( t symbol_idRvt sym_starttsym_endtbindingt symbol_nameRbRhRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR@¡s 6cGsOt|ƒ}dt|ƒd}ti|dd|||ƒ}ti|ƒdS(Ns!hiiiRii(R)R+RdReRWR(t branch_typeRRbRhRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytbranch_type_table§s c-Gs$to|tiddd|d|d|d|d|d|d|d|d|d| d| d| d| d| d|d|d|ƒ$}n‘tiddd|d|d|d|d|d|d|d|d|d| d| d| d| d| d|d|d|d|d|d|d|ƒ,}ti|ƒdS(Ns$!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiiiBiiiis,!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiqiiiBi(RRdReRXR(t sample_idRfRkRnRqRvR}t sym_offsettipttimetcput to_dso_idt to_symbol_idt to_sym_offsettto_iptperiodtweightt transactiontdata_srcR‚tin_txRbRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyRA­s|c GsAd}ti|dd|d|d|d|ƒ }ti|ƒdS(Ns !hiqiqiqiqii(RdReRYR(tcp_idt parent_idR}R†RbRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyRC´s*c Gskd} ti| dd|d|d|d|d|d|d|d|d|d| d| ƒ} ti| ƒdS(Ns!hiqiqiqiqiqiqiqiqiqiqiii ii(RdReRZR(tcr_idRnRqt call_path_idt call_timet return_timet branch_counttcall_idt return_idtparent_call_path_idtflagsRbRiRj((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcall_return_table¹sT(sallsbranches(SR4RRdR9t PySide.QtSqltctypestCDLLtlibpqR"tc_void_ptrestypeR.R$R&R'R*tc_inttargtypesR,tpathtappendtenvirontTruetperf_db_export_modetFalseRBRR)targvR#tcolumnsRtgetcwdRtmkdirRR:t QSqlDatabaset addDatabasetdbt QSqlQueryRtsetDatabaseNameRR[tfinishtclearRReRRRRR!R3R6RPRQRRRSRTRURVRWRXRYRZRDR\R]RaRcR;R<R=R>RtR?R@RƒRARCR(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyt sÒ                                                                 P