Sindbad~EG File Manager

Current Path : /usr/local/share/gdb/python/gdb/dap/__pycache__/
Upload File :
Current File : //usr/local/share/gdb/python/gdb/dap/__pycache__/server.cpython-311.pyc

�

��g�C�	��ddlZddlZddlZddlZddlZddlmZddlZddlm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZddlmZiaiadaGd�de��ZGd	�d
��ZGd�d��Zd/d
�Zd�Z dddd�de!de"de"de"fd�Z#d0d�Z$d�Z%e#dd���d���Z&e#dd���e$d��d�����Z'e#d dd�!��e$d"��dd#�d$e"fd%�����Z(e#d&dd�!��e$d'��d(�����Z)Gd)�d*e*��Z+Gd+�d,e*��Z,d-�Z-d.�Z.dS)1�N)�contextmanager�)�	read_json�start_json_writer)
�DAPException�DAPQueue�LogLevel�exec_and_log�
in_dap_thread�
in_gdb_thread�log�	log_stack�start_thread�
thread_log)�
type_checkc��eZdZdS)�NotStoppedExceptionN)�__name__�
__module__�__qualname__���./gdb/dap/server.pyrr4s�������Drrc�<�eZdZd�Zd�Zd�Zd�Zed���ZdS)�CancellationHandlerc�`�tj��|_d|_d|_g|_dS�N)�	threading�Lock�lock�in_flight_dap_thread�in_flight_gdb_thread�reqs��selfs r�__init__zCancellationHandler.__init__<s,���N�$�$��	�$(��!�$(��!���	�	�	rc�T�|j5||_ddd��dS#1swxYwYdS)z'Call at the start of the given request.N�r r!�r%�reqs  r�startingzCancellationHandler.startingDsv��
�Y�	,�	,�(+�D�%�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,���!�!c�T�|j5d|_ddd��dS#1swxYwYdS)z"Indicate that the request is done.Nr(r)s  r�donezCancellationHandler.doneIsv��
�Y�	-�	-�(,�D�%�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-r,c��|j5||jkrtj��nt	j|j|��ddd��dS#1swxYwYdS)z�Call to cancel a request.

        If the request has already finished, this is ignored.
        If the request is in flight, it is interrupted.
        If the request has not yet been seen, the cancellation is queued.N)r r"�gdb�	interrupt�heapq�heappushr#r)s  r�cancelzCancellationHandler.cancelNs����Y�
	/�
	/��d�/�/�/��
�������t�y�#�.�.�.�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/����
	/�
	/�
	/�
	/�
	/�
	/s�:A�A�Ac#�K�|�dV�dS	|j5t|j��dkre|jd|krTtj|j��|krt���t|j��dkr|jd|k�T||_ddd��n#1swxYwYdV�|j5d|_ddd��dS#1swxYwYdS#|j5d|_ddd��w#1swxYwYwxYw)zKReturn a new context manager that sets in_flight_gdb_thread to
        REQ.Nr)r �lenr#r2�heappop�KeyboardInterruptr"r)s  r�interruptable_regionz(CancellationHandler.interruptable_region`s������;��E�E�E��F�
	1���
0�
0��$�)�n�n�q�(�(�T�Y�q�\�S�-@�-@��}�T�Y�/�/�3�6�6�/�1�1�1��$�)�n�n�q�(�(�T�Y�q�\�S�-@�-@�-0��)�

0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0�
�E�E�E���
1�
1�,0��)�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1�
1����
1�
1�,0��)�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1���se�C�BB$�C�$B(�(C�+B(�,C�:C�C�C�D�$C8�,D�8C<�<D�?C<�DN)	rrrr&r+r.r4rr9rrrrr;sk���������,�,�,�
-�-�-�
/�/�/�$�1�1��^�1�1�1rrc�|�eZdZdZd�Zed���Zd�Zd�Zd�Z	ed���Z
edd	���Zdd
�Zd�Z
dS)
�ServerzThe DAP server class.c���||_||_||_g|_t	��|_t	��|_d|_t��|_	|a
dS)NF)�	in_stream�
out_stream�child_stream�delayed_eventsr�write_queue�
read_queuer.r�	canceller�_server)r%r=r>r?s    rr&zServer.__init__{sX��"���$���(��� ���$�:�:���#�*�*�����	�,�.�.������rc�P�|d}|d|dd�}	|j�|��d|vr	|d}ni}t|dd
i|��}|�||d<d|d<n�#t$r
d	|d<d
|d<Yn�t$r
d	|d<d|d<Yn}t
$r:}t
tj��d	|d<t|��|d<Yd}~n?d}~wt$r/}t
��d	|d<t|��|d<Yd}~nd}~wwxYw|j�|��|S)N�seq�response�command)�request_seq�typerH�	arguments�bodyT�successF�
notStopped�message�	cancelledr)rCr+�	_commandsrr8rrr	�FULL�str�
BaseExceptionr.)r%�paramsr*�result�argsrL�es       r�_handle_commandzServer._handle_command�s����U�m�����i�(�
�
��
	'��N�#�#�C�(�(�(��f�$�$��k�*������V�I�.�/�7�7�$�7�7�D���!%��v�� $�F�9����"�	-�	-�	-�!&�F�9�� ,�F�9���� �	,�	,�	,� %�F�9�� +�F�9�����	'�	'�	'�
�h�m�$�$�$� %�F�9�� #�A���F�9������������	'�	'�	'��K�K�K� %�F�9�� #�A���F�9�����������	'����	
����C� � � ��
s0�A
A$�$D	�:D	�	D	�0C
�

D	�%D�D	c�j�	|j���}|�dd|d����3)NT�output�stdout)�categoryr[)r?�readline�
send_event)r%�lines  r�_read_inferior_outputzServer._read_inferior_output�sI��	��$�-�-�/�/�D��O�O�� (�"���
�
�
�	rc��tdtj|��zdz��|j�|��dS)Nz
WROTE: <<<�>>>)r
�json�dumpsrA�put)r%�objs  r�
_send_jsonzServer._send_json�s?���L�4�:�c�?�?�*�U�2�3�3�3�����S�!�!�!�!�!rc�v�	t|j��}|�n�tdtj|��zdz��d|vr@|ddkr4d|vr0d|dvr&|j�|dd��|j�|����|j�d��dS)NTz	READ: <<<rcrHr4rK�	requestId)	rr=r
rdrerCr4rBrf�r%�cmds  r�_reader_threadzServer._reader_thread�s���	%��D�N�+�+�C��{����d�j��o�o�-��5�6�6�6�
�S� � ��	�N�h�.�.��3�&�&� �3�{�#3�3�3���%�%�c�+�&6�{�&C�D�D�D��O����$�$�$�#	%�&	
����D�!�!�!�!�!rc��td|j��t|j|j��}td|j��|jsy|j���}|�n]|�	|��}|�
|��|j}g|_|D]\}}|�||���|j�y|j�
d��|���td��dS)z The main loop of the DAP server.z
output readerzJSON readerN�quit)rrarr>rArmr.rB�getrYrhr@r_rf�join�send_gdb)r%�json_writerrlrV�events�eventrLs       r�	main_loopzServer.main_loop�s
��
	�_�d�&@�A�A�A�'����9I�J�J���]�D�$7�8�8�8��)�
	-��/�%�%�'�'�C��{���)�)�#�.�.�F��O�O�F�#�#�#��(�F�"$�D��%�
-�
-���t�����t�,�,�,�,��)�
	-�	
����T�"�"�"�������������rNc�>�|j�||f��dS)z^Send a DAP event back to the client, but only after the
        current request has completed.N)r@�append)r%rurLs   r�send_event_laterzServer.send_event_later�s%��	
��"�"�E�4�=�1�1�1�1�1rc�H�d|d�}|�||d<|�|��dS)z�Send an event to the DAP client.
        EVENT is the name of the event, a string.
        BODY is the body of the event, an arbitrary object.ru)rJruNrL)rh)r%rurLrgs    rr_zServer.send_events?��
��
�
�����C��K���������rc��d|_dS)z"Request that the server shut down.TN)r.r$s r�shutdownzServer.shutdowns��
��	�	�	rr)rrr�__doc__r&rrYrarhrmrvryr_r|rrrr;r;xs������������&�&�&��]�&�T	�	�	�"�"�"�"�"�"�,����]��2�2�2�2��]�2�
�
�
�
�����rr;c�<�t�||��dS)z�Send an event to the DAP client.
    EVENT is the name of the event, a string.
    BODY is the body of the event, an arbitrary object.N)rDr_)rurLs  rr_r_s ��
���u�d�#�#�#�#�#rc�F��tj����fd���}|S)Nc�@��ddlm}|rt����|i|��S)Nr)�inferior_running)rtr�r)rW�kwargsr��funcs   �r�checkz!_check_not_running.<locals>.check$s@���	-�,�,�,�,�,��	(�%�'�'�'��t�T�$�V�$�$�$r)�	functools�wraps)r�r�s` r�_check_not_runningr�#s8����_�T���%�%�%�%���%��LrTF)rG�
on_dap_thread�expect_stopped�namerGr�r�c�*������r�sJ�����fd�}|S)a)A decorator for DAP requests.

    This registers the function as the implementation of the DAP
    request NAME.  By default, the function is invoked in the gdb
    thread, and its result is returned as the 'body' of the DAP
    response.

    Some keyword arguments are provided as well:

    If RESPONSE is False, the result of the function will not be
    waited for and no 'body' will be in the response.

    If ON_DAP_THREAD is True, the function will be invoked in the DAP
    thread.  When ON_DAP_THREAD is True, RESPONSE may not be False.

    If EXPECT_STOPPED is True (the default), then the request will
    fail with the 'notStopped' reason if it is processed while the
    inferior is running.  When EXPECT_STOPPED is False, the request
    will proceed regardless of the inferior's state.
    c�j����j}	|jdksJ�n#t$rYnwxYw|jdksJ�|jt
jzsJ�t�����rt���}n t�����r�fd�}|}n�fd�}|}�rt|��}�tvsJ�|t�<|S)Nrc�,���t��fd���S)Nc����di���S�Nrr�rWr�s��r�<lambda>z:request.<locals>.wrap.<locals>.sync_call.<locals>.<lambda>hs���$�$�,�,��,�,�r)�send_gdb_with_responser�s`�r�	sync_callz(request.<locals>.wrap.<locals>.sync_callgs����1�2F�2F�2F�2F�2F�G�G�Grc�,���t��fd���S)Nc����di���Sr�rr�s��rr�z>request.<locals>.wrap.<locals>.non_sync_call.<locals>.<lambda>ns���D�D�L�L�4�L�L�r)rrr�s`�r�
non_sync_callz,request.<locals>.wrap.<locals>.non_sync_callms����#�$8�$8�$8�$8�$8�9�9�9r)�__code__�co_posonlyargcount�AttributeError�co_argcount�co_flags�inspect�CO_VARKEYWORDSrrrr�rQ)	r��coderlr�r�r�r�r�rGs	`    ����r�wrapzrequest.<locals>.wrapPs/�����}��	��*�a�/�/�/�/�/���	�	�	��D�	������1�$�$�$�$��}�w�5�5�5�5�5��$�����	$���%�%�C�C� ��&�&�D��
$�H�H�H�H�H� ���:�:�:�:�:�$��
�	*�$�S�)�)�C��9�$�$�$�$��	�$���
s�
�
&�&r)r�rGr�r�r�s```` r�requestr�1sI������:�(��(�(�(�+�+�+�+�+�+�+�+�Z�Krc������fd�}|S)z\A decorator that indicates that the wrapper function implements
    the DAP capability NAME.c�2���tvsJ��t�<|Sr)�
_capabilities)r�r��values ��rr�zcapability.<locals>.wrap�s#����=�(�(�(�(�#�
�d���rr)r�r�r�s`` r�
capabilityr��s)�����������Krc��|tjvr7ttj|t��rtj|SdS)z�Return the value of a boolean client capability.

    If the capability was not specified, or did not have boolean type,
    False is returned.F)rD�config�
isinstance�bool)r�s r�client_bool_capabilityr��s9���w�~���*�W�^�D�-A�4�"H�"H���~�d�#�#��5r�
initialize)r�c��|t_t�d��t���S)N�initialized)rDr�ryr��copy�rWs rr�r��s1���G�N����]�+�+�+������r�	terminate)r��supportsTerminateRequestc�$�td��dS�N�kill)r
r�s rr�r��s��������r�
disconnect)r�r��supportTerminateDebuggee)�terminateDebuggeer�c�Z�|rtd��t���dSr�)r�rDr|)r�rWs  rr�r��s2���'��v�&�&�&��������rr4�supportsCancelRequestc��dSrrr�s rr4r4�s	���4rc�.�eZdZdZd�Zed���ZdS)�Invokerz-A simple class that can invoke a gdb command.c��||_dSr�rlrks  rr&zInvoker.__init__�s
������rc�.�t|j��dSr)r
rlr$s r�__call__zInvoker.__call__�s���T�X�����rN)rrrr}r&rr�rrrr�r��sD������7�7��������]���rr�c�,�eZdZdd�Zed���ZdS)�CancellableNc��||_||_tjj5tjj|_ddd��dS#1swxYwYdSr)�fn�result_qrDrCr r!r*)r%r�r�s   rr&zCancellable.__init__�s������ ��
�
�
�
#�	>�	>��(�=�D�H�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�	>�	>s�A�A�Ac��	tj�|j��5|���}|j�|j�|��ddd��dS#1swxYwYdS#ttf$r�}|j�|j�|��nPt|t��rn@|�dt|����}td|z��t��Yd}~dSYd}~dSYd}~dSd}~wwxYw)Nz, zcaught exception: )
rDrCr9r*r�r�rf�	Exceptionr8r�rJrr)r%�valrX�
err_strings    rr�zCancellable.__call__�sq��	��"�7�7���A�A�
+�
+��g�g�i�i���=�,��M�%�%�c�*�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+���,�-�	�	�	��}�(��
�!�!�!�$�$�$�$��A�0�1�1�
��*+���D��G�G�G�4�
��/�*�<�=�=�=�����������%�$�$�$�$�$�����������
	���s;�$A6�6A)�A6�)A-�-A6�0A-�1A6�6D
�A,D�D
r)rrrr&rr�rrrr�r��sC������>�>�>�>�����]���rr�c��t|t��rt|��}tjt|����dS)z}Send CMD to the gdb thread.
    CMD can be either a function or a string.
    If it is a string, it is passed to gdb.execute.N)r�rSr�r0�
post_eventr�r�s rrrrr�sA���#�s�����c�l�l���N�;�s�#�#�$�$�$�$�$rc��t|t��rt|��}t��}t	jt
||����|���}t|ttf��r|�|S)z�Send FN to the gdb thread and return its result.
    If FN is a string, it is passed to gdb.execute and None is
    returned as the result.
    If FN throws an exception, this function will throw the
    same exception in the calling thread.
    )
r�rSr�rr0r�r�rpr�r8)r�r�r�s   rr�r��su���"�c����
�R�[�[���z�z�H��N�;�r�8�,�,�-�-�-�
�,�,�.�.�C��#�	�#4�5�6�6���	��Jrr)T)/r�r2r�rdr�
contextlibrr0�iorr�startuprrr	r
rrr
rrr�	typecheckrr�rQrDr�rrr;r_r�rSr�r�r�r�r�r�r�r4�objectr�r�rrr�rrr�<module>r�s��� ��������������������%�%�%�%�%�%�
�
�
�
�,�,�,�,�,�,�,�,�������������������������"�!�!�!�!�!��
�
�	���
	�	�	�	�	�)�	�	�	�:1�:1�:1�:1�:1�:1�:1�:1�z_�_�_�_�_�_�_�_�D$�$�$�$����"���L�L�L�

�L��L��	L�
�L�L�L�L�^
�
�
�
����	���T�*�*�*� � �+�*� �	���U�+�+�+���&�'�'���(�'�,�+��	���T�%�@�@�@���&�'�'�,1����T����(�'�A�@��	����e�<�<�<���#�$�$�
�
�%�$�=�<�
�	�	�	�	�	�f�	�	�	������&����<%�%�%�����r

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