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__/varref.cpython-311.pyc

�

��gT'��$�ddlmZmZddlmZddlmZddlZddlm	Z	ddl
mZmZga
ed���Zejj�e��ed	���Zed
���ZGd�de��ZGd
�de��Zed���ZdS)�)�ABC�abstractmethod)�defaultdict)�contextmanagerN�)�client_bool_capability)�DAPException�
in_gdb_threadc�
�gadS�N)�
all_variables)�events �./gdb/dap/varref.py�
clear_varsrs
���M�M�M�c+�K�dV�dSr�)�ignores r�_nullr)s����	�E�E�E�E�Erc�d�|�!d|vr|drtjdd��St��S)z�Temporarily apply the DAP ValueFormat.

    This returns a new context manager that applies the given DAP
    ValueFormat object globally, then restores gdb's state when finished.N�hexzoutput-radix�)�gdb�with_parameterr)�value_formats r�apply_formatr.s:����E�\�$9�$9�l�5�>Q�$9��!�.�"�5�5�5��7�7�Nrc��eZdZdZed���Zed���Zed���Zd�Z	ed���Z
ed���Zd�Zed	���Z
ed
���ZdS)�
BaseReferencez�Represent a variable or a scope.

    This class is just a base class, some methods must be implemented in
    subclasses.

    The 'ref' field can be used as the variablesReference in the protocol.
    c��t�|��tt��|_||_|���dS)z�Create a new variable reference with the given name.

        NAME is a string or None.  None means this does not have a
        name, e.g., the result of expression evaluation.N)r
�append�len�ref�name�reset_children��selfr#s  r�__init__zBaseReference.__init__BsF��	���T�"�"�"��}�%�%�����	��������rc��d|���r|jndi}|j�t|j��|d<|S)z�Return a dictionary that describes this object for DAP.

        The resulting object is a starting point that can be filled in
        further.  See the Scope or Variable types in the spec�variablesReferencerNr#)�has_childrenr"r#�str)r&�results  r�	to_objectzBaseReference.to_objectOsC��'�D�4E�4E�4G�4G�(N����Q�O���9� � ���^�^�F�6�N��
rc��dS)z(Return True if this object has children.Fr�r&s rr*zBaseReference.has_childrenZs	���urc�L�d|_i|_td���|_dS)z?Reset any cached information about the children of this object.Nc��dS)Nrrrrr�<lambda>z.BaseReference.reset_children.<locals>.<lambda>is��q�r)�children�by_namer�name_countsr/s rr$zBaseReference.reset_children_s,����
����'�y�y�1�1����rc��dS)z�Fetch one child of this variable.

        INDEX is the index of the child to fetch.
        This should return a tuple of the form (NAME, VALUE), where
        NAME is the name of the variable, and VALUE is a gdb.Value.Nr)r&�indexs  r�fetch_one_childzBaseReference.fetch_one_childks	��	�rc��dS)z/Return the number of children of this variable.Nrr/s r�child_countzBaseReference.child_countts	��	�rc��||jvr5|j|xxdz
cc<|dzt|j|��z}|S)Nrz #)r4r5r+r%s  r�
_compute_namezBaseReference._compute_name�sS���4�<�����T�"�"�"�a�'�"�"�"�
�$�;��T�%5�d�%;�!<�!<�<�D��rc#�K�|dkr|���}|j�dg|���z|_t|||z��D]o}|j|�Q|�|��\}}|�|��}t||��}||j|<||j|<|j|V��pdS)z�Fetch children of this variable.

        START is the starting index.
        COUNT is the number to return, with 0 meaning return all.
        Returns an iterable of some kind.rN)r:r3�ranger8r<�VariableReferencer4)r&�start�count�idxr#�value�vars       r�fetch_childrenzBaseReference.fetch_children�s������A�:�:��$�$�&�&�E��=� �!�F�T�%5�%5�%7�%7�7�D�M�����
�.�.�	%�	%�C��}�S�!�)� $� 4� 4�S� 9� 9�
��u��)�)�$�/�/��'��e�4�4��%(��
�c�"�%(���T�"��-��$�$�$�$�$�	%�	%rc�X�||jvr
|j|Std|zdz���)zoFind a child of this variable, given its name.

        Returns the value of the child, or throws if not found.zno variable named '�')r4r	r%s  r�find_child_by_namez BaseReference.find_child_by_name�s7���4�<����<��%�%��0�4�7�#�=�>�>�>rN)�__name__�
__module__�__qualname__�__doc__r
r'r-rr*r$r8r:r<rErHrrrrr9s����������
�
��]�
�����]������^��
2�
2�
2�����^������^������%�%��]�%�&�	?�	?��]�	?�	?�	?rrc�b��eZdZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Z	�fd	�Z
ed
���Z�xZ
S)r?z:Concrete subclass of BaseReference that handles gdb.Value.rCc���t���|��||_||_|���dS)z�Initializer.

        NAME is the name of this reference, see superclass.
        VALUE is a gdb.Value that holds the value.
        RESULT_NAME can be used to change how the simple string result
        is emitted in the result dictionary.N)�superr'�result_namerC�
_update_value)r&r#rCrP�	__class__s    �rr'zVariableReference.__init__�sD���	���������&�����
��������rc���|���tj�|j��|_d|_|���r	d|_dSd|_dS)N���)	r$r�printing�make_visualizerrC�printer�child_cacher*rAr/s rrQzVariableReference._update_value�s_���������|�3�3�D�J�?�?�����������	��D�J�J�J��D�J�J�Jrc�b�|j�|��|���dS)z'Assign VALUE to this object and update.N)rC�assignrQ)r&rCs  rrZzVariableReference.assign�s0���
���%� � � ��������rc�,�t|jd��S)Nr3)�hasattrrWr/s rr*zVariableReference.has_children�s���t�|�Z�0�0�0rc�t�|j�+t|j�����|_|jSr)rX�listrWr3r/s r�cache_childrenz VariableReference.cache_children�s4����#� $�D�L�$9�$9�$;�$;�<�<�D����rc�*�|j�dS|jdkryd}t|jtj��r.t|jd��r|j���}|�!t|�����}||_|jS)NrT�num_children)	rA�
isinstancerWr�ValuePrinterr\rar!r_)r&ras  rr:zVariableReference.child_count�s����:���4��:�����L��$�,��(8�9�9�
;�g���n�?�?�
;� $�|�8�8�:�:���#�"�4�#6�#6�#8�#8�9�9��%�D�J��z�rc�h��t�����}t|j�����||j<|���}|�=t|jd��r#|j���dkr||d<n||d<td��rU|j
j���j
tjkr$t!t#|j
����|d<td��rt|j
j��|d<|S)	N�display_hint�array�indexedVariables�namedVariables�supportsMemoryReferences�memoryReference�supportsVariableType�type)rOr-r+rW�	to_stringrPr:r\rerrCrl�strip_typedefs�coder�
TYPE_CODE_PTRr�int)r&r,rarRs   �rr-zVariableReference.to_object�s������"�"�$�$��#&�t�|�'=�'=�'?�'?�#@�#@��t�� ��'�'�)�)���#����n�5�5�
8��L�-�-�/�/�7�:�:�-9��)�*�*�+7��'�(�!�"<�=�=�	A�
�z��-�-�/�/�4��8I�I�I�,/��D�J���,@�,@��(�)�!�"8�9�9�	2� ����1�1�F�6�N��
rc�D�t|jtj��r3t	|jd��r|j�|��\}}n|���|\}}t|tj��stj|��}||fS)N�child)rbrWrrcr\rsr_�Value)r&rBr#�vals    rr8z!VariableReference.fetch_one_child�s����d�l�C�$4�5�5�	5�'��L�'�;
�;
�	5��,�,�,�S�1�1�K�T�3�3��-�-�/�/��4�K�T�3��#�s�y�)�)�	!��)�C�.�.�C��c�{�r)rC)rIrJrKrLr'rQrZr*r_r:r-r
r8�
__classcell__)rRs@rr?r?�s��������D�D�
�
�
�
�
�
�������
1�1�1�	 �	 �	 ���������.����]�����rr?c��|dz
}|dks|tt��krtd���t|S)zEGiven a variable reference, return the corresponding variable object.rrzinvalid variablesReference)r!r
r	)r"s r�
find_variablerxsB��
��'�C�
�Q�w�w�#��M�*�*�*�*��7�8�8�8����r)�abcrr�collectionsr�
contextlibrr�serverr�startupr	r
r
r�events�cont�connectrrrr?rxrrr�<module>r�ss�� $�#�#�#�#�#�#�#�#�#�#�#�#�#�%�%�%�%�%�%�
�
�
�
�*�*�*�*�*�*�0�0�0�0�0�0�0�0��
�
������
�
����
�#�#�#��
�
���
�������p?�p?�p?�p?�p?�C�p?�p?�p?�f]�]�]�]�]�
�]�]�]�@�������r

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