403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /Python315/Lib/profiling/sampling/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Python315/Lib/profiling/sampling/__pycache__/cli.cpython-315.opt-1.pyc
R
>lqj�c��Qs]PHs]PHs]PHs]PHs]PHs]PHs]PH s]PH$s	]PH(s
]PH,s]PH0s]QH4Gs]QH<GsGsGs]QHLGsGsGsGs]QH\Gs]QHdGs]QHlGsGsGs]QH|G s ]QH�G"s"]Q	H�G$s$]Q
H�G&s&]QH�G(s(]QH�G*s*G+s+G,s,G-s-G.s.G/s/G0s0G1s1G2s2G3s3G4s4G5s5]Q
H�G7s7]QH�G:s:QQ\Ov\Ox2s=QQ\O|2s?Qs@QsAQsBQsCQsD]@sEQEsFQQQQQQQQQQQ QQ!Q!Q"Q#-sGQ\Q\Q\Q\Q\"Q \ Q!\$Q"\&-sHQFsIQ$sJQ%sKQ&sLQ'sMQ(sNQ)sOQ*sPQGQ+ksQ\O�Q,\O�\O�*2sUQ-Q.ksVQ/sWQ0sXQHQ1ksYQ2sZQ3s[Q4s\QIQ5ks]Q6s^Q7s_Q8s`Q9saQ:sbQ;scQ<sdQ=seQ>sfQ?sgQ@shQAsiQBsjQCsk\lQD6Xc
\d2P!P!\8cPs7CKh9h\8cPs:CK(h9h)Jz1Command-line interface for the sampling profiler.)�nullcontext)�SamplingUnknownProcessError�SamplingModuleNotFoundError�SamplingScriptNotFoundError)�sample�sample_live�
dump_stack�_is_process_running)�print_stack_dump)�PstatsCollector)�CollapsedStackCollector�FlamegraphCollector�DiffFlamegraphCollector)�HeatmapCollector)�GeckoCollector)�JsonlCollector)�BinaryCollector)�BinaryReader)�MICROSECONDS_PER_SECOND�PROFILING_MODE_ALL�PROFILING_MODE_WALL�PROFILING_MODE_CPU�PROFILING_MODE_GIL�PROFILING_MODE_EXCEPTION�SORT_MODE_NSAMPLES�SORT_MODE_TOTTIME�SORT_MODE_CUMTIME�SORT_MODE_SAMPLE_PCT�SORT_MODE_CUMUL_PCT�SORT_MODE_NSAMPLES_CUMUL)�ChildProcessMonitor)�LiveStatsCollectorc��\sQs]5sQsQsP!)�CustomFormatterzVCustom formatter that combines default values display with raw description formatting.�)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r#��+C:\Python315\\Lib\profiling\sampling\cli.pyr"r"5s��a�r*r"c�0`�\sQs]=snQsQQksQsUsP!)�DiffFlamegraphActionzLCustom action for --diff-flamegraph that sets both format and baseline path.c�"�QUmV2mP!)�diff_flamegraph��format�
diff_baseline)�self�parser�	namespace�values�
option_strings&&&&&r+�__call__�DiffFlamegraphAction.__call__?s��,�	��"(�r*r#)N)r$r%r&r'r(r8r)�__classdictcell__)�
__classdict__s@r+r-r-=s����V�)�)r*r-aUSample a process's stack frames and generate profiling data.

Examples:
  # Run and profile a script
  `python -m profiling.sampling run script.py arg1 arg2`

  # Attach to a running process
  `python -m profiling.sampling attach 1234`

  # Dump a running process's current stack
  `python -m profiling.sampling dump 1234`

  # Live interactive mode for a script
  `python -m profiling.sampling run --live script.py`

  # Live interactive mode for a running process
  `python -m profiling.sampling attach --live 1234`

Use `python -m profiling.sampling <command> --help` for command-specific help.g@g@sready��pstats�	collapsed�txt�
flamegraph�htmlr/�gecko�json�heatmap�jsonl�binary�binc�L�[U2o[U2o[UUUQ5!))�pid�cli_args�output_pattern)�_build_child_profiler_args�_build_output_patternr)�args�
parent_pid�child_cli_argsrKs&&  r+�_setup_child_monitorrQ{s.��/��5�N�+�4�0�N����%��r*c�T�[UQP
2%c[V2![2!)�subprocesses)�getattrrQr)rNrIs&&r+�_get_child_monitor_contextrU�s$���t�^�U�+�+�#�D�.�.��=�r*c���,o[UO*oUOQ[U2,2UOd'UOQ[UO2,2UO
%cUO
Q2UO%cUO
Q2UO%cUO
Q2UO%fUO
Q2UO%cUO
Q2UO%c9UO
Q2[UQQ	2oUQ	6wcUOQ
U,2[UQQ2oUQ6wcUOQ
U,2UOQ6Xc UOQUO,2U!UOQ6wcUO
QUO02U!)�-r�-d�-a�--realtime-stats�--native�--no-gc�	--opcodes�
--async-aware�
async_mode�running�--async-mode�mode�wall�--moder/�--diff-flamegraphr=�--)r�sample_interval_usec�extend�str�duration�all_threads�append�realtime_stats�native�gc�opcodes�async_awarerTr1r2)rN�
child_args�hzr_rbs&    r+rLrL�s����J�
!�D�$=�$=�	=�B����t�S��W�o�&��}�}� ����4��T�]�]�!3�4�5��������$���������,�-��{�{�{����*�%��7�7�7����)�$��|�|�|����+�&��������/�*��T�<��;�
���"����~�z�:�;��4���(�D��v�~����8�T�*�+��{�{�'�'����.��0B�0B�C�D���
����	 ����B�t�{�{�m�,�-��r*c�h�UO%cJ[OOUO2vqU%cUQU0!UOQ0![OUOQ2oUOQ6XcQ!UOQ6XcQ!UOQU0!)z�Build output filename pattern for child profilers.

The pattern uses {pid} as a placeholder which will be replaced with the
actual child PID using str.replace(), so user filenames with braces are safe.
z_{pid}r?rDz
heatmap_{pid}r=zprofile_{pid}.pstatsz_{pid}.)�outfile�os�path�splitext�FORMAT_EXTENSIONS�getr1)rN�base�ext�	extensions&   r+rMrM�s����|�|�|��G�G�$�$�T�\�\�2�	����V�8�C�5�)�)��l�l�^�8�,�,�&�)�)�$�+�+�u�=�	��;�;�)�#�"��;�;�(�"�)��+�+��i�	�{�3�3r*c�H�Q[Q[Q[Q[-oV*!)z%Convert mode string to mode constant.rc�cpu�gil�	exception)rrrr)�mode_string�mode_maps& r+�_parse_moder��s.��	�#�
�!�
�!��-�	�H�� � r*c�F�UO2eP!PoUO%c8UOO2O2O	2oU%c[U2g[QUO02g[
[1cK>h9h)zBCheck if process died and raise an error with stderr if available.zProcess exited with code )	�poll�stderr�read�decode�strip�OSError�UnicodeDecodeError�RuntimeError�
returncode)�process�
stderr_msgs& r+�_check_process_diedr��s����|�|�~����J��~�~�~�	� ���,�,�.�5�5�7�=�=�?�J���:�&�&�
�2�7�3E�3E�2F�G�
H�H���+�,�	��	�s�6B�B �B �B c��[O2U*o[O2oUO	U[O
2[
U2U[O2*
oU]6:c[OQ2gUO[QU2Q5%fJiUO2vqgUO[2oUO2U[6wc[!QU802gUO2P!SO2h9hSO2h9h)zHWait for the ready signal from the subprocess, checking for early death.z	timed outg�������?��timeoutzInvalid ready signal received: )�time�	monotonic�	selectors�DefaultSelector�register�
EVENT_READr��socketr��select�min�accept�recv�_RECV_BUFFER_SIZE�close�_READY_MESSAGEr�)	�	sync_sockr�r��deadline�sel�	remaining�conn�_�ready_signals	&&&      r+�_wait_for_ready_signalr��s����~�~��'�)�H�
�
#�
#�
%�C��L�L��I�0�0�1�����(� �4�>�>�#3�3�I��A�~��n�n�[�1�1��:�:�c�#�y�&9�:�:�:���&�&�(�G�D�
�#�y�y�):�;���
�
���~�-�"�%D�\�DT�#U�V�V���	�	���
�
�
���	�	�	��s6�.D7�7D7�;D7�D"�%D7�D7�"D4�4D7�7E	c�X�[O[O[O29^tt^2oUO[O[O
]2UO
Q	2UO2]*oUO]2UO[2[O2oUQ*o[OQQ[U2U1[!U2*o-oU%c:["O$UQ$["O$UQ$["O&UQ$["O(U1-U@o[+V([2UttPPP2![O,c�SO/2edSO12SO3[4Q5L;["O6c$SO92SO32Lh9h[;Q2gh9h)%fhP!9h)
zGRun a command with socket-based synchronization and return the process.:�NN�-mz$profiling.sampling._sync_coordinator�stdin�stdoutr�r�z1Process failed to signal readiness within timeout)z	127.0.0.1�)r��AF_INET�SOCK_STREAM�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�bind�getsockname�listen�
settimeout�_SYNC_TIMEOUT_SECrv�getcwd�sys�
executableri�tuple�
subprocess�DEVNULL�PIPE�Popenr�r�r��	terminate�wait�_PROCESS_KILL_TIMEOUT_SEC�TimeoutExpired�killr�)	�original_cmd�suppress_outputr��	sync_port�cwd�target_args�cmd�popen_kwargsr�s	&&       r+�_run_with_syncr�s���
���v�~�~�v�'9�'9�	:�	:�i����V�.�.��0C�0C�Q�G����'�(��)�)�+�A�.�	���������.�/��i�i�k��#�2�&���N�N��2��	�N��
�
�+��
�����$.�$6�$6�L��!�%/�%7�%7�L��"�%/�_�_�L��"��"�"�3�7�,�7��
	�"�9�7H�I��c
;�	:��H�~�~�	��|�|�~�%��!�!�#�#��L�L�)B�L�C��!�0�0�#��L�L�N��L�L�N�#���C��
�	��I
;�	:�	:�sg�CH�AH�#E?�3H�?H�H�&H�7G�
H�H	�"!H	�H�H	�H�H�H)	�!H)	al
      ^                   # Start of string
      (                   # Group 1: The numeric value
          \d+             #   One or more digits (integer part)
          (?:\.\d+)?      #   Optional: decimal point followed by digits
      )                   #   Examples: "10", "0.5", "100.25"
      (                   # Group 2: Optional unit suffix
          hz              #   "hz" - hertz
          | khz           #   "khz" - kilohertz
          | k             #   "k" - shorthand for kilohertz
      )?                  #   Suffix is optional (bare number = Hz)
      $                   # End of string
  c�2�U]6�cPgQ[Q[-!)��rate_str�return)ri�int)r1s"r+�__annotate__�!_parse_sampling_rate.__annotate__Ns����3��3�r*c��UO2O2o[OU2oU%f[O
QUQ02gUO
]2oUO
]29%fPoQ]QQQQ-oUOU]2o[U2U*oU]6:c[O
QU02g[[U*2oU]6c[O
QU02gU!)	z+Parse sampling rate string to microseconds.zInvalid sampling rate format: zX. Expected: number followed by optional suffix (hz, khz, k) with no spaces (e.g., 10khz)rs�khz���kz Sampling rate must be positive: zSampling rate too high: )r��lower�
_RATE_PATTERN�match�argparse�ArgumentTypeError�grouprz�floatr�r)r�r��number_part�suffix�
suffix_map�
multiplierrs�
interval_usecs&       r+�_parse_sampling_rater�Ns���~�~��%�%�'�H�����)�E���(�(�,�X�J�7e�
e�
�	
�
�+�+�a�.�K�
�[�[��^�
!�
!�r�F�	
�a�
�t��T��J�
�����*�J�	�{�	�j�	(�B�	�Q�w��(�(�+K�H�:�)V�W�W��/�"�4�5�M��q���(�(�+C�H�:�)N�O�O��r*c
���UOQ2oUOQQ[QQQQQ5UOQ	Q
[PQQQ
5UOQQQQQ5UOQQQQ5UOQQQQ5UOQQQQQ5UOQQQQ5UOQQQQ5UOQ QQ!Q5UOQ"QQ#Q5P!)$z/Add sampling configuration options to a parser.zSampling configurationrWz--sampling-rate�1khz�RATErgz'sampling rate (e.g., 10000, 10khz, 10k))�type�default�metavar�dest�helprXz
--duration�SECONDSz.Sampling duration (default: run to completion))r�r�r�r�rY�
--all-threads�
store_truezASample all threads in the process instead of just the main thread��actionr�rZzIPrint real-time sampling statistics (Hz, mean, min, max) during profilingr[�GInclude artificial `<native>` frames to denote calls to non-Python coder\�store_falsero�JDon't include artificial `<GC>` frames to denote active garbage collection�r�r�r�r]z�Gather bytecode opcode information for instruction-level profiling (shows which bytecode instructions are executing, including specializations).r^zCEnable async-aware profiling (uses task-based stack reconstruction)z--subprocesseszQAlso profile subprocesses. Each subprocess gets its own profiler and output file.�
--blockingz�Stop all threads in target process before sampling to get consistent snapshots. Uses thread_suspend on macOS and ptrace on Linux. Adds overhead but ensures memory reads are from a frozen state.)�add_argument_group�add_argumentr�r�)r4�sampling_groups& r+�_add_sampling_optionsr�ns]���.�.�/G�H�N������
!���
#�
6� �������
���
=�
 ��������
P�	 �������
X� ��
�����
V� ��
�����
�
Z�	 �������X� �������
R� ��
�����
`� ��
�����)� �r*c��UOQ2oUOQ,Q
NQQQ5UOQQQ,QQ	Q5P!)zAdd mode options to a parser.zMode optionsrdrcz�Sampling mode: wall (all samples), cpu (only samples when thread is on CPU), gil (only samples when thread holds the GIL), exception (only samples when thread has an active exception). Incompatible with `--async-aware`��choicesr�r�rar`�allztAsync profiling mode: "running" (only running task) or "all" (all tasks including waiting). Requires `--async-aware`)rcrr�r�)r�r�)r4�
mode_groups& r+�_add_mode_optionsr�s\���*�*�>�:�J�����3��,�	�������E�"��K�	�r*c	��UOQ2oUO2oUOQQQQQQ5UOQQQ	QQ
Q5UOQQQQQ
Q5UOQQQQQQ5UOQQQQQQ5UOQQ[QQ5UOQQQQQQ5U%cUOQQQQQQ5UO	QPQ5U%cUOQ,Q/NQ Q!Q"5UOQ#Q$Q%Q&Q'5UOQ(Q)Q*Q+OQ,[22Q-0Q.5P!)0z&Add output format options to a parser.zOutput optionsz--pstats�store_constr=r1z Generate pstats output (default))r��constr�r�z--collapsedr>z/Generate collapsed stack traces for flamegraphsz--flamegraphr@z2Generate interactive HTML flamegraph visualizationz--geckorBz*Generate Gecko format for Firefox Profilerz	--heatmaprDzMGenerate interactive HTML heatmap visualization with line-level sample countsre�BASELINEzTGenerate differential flamegraph comparing current profile to `BASELINE` binary file)r�r�r�z--jsonlrEzBGenerate newline-delimited JSON (JSONL) for programmatic consumers�--binaryrFzIGenerate high-performance binary format (use `replay` command to convert)r0z
--compression�autozGCompression for binary format: auto (use zstd if available), zstd, noner�z-oz--outputruz�Output path (default: `stdout` for `pstats` text; with `-o`, `pstats` is binary). Auto-generated for other formats. For heatmap: directory name (default: `heatmap_PID`))r�r�z	--browserr�z Automatically open HTML output (�, c3�`�SF �DoQUOQQ2*w�	J!	P!3h)rfr��-)�replace��.0�fs& r+�	<genexpr>�&_add_format_options.<locals>.<genexpr>s&��>X���>X��$����3��!4�4�4�>X�s�'.zR) in browser. When using `--subprocesses`, only the main process opens the browserr�)r	�zstd�none)r��add_mutually_exclusive_groupr�r-�set_defaults�join�BROWSER_COMPATIBLE_FORMATS)r4�include_compression�include_binary�output_group�format_groups&&&  r+�_add_format_optionsr�s����,�,�-=�>�L��<�<�>�L�������
�
/���������
�
>���������
�
A���������
�
9���������
�
\��������#�
c�	��������
�
Q�����!�!�� ���\�	"�	
����x�t��<���!�!��,��Z�		"�	
������
�a�	�������
��	�	�Y�>X�Y�Y�Z�[S�
S�	�	r*c��UOQ2oUOQ,Q
NPQQ5UOQQ[PQQ5UOQ	Q
QQ5P!)z0Add pstats-specific display options to a parser.zpstats format options�--sortz0Sort order for pstats output (default: nsamples)r�z-l�--limitz4Limit the number of rows in the output (default: 15))r�r�r��--no-summaryr�z0Disable the summary section in the pstats outputr�)�nsamples�tottime�cumtime�
sample-pct�	cumul-pct�nsamples-cumul�name)r�r�r�)r4�pstats_groups& r+�_add_pstats_optionsr*sx���,�,�-D�E�L�����
��
?��
������
��
C��������
?��r*c�h�UOQ2oUOQQQQQ5UOQQQQ5UOQ	Q
QQQ
5UOQQQQ5UOQQQQ5UOQQQ,[OQQ5UOQQQQ5P!)z,Add one-shot stack dump options to a parser.zDump optionsrYr�r�z?Dump all threads in the process instead of just the main threadr�r[r�r\r�ror�r�r]z*Show bytecode opcode names when available.r^z'Enable async-aware stack reconstructionrar`rz�Async stack mode: "running" (only running task) or "all" (all tasks including waiting, default for dump). Requires `--async-aware`r�r�z<Stop all threads in target process before dumping the stack.)r�r�r��SUPPRESS)r4�
dump_groups& r+�_add_dump_optionsr.>s����*�*�>�:�J�������
N�	�������
V���
�����
�
Z�	�������
9���
�����
6���
�����E�"��!�!�#�	�������
K��r*c��Q[Q[Q[Q[Q[Q[
QP-oUO
U[2!)z1Convert sort choice string to SORT_MODE constant.r"r#r$r%r&r'r()rrrrrrrz)�sort_choice�sort_maps& r+�
_sort_to_moder2ksH��	�&��$��$��*��(��2����H��<�<��%7�8�8r*c��[OU2oUe[QU02gUQ6XcNUe[Q2g[OOU2%f[QU02gUUUUQ5!UQ6XcUe[Q2gUVQUUQ5!UQ	6Xc
P
oUVUQ
5!UQ6XcUVUQ5!UVQ
5!)aCreate the appropriate collector based on format type.

Args:
    format_type: The output format ('pstats', 'collapsed', 'flamegraph',
                'gecko', 'heatmap', 'jsonl', 'binary', 'diff_flamegraph')
    sample_interval_usec: Sampling interval in microseconds
    skip_idle: Whether to skip idle samples
    opcodes: Whether to collect opcode information (only used by gecko format
             for creating interval markers in Firefox Profiler)
    mode: Profiling mode for collectors that expose it in metadata
    output_file: Output file path (required for binary format)
    compression: Compression type for binary format ('auto', 'zstd', 'none')
    diff_baseline: Path to baseline binary file for differential flamegraph

Returns:
    A collector instance of the appropriate type
zUnknown format: r/z0Differential flamegraph requires a baseline filezBaseline file not found: )�baseline_binary_path�	skip_idlerFz%Binary format requires an output file)r5�compressionrB)r5rprE)r5rb)r5)�
COLLECTOR_MAPrz�
ValueErrorrvrw�exists)	�format_typergr5rprb�output_filer6r2�collector_classs	&&&&&&&& r+�_create_collectorr=xs���($�'�'��4�O����+�K�=�9�:�:��'�'�� ��O�P�P��w�w�~�~�m�,�,��8���H�I�I�� �!.��
�	
��h�����D�E�E��{�I�*5�7�	7�
�g���	��3�RY�Z�Z��g��� �D�
�	
��/�E�Er*c�\�[OUQ2oUQ6XcQU0!UQUQU0!)z�Generate output filename based on format and PID.

Args:
    format_type: The output format
    pid: Process ID

Returns:
    Generated filename
r?rD�heatmap_r��.)ryrz)r:rIr}s&& r+�_generate_output_filenamerA�sB��"�%�%�k�5�9�I��i���#�����]�!�C�5��)��-�-r*c��[OOU2o[OOU2%ci[OO	UQ2o[OOU2%cSoL [
QU0[OQ5P!QU0o[OU2P![c*o[
QS0[OQ5Po=P!Po=hh9h)z�Open a file or directory in the default web browser.

Args:
    path: File path or directory path to open

For directories (heatmap), opens the index.html file inside.
z
index.htmlz&Warning: Could not find index.html in ��filezfile://z!Warning: Could not open browser: )rvrw�abspath�isdirrr9�printr�r��
webbrowser�open�	Exception)rw�abs_path�
index_path�file_url�es&    r+�_open_in_browserrO�s����w�w���t�$�H�
�w�w�}�}�X����W�W�\�\�(�L�9�
�
�7�7�>�>�*�%�%�!�H��:�4�&�A��
�
�S����
�#�H�H�����!���H�
�1�!��5�C�J�J�G�G��H�s�4C�	D�D�C;�;Dc�x�[UQ29^tt^2oUO[2oPPP2[
W2[6fUQ*[7c[O
Q2P!P!)%fhKP9h[c'o[O
QSQS02Po=KPo=hh9h)zDValidate that the replay input looks like a sampling binary profile.�rbz!Error: Could not read input file z: :N�NzoError: Input file is not a binary sampling profile. The replay command only accepts files created with --binary)rIr��_BINARY_PROFILE_HEADER_SIZEr�r��exit�len�_BINARY_PROFILE_MAGICS)�filenamerD�header�excs&   r+�_validate_replay_input_filerZ�s���H�
�(�D�
!�
!�T��Y�Y�:�;�F�"�	�F��1�1��"�:�3�3����
J�	
�4�"�
!���H����4�X�J�b���F�G�G��H�s?�B�A5�B�5B	�>B	�B�B�	B9�B9�B4�4B9c���UO2oUQ*o[QUQ*QUO02[QUQ02[QUOQ]2]6XcQ	LQ
02[	UO
UP
UOQ5oQoUOVE2o[2UO
Q
6Xc�UO%cUOUO2L�UOd
UOLQoUOd
UOL]o[U2o	UOV�UO%([2L�UO9%f*[!UO
["O$22o
UOU
2oU%c4UO
[&7c[)UQP
2%c[+U
2[QUQ02P!)z*Replay samples from an open binary reader.�sample_interval_usz
Replaying �sample_countz samples from z  Sample interval: z usz  Compression: �compression_typerr)r5r2c���U]6�c`V*o](o[V2*2oQU*QV4*
**o[QUQU]d*Q
QUQ
QUQ
Q	0	PP	Q
5P!P!)r�u█u░z
  [z] z5.1fz% (�,�/�))�end�flush)r�rG)�current�total�pct�	bar_width�filled�bars&&    r+�progress_callback�._replay_with_reader.<locals>.progress_callback�sr���1�9��/�C��I����)�F��&�.�5�I�,>�#?�?�C����u�B�s�3�w�t�n�C���{�!�E�!�9�A�F���
�r*r=r"�browserz	Replayed z samples)�get_inforG�
input_filerzr=r1r2�replay_samplesru�export�sort�limitr2�print_stats�
no_summaryrrArv�getpidrrTrO)rN�reader�info�interval�	collectorrk�countr0rs�	sort_moderW�	export_oks&&          r+�_replay_with_readerr~�s����?�?��D��(�)�H�	�J�t�N�+�,�N�4�?�?�:K�
L�M�	���z��
-�.�	���X�X�0�!�4��9�6�v�
F�	H��
"����X���(�(��I�

�
�!�!�)�?�E�	�G��{�{�h���<�<�<����T�\�\�*�"�Y�Y�2��	�	�
�
�#'�*�*�"8�D�J�J�b�E�%�k�2�I��!�!��d�o�o�"5�#�
�
�L�L�
C�
C�(����b�i�i�k�B�	��$�$�X�.�	�
����9�9���i��/�/��X�&�	�I�e�W�H�
%�&r*c���UOQ6Xc<UOP2UOo[QUQUOQ02P!UOQ6XCcUO
%c�[OOUO
2%cR[OOUO
[UOU22oUOU2P!UOUO
2P!UOd
UOLQoUOd
UOL]o[U2oUOVvUO%(U2P!UO
%co[OOUO
2%c@[OOUO
[UOU22oL*UO
9%f[UOU2oUOU2oU%c:UO[ 7c#[#UQP
2%c[%U2P!P!P!P!)z�Handle output for the collector based on format and arguments.

Args:
    collector: The collector instance with profiling data
    args: Parsed command-line arguments
    pid: Process ID (for generating filenames)
    mode: Profiling mode used
rFzBinary profile written to z (z	 samples)r=r"rm)r1rqrWrG�
total_samplesrurvrwrFrrArrrsr2rtrurrTrO)	rzrNrIrbrWr0rsr|r}s	&&&&     r+�_handle_outputr�,s����{�{�h��������%�%��
�*�8�*�B�y�7N�7N�6O�y�Y�Z�	
����	 ��<�<�<��w�w�}�}�T�\�\�*�*��7�7�<�<����6O�PT�P[�P[�]`�6a�b��� � ��*�� � ����.�(,�y�y�'<�$�)�)�*�K�"&�*�*�"8�D�J�J�b�E�%�k�2�I��!�!��d�o�o�"5�t�
�
�<�<�<�B�G�G�M�M�$�,�,�7�7��w�w�|�|�D�L�L�2K�D�K�K�Y\�2]�^�H��|�|�R�R�'@����c�'R�H��$�$�X�.�	�
����9�9���i��/�/��X�&�0�:�
r*c��	�[UQP2oUQ6XcP![UQ2%c,UO%c[eUO	Q2[UQ2%caUO
%cO[eUO	Q2[UQ2%c$UO%cUO	Q2[UQP
2%Cc,o[UQ	P
2%cUOQ
2[UQP	2%fUOQ2[UQ
P2Q6XcUOQ2[UQ2%c0UOQ6wcUOQUO02[UQ2%c$UO%cUOQ2U%c%UO	QQOU2Q02[UQP
2%f`UQ6Xc%[UQ2%cUO	Q2L4[UQ2%c#UOQ6wcUO	Q2UQ6XcP!UO%cOUO]d6c>[QUOQQUO*Q0[O Q 5[UQ2%c�UO%c�UO"Q!6wc%Q"UO"0oUO	Q#UQ$02,oUO$dUOQ%2UO&dUOQ&2UO(%cUOQ'2U%c%UO	QQOU2Q(02P!UO"Q)6Xc$[UQQ2Q6wcUO	Q*2Q0o[UQ+P
2%c<UO"U7c+UO	Q,QOQ-U22Q.02UO"Q!6wc�,oUO$dUOQ%2UO&dUOQ&2UO(%cUOQ'2U%c8Q"UO"0oUO	QQOU2Q/U02P!P!P!)1z�Validate format-specific options and live mode requirements.

Args:
    args: Parsed command-line arguments
    parser: ArgumentParser instance for error reporting
�command�replay�livez=Live mode requires the curses module, which is not available.rSzU--subprocesses is not available on this platform (requires _remote_debugging module).z0--subprocesses is incompatible with --live mode.rqrnr[ror\r1rFrrbrcz--mode=rkr�zOptions r
za are incompatible with --async-aware. Async-aware profiling uses task-based stack reconstruction.�dumpr_z2--async-mode requires --async-aware to be enabled.r`zWarning: --blocking with a u$ µs interval will stop all threads i@BzS times per second. Consider using --sampling-rate 1khz or lower to reduce overhead.rCr=rfz--live is incompatible with z!. Live mode uses a TUI interface.rr r!zT are incompatible with --live. Live mode uses a TUI interface with its own controls.rBzy--mode option is incompatible with --gecko. Gecko format automatically includes both GIL-holding and CPU status analysis.rpz"--opcodes is only compatible with c3�@�SF �DoQU*w�	J	P!3h)rfr#rs& r+r�!_validate_args.<locals>.<genexpr>�s��Mg���Mg��4�!�8�8�Mg�s�r@z# are only valid with --pstats, not )r�rBr@r/rDrF)rT�hasattrr�r �errorrSrrlrbrkrr_�blockingrgrGr�r�r1rrrsru)rNr4r��issues�format_flag�opcodes_compatible_formatss&&    r+�_validate_argsr�\s���d�I�t�,�G��(����t�V�������/A�/I����K�	
�
�t�^�$�$��):�):�):��&��L�L�7�
��4�� � �T�Y�Y�Y��L�L�K�L��t�]�E�*�*����4��5�)�)��M�M�*�%��t�T�4�(�(��M�M�)�$��4��4�(�H�4��M�M�*�%��4�� � �T�Y�Y�&�%8��M�M�G�D�I�I�;�/�0��4��'�'�D�,<�,<�,<��M�M�/�*���L�L��4�9�9�V�,�-�.N�N�
��4���.�.��f���t�\�*�*����Q�R��
�T�<�
(�
(�T�_�_�	�-I��L�L�M�N��&����}�}�}��2�2�S�8�
�)�$�*C�*C�)D�Dh��D�5�5�5�6�7O�
O����		
��t�V��������;�;�(�"��t�{�{�m�,�K��L�L�.�{�m�;\�]�
�
���9�9� ��M�M�(�#��:�:�!��M�M�)�$��?�?�?��M�M�.�)���L�L��4�9�9�V�,�-�.H�H�
�	��{�{�g��'�$���"?�6�"I����
\�	
�"i���t�Y��&�&�4�;�;�>X�+X����0����:h�Mg�:h�1h�0i�ij�k�	
�
�{�{�h�����9�9� ��M�M�(�#��:�:�!��M�M�)�$��?�?�?��M�M�.�)���t�{�{�m�,�K��L�L��4�9�9�V�,�-�-P�Q\�P]�^�
��r*c�P�[O[OP2o[O[OP2[2[O[OU2P![O[OS2h9h)zMain entry point for the CLI.)�locale�	setlocale�LC_ALL�_main)�
old_locales r+�mainr��sa���!�!�&�-�-��6�J�
���V�]�]�B�'�4�
��������
�3��������
�3�s�
A>�>'B%c��[O[[Q5oUO	QP	QQ5oUOQQ[QQ5oUO
QQ	Q
QQ5UO
Q
QQ5UO
Q[OQQ5UO
QQ
QQ5[U2[U2[U2[U2UOQQ[QQ5oUO
Q[QQ5UO
QQ
QQ5[U2[U2[U2[U2UOQQ[QQ5oUO
Q[QQ5[U2UOQQ [Q!Q5oUO
Q"Q#Q5[UP
P
Q$5[U2UO2o[V`2Q[ Q["Q[$Q[&-oUO)UO*2oU%cUU2P!UO-Q%UO*02P!)&)�description�formatter_classr�zCommand to run)r��requiredr��runz"Run and profile a script or modulea0Run and profile a Python script or module

Examples:
  # Run and profile a module
  `python -m profiling.sampling run -m mymodule arg1 arg2`

  # Generate flamegraph from a script
  `python -m profiling.sampling run --flamegraph -o output.html script.py`

  # Profile with custom rate and duration
  `python -m profiling.sampling run -r 5khz -d 30 script.py`

  # Save collapsed stacks to file
  `python -m profiling.sampling run --collapsed -o stacks.txt script.py`

  # Live interactive mode for a script
  `python -m profiling.sampling run --live script.py`)r�r�r�r�z--moduler�z)Run target as a module (like `python -m`)r��targetz%Script file or module name to profile)r�rNz)Arguments to pass to the script or module)�nargsr�z--livezSInteractive TUI profiler (top-like interface, press 'q' to quit, 's' to cycle sort)�attachz'Attach to and profile a running processaAttach to a running process and profile it

Examples:
  # Profile all threads, sort by total time
  `python -m profiling.sampling attach -a --sort tottime 1234`

  # Live interactive mode for a running process
  `python -m profiling.sampling attach --live 1234`rIzProcess ID to attach to)r�r�r�z&Dump a running process's current stackz�Dump a running process's current Python stack

Examples:
  # Dump the main thread stack
  `python -m profiling.sampling dump 1234`

  # Dump all thread stacks
  `python -m profiling.sampling dump -a 1234`zProcess ID to dumpr�z5Replay a binary profile and convert to another formata�Replay a binary profile file and convert to another format

Examples:
  # Convert binary to flamegraph
  `python -m profiling.sampling replay --flamegraph -o output.html profile.bin`

  # Convert binary to pstats and print to stdout
  `python -m profiling.sampling replay profile.bin`

  # Convert binary to gecko format
  `python -m profiling.sampling replay --gecko -o profile.json profile.bin`rozBinary profile file to replay)rrzUnknown command: )r��ArgumentParser�_HELP_DESCRIPTIONr"�add_subparsers�
add_parserr��	REMAINDERr�rrr*r�r.�
parse_argsr��_handle_run�_handle_attach�_handle_dump�_handle_replayrzr�r�)	r4�
subparsers�
run_parser�
attach_parser�dump_parser�
replay_parserrN�command_handlers�handlers	         r+r�r��s���
�
$�
$�%�'��F��&�&�
��,<�'��J�
�&�&�
�
1�'�9�	'��J�,������
8�	������
4�������� � �
8���
�����
b���
�*�%��j�!��
�#��
�#��)�)��
6�'�7�	*��M����
�
�
&���
�����
b���
�-�(��m�$��
�&��
�&��'�'��
5�'�1�	(��K����
�
�
!���
�k�"��)�)��
D�'�
O�	*��M� ����
,����
�5�QV�W��
�&�����D��4� �	�{��.����.�	���"�"�4�<�<�0�G����
����(�����7�8r*c��[UO2%f[UO2gUO%c[	VO2P!UO
Q6Xc[L[UO2oU[6wc
U[6gLP
oPoUO
Q6Xc5UO9%f![UO
UO2o[UO
UOV OUU[UQQ2UO Q5o[#VO29^tt^2[%UOSUO&UO(UO*SUO,%c
UO.LPUO0UO2UOUO4Q5o[7V@UOU2PPP2P!)%fhP!9h)zHandle the 'attach' command.rBrFr6r	�r;r6r2�	�duration_secrkrmrbrqrnrorpr�)rrIrr��_handle_live_attachr1rr�rbrrurAr=rgrprTr2rUrrjrkrmrqr_rnror�r�)rNrbr5r;rzs&    r+r�r�~sw���t�x�x�(�(�)�$�(�(�3�3��y�y�y��D�(�(�+��
�;�;�'�!�	�
����
#�	�(,�/A�'A��#�#�u���K��{�{�h���l�l�V�V�&?����T�X�X�&V��"����T�.�.�	�<�<����D�-��8��(�(�	�I�
$�D�(�(�	3�	3���H�H������(�(��.�.��+/�+;�+;�+;������;�;��w�w��L�L��]�]�
�	�	�y����$�7�
4�	3�	3�	3�s�AG,�AG,�,G=	�5G=	c��[UO2%f[UO2gUO%c[L[
oUO%c[
UQQ2LPo[UOUOUUUOUOUOUOQ5o[!WUOQ5P![c([OQSOQ02KJh9h)r_r)rkrbrqrnrorpr�z"No stack dump collected - process z' exited before its stack could be read.)rI)rrIrrqrrrTrrkrnrorpr��ProcessLookupErrorr�rTr	)rNrbr_�stack_framess&   r+r�r��s����t�x�x�(�(�)�$�(�(�3�3�#'�"2�"2�"2��8J�D�7;�7G�7G�7G���|�U�3�T�J�
�!��H�H��(�(��"��;�;��w�w��L�L��]�]�	
�� �\�t�x�x�0��
�
����0����
�;'�
'�	
�
�s�2AC�	D�$%D�Dc�2	�UO%c�[O2oP
oU[O7c#[OO]U2P	o[OOUO2e[UO2gU%c [OOU2LD[OOUO2%f[UO2gUO%c[U2P!UO%c,[O QUO,UO"N3oL)[O UO,UO"N3o[%UP
Q5oUO*Q6Xc[,L[/UO02oU[,6wc
U[26gLP
oPoUO*Q6Xc5UO49%f![7UO*WO82o[;UO*UO<VpO>UU[AUQQ2UOBQ5o	[EUWO829^tt^2[GUO8S	UOHUOJUOLSUON%c
UOPLPUORUOTUO>UOVQ	5o	[YV�UO8U2UO[2e)UO]2UO_[`Q
5LPPP2P!S%c![OOS2hh9h[&c%o[O(QS02Po=CK%Po=hh9h[bOdc$SOg2SO_2K�h9hSO[2edSO]2SO_[`Q
5h[bOdc$SOg2SO_2hh9hh9h)%fhP!9h)zHandle the 'run' command.r��r��Error: rBrFr6r	r�r�r�)4�modulervr�r�rw�insert�	importlib�util�	find_specr�r�remover9rr��_handle_live_runr�rNr�r�rTr1rr�rbrrurArIr=rgrprTr2rUrrjrkrmrqr_rnror�r�r�r�r�r�r�r�r�)
rNr��	added_cwdr�r�rNrbr5r;rzs
&         r+r�r��s_���{�{�{��i�i�k���	��c�h�h���H�H�O�O�A�s�#��I�	%��~�~�'�'����4�<�1�$�+�+�>�>�=��������$���w�w�~�~�d�k�k�*�*�-�d�k�k�:�:��y�y�y������{�{�{��~�~�t�T�[�[�=�4�9�9�=���~�~�t�{�{�7�T�Y�Y�7�� � ��e�<���;�;�'�!�	�
����
#�	�(,�/A�'A��#�#�u���K��{�{�h���l�l�Y�Y�&?����W�[�[�&Y��"����T�.�.�	�<�<����D�-��8��(�(�	�I�
$�D�'�+�+�	6�	6�	#������!�]�]� �,�,�#�2�2��/3�/?�/?�/?�D�O�O�T��{�{��7�7��������I�
�9�G�K�K��>��|�|�~�%��!�!�#�#��L�L�)B�L�C�&�'
7�	6��_�������$���(� ����7�1�#����� ��d"�0�0�#��L�L�N��L�L�N�#��	�|�|�~�%��!�!�#�#��L�L�)B�L�C��!�0�0�#��L�L�N��L�L�N�#��	&��'
7�	6�	6�s��#*M1�M1�
N�R�AP�AP�,R�>R�O�%R�1N�:!N�	O
�(O
�)O�O
�P�$!P�R�P�R�R�R�/Q�R�Q>�!Q>�;R�=Q>�>R�R�R	�R	c���[UO2oU[6go[UOSQ]SSUO
UO%c
UOLPQ5o[SSUOUOUOSUO%c
UOLPUOUOUO
UOQ5P!)z)Handle live mode for an existing process.r#�r5�sort_byrsrIrbrprqr�)r�rbrr rgrprqr_rrjrkrmrnror�)rNrIrbr5rzs&&   r+r�r�&s����t�y�y�!�D��+�+�I�#��!�!�����
����'+�'7�'7�'7�D�O�O�T�	�I�����]�]��$�$��*�*�
�'+�'7�'7�'7�D�O�O�T��{�{��7�7�������r*c��UO%c,[OQUO,UON3oL)[OUO,UON3o[UP	Q5o[UO2oU[6go[UOSQ]WOSUOUO%c
UO LPQ5o[#UOSUO$UO&UO(SUO%c
UO LPUO*UO,UOUO.Q5UO12oUe(UO32UO5[6Q5UO52UO>%clUO>9^tt^2UO>OA2oU%c*[CUOE2[O>Q5PPP2P!P![c%o[OQS02Po=CK�Po=hh9h[8O:cSO=2K�h9h[F[H1cK|h9h)%fhP!9hSO12oSeTSO32SO5[6Q5L+[8O:cSO=2Lh9hSO52SO>%c�SO>9^tt^2SO>OA2oS%c*[CSOE2[O>Q5L[F[H1cLh9hPPP2h)%fhh9hh9h)	z-Handle live mode for running a script/module.r�r�r�r#r�r�r�rC)%r�r�r�r�rNr�r�rTr�rbrr rgrIrprqr_rrjrkrmrnror�r�r�r�r�r�r�r�r�r�rGr�r�r8)	rNr�r�rNrbr5rzr�r�s	&        r+r�r�Is����{�{�{��~�~�t�T�[�[�=�4�9�9�=���~�~�t�{�{�7�T�Y�Y�7�� � ��d�;���t�y�y�!�D��+�+�I�#��!�!�����K�K�
����'+�'7�'7�'7�D�O�O�T�	�I�#���K�K������(�(��.�.��+/�+;�+;�+;������;�;��w�w��L�L��]�]�	
��\�\�^�
�������
����%>��?�	�����>�>�>������$�^�^�0�0�2�F���f�m�m�o�C�J�J�?�	 ����a� ����7�1�#����� ��V�,�,�
�����
�� ��,����� �����\�\�^�
�������
����%>��?���,�,�
�����
��	�����>�>�>������$�^�^�0�0�2�F���f�m�m�o�C�J�J�?����,����� ������s	�)
H2�$AJ:�)?J:�
I$�J&�!J�=)J�2	I!�<I!�=I�I!�$J�8J�J�J#�J#� J&�"J#�#J&�&J7	�/J7	�:O�O� K7�6O�7L�L�O�L�$O�O�O	�!N&�<)N&�%O	�&N:�6N:�7O	�9N:�:O	�=	O�O
�O
�	Oc���[OOUO2%f$[O
QUO02[
UO2[UO29^tt^2o[V2PPP2P!)%fhP!9h[[1c%o[O
QS02Po=P!Po=hh9h)zGHandle the 'replay' command - convert binary profile to another format.zError: Input file not found: r�)rvrwr9ror�rTrZrr~r�r8)rNrwrYs&  r+r�r��s���
�7�7�>�>�$�/�/�*�*����0����0A�B�C�����0�"�
�$�/�/�
*�
*�f���-�+�
*�
*�
*���Z� �"����7�3�%��!�!��"�sB�*B1�B�B1�B.	�&B.	�(B1�.B1�1C&�C&�C!�!C&�__main__)sHCATsTACH)r@r/rD)F)TT)FNNr	N)mr(r��importlib.utilr�r�rv�rer�r�r�r�r�rH�
contextlibr�errorsrrrrrrrr�r	�pstats_collectorr
�stack_collectorrrr
�heatmap_collectorr�gecko_collectorr�jsonl_collectorr�binary_collectorr�
binary_readerr�	constantsrrrrrrrrrrrr�_child_monitorr�ImportError�live_collectorr �ArgumentDefaultsHelpFormatter�RawDescriptionHelpFormatterr"�Actionr-r�r�r�r�r�rSrVryr7rrQrUrLrMr�r�r�r��compile�VERBOSE�
IGNORECASEr�r�r�rrr*r.r2r=rArOrZr~r�r�r�r�r�r�r�r�r�r�r$r#r*r+�<module>r�sX��7���
�	�	��
��
���"�i�i�H�H�"�-�b�b�/�+�+�-�'�
�
�
�
��3�
�2�
	��*�*��(�(�	�)�8�?�?�)�R��,�������� ��+��
�h����&��v��V�
�v��W��e�	��
�o��(��%��.��^�
���^��o�	�
�J����#�L4�0!�I�$�<4�n�
�
��
�z�z�B�M�M�!�#�
��@@�F�*V�r�>*�Z9�5F�p.�"H�4
�$<'�~-'�`x�v4�Y9�x/8�d1�8W#�t �FC�L"��z���F���e+�����������s0�F6�$G�6G�<G�G�G�G�G

Youez - 2016 - github.com/yon3zu
LinuXploit