Your IP : 172.28.240.42


Current Path : /usr/share/gdb/python/gdb/command/
Upload File :
Current File : //usr/share/gdb/python/gdb/command/pretty_printers.pyc


&Oc@sdZddlZddlZddlZdZdZdejfdYZdZdZ	d	d
Z
dZdZd
Z
dejfdYZdejfdYZdZedS(s.GDB commands for working with pretty-printers.iNc
Csvtj|}t|}d}d}d}|dkrHtdn|dkra|d}n|dkr|djdd}|d}t|dkr|d}qnytj|}Wn!tk
rtd|nXytj|}Wn!tk
rtd	|nX|dk	rcytj|}	Wqitk
r_td
|qiXnd}	|||	fS(sInternal 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|dr|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_pLstInfoPrettyPrintercBsPeZdZdZedZedZdZdZdZ	RS(sGDB 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|jdtjdS(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|dr|jSt|dr,|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
s
tj|}|jfdx|D]}j|}j|}|j|r,d||fGHt|dr|jdk	rtj|j}|jfdxH|D]=}	|s|j|	jrd|	jj|	fGHqqWqq,q,WdS(s Print a list of pretty-printers.cstj|j|S(N(tcmpR#(txty(R(s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt<lambda>ss  %s%stsubprinterscstj|j|S(N(R$R#(R%R&(R(s4/usr/share/gdb/python/gdb/command/pretty_printers.pyR'ss    %s%sN(	tcopytsortR#RtmatchRR(RR (
Rtpretty_printersRRtsorted_pretty_printersRR Rtsorted_subprinterst
subprinter((Rs4/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+R0(Rttitletprinter_listtobj_name_to_matchRRR((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvoke1scCst|\}}}|jdtjd|||tj}|jd|j|jd|||x=tjD]/}|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(RR4RR,tcurrent_progspacetfilenametobjfiles(RR
tfrom_ttyRRRtcptobjfile((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvokes	
(
R!t
__module__t__doc__RtstaticmethodRR#R0R4R=(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRTs	
		cCsd}d}x|D]}t|dr|jdk	rt|rsx-|jD]}t|rM|d7}qMqMWn|t|j7}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_printerss

cCsd}d}ttj\}}||7}||7}ttjj\}}||7}||7}x=tjD]/}t|j\}}||7}||7}qqW||fS(skReturn a 2-tuble of the enabled state and total number of all printers.
    This includes subprinters.
    i(RBRR,R7R9(t
enabled_countttotal_countt	t_enabledtt_totalR<((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytcount_all_enabled_printerss




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	pluralizescCs"t\}}d||fGHdS(sZPrint the number of printers enabled/disabled.
    We count subprinters individually.
    s%d of %d printers enabledN(RG(RCRD((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt#show_pretty_printer_enabled_summarysc	Cscd}xV|D]N}t|dr4|j|jsUt|dr
|j|jr
t|dr'|jdk	r'|st||krx-|jD]}t|r|d7}qqWn||_qXx|jD]O}|j|jrt|rt||kr|d7}n||_qqWq[|s[t||krL|d7}n||_q[q
q
W|S(sWorker 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,RRtflagRARR/((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytdo_enable_pretty_printer_1s.
!!

c	Cst|\}}}d}|jdrI|ttj|||7}ntj}|jdr|t|j|||7}nxEtjD]7}|j|jr|t|j|||7}qqW|rd}nd}d|td||fGHt	dS(	s7Internal worker for enabling/disabling pretty-printers.iR5R6Rtdisableds%d %s %sRN(
RR+RORR,R7R9R8RLRM(	R
RNRRRRAR;R<tstate((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytdo_enable_pretty_printers$	tEnablePrettyPrintercBs eZdZdZdZRS(sGDB 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|jdtjdS(Nsenable pretty-printer(RRSRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRNscCst|tdS(s&GDB calls this to perform the command.N(RRR(RR
R:((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyR=Rs(R!R>R?RR=(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRS@s	tDisablePrettyPrintercBs eZdZdZdZRS(sGDB 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|jdtjdS(Nsdisable pretty-printer(RRTRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRescCst|tdS(s&GDB calls this to perform the command.N(RRtFalse(RR
R:((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyR=is(R!R>R?RR=(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRTWs	cCstttdS(sDCall from a top level script to install the pretty-printer commands.N(RRSRT(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt register_pretty_printer_commandsns(R?R)RRRRtCommandRRBRGRLRMRORRRSRTRV(((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyt<module>s 	4	W				:	%