Viewing File: /usr/share/gdb/python/gdb/command/pretty_printers.pyc

ó
›à Rc@sÔdZddlZddlZddlZd„Zd„Zdejfd„ƒYZd„Zd„Z	d	d
„Z
d„Zd„Zd
„Z
dejfd„ƒYZdejfd„ƒYZd„ZeƒdS(s.GDB commands for working with pretty-printers.iÿÿÿÿNc
Csvtj|ƒ}t|ƒ}d}d}d}|dkrHtdƒ‚n|dkra|d}n|dkr¯|djddƒ}|d}t|ƒdkr¯|d}q¯nytj|ƒ}Wn!tk
råtd|ƒ‚nXytj|ƒ}Wn!tk
rtd	|ƒ‚nX|dk	rcytj|ƒ}	Wqitk
r_td
|ƒ‚qiXnd}	|||	fS(sü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
    tistoo many argumentsiiit;sinvalid object regexp: %ssinvalid name regexp: %ssinvalid subname regexp: %sN(tgdbtstring_to_argvtlentNonetSyntaxErrortsplittretcompile(
targtargvtargct
object_regexptname_regexptsubname_regexptname_subnamet	object_retname_ret
subname_re((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytparse_printer_regexpss:




cCst|dƒr|jStSdS(s>Internal utility to see if printer (or subprinter) is enabled.tenabledN(thasattrRtTrue(tprinter((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytprinter_enabled_pLstInfoPrettyPrintercBsPeZdZd„Zed„ƒZed„ƒZd„Zd„Zd„Z	RS(s³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.
    cCs tt|ƒjdtjƒdS(Nsinfo pretty-printer(tsuperRt__init__RtCOMMAND_DATA(tself((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRbscCst|ƒrdSdSdS(s9Return "" if PRINTER is enabled, otherwise " [disabled]".Rs [disabled]N(R(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytenabled_stringfscCs0t|dƒr|jSt|dƒr,|jSdS(sReturn the printer's name.tnamet__name__tunknown(RR R!(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytprinter_namens
c
Csüttj|ƒd|jƒ}x×|D]Ï}|j|ƒ}|j|ƒ}|j|ƒr%d||fGHt|dƒrô|jdk	rôttj|jƒd|jƒ}xH|D]=}	|sÌ|j|	jƒr­d|	j|j|	ƒfGHq­q­Wqôq%q%WdS(s Print a list of pretty-printers.tkeys  %s%stsubprinterss    %s%sN(	tsortedtcopyR#RtmatchRR%RR (
Rtpretty_printersRRtsorted_pretty_printersRR Rtsorted_subprinterst
subprinter((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytlist_pretty_printers{s"

cCs4|r0|j|ƒr0|GH|j|||ƒndS(s$Subroutine of invoke to simplify it.N(R(R-(Rttitletprinter_listtobj_name_to_matchRRR((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvoke1‘scCsªt|ƒ\}}}|jdtjd|||ƒtjƒ}|jd|j|jd|||ƒx=tjƒD]/}|jd|j|j|j|||ƒqsWdS(s&GDB calls this to perform the command.sglobal pretty-printers:tglobalsprogspace %s pretty-printers:t	progspaces  objfile %s pretty-printers:N(RR1RR)tcurrent_progspacetfilenametobjfiles(RR
tfrom_ttyRRRtcptobjfile((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvoke˜s	
(
R!t
__module__t__doc__RtstaticmethodRR#R-R1R:(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRTs	
		cCsºd}d}x¡|D]™}t|dƒr‰|jdk	r‰t|ƒrsx-|jD]}t|ƒrM|d7}qMqMWn|t|jƒ7}qt|ƒr¢|d7}n|d7}qW||fS(s9Return a 2-tuple of number of enabled and total printers.iR%iN(RR%RRR(R)RttotalRR,((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytcount_enabled_printers§s

cCs®d}d}ttjƒ\}}||7}||7}ttjƒjƒ\}}||7}||7}x=tjƒD]/}t|jƒ\}}||7}||7}qqW||fS(skReturn a 2-tuble of the enabled state and total number of all printers.
    This includes subprinters.
    i(R?RR)R4R6(t
enabled_countttotal_countt	t_enabledtt_totalR9((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytcount_all_enabled_printersºs




tscCs"|dkrd||fS|SdS(s!Return TEXT pluralized if N != 1.is%s%sN((ttexttntsuffix((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt	pluralizeÍscCs"tƒ\}}d||fGHdS(sZPrint the number of printers enabled/disabled.
    We count subprinters individually.
    s%d of %d printers enabledN(RD(R@RA((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt#show_pretty_printer_enabled_summaryÕsc	Cscd}xV|D]N}t|dƒr4|j|jƒsUt|dƒr
|j|jƒr
t|dƒr'|jdk	r'|sÇt|ƒ|kr»x-|jD]}t|ƒr•|d7}q•q•Wn||_qXxŽ|jD]O}|j|jƒrÑt|ƒrt|ƒ|kr|d7}n||_qÑqÑWq[|s[t|ƒ|krL|d7}n||_q[q
q
W|S(sÌ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.
    iR R!R%iN(RR(R R!R%RRR(R)RRtflagR>RR,((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytdo_enable_pretty_printer_1Ýs.
!!

c	Cst|ƒ\}}}d}|jdƒrI|ttj|||ƒ7}ntjƒ}|jdƒrƒ|t|j|||ƒ7}nxEtjƒD]7}|j|jƒr|t|j|||ƒ7}qqW|rÚd}nd}d|td|ƒ|fGHt	ƒdS(	s7Internal worker for enabling/disabling pretty-printers.iR2R3Rtdisableds%d %s %sRN(
RR(RLRR)R4R6R5RIRJ(	R
RKRRRR>R8R9tstate((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytdo_enable_pretty_printers$	tEnablePrettyPrintercBs eZdZd„Zd„ZRS(s¸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.
    cCs tt|ƒjdtjƒdS(Nsenable pretty-printer(RRPRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRJscCst|tƒdS(s&GDB calls this to perform the command.N(ROR(RR
R7((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyR:Ns(R!R;R<RR:(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRP<s	tDisablePrettyPrintercBs eZdZd„Zd„ZRS(sº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.
    cCs tt|ƒjdtjƒdS(Nsdisable pretty-printer(RRQRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRascCst|tƒdS(s&GDB calls this to perform the command.N(ROtFalse(RR
R7((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyR:es(R!R;R<RR:(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRQSs	cCstƒtƒtƒdS(sDCall from a top level script to install the pretty-printer commands.N(RRPRQ(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt register_pretty_printer_commandsjs(R<R'RRRRtCommandRR?RDRIRJRLRORPRQRS(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt<module>s 	4	S				:	%	
Back to Directory File Manager