HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/debug.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z	dd�Zdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zddd�ZdS)z6
Print a stacktrace when sent a SIGUSR1 for debugging
�NcCs&|�d�tj||d�|�d�dS)z
    Pretty print the stack trace and environment information
    for debugging those hard to reproduce user problems.  :)
    z*======== Salt Debug Stack Trace =========
)�filez*=========================================
N)�write�	traceback�print_stack)Zprintout�stack�r�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/debug.py�_makeprettys
r	cCs�tj��rtj}t||�dSdtt����d�}tj�t	�
�|�}tjj
�|d��}t||�Wd�dS1s;wYdS)zI
    Signal handler for SIGUSR1, only available on Unix-like systems
    zsalt-debug-z.log�wN)�sys�stderr�isattyr	�int�time�os�path�join�tempfile�
gettempdir�salt�utils�filesZfopen)�sigr�output�filename�destfilerrr�_handle_sigusr1s
"�rcCs�zddl}Wn
tyYdSw|��rN|��dtt����dt����}tj�	t
��|�}|��j
|dd�tj��rHtj�d|�d��|��dStj��rYtj�d	�|��dS)
zI
    Signal handler for SIGUSR2, only available on Unix-like systems
    rNzcallgrind.salt-�-Z	CALLGRIND)�typezSaved profiling data to: �
zProfiling started
)�yappi�ImportErrorZ
is_running�stoprrr�getpidrrrrZget_func_statsZsaverrr
rZclear_stats�start)rrr rrrrr�_handle_sigusr2+s �

r%cCs$tt|�rt�tt|�|�dSdS)zK
    Add signal handler for signal name if it exists on given platform
    N)�hasattr�signal�getattr)Zsignal_name�handlerrrr�enable_sig_handlerAs
�r*cCstdt�tdt�dS)z�
    Pretty print a stack trace to the console or a debug log under /tmp
    when any of the salt daemons such as salt-master are sent a SIGUSR1
    �SIGUSR1ZSIGINFON)r*rrrrr�enable_sigusr1_handlerIs
r,cCstdt�dS)z
    Toggle YAPPI profiler
    �SIGUSR2N)r*r%rrrr�enable_sigusr2_handlerTsr.cCsdt��ddiS)z@
    Return a string of which function we are currently in.
    �co_name��)�inspectrrrrr�
inspect_stack[sr3�Fc
Cs�t��}d|}t|�|dkrdS||d}g}|dur-zt�|�j}Wnd}Yt�|�}|r:|�|j�d|jvrI|�|jdj	j�|j
j}|dkrV|�|�~d�|�}	|rg|rg|	d	|��7}	|	S)
aU
    Get a name of a caller in the format module.class.method

    `skip` specifies how many levels of stack to skip while getting caller
    name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.

    An empty string is returned if skipped levels exceed stack height

    Source: https://gist.github.com/techtonik/2151727
    rr0�TN�selfz<module>�.�:)
r2r�lenZgetframeinfo�linenoZ	getmodule�append�__name__�f_locals�	__class__�f_coder/r)
�skipZinclude_linenorr$Zparentframe�namer:�moduleZcodename�fullnamerrr�caller_namebs0



rD)r4F)�__doc__r2rr'rrrrZsalt.utils.filesrZsalt.utils.stringutilsr	rr%r*r,r.r3rDrrrr�<module>s$