Current File : //usr/share/gdb/python/gdb/command/__pycache__/pretty_printers.cpython-39.opt-1.pyc
a

ɱZh�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}|dkr.td��|dkr>|d}|dkrr|d�dd�}|d}t|�dkrr|d}zt�|�}Wnty�td	|��Yn0zt�|�}Wnty�td
|��Yn0|du�r
zt�|�}	Wn t�ytd|��Yn0nd}	|||	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)�gdbZstring_to_argv�len�SyntaxError�split�re�compile)
�arg�argvZargcZ
object_regexpZname_regexpZsubname_regexpZ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|jSdSdS)z>Internal utility to see if printer (or subprinter) is enabled.�enabledTN)�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.cstt|��dtj�dS)Nzinfo pretty-printer)�superr�__init__r�COMMAND_DATA��self��	__class__rrraszInfoPrettyPrinter.__init__cCst|�rdSdSdS)z9Return "" if PRINTER is enabled, otherwise " [disabled]".rz [disabled]N)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]�}|�|�}|�|�}|�|�rtd||f�t|d�r|jdurtt�|j�|jd�}|D],}	|r�|�|	j�rxtd|	j|�|	�f�qxqdS)z Print a list of pretty-printers.)�keyz  %s%s�subprintersNz    %s%s)	�sorted�copyr&r"�match�printrr(r#)
r�pretty_printersrrZsorted_pretty_printersrr#rZsorted_subprinters�
subprinterrrr�list_pretty_printersys&�


���z&InfoPrettyPrinter.list_pretty_printerscCs(|r$|�|�r$t|�|�|||�dS)z$Subroutine of invoke to simplify it.N)r+r,r/)r�titleZprinter_listZobj_name_to_matchrrrrrr�invoke1�szInfoPrettyPrinter.invoke1c	Csxt|�\}}}|�dtjd|||�t��}|�d|j|jd|||�t��D]"}|�d|j|j|j|||�qPdS)�&GDB calls this to perform the command.zglobal pretty-printers:�globalzprogspace %s pretty-printers:�	progspacezobjfile %s pretty-printers:N)rr1rr-�current_progspace�filename�objfiles)rr
�from_ttyrrr�cp�objfilerrr�invoke�s6���zInfoPrettyPrinter.invoke)r$�
__module__�__qualname__�__doc__r�staticmethodr"r&r/r1r;�
__classcell__rrr rrTs

rcCszd}d}|D]d}t|d�rX|jdurXt|�rH|jD]}t|�r2|d7}q2|t|j�7}qt|�rh|d7}|d7}q||fS)z9Return a 2-tuple of number of enabled and total printers.rr(Nr)rr(rr)r-r�totalrr.rrr�count_enabled_printers�s


rBcCs|d}d}ttj�\}}||7}||7}tt��j�\}}||7}||7}t��D]"}t|j�\}}||7}||7}qP||fS)zkReturn a 2-tuble of the enabled state and total number of all printers.
    This includes subprinters.
    r)rBrr-r5r7)�
enabled_count�total_countZ	t_enabledZt_totalr:rrr�count_all_enabled_printers�s�
rE�scCs|dkrd||fS|SdS)z!Return TEXT pluralized if N != 1.rz%s%sNr)�text�n�suffixrrr�	pluralize�srJcCst�\}}td||f�dS)zZPrint the number of printers enabled/disabled.
    We count subprinters individually.
    z%d of %d printers enabledN)rEr,)rCrDrrr�#show_pretty_printer_enabled_summary�s
rKcCs�d}|D]�}t|d�r"|�|j�s8t|d�r|�|j�rt|d�r�|jdur�|s�t|�|krx|jD]}t|�rb|d7}qb||_q�|jD]2}|�|j�r�t|�r�t|�|kr�|d7}||_q�q|st|�|kr�|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)rr+r#r$r(rr)r-rr�flagrArr.rrr�do_enable_pretty_printer_1�s<�
��
�


�
�
rMc	Cs�t|�\}}}d}|�d�r0|ttj|||�7}t��}|�d�rV|t|j|||�7}t��D]$}|�|j�r^|t|j|||�7}q^|r�d}nd}td|t	d|�|f�t
�dS)	z7Internal worker for enabling/disabling pretty-printers.rr3r4rZdisabledz%d %s %srN)rr+rMrr-r5r7r6r,rJrK)	r
rLrrrrAr9r:�staterrr�do_enable_pretty_printer-s*

�

�
�rOcs(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.cstt|��dtj�dS)Nzenable pretty-printer)rrPrrrrr rrrcs
�zEnablePrettyPrinter.__init__cCst|d�dS)r2TN�rO�rr
r8rrrr;hszEnablePrettyPrinter.invoke�r$r<r=r>rr;r@rrr rrPVsrPcs(eZdZdZ�fdd�Zdd�Z�ZS)�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.cstt|��dtj�dS)Nzdisable pretty-printer)rrTrrrrr rrrzs
�zDisablePrettyPrinter.__init__cCst|d�dS)r2FNrQrRrrrr;szDisablePrettyPrinter.invokerSrrr rrTmsrTcCst�t�t�dS)zDCall from a top level script to install the pretty-printer commands.N)rrPrTrrrr� register_pretty_printer_commands�srU)rF)r>r*rrrrZCommandrrBrErJrKrMrOrPrTrUrrrr�<module>s 4c
?)