HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/share/gdb/python/gdb/command/__pycache__/pretty_printers.cpython-310.pyc
o

̴6b�8�@s�dZddlZddlZddlZdd�Zdd�ZGdd�dej�Zd	d
�Zdd�Z	ddd�Z
dd�Zdd�Zdd�Z
Gdd�dej�ZGdd�dej�Zdd�Ze�dS)z.GDB commands for working with pretty-printers.�Nc
Cst�|�}t|�}d}d}d}|dkrtd��|dkr|d}|dkr9|d�dd�}|d}t|�dkr9|d}zt�|�}Wn
tyMtd	|��wzt�|�}Wn
tybtd
|��w|dur|zt�|�}	Wnty{td|��wd}	|||	fS)a�Internal utility to parse a pretty-printer command argv.

    Arguments:
        arg: The arguments to the command.  The format is:
             [object-regexp [name-regexp]].
             Individual printers in a collection are named as
             printer-name;subprinter-name.

    Returns:
        The result is a 3-tuple of compiled regular expressions, except that
        the resulting compiled subprinter regexp is None if not provided.

    Raises:
        SyntaxError: an error processing ARG
    �N�ztoo many arguments�r��;zinvalid object regexp: %szinvalid name regexp: %szinvalid subname regexp: %s)�gdb�string_to_argv�len�SyntaxError�split�re�compile)
�arg�argv�argc�
object_regexp�name_regexp�subname_regexp�name_subname�	object_re�name_re�
subname_re�r�4/usr/share/gdb/python/gdb/command/pretty_printers.py�parse_printer_regexpss@
���
rcCst|d�r|jSdS)z>Internal utility to see if printer (or subprinter) is enabled.�enabledT)�hasattrr��printerrrr�printer_enabled_pLs
rcsPeZdZdZ�fdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
�ZS)�InfoPrettyPrintera�GDB command to list all registered pretty-printers.

    Usage: info pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]

    OBJECT-REGEXP is a regular expression matching the objects to list.
    Objects are "global", the program space's file, and the objfiles within
    that program space.

    NAME-REGEXP matches the name of the pretty-printer.
    Individual printers in a collection are named as
    printer-name;subprinter-name.c�tt|��dtj�dS)Nzinfo pretty-printer)�superr �__init__r�COMMAND_DATA��self��	__class__rrr#aszInfoPrettyPrinter.__init__cCst|�rdSdS)z9Return "" if PRINTER is enabled, otherwise " [disabled]".rz [disabled])rrrrr�enabled_stringdsz InfoPrettyPrinter.enabled_stringcCs$t|d�r|jSt|d�r|jSdS)zReturn the printer's name.�name�__name__�unknown)rr*r+rrrr�printer_namels


zInfoPrettyPrinter.printer_namec
Cs�tt�|�|jd�}|D]G}|�|�}|�|�}|�|�rStd||f�t|d�rS|jdurStt�|j�|jd�}|D]}	|rF|�|	j�rRtd|	j|�|	�f�q<qdS)z Print a list of pretty-printers.)�keyz  %s%s�subprintersNz    %s%s)	�sorted�copyr-r)�match�printrr/r*)
r&�pretty_printersrr�sorted_pretty_printersrr*r�sorted_subprinters�
subprinterrrr�list_pretty_printersys*�


�����z&InfoPrettyPrinter.list_pretty_printerscCs0|r|�|�rt|�|�|||�dSdSdS)z$Subroutine of invoke to simplify it.N)r2r3r8)r&�title�printer_list�obj_name_to_matchrrrrrr�invoke1�s�zInfoPrettyPrinter.invoke1c	Csxt|�\}}}|�dtjd|||�t��}|�d|j|jd|||�t��D]}|�d|j|j|j|||�q(dS)�&GDB calls this to perform the command.zglobal pretty-printers:�globalzprogspace %s pretty-printers:�	progspacezobjfile %s pretty-printers:N)rr<rr4�current_progspace�filename�objfiles)r&r�from_ttyrrr�cp�objfilerrr�invoke�s8����zInfoPrettyPrinter.invoke)r+�
__module__�__qualname__�__doc__r#�staticmethodr)r-r8r<rF�
__classcell__rrr'rr Ts

r cCszd}d}|D]2}t|d�r,|jdur,t|�r$|jD]
}t|�r#|d7}q|t|j�7}qt|�r4|d7}|d7}q||fS)z9Return a 2-tuple of number of enabled and total printers.rr/Nr)rr/rr	)r4r�totalrr7rrr�count_enabled_printers�s
�
rMcCs|d}d}ttj�\}}||7}||7}tt��j�\}}||7}||7}t��D]}t|j�\}}||7}||7}q(||fS)zkReturn a 2-tuble of the enabled state and total number of all printers.
    This includes subprinters.
    r)rMrr4r@rB)�
enabled_count�total_count�	t_enabled�t_totalrErrr�count_all_enabled_printers�s�
rR�scCs|dkr
d||fS|S)z!Return TEXT pluralized if N != 1.rz%s%sr)�text�n�suffixrrr�	pluralize�srWcCst�\}}td||f�dS)zZPrint the number of printers enabled/disabled.
    We count subprinters individually.
    z%d of %d printers enabledN)rRr3)rNrOrrr�#show_pretty_printer_enabled_summary�s
rXcCs�d}|D]i}t|d�r|�|j�st|d�rm|�|j�rmt|d�r^|jdur^|s@t|�|kr<|jD]
}t|�r;|d7}q1||_q|jD]}|�|j�r\t|�rYt|�|krY|d7}||_qCq|smt|�|krj|d7}||_q|S)a�Worker for enabling/disabling pretty-printers.

    Arguments:
        pretty_printers: list of pretty-printers
        name_re: regular-expression object to select printers
        subname_re: regular expression object to select subprinters or None
                    if all are affected
        flag: True for Enable, False for Disable

    Returns:
        The number of printers affected.
        This is just for informational purposes for the user.
    rr*r+r/Nr)rr2r*r+r/rr)r4rr�flagrLrr7rrr�do_enable_pretty_printer_1�sB�
��
�
�
����rZc	Cs�t|�\}}}d}|�d�r|ttj|||�7}t��}|�d�r+|t|j|||�7}t��D]}|�|j�rA|t|j|||�7}q/|rGd}nd}td|t	d|�|f�t
�dS)	z7Internal worker for enabling/disabling pretty-printers.rr>r?r�disabledz%d %s %srN)rr2rZrr4r@rBrAr3rWrX)	rrYrrrrLrDrE�staterrr�do_enable_pretty_printer-s,

�

�
��
r]c�(eZdZdZ�fdd�Zdd�Z�ZS)�EnablePrettyPrintera�GDB command to enable the specified pretty-printer.

    Usage: enable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]

    OBJECT-REGEXP is a regular expression matching the objects to examine.
    Objects are "global", the program space's file, and the objfiles within
    that program space.

    NAME-REGEXP matches the name of the pretty-printer.
    Individual printers in a collection are named as
    printer-name;subprinter-name.cr!)Nzenable pretty-printer)r"r_r#rr$r%r'rrr#c�
�zEnablePrettyPrinter.__init__cC�t|d�dS)r=TN�r]�r&rrCrrrrFh�zEnablePrettyPrinter.invoke�r+rGrHrIr#rFrKrrr'rr_V�r_cr^)�DisablePrettyPrintera�GDB command to disable the specified pretty-printer.

    Usage: disable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]

    OBJECT-REGEXP is a regular expression matching the objects to examine.
    Objects are "global", the program space's file, and the objfiles within
    that program space.

    NAME-REGEXP matches the name of the pretty-printer.
    Individual printers in a collection are named as
    printer-name;subprinter-name.cr!)Nzdisable pretty-printer)r"rgr#rr$r%r'rrr#zr`zDisablePrettyPrinter.__init__cCra)r=FNrbrcrrrrFrdzDisablePrettyPrinter.invokererrr'rrgmrfrgcCst�t�t�dS)zDCall from a top level script to install the pretty-printer commands.N)r r_rgrrrr� register_pretty_printer_commands�s
rh)rS)rIr1rrrr�Commandr rMrRrWrXrZr]r_rgrhrrrr�<module>s"4c
?)