Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_gdb/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_gdb/__pycache__/util.cpython-312.opt-1.pyc

�

)Μg�)��B�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ejd�xsdZejjejjej�d�Zejjejje�d�ZdZdZd�Zd	Zdd
d�d�Zd
�Ze�\ZZedkr!ej4ded�ded�de����d�Ze�d�Ze�Zd�ZGd�dej>�Z y)�N)�support�gdbz
python-gdb.pyz
gdb_sample.py�
builtin_id�123c��tjj�D��cic]\}}|jd�s||��c}}Scc}}w)N�PYTHON)�os�environ�items�
startswith)�name�values  �//usr/local/lib/python3.12/test/test_gdb/util.py�clean_environmentrsH��+-�:�:�+;�+;�+=�.�+=�K�D�%��?�?�8�,�
�%�K�+=�.�.��.s�A)rrT)�exitcode�checkc��t�}|r|j|�tddg}tdk\r|j	ddt
��f�|j	|�t
j|tjtjtjdd|��}|j}|j}|rG|j|k7r8tj|�}	t|	�d	|j�d
|�d|�d|��	��||fS)
z�Runs gdb in --batch mode with the additional arguments given by *args.

    Returns its (stdout, stderr) decoded from utf-8 using the replace handler.
    z--batchz-nx���z--init-eval-commandzadd-auto-load-safe-path �utf8�backslashreplace)�stdin�stdout�stderr�encoding�errors�envz failed with exit code z, expected exit code z	:
stdout=z
stderr=)r�update�GDB_PROGRAM�GDB_VERSION�extend�CHECKOUT_HOOK_PATH�
subprocess�run�PIPErr�
returncode�shlex�join�	Exception)
rr�args�env_varsr�cmd�procrr�cmd_texts
          r�run_gdbr0!s��
�
�C���
�
�8�����
�C��f���
�
�)�.�/A�.B�C�E�	F��J�J�t���>�>���o�o�������� 2���D��[�[�F�
�[�[�F�����H�,��:�:�c�?���8�*�$;�D�O�O�;L�M.�.6�Z�8"�"(��,"�"(��-�.�	.�

�F���c�:�	td�\}}t	j
d|�}|�t
d|z��|}t|jd��}t|jd��}||f}||fS#t$r}tjd|����d}~wwxYw)Nz	--versionz'Couldn't find gdb program on the path: z ^(?:GNU|HP) gdb.*?\b(\d+)\.(\d+)zunable to parse gdb version: %r��)	r0�OSError�unittest�SkipTest�re�searchr*�int�group)rr�exc�match�version_text�major�minor�versions        r�get_gdb_versionrBKs���Q� ��-����
�I�I�9�6�B�E��}��9�F�B�C�C��L�����A���E�����A���E��e�n�G��'�"�"��%�Q����"I�#�� O�P�P��Q�s�A4�4	B�=B�B)rrzIgdb versions before 7.0 didn't support python embedding. Saw gdb version �.r3z:
c���tddtjd��\}}d|vrtjd|����|stjd|����d|vrtjd	��y)
Nz9--eval-command=python import sys; print(sys.version_info)�--argsF)rzauto-loading has been declinedz;gdb security settings prevent use of custom hooks; stderr: z4gdb not built with embedded python support; stderr: zmajor=2zgdb built with Python 2)r0�sys�
executabler6r7)rrs  r�check_usable_gdbrHjs����C��#�.�.���N�F�F�
(�6�1������j�
"�#�	#�������j�
"�#�	#��F����� 9�:�:�r1c��tjd�}|sy|j�}d|vxrtd�|D��S)N�CFLAGSFz-mcetc3�fK�|])}|jd�xr|jd����+y�w)z-fcf-protection)z=nonez=returnN)r�endswith)�.0�flags  r�	<genexpr>z!cet_protection.<locals>.<genexpr>�s>����'� %���_�_�%6�7�A�!�]�]�+?�@�@�A� %�s�/1)�	sysconfig�get_config_var�split�any)�cflags�flagss  r�cet_protectionrV�sL��
�
%�
%�h�
/�F����L�L�N�E���
�
'��'� %�'�'�(r1c���tjrdtdtd�dtd�d��tj�D]}td|z��tdt���t�yy)Nzgdb version rrCr3�:z    z
    path: )r�verbose�printr!�GDB_VERSION_TEXT�
splitlinesr )�lines r�setup_moduler^�sb�����
��[��^�,�A�k�!�n�-=�Q�?�@�$�/�/�1�D��'�D�.�!�2�
�
�;�-�(�)�
��r1c�0�eZdZdZddedddfd�Zd�Zd�Zy)�
DebuggerTestsz(Test that the debugger can debug Python.NFc�<�dd|zddg}tdk\r|dgz
}|rtr|dgz
}||z
}n|dgz
}|D�cgc]}d	|z��	}	}|	d
tjgz
}	|	j	tj��|s|	dgz
}	|r|	d|gz
}	n|r|	|gz
}	t|	d
ti�\}
}|s0|j�D]}t|tj���d|vrtjd��dD]}
|
|
vs�tj|
�d���|
Scc}w)z�
        Run 'python -c SOURCE' under gdb with a breakpoint.

        Support injecting commands after the breakpoint is reached

        Returns the stdout from gdb

        cmds_after_breakpoint: if provided, a list of strings: gdb commands
        zset breakpoint pending yeszbreak %szset print address offr%rzset print entry-values no�next�	backtracez--eval-command=%srEz-Sz-c�PYTHONHASHSEED)�filezPC not savedzKgdb cannot walk the frame object because the Program Counter is not present)z!(frame information optimized out)z*Unable to read information on python framez)(unable to read python frame information)z,Backtrace stopped: frame did not save the PCz ?? ()z found in gdb output)r!�CET_PROTECTIONrFrGr"r$�_args_from_interpreter_flagsr0rdr\rZrr6r7)�self�source�script�
breakpoint�cmds_after_breakpoint�import_site�
ignore_stderr�commandsr-r+�out�errr]�patterns              r�get_stack_tracezDebuggerTests.get_stack_trace�sl��:
)���#�
$��
��.�&� ��4�5�5�H� ��
�V�H�$���-�-�H���
�%�H�
6>�>�X�c�#�c�)�X��>������!�	!�����J�;�;�=�>���T�F�N�D���T�6�N�"�D�
��V�H��D��D�@��@���S�����(���d����,�)��S� ��#�#�%3�4�
4�
�G�$�#�~��'�'�7�+�5I�(J�K�K�'
�*�
��m?s�Dc�R�|j|j|�|�d|����y)z9Ensure that the given "actual" string ends with "exp_end"z did not end with ��msgN)�
assertTruerL)rh�actual�exp_ends   r�assertEndsWithzDebuggerTests.assertEndsWiths'���������0�8>��H�	�	Jr1c��tj||tj�}|s|j|�d|����yy)Nz did not match ru)r8r=�DOTALL�fail)rhrxrr�ms    r�assertMultilineMatchesz$DebuggerTests.assertMultilineMatches s3���H�H�W�f�b�i�i�0����I�I�6�7�C�I�D�r1)�__name__�
__module__�__qualname__�__doc__�
BREAKPOINT_FNrsrzr�r1rr`r`�s)��2�%)�$�#0�.2�$)�&+�	z�xJ�
Er1r`)!r	r8r(�shutilr$rFrPr6�testr�whichr �pathr)�dirnamerGr#�__file__�
SAMPLE_SCRIPTr�rdrr!r0rBr[r7rHrVrfr^�TestCaser`r�r1r�<module>r�s6��	�	��
��
�����f�l�l�5�!�*�U���W�W�\�\�"�'�'�/�/�#�.�.�"A�"1�3�������R�W�W�_�_�X�6��H�
��
���.����T�'�T#�.!0� 1���+����
�(�
�
��&�q�>�*�!�K��N�+;�3��
�	���;�,��
(� �!���HE�H�%�%�HEr1

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists