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

ɱZh'�@s�ddlZddlZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�ZGdd�dej	�Z
Gdd�dej	�ZGdd�dej	�Zdd�Z
e
�dS)�NcCs0zt�|�WSty*td||��Yn0dS)NzInvalid %s regexp: %s)�re�compile�SyntaxError)Z	part_nameZregexp�r�-/usr/share/gdb/python/gdb/command/xmethods.py�validate_xm_regexpsrcCs�t�|�}t|�}|dkr"td��d}d}d}|dkr>|d}|dkrr|d�dd�}|d}t|�dkrr|d}|r�td|�}nd}td	|�td
|�|fS)a?Parses the arguments passed to a xmethod command.

    Arguments:
        arg: The argument string passed to a xmethod command.

    Returns:
        A 3-tuple: (<locus matching regular expression>,
                    <matcher matching regular expression>,
                    <name matching regular experession>)
    �zToo many arguments to command.�N�r�;zxmethod name�locuszmatcher name)�gdbZstring_to_argv�lenr�splitr)�arg�argvZargcZlocus_regexpZmatcher_name_regexpZxm_name_regexp�parts�name_rerrr�parse_xm_command_argss*
�rcs8d}|gi}|�d�r4||��fdd�tjD��|S)a�Returns a dict of matching globally registered xmethods.

    Arguments:
        locus_re: Even though only globally registered xmethods are
                  looked up, they will be looked up only if 'global' matches
                  LOCUS_RE.
        matcher_re: The regular expression matching the names of xmethods.

    Returns:
        A dict of matching globally registered xmethod matchers.  The only
        key in the dict will be 'global'.
    �globalcsg|]}��|j�r|�qSr��match�name��.0�m��
matcher_rerr�
<listcomp>R�z.get_global_method_matchers.<locals>.<listcomp>)r�extendr
�xmethods)�locus_rer�	locus_str�xm_dictrrr�get_global_method_matchersBs


r%cshi}|D]Z}t|tj�r*|�d�s$qd}n|�|j�s8qd}d||jf}�fdd�|jD�||<q|S)a�Returns a dict of matching registered xmethods in the LOCI.

    Arguments:
        loci: The list of loci to lookup matching xmethods in.
        locus_re: If a locus is an objfile, then xmethod matchers will be
                  looked up in it only if its filename matches the regular
                  expression LOCUS_RE.  If a locus is the current progspace,
                  then xmethod matchers will be looked up in it only if the
                  string "progspace" matches LOCUS_RE.
        matcher_re: The regular expression to match the xmethod matcher
                    names.

    Returns:
        A dict of matching xmethod matchers.  The keys of the dict are the
        filenames of the loci the xmethod matchers belong to.
    Z	progspaceZobjfilez%s %scsg|]}��|j�r|�qSrrrrrrrrrz/get_method_matchers_in_loci.<locals>.<listcomp>)�
isinstancer
Z	Progspacer�filenamer!)Zlocir"rr$rZ
locus_typer#rrr�get_method_matchers_in_lociVs
r(cCs�dd�}|sdS|D]|}||s"qtd|�||D]X}td|j||�f�|jsXq6|jD].}|dusv|�|j�r^td|j||�f�q^q6qdS)zPrint a dictionary of xmethods.cSs|js
dSdSdS)Nz [disabled]r	)�enabled)rrrr�get_status_stringysz(print_xm_info.<locals>.get_status_stringNzXmethods in %s:z  %s%sz    %s%s)�printr�methodsr)r$rr*r#�matcherrrrr�
print_xm_infovs
r.cCsR|��D]D\}}|D]6}|s$||_q|js,q|jD]}|�|j�r2||_q2qqdS)z>Set the status (enabled/disabled) of a dictionary of xmethods.N)�itemsr)r,rr)r$r�statusr#Zmatchersr-rrrr�set_xm_status1�s
r1cCsVt|�\}}}tt||�||�ttt��g||�||�ttt��||�||�dS)z�Set the status (enabled/disabled) of xmethods matching ARG.
    This is a helper function for enable/disable commands.  ARG is the
    argument string passed to the commands.
    N)rr1r%r(r
�current_progspace�objfiles)rr0r"rrrrr�
set_xm_status�s��r4cs(eZdZdZ�fdd�Zdd�Z�ZS)�InfoXMethodaiGDB command to list registered xmethod matchers.

    Usage: info xmethod [LOCUS-REGEXP [NAME-REGEXP]]

    LOCUS-REGEXP is a regular expression matching the location of the
    xmethod matchers.  If it is omitted, all registered xmethod matchers
    from all loci are listed.  A locus could be 'global', a regular expression
    matching the current program space's filename, or a regular expression
    matching filenames of objfiles.  Locus could be 'progspace' to specify that
    only xmethods from the current progspace should be listed.

    NAME-REGEXP is a regular expression matching the names of xmethod
    matchers.  If this omitted for a specified locus, then all registered
    xmethods in the locus are listed.  To list only a certain xmethods
    managed by a single matcher, the name regexp can be specified as
    matcher-name-regexp;xmethod-name-regexp.cstt|��dtj�dS)Nzinfo xmethod)�superr5�__init__r
�COMMAND_DATA��self��	__class__rrr7�szInfoXMethod.__init__cCsPt|�\}}}tt||�|�ttt��g||�|�ttt��||�|�dS)N)rr.r%r(r
r2r3)r:r�from_ttyr"rrrrr�invoke�s���zInfoXMethod.invoke��__name__�
__module__�__qualname__�__doc__r7r>�
__classcell__rrr;rr5�sr5cs(eZdZdZ�fdd�Zdd�Z�ZS)�
EnableXMethoda�GDB command to enable a specified (group of) xmethod(s).

    Usage: enable xmethod [LOCUS-REGEXP [NAME-REGEXP]]

    LOCUS-REGEXP is a regular expression matching the location of the
    xmethod matchers.  If it is omitted, all registered xmethods matchers
    from all loci are enabled.  A locus could be 'global', a regular expression
    matching the current program space's filename, or a regular expression
    matching filenames of objfiles.  Locus could be 'progspace' to specify that
    only xmethods from the current progspace should be enabled.

    NAME-REGEXP is a regular expression matching the names of xmethods
    within a given locus.  If this omitted for a specified locus, then all
    registered xmethod matchers in the locus are enabled.  To enable only
    a certain xmethods managed by a single matcher, the name regexp can be
    specified as matcher-name-regexp;xmethod-name-regexp.cstt|��dtj�dS)Nzenable xmethod)r6rEr7r
r8r9r;rrr7�szEnableXMethod.__init__cCst|d�dS)NT�r4�r:rr=rrrr>�szEnableXMethod.invoker?rrr;rrE�srEcs(eZdZdZ�fdd�Zdd�Z�ZS)�DisableXMethoda�GDB command to disable a specified (group of) xmethod(s).

    Usage: disable xmethod [LOCUS-REGEXP [NAME-REGEXP]]

    LOCUS-REGEXP is a regular expression matching the location of the
    xmethod matchers.  If it is omitted, all registered xmethod matchers
    from all loci are disabled.  A locus could be 'global', a regular
    expression matching the current program space's filename, or a regular
    expression filenames of objfiles. Locus could be 'progspace' to specify
    that only xmethods from the current progspace should be disabled.

    NAME-REGEXP is a regular expression matching the names of xmethods
    within a given locus.  If this omitted for a specified locus, then all
    registered xmethod matchers in the locus are disabled.  To disable
    only a certain xmethods managed by a single matcher, the name regexp
    can be specified as matcher-name-regexp;xmethod-name-regexp.cstt|��dtj�dS)Nzdisable xmethod)r6rHr7r
r8r9r;rrr7szDisableXMethod.__init__cCst|d�dS)NFrFrGrrrr>szDisableXMethod.invoker?rrr;rrH�srHcCst�t�t�dS)zInstalls the xmethod commands.N)r5rErHrrrr�register_xmethod_commandssrI)r
rrrr%r(r.r1r4ZCommandr5rErHrIrrrr�<module>s$ #