File: //usr/share/gdb/python/gdb/command/__pycache__/pretty_printers.cpython-310.pyc
o
̴6b�8 � @ s� d Z ddlZddlZddlZdd� Zdd� ZG dd� dej�Zd d
� Zdd� Z ddd�Z
dd� Zdd� Zdd� Z
G dd� dej�ZG dd� dej�Zdd� Ze� dS )z.GDB commands for working with pretty-printers.� Nc
C s t �| �}t|�}d}d}d}|dkrtd��|dkr|d }|dkr9|d �dd�}|d }t|�dkr9|d }zt�|�}W n
tyM td | ��w zt�|�}W n
tyb td
| ��w |dur|zt�|�} W n ty{ td| ��w d} ||| 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_regexps s@
���
r c C s t | d�r| jS dS )z>Internal utility to see if printer (or subprinter) is enabled.�enabledT)�hasattrr ��printerr r r �printer_enabled_pL s
r c sP e Zd ZdZ� fdd�Zedd� �Zedd� �Zdd � Zd
d� Z dd
� 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 � t t| ��dtj� d S )Nzinfo pretty-printer)�superr �__init__r �COMMAND_DATA��self�� __class__r r r# a s zInfoPrettyPrinter.__init__c C s t | �rdS dS )z9Return "" if PRINTER is enabled, otherwise " [disabled]".r z [disabled])r r r r r �enabled_stringd s z InfoPrettyPrinter.enabled_stringc C s$ t | d�r| jS t | d�r| jS dS )zReturn the printer's name.�name�__name__�unknown)r r* r+ r r r r �printer_namel s
zInfoPrettyPrinter.printer_namec
C s� t t�|�| jd�}|D ]G}| �|�}| �|�}|�|�rStd||f � t|d�rS|jdurSt t�|j�| jd�}|D ]} |rF|�| j�rRtd| j| �| �f � q<qdS )z Print a list of pretty-printers.)�keyz %s%s�subprintersNz %s%s) �sorted�copyr- r) �match�printr r/ r* )
r&