HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/bcc/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/bcc/__pycache__/usdt.cpython-312.pyc
�

f#$���ddlmZddlZddlZddlmZmZmZm	Z	m
Z
mZGd�de�Z
Gd�de�ZGd	�d
e�ZGd�de�ZGd
�de�Zy)�)�print_functionN�)�lib�_USDT_CB�_USDT_PROBE_CB�bcc_usdt_location�bcc_usdt_argument�BCC_USDT_ARGUMENT_FLAGSc��eZdZy)�
USDTExceptionN)�__name__�
__module__�__qualname__���*/usr/lib/python3/dist-packages/bcc/usdt.pyrrs��rrc�$�eZdZd�Zd�Zd�Zd�Zy)�USDTProbeArgumentc���|jdk|_t|j�|_|j|_|jtj
zdk7r|j|_|jtjzdk7r|j|_|jtjzdk7r|j|_
|jtjzdk7r|j|_|jtjzdk7r|j|_|jtjzdk7r|j |_yy)Nr)�size�signed�abs�validr
�CONSTANT�constant�DEREF_OFFSET�deref_offset�DEREF_IDENT�deref_ident�BASE_REGISTER_NAME�base_register_name�INDEX_REGISTER_NAME�index_register_name�SCALE�scale)�self�arguments  r�__init__zUSDTProbeArgument.__init__s���m�m�a�'�����
�
�&��	��^�^��
��:�:�/�8�8�8�A�=�$�-�-�D�M��:�:�/�<�<�<��A� (� 5� 5�D���:�:�/�;�;�;�q�@�'�3�3�D���:�:�/�B�B�B�a�G�&.�&A�&A�D�#��:�:�/�C�C�C�q�H�'/�'C�'C�D�$��:�:�/�5�5�5��:�!���D�J�;rc�F�d|j|jrdfzSdfzS)Nz%d %s byteszsigned  �unsigned)rr�r&s r�_size_prefixzUSDTProbeArgument._size_prefix+s5������$�+�+�J�F�G�	G�;E�F�G�	Grc�T�|jtjzdk7rd|jzS|jtjzdk(rd|j
j
�zS|jtjzdk7r�|jtjzdk(r�|jtjzdk7rPd|jj
�z}|jtjzdk7r|d|jzz
}nd}|jdk\rdnd}d	|j
j
�|t|j�|fzS|jtjzdk7r�|jtjzdk7ru|jtjzdk7rU|j
d
k(rF|jdk\rdnd}d|jj
�|t|j�fzSd|jzS)
Nrz%dz%sz + %sz * %d��+�-z
*(%s %s %d%s)�ipz*(&%s %s %d)z&unrecognized argument format, flags %d)rr
rrrr!�decoderr"r#r$r%rrr r)r&�index_offset�signs   r�_formatzUSDTProbeArgument._format/s����:�:�/�8�8�8�A�=��$�-�-�'�'��:�:�/�<�<�<��A��$�1�1�8�8�:�:�:��:�:�/�<�<�<��A��:�:�/�;�;�;�q�@��z�z�3�G�G�G�1�L�&��)A�)A�)H�)H�)J�J���:�:� 7� =� =�=��B� �G�d�j�j�$8�8�L�!���+�+�q�0�3�c�D�"�d�&=�&=�&D�&D�&F�&*�C��0A�0A�,B�L�&R�R�
R��:�:�/�<�<�<��A��:�:�/�;�;�;�q�@��:�:�/�B�B�B�a�G��"�"�d�*��+�+�q�0�3�c�D�!�T�%5�%5�%<�%<�%>�%)�3�t�/@�/@�+A�%C�C�
C�
8�$�*�*�D�Drc�H�|j��d|j���S)Nz @ )r,r5r+s r�__str__zUSDTProbeArgument.__str__Ms�� �-�-�/�����@�@rN)r
rrr(r,r5r7rrrrrs��(�"G�E�<Arrc��eZdZd�Zd�Zd�Zy)�USDTProbeLocationc��||_||_|j|_|j|_|j|_y�N)�probe�index�
num_arguments�address�bin_path)r&r<r=�locations    rr(zUSDTProbeLocation.__init__Qs8����
���
�"�0�0����'�'��� �)�)��
rc�T�d|jj�|jfzS)Nz%s 0x%x)r@r2r?r+s rr7zUSDTProbeLocation.__str__Xs#���D�M�M�0�0�2�D�L�L�A�A�Arc
�P�t�}tj|jj|jj
|jj|j|tj|��}|dk7rtd||jfz��t|�S)Nrz.error retrieving probe argument %d location %d)r	r�bcc_usdt_get_argumentr<�context�provider�namer=�ct�byrefrr)r&r=�arg�ress    r�get_argumentzUSDTProbeLocation.get_argument[s����!���'�'��
�
�(:�(:�D�J�J�<O�<O�(,�
�
���(,�
�
�E�2�8�8�C�=�J���!�8��D��D�J�J�'�(�)�
)�!��%�%rN)r
rrr(r7rLrrrr9r9Ps��*�B�	&rr9c�$�eZdZd�Zd�Zd�Zd�Zy)�	USDTProbec���||_|j|_|j|_|j|_|j|_|j
|_|j|_yr;)rErFrGr@�	semaphore�
num_locationsr>)r&rEr<s   rr(zUSDTProbe.__init__gsQ���������
��J�J��	�����
������"�0�0���"�0�0��rc��d|jj�|jj�|jfzS)Nz%s:%s [sema 0x%x])rFr2rGrPr+s rr7zUSDTProbe.__str__ps9��"��
�
�$�$�&��	�	�(8�(8�(:�D�N�N�K�L�	Lrc�p�|jj��d|jj���S)N�:)rFr2rGr+s r�
short_namezUSDTProbe.short_namets'���-�-�.�.�0�$�)�)�2B�2B�2D�E�Erc	���t�}tj|j|j|j
|t
j|��}|dk7rtd|z��t|||�S)Nrz"error retrieving probe location %d)
rr�bcc_usdt_get_locationrErFrGrHrIrr9)r&r=�locrKs    r�get_locationzUSDTProbe.get_locationws`���!���'�'����d�m�m�T�Y�Y�(-�r�x�x��}�>���!�8�� D�u� L�M�M� ��u�c�2�2rN)r
rrr(r7rUrYrrrrNrNfs��1�L�F�3rrNc�J�eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
�USDTNc���|r�|dk7r�||_|r+tj||jd��|_n.tj|tjd��|_|jdk(rtd|z��y|rN||_tj|jd��|_|jdk(rtd|z��ytd��)N����asciirz USDT failed to instrument PID %dz!USDT failed to instrument path %sz/either a pid or a binary path must be specified)
�pidr�bcc_usdt_new_frompid�encoderErH�c_char_pr�path�bcc_usdt_new_frompath)r&r_rcs   rr(z
USDT.__init__�s����3�"�9��D�H��"�7�7��T�[�[��=Q�R���"�7�7��R�[�[��^�L����|�|�t�#�#�$F��$L�M�M�$�
��D�I��4�4�T�[�[��5I�J�D�L��|�|�t�#�#�$G�$�$N�O�O�$� �E�G�
Grc�B�tj|j�yr;)r�bcc_usdt_closerEr+s r�__del__zUSDT.__del__�s�����4�<�<�(rc��|jdd�}t|�dk(r@tj|j|jd�|jd��}nT|\}}tj|j|jd�|jd�|jd��}|dk7rtd|z��y)NrTrr^ra.Failed to enable USDT probe '%s':
the specified pid might not contain the given language's runtime,
or the runtime was not built with the required USDT probes. Look
for a configure flag similar to --with-dtrace or --enable-dtrace.
To check which probes are present in the process, use the tplist tool.
)�split�lenr�bcc_usdt_enable_proberEra�%bcc_usdt_enable_fully_specified_prober)r&r<�fn_name�probe_parts�ret�
provider_name�
probe_names       r�enable_probezUSDT.enable_probe�s����k�k�#�q�)���{��q� ��+�+����e�l�l�7�3�W�^�^�G�5L�N�C�+6�'�]�J��;�;����m�2�2�7�;�Z�=N�=N�w�=W����w�'�)�C��!�8���
��
�

�rc��	|j||�y#t$r:}t|tj��tj
d�Yd}~yd}~wwxYw)N)�filer)rrr�print�sys�stderr�exit)r&r<rm�es    r�enable_probe_or_bailzUSDT.enable_probe_or_bail�sB��	����e�W�-���	��!�#�*�*�%��H�H�Q�K�K��	�s��	A�0A�Ac��|jSr;)rEr+s r�get_contextzUSDT.get_context�s���|�|�rc��tjdz�}tj|j�|d<tj|d�j�S)Nrr)rH�c_void_prEr�bcc_usdt_genargsr2)r&�	ctx_arrays  r�get_textz
USDT.get_text�sD���[�[�1�_�'�	��{�{�4�<�<�0�	�!���#�#�I�q�1�8�8�:�:rc�d�|jdd�}t|�dk(r>tj|j|jd�|�j
�S|\}}tj|j|jd�|jd�|�j
�S)NrTrr^)rirjr�bcc_usdt_get_probe_argctyperErar2�+bcc_usdt_get_fully_specified_probe_argctype)r&rq�	arg_indexrnrpr<s      r�get_probe_arg_ctypezUSDT.get_probe_arg_ctype�s��� �&�&�s�A�.���{��q� ��2�2����j�/�/��8�)�E�EK�V�X�
N�&1�"�]�E��B�B����m�2�2�7�;�U�\�\�'�=R�T]�_�_e�_e�_g�
hrc�l���g���fd�}tj�jt|���S)Nc�d���jt�j|j��yr;)�appendrNrE�contents)r<�probesr&s ��r�
_add_probez)USDT.enumerate_probes.<locals>._add_probe�s����M�M�)�D�L�L�%�.�.�A�Br)r�bcc_usdt_foreachrEr�r&r�r�s` @r�enumerate_probeszUSDT.enumerate_probes�s.�����	C�	���T�\�\�8�J�+?�@��
rc�n�|j�}|D] \}}}}|rd}|j||||���"y)Nr])rGrm�addrr_)�enumerate_active_probes�
attach_uprobe)r&�bpf�attach_usdt_ignore_pidr��binpathrmr�r_s        r�attach_uprobeszUSDT.attach_uprobes�sL���-�-�/��-3�	2�)�W�g�t�S�%������7�G�#'�S�
�
2�	2rc�h��g��fd�}tj|jt|���S)Nc�0���j||||f�yr;)r�)r�rmr�r_r�s    �rr�z0USDT.enumerate_active_probes.<locals>._add_probe�s����M�M�7�G�T�3�7�8r)r�bcc_usdt_foreach_uproberErr�s  @rr�zUSDT.enumerate_active_probes�s-�����	9�	�#�#�D�L�L�.��2L�M��
r)NN)
r
rrr(rgrrrzr|r�r�r�r�r�rrrr[r[s6��G�$)�
�(��;�
h��2�rr[)�
__future__r�ctypesrHrv�libbccrrrrr	r
�	Exceptionr�objectrr9rNr[rrr�<module>r�s[��&��
�,�,�	�I�	�5A��5A�n&��&�,3��3�2[�6�[r