403 Forbidden


Disable Functions:
Path : /usr/libexec/perf-core/scripts/python/
File Upload :
Command :
Current File : //usr/libexec/perf-core/scripts/python/export-to-postgresql.pyc

�
G��dc@s�ddlZddlZddlZddlZddlTddlTed�ZejZe	e_
ege_ej
Z
e	ge
_ejZee_
e	ge_ejZe	e_
e	ege_ejZee_
e	ge_ejZee_
e	e	ege_ejZee_
e	e	ge_ejjejdd�eZeZeZd�Zeej�dkrze�nejdZeej�d	kr�ejdZ nd
Z e dMkr�e�ne dkZ!x_e"d	eej��D]EZ#eje#dkreZq�eje#d
kr+eZq�e�q�Wej$�dedZ%ej&e%�d�Z'ejj(�GdGHe)j*d�Z+e,e+�Z-e+j.d�e+j/�ye'e-de�Wnej0e%��nXe-j1�e-j2�e+j3�e+j.e�e+j/�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�e!r�e'e-d�n
e'e-d�es�er�e'e-d �ner�e'e-d!�ne'e-d"�e'e-d#�e'e-d$�e'e-d%�e'e-d&�es/er?e'e-d'�nerUe'e-d(�ne'e-d)�ej4d*d+d,d,�Z5d-Z6d.�Z7d/�Z8d0�Z9d1�Z:d2�Z;e7d3�Z<e7d4�Z=e7d5�Z>e7d6�Z?e7d7�Z@e7d8�ZAe7d9�ZBe7d:�ZCe7d;�ZDes%er4e7d<�ZEnerIe7d=�ZFnd>�ZGd,aHd?�ZId@�ZJdA�ZKdB�ZLdC�ZMdD�ZNdE�ZOdF�ZPdG�ZQdH�ZRdI�ZSdJ�ZTdK�ZUdL�ZVdS(Ni����N(t*s
libpq.so.5tPERF_EXEC_PATHs./scripts/python/Perf-Trace-Util/lib/Perf/TracecCsDtjdIJtjdIJtjdIJtjdIJtd��dS(NsVUsage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>]s#where:	columns		'all' or 'branches's5		calls		'calls' => create calls and call_paths tables4		callchains	'callchains' => create call_paths tablesToo few arguments(tsyststderrt	Exception(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytusage�s




iiitalltbranchestcallst
callchainst/s
-perf-datacCs3|j|�rdStd|j�j���dS(NsQuery failed: (texec_Rt	lastErrorttext(tqts((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytdo_queryssCreating 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))sCCREATE 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,call_path_id	bigint)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,period		bigint,weight		bigint,transaction	bigint,data_src	bigint,branch_type	integer,in_tx		boolean,call_path_id	bigint)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 machines_view AS SELECT id,pid,root_dir,CASE WHEN id=0 THEN 'unknown' WHEN pid=-1 THEN 'host' ELSE 'guest' END AS host_or_guest FROM machiness�CREATE VIEW dsos_view AS SELECT id,machine_id,(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,short_name,long_name,build_id FROM dsoss�CREATE VIEW symbols_view AS SELECT id,name,(SELECT short_name FROM dsos WHERE id=dso_id) AS dso,dso_id,sym_start,sym_end,CASE WHEN binding=0 THEN 'local' WHEN binding=1 THEN 'global' ELSE 'weak' END AS binding FROM symbolss�CREATE VIEW threads_view AS SELECT id,machine_id,(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,process_id,pid,tid FROM threadss�CREATE VIEW comm_threads_view AS SELECT comm_id,(SELECT comm FROM comms WHERE id = comm_id) AS command,thread_id,(SELECT pid FROM threads WHERE id = thread_id) AS pid,(SELECT tid FROM threads WHERE id = thread_id) AS tid FROM comm_threadssjCREATE VIEW call_paths_view AS SELECT c.id,to_hex(c.ip) AS ip,c.symbol_id,(SELECT name FROM symbols WHERE id = c.symbol_id) AS symbol,(SELECT dso_id FROM symbols WHERE id = c.symbol_id) AS dso_id,(SELECT dso FROM symbols_view  WHERE id = c.symbol_id) AS dso_short_name,c.parent_id,to_hex(p.ip) AS parent_ip,p.symbol_id AS parent_symbol_id,(SELECT name FROM symbols WHERE id = p.symbol_id) AS parent_symbol,(SELECT dso_id FROM symbols WHERE id = p.symbol_id) AS parent_dso_id,(SELECT dso FROM symbols_view  WHERE id = p.symbol_id) AS parent_dso_short_name FROM call_paths c INNER JOIN call_paths p ON p.id = c.parent_idsaCREATE VIEW calls_view AS SELECT calls.id,thread_id,(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,call_path_id,to_hex(ip) AS ip,symbol_id,(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,call_time,return_time,return_time - call_time AS elapsed_time,branch_count,call_id,return_id,CASE WHEN flags=1 THEN 'no call' WHEN flags=2 THEN 'no return' WHEN flags=3 THEN 'no call/return' ELSE '' END AS flags,parent_call_path_id FROM calls INNER JOIN call_paths ON call_paths.id = call_path_ids�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!11siisPGCOPY
�
is��cCs.td|}t|d�}|jt�|S(NR
sw+(toutput_dir_nametopentwritetfile_header(t	file_namet	path_nametfile((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytopen_output_file�s
cCs|jt�|j�dS(N(Rtfile_trailertclose(R((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytclose_output_files
cCs4t|�d|d|jd}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_directs
cCs3tdt�}t|�r+td��n|jt�|jd�d|d}t||�}t|�dkr�td��n|j	d�}x\t
|�r�t||t
|��}|d	kr�td
t|���n|j	d�}q�Wt
|d�}|d	kr%tdt|���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 (tPQconnectdbtdbnametPQstatusRRRtseektPQexectPQresultStatustreadtlent
PQputCopyDatatstrtPQputCopyEndtNonetPQfinish(RR tconnR!trestdatatret((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcopy_output_files&

cCs$|j}|j�tj|�dS(N(RRtostunlink(RR((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytremove_output_file#s	
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�tjj�GdGHtdd�tddd�tddddd�tdd�tddddd�tdddddd�tdddddddddddddddddddddd�t	s�t
r�tdddd�ndS(Ns Writing to intermediate files...itunknowni����t(tdatetimettodaytevsel_tablet
machine_tabletthread_tablet
comm_tablet	dso_tabletsymbol_tabletsample_tabletperf_db_export_callstperf_db_export_callchainstcall_path_table(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyttrace_begin6s

IcCs�tjj�GdGHttd�ttd�ttd�ttd�ttd�ttd�tt	d�tt
d	�ttd
�ts�t
r�ttd�ntr�ttd�ntjj�Gd
GHtt�tt�tt�tt�tt�tt�tt	�tt
�tt�ts1t
r>tt�ntrQtt�ntjt�tjj�GdGHttd�ttd�ttd�ttd�ttd�ttd�ttd�ttd�ttd�ts�t
rttd�ntrttd�ntjj�GdGHttd�ttd�ttd�ttd�ttd�tsvt
r�ttd �ntr�ttd!�ttd"�ntr�tjj�Gd#GtGd$GHntjj�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(R:R;R4t
evsel_filetmachine_filetthread_filet	comm_filetcomm_thread_filetdso_filetsymbol_filetbranch_type_filetsample_fileRCRDtcall_path_filet	call_fileR7R5trmdirRRRtunhandled_count(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyt	trace_endEsr


































	
cCstd7adS(Ni(R^(t
event_nametcontexttevent_fields_dict((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyttrace_unhandled�scGsdS(N((tx((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytsched__sched_switch�scGsOt|�}dt|�d}tj|dd|||�}tj|�dS(Ns!hiqiRii(R*R,tstructtpackRRR(tevsel_idt
evsel_nameRdtntfmttvalue((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR<�sc	GsUt|�}dt|�d}tj|dd|d|||�}tj|�dS(Ns!hiqiiiRiii(R*R,RfRgRSR(t
machine_idtpidtroot_dirRdRjRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR=�s$c
GsAtjddd|d|d|d|d|�}tj|�dS(Ns!hiqiqiqiiiiiii(RfRgRTR(t	thread_idRmt
process_idRnttidRdRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR>�s0cGsOt|�}dt|�d}tj|dd|||�}tj|�dS(Ns!hiqiRii(R*R,RfRgRUR(tcomm_idtcomm_strRdRjRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR?�sc	Gs;d}tj|dd|d|d|�}tj|�dS(Ns!hiqiqiqii(RfRgRVR(tcomm_thread_idRsRpRdRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcomm_thread_table�s$c
Gs�t|�}t|�}t|�}dt|�dt|�dt|�d}	tj|	dd|d|||||||�}
tj|
�dS(Ns!hiqiqitsiRii(R*R,RfRgRWR(tdso_idRmt
short_namet	long_nametbuild_idRdtn1tn2tn3RkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyR@�s00c
Gsgt|�}dt|�d}tj|dd|d|d|d|d|||�}	tj|	�dS(Ns
!hiqiqiqiqiiiRiii(R*R,RfRgRXR(
t	symbol_idRxt	sym_starttsym_endtbindingtsymbol_nameRdRjRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyRA�s6cGsOt|�}dt|�d}tj|dd|||�}tj|�dS(Ns!hiiiRii(R*R,RfRgRYR(tbranch_typeRRdRjRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytbranch_type_table�sc/Gs.tr�tjddd|d|d|d|d|d|d|d|d|d|	d|
d|d|d|
d|d|d|d|�&}n�tjddd|d|d|d|d|d|d|d|d|d|	d|
d|d|d|
d|d|d|d|d|d|d|d|�.}tj|�dS(Ns&!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiiiBiqiiiis.!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiqiiiBiqi(RRfRgRZR(t	sample_idRhRmRpRsRxRt
sym_offsettipttimetcput	to_dso_idtto_symbol_idt
to_sym_offsettto_iptperiodtweightttransactiontdata_srcR�tin_txtcall_path_idRdRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyRB�s��cGsAd}tj|dd|d|d|d|�
}tj|�dS(Ns
!hiqiqiqiqii(RfRgR[R(tcp_idt	parent_idRR�RdRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyRE�s*cGskd}tj|dd|d|d|d|d|d|d|d|d|d|	d|
�}
tj|
�dS(Ns!hiqiqiqiqiqiqiqiqiqiqiiiii(RfRgR\R(tcr_idRpRsR�t	call_timetreturn_timetbranch_counttcall_idt	return_idtparent_call_path_idtflagsRdRkRl((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pytcall_return_table�sT(sallsbranches(WR5RRfR:tPySide.QtSqltctypestCDLLtlibpqR#tc_void_ptrestypetc_char_ptargtypesR/R%tc_intR'R(R+R-tpathtappendtenvirontTruetperf_db_export_modetFalseRCRDRR*targvR$tcolumnsRtrangetitgetcwdRtmkdirRR;tQSqlDatabasetaddDatabasetdbt	QSqlQueryRtsetDatabaseNameRR]tfinishtclearRRgRRRRR"R4R7RRRSRTRURVRWRXRYRZR[R\RFR^R_RcReR<R=R>R?RvR@RAR�RBRER�(((s=/usr/libexec/perf-core/scripts/python/export-to-postgresql.pyt<module>
s�

														


		
	























	
						
	T												

404 Not Found
[ LogOut ]