
    Xh                         d dl Z d dlZd dlZd dlZddlmZmZmZ ddlm	Z	 d dl
Z
d Zd ZddZddZd	 Zd
 Zd Zedk    r e             dS dS )    N   )startfinalize_select_backend)set_command_linec            	      P   t          j        ddt           j                  } |                     ddt          d           |                     dd	t          d
d g d           |                     ddt          ddddg           |                     ddt          dddg           |                     ddt          dd d dg           |                     ddt          dd d dg           |                     dt           j        d            |                                 }||j        fS )!NzBThe proton command utility for profiling scripts and pytest tests.z
    proton [options] script.py [script_args] [script_options]
    proton [options] pytest [pytest_args] [script_options]
    python -m triton.profiler.proton [options] script.py [script_args] [script_options]
)descriptionusageformatter_classz-nz--namezName of the profiling session)typehelpz-bz	--backendzProfiling backend)cupticupti_pcsampling	roctracer)r   r   defaultchoicesz-cz	--contextzProfiling contextshadowpythonz-dz--datazProfiling datatreez-kz--hookzProfiling hooktritonz-iz--instrumentzInstrumentation analysis typeprint-mem-spacestarget_argszSubcommand and its arguments)nargsr   )argparseArgumentParserRawTextHelpFormatteradd_argumentstr	REMAINDER
parse_argsr   )parserargss     h/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/triton/profiler/proton.pyparse_argumentsr$   
   sq   $X a 24 4 4F hS7VWWW
k:MW[ J J J  L L L
k:MW_!)8 4  6 6 6
hS7GQWbhaijjj
hS7GQU`dfn_oppp
n3=\fj!%'9 :  < < <
X-?FdeeeD!!!    c                 H    t           j                            |           dk    S )Npytest)ospathbasename)scripts    r#   	is_pytestr,      s    7F##x//r%   c                    t           j                            |           }ddd|dt          t          j        t          i}t          j        }| g|z   t          _        t          j                            t           j                            |                     t           j                            t          j
                  }|dk    rot          t          t          j        |                              d          d                     }dt           j        d<   d	t           j        d
<   |t           j        d<   	 t#          |d          5 }t%          |                                |d          }	d d d            n# 1 swxY w Y   t)          |	|           n)# t*          $ r}
t-          d|
            Y d }
~
nd }
~
ww xY w|t          _        d S # |t          _        w xY w)N__name____main____file____builtins__r   zlibPrintLoadStoreMemSpaces.so1TRITON_ALWAYS_COMPILE0TRITON_DISABLE_LINE_INFOLLVM_PASS_PLUGIN_PATHrbexecz.An error occurred while executing the script: )r(   r)   abspathr1   sysr.   argvappenddirnamer   r0   r   nextpathlibPathrglobenvironopencompilereadr8   	Exceptionprint)r+   r"   instrumentation_passscript_pathclean_globalsoriginal_argvtop_level_triton_pathinstrumentation_pass_pathfilecodees              r#   execute_as_mainrQ   #   s   '//&))K 	JKc	M HMx$CHHOOBGOOK00111GOOFO<<111$'344::;Z[[]abb%d %d!.1
*+14
-..G
*+!+t$$ 	=499;;V<<D	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=T=!!!! D D DBqBBCCCCCCCCD !=    sT   5F $E5)F 5E99F <E9=F G 
F7F2-G 2F77G Gc                     t                       | d         }t          |           dk    r
| dd          ng }t          |          rdd l}|                    |           d S t          |||           d S )Nr   r   )r   lenr,   r'   mainrQ   )r   rH   r+   script_argsr'   s        r#   do_setup_and_executerV   E   s    ^F%(%5%5%9%9+abb//rK CK     -ABBBBBr%   c                     | j         r| j         nt                      }t          | j        | j        | j        || j                   t          |           t                       d S )N)contextdatabackendhook)	rZ   r   r   namerX   rY   r[   rV   r   )r"   r   rZ   s      r#   run_profilingr]   R   sX    "lAdll0A0AG	$)T\	7QUQZ[[[[%%%JJJJJr%   c                 0    t          || j                   d S N)rV   
instrumentr"   r   s     r#   run_instrumentationrb   \   s    do66666r%   c                  z    t                      \  } }| j        rt          | |           d S t          | |           d S r_   )r$   r`   rb   r]   ra   s     r#   rT   rT   `   sG    '))D+ D+...$$$$$$r%   r/   r_   )r   r:   r(   r?   profiler   r   r   flagsr   r   r$   r,   rQ   rV   r]   rb   rT   r.    r%   r#   <module>rg      s     



 				  5 5 5 5 5 5 5 5 5 5 # # # # # # " " "*0 0 0! ! ! !D
C 
C 
C 
C  7 7 7% % % zDFFFFF r%   