PK!auto-load/usr/lib64nuȯPK!auto-load/usr/sbinnuȯPK!auto-load/usr/binnuȯPK!La/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyonu[ Qc@suddlZddlZddlZddlZdZdZejdk rQejj eZejj eZejj eegZ e ddkrejj e dZ nee e Zee e Zdeje ejejZejjZejjejj eeeZeejkrQejjdeqQnddlmZeejdS(iNs/usr/share/gcc-4.8.5/pythons/usr/lib/../lib64t/s..i(tregister_libstdcxx_printers(tsystgdbtostos.patht pythondirtlibdirtcurrent_objfiletNonetpathtnormpatht commonprefixtprefixtdirnametlentseptsplittdotdotstfilenametobjfiletjointdir_tinserttlibstdcxx.v6.printersR(((s=/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyts(    #$PK!|.auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pynu[# -*- python -*- # Copyright (C) 2009-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import sys import gdb import os import os.path pythondir = '/usr/share/gcc-4.8.5/python' libdir = '/usr/lib/../lib64' # This file might be loaded when there is no current objfile. This # can happen if the user loads it manually. In this case we don't # update sys.path; instead we just hope the user managed to do that # beforehand. if gdb.current_objfile () is not None: # Update module path. We want to find the relative path from libdir # to pythondir, and then we want to apply that relative path to the # directory holding the objfile with which this file is associated. # This preserves relocatability of the gcc tree. # Do a simple normalization that removes duplicate separators. pythondir = os.path.normpath (pythondir) libdir = os.path.normpath (libdir) prefix = os.path.commonprefix ([libdir, pythondir]) # In some bizarre configuration we might have found a match in the # middle of a directory name. if prefix[-1] != '/': prefix = os.path.dirname (prefix) + '/' # Strip off the prefix. pythondir = pythondir[len (prefix):] libdir = libdir[len (prefix):] # Compute the ".."s needed to get from libdir to the prefix. dotdots = ('..' + os.sep) * len (libdir.split (os.sep)) objfile = gdb.current_objfile ().filename dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir) if not dir_ in sys.path: sys.path.insert(0, dir_) # Load the pretty-printers. from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers (gdb.current_objfile ()) PK!La/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pycnu[ Qc@suddlZddlZddlZddlZdZdZejdk rQejj eZejj eZejj eegZ e ddkrejj e dZ nee e Zee e Zdeje ejejZejjZejjejj eeeZeejkrQejjdeqQnddlmZeejdS(iNs/usr/share/gcc-4.8.5/pythons/usr/lib/../lib64t/s..i(tregister_libstdcxx_printers(tsystgdbtostos.patht pythondirtlibdirtcurrent_objfiletNonetpathtnormpatht commonprefixtprefixtdirnametlentseptsplittdotdotstfilenametobjfiletjointdir_tinserttlibstdcxx.v6.printersR(((s=/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyts(    #$PK!auto-load/usr/libnuȯPK!t?7?7syscalls/i386-linux.xmlnu[ PK!33syscalls/amd64-linux.xmlnu[ PK!_Esyscalls/gdb-syscalls.dtdnu[ PK!~~~python/gdb/types.pycnu[ Rc@stdZddlZdZdZdZdZdefdYZd Zd Z d Z d Z dS( s%Utilities for working with gdb.Types.iNcCsbxU|jtjks'|jtjkrW|jtjkrH|j}q|j}qW|jS(sReturn the "basic" type of a type. Arguments: type_: The type to reduce to its basic type. Returns: type_ with const/volatile is stripped away, and typedefs/references converted to the underlying type. (tcodetgdbt TYPE_CODE_REFtTYPE_CODE_TYPEDEFttargettstrip_typedefst unqualified(ttype_((s"/usr/share/gdb/python/gdb/types.pytget_basic_types cCst|}|jtjkr?|jtjkr?tdnxI|jD];}|jrtt|j |rt SqL|j |krLt SqLWt S(syReturn True if a type has the specified field. Arguments: type_: The type to examine. It must be one of gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION. field: The name of the field to look up. Returns: True if the field is present either in type_ or any baseclass. Raises: TypeError: The type is not a struct or union. snot a struct or union( RRRtTYPE_CODE_STRUCTtTYPE_CODE_UNIONt TypeErrortfieldst is_base_classt has_fieldttypetTruetnametFalse(Rtfieldtf((s"/usr/share/gdb/python/gdb/types.pyR*s  cCsR|jtjkr!tdni}x$|jD]}|j||js        PK! v| | python/gdb/__init__.pynu[# Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import traceback import os import sys import _gdb if sys.version_info[0] > 2: # Python 3 moved "reload" from imp import reload from _gdb import * class _GdbFile (object): # These two are needed in Python 3 encoding = "UTF-8" errors = "strict" def close(self): # Do nothing. return None def isatty(self): return False def writelines(self, iterable): for line in iterable: self.write(line) def flush(self): flush() class GdbOutputFile (_GdbFile): def write(self, s): write(s, stream=STDOUT) sys.stdout = GdbOutputFile() class GdbOutputErrorFile (_GdbFile): def write(self, s): write(s, stream=STDERR) sys.stderr = GdbOutputErrorFile() # Default prompt hook does nothing. prompt_hook = None # Ensure that sys.argv is set to something. # We do not use PySys_SetArgvEx because it did not appear until 2.6.6. sys.argv = [''] # Initial pretty printers. pretty_printers = [] # Initial type printers. type_printers = [] # Initial frame filters. frame_filters = {} # Convenience variable to GDB's python directory PYTHONDIR = os.path.dirname(os.path.dirname(__file__)) # Auto-load all functions/commands. # Packages to auto-load. packages = [ 'function', 'command' ] # pkgutil.iter_modules is not available prior to Python 2.6. Instead, # manually iterate the list, collating the Python files in each module # path. Construct the module name, and import. def auto_load_packages(): for package in packages: location = os.path.join(os.path.dirname(__file__), package) if os.path.exists(location): py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py', os.listdir(location)) for py_file in py_files: # Construct from foo.py, gdb.module.foo modname = "%s.%s.%s" % ( __name__, package, py_file[:-3] ) try: if modname in sys.modules: # reload modules with duplicate names reload(__import__(modname)) else: __import__(modname) except: sys.stderr.write (traceback.format_exc() + "\n") auto_load_packages() def GdbSetPythonDirectory(dir): """Update sys.path, reload gdb and auto-load packages.""" global PYTHONDIR try: sys.path.remove(PYTHONDIR) except ValueError: pass sys.path.insert(0, dir) PYTHONDIR = dir # note that reload overwrites the gdb module without deleting existing # attributes reload(__import__(__name__)) auto_load_packages() PK!$cz  python/gdb/frames.pyonu[ Rc@sdZddlZddlmZddlmZddlZddlZdZdZ dZ dZ d Z d Z d ZdS( s2Internal functions for working with frame-filters.iN(t FrameIterator(tFrameDecoratorcCst|ddS(sC Internal worker function to return the frame-filter's priority from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the priority attribute, return zero (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The priority of the frame filter from the "priority" attribute, or zero. tpriorityi(tgetattr(t filter_item((s#/usr/share/gdb/python/gdb/frames.pyt get_priorityscCs ||_dS(s Internal worker function to set the frame-filter's priority. Arguments: filter_item: An object conforming to the frame filter interface. priority: The priority to assign as an integer. N(R(RR((s#/usr/share/gdb/python/gdb/frames.pyt set_priority-s cCst|dtS(sE Internal worker function to return a filter's enabled state from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the enabled attribute, return False (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The enabled state of the frame filter from the "enabled" attribute, or False. tenabled(RtFalse(R((s#/usr/share/gdb/python/gdb/frames.pyt get_enabled8scCs ||_dS(s Internal Worker function to set the frame-filter's enabled state. Arguments: filter_item: An object conforming to the frame filter interface. state: True or False, depending on desired state. N(R(Rtstate((s#/usr/share/gdb/python/gdb/frames.pyt set_enabledNs cCs|dkrbtjj}|tjjj}x+tjD]}||jj}|SWn|dkrutjS|dkrtj}|jSx*tjD]}||jkr|jSqWd|d}tj|dS(s Internal Worker function to return the frame filter dictionary, depending on the name supplied as an argument. If the name is not "all", "global" or "progspace", it is assumed to name an object-file. Arguments: name: The name of the list, as specified by GDB user commands. Returns: A dictionary object for a single specified dictionary, or a list containing all the items for "all" Raises: gdb.GdbError: A dictionary of that name cannot be found. talltglobalt progspaces)Cannot find frame-filter dictionary for 't'N(tgdbt frame_filterstvaluestcurrent_progspacetobjfilestfilenametGdbError(tnamet all_dictstobjfiletcptmsg((s#/usr/share/gdb/python/gdb/frames.pyt return_listZs      cCsg}x'tjD]}||jj}qWtj}||jj}|tjj}t|dtdt}tt |}|S(s* Internal Worker function to merge all known frame-filter lists, prune any filters with the state set to "disabled", and sort the list on the frame-filter's "priority" attribute. Returns: sorted_list: A sorted, pruned list of frame filters to execute. tkeytreverse( RRRRRtsortedRtTruetfilterR (t all_filtersRRtsorted_frame_filters((s#/usr/share/gdb/python/gdb/frames.pyt _sort_lists    c Cs t}t|dkrdSt|}tjt|}x|D]}|j|}qDW|dkrd}t|}t j }x>|D]6} ||kr|j n|d}|j | qWt |S|dkrd}n |d}tj|||}|S(s  Internal function called from GDB that will execute the chain of frame filters. Each filter is executed in priority order. After the execution completes, slice the iterator to frame_low - frame_high range. Arguments: frame: The initial frame. frame_low: The low range of the slice. If this is a negative integer then it indicates a backward slice (ie bt -4) which counts backward from the last frame in the backtrace. frame_high: The high range of the slice. If this is -1 then it indicates all frames until the end of the stack from frame_low. Returns: frame_iterator: The sliced iterator after all frame filters have had a change to execute, or None if no frame filters are registered. iiiN(R$tlentNoneRt itertoolstimapRR!tabst collectionstdequetpoplefttappendtitertislice( tframet frame_lowt frame_hight sorted_listtframe_iteratortfftcountt slice_lengthtslicedt frame_item((s#/usr/share/gdb/python/gdb/frames.pytexecute_frame_filterss,              (t__doc__Rtgdb.FrameIteratorRtgdb.FrameDecoratorRR'R*RRR R RR$R:(((s#/usr/share/gdb/python/gdb/frames.pyts      + PK!0ߕpython/gdb/FrameIterator.pyonu[ Rc@s2ddlZddlZdefdYZdS(iNt FrameIteratorcBs)eZdZdZdZdZRS(s^A gdb.Frame iterator. Iterates over gdb.Frames or objects that conform to that interface.cCs tt|j||_dS(sYInitialize a FrameIterator. Arguments: frame_obj the starting frame.N(tsuperRt__init__tframe(tselft frame_obj((s*/usr/share/gdb/python/gdb/FrameIterator.pyRscCs|S(N((R((s*/usr/share/gdb/python/gdb/FrameIterator.pyt__iter__ scCs1|j}|dkrtn|j|_|S(sInext implementation. Returns: The next oldest frame.N(RtNonet StopIterationtolder(Rtresult((s*/usr/share/gdb/python/gdb/FrameIterator.pytnext#s    (t__name__t __module__t__doc__RRR (((s*/usr/share/gdb/python/gdb/FrameIterator.pyRs (tgdbt itertoolstobjectR(((s*/usr/share/gdb/python/gdb/FrameIterator.pyts  PK!$cz  python/gdb/frames.pycnu[ Rc@sdZddlZddlmZddlmZddlZddlZdZdZ dZ dZ d Z d Z d ZdS( s2Internal functions for working with frame-filters.iN(t FrameIterator(tFrameDecoratorcCst|ddS(sC Internal worker function to return the frame-filter's priority from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the priority attribute, return zero (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The priority of the frame filter from the "priority" attribute, or zero. tpriorityi(tgetattr(t filter_item((s#/usr/share/gdb/python/gdb/frames.pyt get_priorityscCs ||_dS(s Internal worker function to set the frame-filter's priority. Arguments: filter_item: An object conforming to the frame filter interface. priority: The priority to assign as an integer. N(R(RR((s#/usr/share/gdb/python/gdb/frames.pyt set_priority-s cCst|dtS(sE Internal worker function to return a filter's enabled state from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the enabled attribute, return False (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The enabled state of the frame filter from the "enabled" attribute, or False. tenabled(RtFalse(R((s#/usr/share/gdb/python/gdb/frames.pyt get_enabled8scCs ||_dS(s Internal Worker function to set the frame-filter's enabled state. Arguments: filter_item: An object conforming to the frame filter interface. state: True or False, depending on desired state. N(R(Rtstate((s#/usr/share/gdb/python/gdb/frames.pyt set_enabledNs cCs|dkrbtjj}|tjjj}x+tjD]}||jj}|SWn|dkrutjS|dkrtj}|jSx*tjD]}||jkr|jSqWd|d}tj|dS(s Internal Worker function to return the frame filter dictionary, depending on the name supplied as an argument. If the name is not "all", "global" or "progspace", it is assumed to name an object-file. Arguments: name: The name of the list, as specified by GDB user commands. Returns: A dictionary object for a single specified dictionary, or a list containing all the items for "all" Raises: gdb.GdbError: A dictionary of that name cannot be found. talltglobalt progspaces)Cannot find frame-filter dictionary for 't'N(tgdbt frame_filterstvaluestcurrent_progspacetobjfilestfilenametGdbError(tnamet all_dictstobjfiletcptmsg((s#/usr/share/gdb/python/gdb/frames.pyt return_listZs      cCsg}x'tjD]}||jj}qWtj}||jj}|tjj}t|dtdt}tt |}|S(s* Internal Worker function to merge all known frame-filter lists, prune any filters with the state set to "disabled", and sort the list on the frame-filter's "priority" attribute. Returns: sorted_list: A sorted, pruned list of frame filters to execute. tkeytreverse( RRRRRtsortedRtTruetfilterR (t all_filtersRRtsorted_frame_filters((s#/usr/share/gdb/python/gdb/frames.pyt _sort_lists    c Cs t}t|dkrdSt|}tjt|}x|D]}|j|}qDW|dkrd}t|}t j }x>|D]6} ||kr|j n|d}|j | qWt |S|dkrd}n |d}tj|||}|S(s  Internal function called from GDB that will execute the chain of frame filters. Each filter is executed in priority order. After the execution completes, slice the iterator to frame_low - frame_high range. Arguments: frame: The initial frame. frame_low: The low range of the slice. If this is a negative integer then it indicates a backward slice (ie bt -4) which counts backward from the last frame in the backtrace. frame_high: The high range of the slice. If this is -1 then it indicates all frames until the end of the stack from frame_low. Returns: frame_iterator: The sliced iterator after all frame filters have had a change to execute, or None if no frame filters are registered. iiiN(R$tlentNoneRt itertoolstimapRR!tabst collectionstdequetpoplefttappendtitertislice( tframet frame_lowt frame_hight sorted_listtframe_iteratortfftcountt slice_lengthtslicedt frame_item((s#/usr/share/gdb/python/gdb/frames.pytexecute_frame_filterss,              (t__doc__Rtgdb.FrameIteratorRtgdb.FrameDecoratorRR'R*RRR R RR$R:(((s#/usr/share/gdb/python/gdb/frames.pyts      + PK!Ɂ$$python/gdb/printing.pycnu[ Rc@sdZddlZddlZddlZddlZejddkrXeZeZ nde fdYZ de fdYZ e d Zd e fd YZd dd YZde fdYZdS(s+Utilities for working with pretty-printers.iNiit PrettyPrintercBs#eZdZddZdZRS(sA basic pretty-printer. Attributes: name: A unique string among all printers for the context in which it is defined (objfile, progspace, or global(gdb)), and should meaningfully describe what can be pretty-printed. E.g., "StringPiece" or "protobufs". subprinters: An iterable object with each element having a `name' attribute, and, potentially, "enabled" attribute. Or this is None if there are no subprinters. enabled: A boolean indicating if the printer is enabled. Subprinters are for situations where "one" pretty-printer is actually a collection of several printers. E.g., The libstdc++ pretty-printer has a pretty-printer for each of several different types, based on regexps. cCs||_||_t|_dS(N(tnamet subprinterstTruetenabled(tselfRR((s%/usr/share/gdb/python/gdb/printing.pyt__init__3s  cCstddS(NsPrettyPrinter __call__(tNotImplementedError(Rtval((s%/usr/share/gdb/python/gdb/printing.pyt__call__8sN(t__name__t __module__t__doc__tNoneRR (((s%/usr/share/gdb/python/gdb/printing.pyRs tSubPrettyPrintercBseZdZdZRS(sBaseclass for sub-pretty-printers. Sub-pretty-printers needn't use this, but it formalizes what's needed. Attributes: name: The name of the subprinter. enabled: A boolean indicating if the subprinter is enabled. cCs||_t|_dS(N(RRR(RR((s%/usr/share/gdb/python/gdb/printing.pyRGs (R R R R(((s%/usr/share/gdb/python/gdb/printing.pyR=scCst|d r/t|d r/tdnt|dr]t|d r]tdnt|ds{tdn|dkrtjdrtjd tnt}n/tjdrtjd |j|jfnt|drt|jt std n|jj d d kr9t dnd }xi|j D][}t|dr|j|jkr|r|j |=Pqt d|jn|d}qIWn|j jd |dS(sRegister pretty-printer PRINTER with OBJ. The printer is added to the front of the search list, thus one can override an existing printer if one needs to. Use a different name when overriding an existing printer, otherwise an exception will be raised; multiple printers with the same name are disallowed. Arguments: obj: Either an objfile, progspace, or None (in which case the printer is registered globally). printer: Either a function of one argument (old way) or any object which has attributes: name, enabled, __call__. replace: If True replace any existing copy of the printer. Otherwise if the printer already exists raise an exception. Returns: Nothing. Raises: TypeError: A problem with the type of the printer. ValueError: The printer's name contains a semicolon ";". RuntimeError: A printer with the same name is already registered. If the caller wants the printer to be listable and disableable, it must follow the PrettyPrinter API. This applies to the old way (functions) too. If printer is an object, __call__ is a method of two arguments: self, and the value to be pretty-printed. See PrettyPrinter. R Rsprinter missing attribute: nameRs"printer missing attribute: enabledR s#printer missing attribute: __call__tverboses)Registering global %s pretty-printer ... s)Registering %s pretty-printer for %s ... sprinter name is not a stringt;issemicolon ';' in printer names%pretty-printer already registered: %siN(thasattrt TypeErrorR tgdbt parametertwriteRtfilenamet isinstancet basestringtfindt ValueErrortpretty_printerst RuntimeErrortinsert(tobjtprintertreplacetitp((s%/usr/share/gdb/python/gdb/printing.pytregister_pretty_printerLs8"    ! tRegexpCollectionPrettyPrintercBs?eZdZdefdYZdZdZdZRS(syClass for implementing a collection of regular-expression based pretty-printers. Intended usage: pretty_printer = RegexpCollectionPrettyPrinter("my_library") pretty_printer.add_printer("myclass1", "^myclass1$", MyClass1Printer) ... pretty_printer.add_printer("myclassN", "^myclassN$", MyClassNPrinter) register_pretty_printer(obj, pretty_printer) tRegexpSubprintercBseZdZRS(cCsAttj|j|||_||_tj||_dS(N( tsuperR$R%Rtregexpt gen_printertretcompilet compiled_re(RRR'R(((s%/usr/share/gdb/python/gdb/printing.pyRs  (R R R(((s%/usr/share/gdb/python/gdb/printing.pyR%scCstt|j|gdS(N(R&R$R(RR((s%/usr/share/gdb/python/gdb/printing.pyRscCs#|jj|j|||dS(soAdd a printer to the list. The printer is added to the end of the list. Arguments: name: The name of the subprinter. regexp: The regular expression, as a string. gen_printer: A function/method that given a value returns an object to pretty-print it. Returns: Nothing. N(RtappendR%(RRR'R(((s%/usr/share/gdb/python/gdb/printing.pyt add_printerscCsbtjj|jj}|s"dSx9|jD].}|jr,|jj |r,|j |Sq,WdS(s1Lookup the pretty-printer for the provided value.N( Rttypestget_basic_typettypettagR RRR+tsearchR((RRttypenameR((s%/usr/share/gdb/python/gdb/printing.pyR s(R R R RR%RR-R (((s%/usr/share/gdb/python/gdb/printing.pyR$s    t _EnumInstancecBseZdZdZRS(cCs||_||_dS(N(t enumeratorsR(RR5R((s%/usr/share/gdb/python/gdb/printing.pyRs cCsg}t|j}t}xH|jD]=\}}||@dkr%|j|||@}t}q%q%W| sy|dkr|jd|nd|jdj|fS(Niss 0x%x [%s]s | (tlongRtFalseR5R,Rtjoin(Rt flag_listtvt any_foundte_namete_value((s%/usr/share/gdb/python/gdb/printing.pyt to_strings   (R R RR>(((s%/usr/share/gdb/python/gdb/printing.pyR4s tFlagEnumerationPrintercBs eZdZdZdZRS(sA pretty-printer which can be used to print a flag-style enumeration. A flag-style enumeration is one where the enumerators are or'd together to create values. The new printer will print these symbolically using '|' notation. The printer must be registered manually. This printer is most useful when an enum is flag-like, but has some overlap. GDB's built-in printing will not handle this case, but this printer will attempt to.cCs#tt|j|t|_dS(N(R&R?RR7t initialized(Rt enum_type((s%/usr/share/gdb/python/gdb/printing.pyRscCs|jsyt|_tj|j}g|_x0|jD]"}|jj|j|jfq:W|jj ddn|j rt |j|SdSdS(NtkeycSs|jS(N(tenumval(tx((s%/usr/share/gdb/python/gdb/printing.pyts( R@RRt lookup_typeRR5tfieldsR,RCtsortRR4R (RRtflagstfield((s%/usr/share/gdb/python/gdb/printing.pyR s     (R R R RR (((s%/usr/share/gdb/python/gdb/printing.pyR?s ((R Rt gdb.typesR)tsyst version_infotstrRtintR6tobjectRRR7R#R$R4R?(((s%/usr/share/gdb/python/gdb/printing.pyts       LAPK!\v python/gdb/FrameDecorator.pycnu[ Rc@sRddlZdefdYZdefdYZdefdYZdS(iNtFrameDecoratorcBsneZdZdZedZdZdZdZdZ dZ dZ d Z d Z RS( s)Basic implementation of a Frame DecoratorcCs ||_dS(N(t_base(tselftbase((s+/usr/share/gdb/python/gdb/FrameDecorator.pyt__init__3scCsU|j}|j sM|jj sM|jtjksM|jtjkrQtStS(sIInternal utility to determine if the frame is special or limited.( tfind_saltsymtabtfilenamettypetgdbt DUMMY_FRAMEtSIGTRAMP_FRAMEtTruetFalse(tframetsal((s+/usr/share/gdb/python/gdb/FrameDecorator.pyt_is_limited_frame6s  cCs#t|jdr|jjSdS(sLReturn any elided frames that this class might be wrapping, or None.telidedN(thasattrRRtNone(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRDs cCst|jtjs7t|jdr7|jjSn|j}|jtjkr\dS|jtj krudS|j}|dkr|j }|St |S(s Return the name of the frame's function or an address of the function of the frame. First determine if this is a special frame. If not, try to determine filename from GDB's frame internal function API. Finally, if a name cannot be determined return the address. If this function returns an address, GDB will attempt to determine the function name from its internal minimal symbols store (for example, for inferiors without debug-info).tfunctionssN( t isinstanceRR tFrameRRtinferior_frameRR R Rtpctstr(RRtfuncR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRLs     cCs5t|jdr|jjS|j}|jS(s% Return the address of the frame's pctaddress(RRRRR(RR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRqs  cCsut|jdr|jjS|j}|j}|j sN|jj rg|j}tj|S|jjSdS(s Return the filename associated with this frame, detecting and returning the appropriate library name is this is a shared library.RN( RRRRRRRR t solib_name(RRRR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRzs     cCsTt|jdr|jjS|j}|j|r>dSt|}|jS(s Return an iterable of frame arguments for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame arguments, or if this frame is deemed to be a special case, return None.t frame_argsN(RRRRRRt FrameVarstfetch_frame_args(RRtargs((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   cCsTt|jdr|jjS|j}|j|r>dSt|}|jS(s Return an iterable of local variables for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame locals, or if this frame is deemed to be a special case, return None.t frame_localsN(RRR!RRRRtfetch_frame_locals(RRR ((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR!s   cCs_t|jdr|jjS|j}|j|r>dS|j}|rW|jSdSdS(s Return line number information associated with the frame's pc. If symbol table/line information does not exist, or if this frame is deemed to be a special case, return NonetlineN(RRR#RRRR(RRR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR#s   cCs&t|jdr|jjS|jS(s8 Return the gdb.Frame underpinning this frame decorator.R(RRR(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs (t__name__t __module__t__doc__Rt staticmethodRRRRRRR!R#R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   %    tSymValueWrappercBs)eZdZdZdZdZRS(skA container class conforming to the Symbol/Value interface which holds frame locals or frame arguments.cCs||_||_dS(N(tsymtval(Rtsymboltvalue((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs cCs|jS(s6 Return the value associated with this symbol, or None(R*(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR,scCs|jS(sP Return the symbol, or Python text, associated with this symbol, or None(R)(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR+s(R$R%R&RR,R+(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR(s  RcBs2eZdZdZdZdZdZRS(sOUtility class to fetch and store frame local variables, or frame arguments.cCs\||_ittj6ttj6ttj6ttj6ttj6ttj6ttj 6|_ dS(N( RR R tSYMBOL_LOC_STATICtSYMBOL_LOC_REGISTERtSYMBOL_LOC_ARGtSYMBOL_LOC_REF_ARGtSYMBOL_LOC_LOCALtSYMBOL_LOC_REGPARM_ADDRtSYMBOL_LOC_COMPUTEDt symbol_class(RR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs       cCs/t|trtS|j}|jj|tS(s Local utility method to determine if according to Symbol type whether it should be included in the iterator. Not all symbols are fetched, and only symbols that return True from this method should be fetched.(Rt basestringR t addr_classR4tgetR (RR)tsym_type((s+/usr/share/gdb/python/gdb/FrameDecorator.pytfetch_bs  cCsg}y|jj}Wntk r2d}nXxw|dkr|jsT|jrXPnxE|D]=}|jrtq_n|j|r_|jt |dq_q_W|j }q6W|S(sPublic utility method to fetch frame local variables for the stored frame. Frame arguments are not fetched. If there are no frame local variables, return an empty list.N( Rtblockt RuntimeErrorRt is_globalt is_statict is_argumentR9tappendR(t superblock(RtlvarsR:R)((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR"s     cCsg}y|jj}Wntk r2d}nXx,|dkra|jdkrUPn|j}q6W|dkrx6|D]+}|jsqun|jt|dquWn|S(sPublic utility method to fetch frame arguments for the stored frame. Frame arguments are the only type fetched. If there are no frame argument variables, return an empty list.N( RR:R;RRR@R>R?R((RR R:R)((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs      (R$R%R&RR9R"R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   (R tobjectRR(R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyts PK!0ߕpython/gdb/FrameIterator.pycnu[ Rc@s2ddlZddlZdefdYZdS(iNt FrameIteratorcBs)eZdZdZdZdZRS(s^A gdb.Frame iterator. Iterates over gdb.Frames or objects that conform to that interface.cCs tt|j||_dS(sYInitialize a FrameIterator. Arguments: frame_obj the starting frame.N(tsuperRt__init__tframe(tselft frame_obj((s*/usr/share/gdb/python/gdb/FrameIterator.pyRscCs|S(N((R((s*/usr/share/gdb/python/gdb/FrameIterator.pyt__iter__ scCs1|j}|dkrtn|j|_|S(sInext implementation. Returns: The next oldest frame.N(RtNonet StopIterationtolder(Rtresult((s*/usr/share/gdb/python/gdb/FrameIterator.pytnext#s    (t__name__t __module__t__doc__RRR (((s*/usr/share/gdb/python/gdb/FrameIterator.pyRs (tgdbt itertoolstobjectR(((s*/usr/share/gdb/python/gdb/FrameIterator.pyts  PK! python/gdb/__init__.pycnu[ Rc@s%ddlZddlZddlZddlZejddkrVddlmZnddlTdefdYZdefd YZ e e_ d efd YZ e e_ dZd ge_gZgZiZejjejjead dgZdZedZdS(iNii(treload(t*t_GdbFilecBs8eZdZdZdZdZdZdZRS(sUTF-8tstrictcCsdS(N(tNone(tself((s%/usr/share/gdb/python/gdb/__init__.pytclose scCstS(N(tFalse(R((s%/usr/share/gdb/python/gdb/__init__.pytisatty$scCs"x|D]}|j|qWdS(N(twrite(Rtiterabletline((s%/usr/share/gdb/python/gdb/__init__.pyt writelines's cCs tdS(N(tflush(R((s%/usr/share/gdb/python/gdb/__init__.pyR +s(t__name__t __module__tencodingterrorsRRR R (((s%/usr/share/gdb/python/gdb/__init__.pyRs    t GdbOutputFilecBseZdZRS(cCst|dtdS(Ntstream(R tSTDOUT(Rts((s%/usr/share/gdb/python/gdb/__init__.pyR /s(RRR (((s%/usr/share/gdb/python/gdb/__init__.pyR.stGdbOutputErrorFilecBseZdZRS(cCst|dtdS(NR(R tSTDERR(RR((s%/usr/share/gdb/python/gdb/__init__.pyR 5s(RRR (((s%/usr/share/gdb/python/gdb/__init__.pyR4sttfunctiontcommandcCsxtD]}tjjtjjt|}tjj|rtdtj|}x||D]q}dt ||d f}y0|t j krt t |n t |Wqbt jjtjdqbXqbWqqWdS(NcSs|jdo|dkS(Ns.pys __init__.py(tendswith(tx((s%/usr/share/gdb/python/gdb/__init__.pyt]ss%s.%s.%sis (tpackagestostpathtjointdirnamet__file__texiststfiltertlistdirRtsystmodulesRt __import__tstderrR t tracebackt format_exc(tpackagetlocationtpy_filestpy_filetmodname((s%/usr/share/gdb/python/gdb/__init__.pytauto_load_packagesYs !  cCs\ytjjtWntk r'nXtjjd||atttt dS(s3Update sys.path, reload gdb and auto-load packages.iN( R'R tremovet PYTHONDIRt ValueErrortinsertRR)RR2(tdir((s%/usr/share/gdb/python/gdb/__init__.pytGdbSetPythonDirectoryos (R+RR't_gdbt version_infotimpRtobjectRRtstdoutRR*Rt prompt_hooktargvtpretty_printerst type_printerst frame_filtersR R"R#R4RR2R8(((s%/usr/share/gdb/python/gdb/__init__.pyts,          PK!B*!%%python/gdb/frames.pynu[# Frame-filter commands. # Copyright (C) 2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Internal functions for working with frame-filters.""" import gdb from gdb.FrameIterator import FrameIterator from gdb.FrameDecorator import FrameDecorator import itertools import collections def get_priority(filter_item): """ Internal worker function to return the frame-filter's priority from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the priority attribute, return zero (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The priority of the frame filter from the "priority" attribute, or zero. """ # Do not fail here, as the sort will fail. If a filter has not # (incorrectly) set a priority, set it to zero. return getattr(filter_item, "priority", 0) def set_priority(filter_item, priority): """ Internal worker function to set the frame-filter's priority. Arguments: filter_item: An object conforming to the frame filter interface. priority: The priority to assign as an integer. """ filter_item.priority = priority def get_enabled(filter_item): """ Internal worker function to return a filter's enabled state from a frame filter object. This is a fail free function as it is used in sorting and filtering. If a badly implemented frame filter does not implement the enabled attribute, return False (otherwise sorting/filtering will fail and prevent other frame filters from executing). Arguments: filter_item: An object conforming to the frame filter interface. Returns: The enabled state of the frame filter from the "enabled" attribute, or False. """ # If the filter class is badly implemented when called from the # Python filter command, do not cease filter operations, just set # enabled to False. return getattr(filter_item, "enabled", False) def set_enabled(filter_item, state): """ Internal Worker function to set the frame-filter's enabled state. Arguments: filter_item: An object conforming to the frame filter interface. state: True or False, depending on desired state. """ filter_item.enabled = state def return_list(name): """ Internal Worker function to return the frame filter dictionary, depending on the name supplied as an argument. If the name is not "all", "global" or "progspace", it is assumed to name an object-file. Arguments: name: The name of the list, as specified by GDB user commands. Returns: A dictionary object for a single specified dictionary, or a list containing all the items for "all" Raises: gdb.GdbError: A dictionary of that name cannot be found. """ # If all dictionaries are wanted in the case of "all" we # cannot return a combined dictionary as keys() may clash in # between different dictionaries. As we just want all the frame # filters to enable/disable them all, just return the combined # items() as a list. if name == "all": all_dicts = gdb.frame_filters.values() all_dicts = all_dicts + gdb.current_progspace().frame_filters.values() for objfile in gdb.objfiles(): all_dicts = all_dicts + objfile.frame_filters.values() return all_dicts if name == "global": return gdb.frame_filters else: if name == "progspace": cp = gdb.current_progspace() return cp.frame_filters else: for objfile in gdb.objfiles(): if name == objfile.filename: return objfile.frame_filters msg = "Cannot find frame-filter dictionary for '" + name + "'" raise gdb.GdbError(msg) def _sort_list(): """ Internal Worker function to merge all known frame-filter lists, prune any filters with the state set to "disabled", and sort the list on the frame-filter's "priority" attribute. Returns: sorted_list: A sorted, pruned list of frame filters to execute. """ all_filters = [] for objfile in gdb.objfiles(): all_filters = all_filters + objfile.frame_filters.values() cp = gdb.current_progspace() all_filters = all_filters + cp.frame_filters.values() all_filters = all_filters + gdb.frame_filters.values() sorted_frame_filters = sorted(all_filters, key = get_priority, reverse = True) sorted_frame_filters = filter(get_enabled, sorted_frame_filters) return sorted_frame_filters def execute_frame_filters(frame, frame_low, frame_high): """ Internal function called from GDB that will execute the chain of frame filters. Each filter is executed in priority order. After the execution completes, slice the iterator to frame_low - frame_high range. Arguments: frame: The initial frame. frame_low: The low range of the slice. If this is a negative integer then it indicates a backward slice (ie bt -4) which counts backward from the last frame in the backtrace. frame_high: The high range of the slice. If this is -1 then it indicates all frames until the end of the stack from frame_low. Returns: frame_iterator: The sliced iterator after all frame filters have had a change to execute, or None if no frame filters are registered. """ # Get a sorted list of frame filters. sorted_list = _sort_list() # Check to see if there are any frame-filters. If not, just # return None and let default backtrace printing occur. if len(sorted_list) == 0: return None frame_iterator = FrameIterator(frame) # Apply a basic frame decorator to all gdb.Frames. This unifies the # interface. frame_iterator = itertools.imap(FrameDecorator, frame_iterator) for ff in sorted_list: frame_iterator = ff.filter(frame_iterator) # Slicing # Is this a slice from the end of the backtrace, ie bt -2? if frame_low < 0: count = 0 slice_length = abs(frame_low) # We cannot use MAXLEN argument for deque as it is 2.6 onwards # and some GDB versions might be < 2.6. sliced = collections.deque() for frame_item in frame_iterator: if count >= slice_length: sliced.popleft(); count = count + 1 sliced.append(frame_item) return iter(sliced) # -1 for frame_high means until the end of the backtrace. Set to # None if that is the case, to indicate to itertools.islice to # slice to the end of the iterator. if frame_high == -1: frame_high = None else: # As frames start from 0, add one to frame_high so islice # correctly finds the end frame_high = frame_high + 1; sliced = itertools.islice(frame_iterator, frame_low, frame_high) return sliced PK!*:''python/gdb/printing.pynu[# Pretty-printer utilities. # Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Utilities for working with pretty-printers.""" import gdb import gdb.types import re import sys if sys.version_info[0] > 2: # Python 3 removed basestring and long basestring = str long = int class PrettyPrinter(object): """A basic pretty-printer. Attributes: name: A unique string among all printers for the context in which it is defined (objfile, progspace, or global(gdb)), and should meaningfully describe what can be pretty-printed. E.g., "StringPiece" or "protobufs". subprinters: An iterable object with each element having a `name' attribute, and, potentially, "enabled" attribute. Or this is None if there are no subprinters. enabled: A boolean indicating if the printer is enabled. Subprinters are for situations where "one" pretty-printer is actually a collection of several printers. E.g., The libstdc++ pretty-printer has a pretty-printer for each of several different types, based on regexps. """ # While one might want to push subprinters into the subclass, it's # present here to formalize such support to simplify # commands/pretty_printers.py. def __init__(self, name, subprinters=None): self.name = name self.subprinters = subprinters self.enabled = True def __call__(self, val): # The subclass must define this. raise NotImplementedError("PrettyPrinter __call__") class SubPrettyPrinter(object): """Baseclass for sub-pretty-printers. Sub-pretty-printers needn't use this, but it formalizes what's needed. Attributes: name: The name of the subprinter. enabled: A boolean indicating if the subprinter is enabled. """ def __init__(self, name): self.name = name self.enabled = True def register_pretty_printer(obj, printer, replace=False): """Register pretty-printer PRINTER with OBJ. The printer is added to the front of the search list, thus one can override an existing printer if one needs to. Use a different name when overriding an existing printer, otherwise an exception will be raised; multiple printers with the same name are disallowed. Arguments: obj: Either an objfile, progspace, or None (in which case the printer is registered globally). printer: Either a function of one argument (old way) or any object which has attributes: name, enabled, __call__. replace: If True replace any existing copy of the printer. Otherwise if the printer already exists raise an exception. Returns: Nothing. Raises: TypeError: A problem with the type of the printer. ValueError: The printer's name contains a semicolon ";". RuntimeError: A printer with the same name is already registered. If the caller wants the printer to be listable and disableable, it must follow the PrettyPrinter API. This applies to the old way (functions) too. If printer is an object, __call__ is a method of two arguments: self, and the value to be pretty-printed. See PrettyPrinter. """ # Watch for both __name__ and name. # Functions get the former for free, but we don't want to use an # attribute named __foo__ for pretty-printers-as-objects. # If printer has both, we use `name'. if not hasattr(printer, "__name__") and not hasattr(printer, "name"): raise TypeError("printer missing attribute: name") if hasattr(printer, "name") and not hasattr(printer, "enabled"): raise TypeError("printer missing attribute: enabled") if not hasattr(printer, "__call__"): raise TypeError("printer missing attribute: __call__") if obj is None: if gdb.parameter("verbose"): gdb.write("Registering global %s pretty-printer ...\n" % name) obj = gdb else: if gdb.parameter("verbose"): gdb.write("Registering %s pretty-printer for %s ...\n" % (printer.name, obj.filename)) if hasattr(printer, "name"): if not isinstance(printer.name, basestring): raise TypeError("printer name is not a string") # If printer provides a name, make sure it doesn't contain ";". # Semicolon is used by the info/enable/disable pretty-printer commands # to delimit subprinters. if printer.name.find(";") >= 0: raise ValueError("semicolon ';' in printer name") # Also make sure the name is unique. # Alas, we can't do the same for functions and __name__, they could # all have a canonical name like "lookup_function". # PERF: gdb records printers in a list, making this inefficient. i = 0 for p in obj.pretty_printers: if hasattr(p, "name") and p.name == printer.name: if replace: del obj.pretty_printers[i] break else: raise RuntimeError("pretty-printer already registered: %s" % printer.name) i = i + 1 obj.pretty_printers.insert(0, printer) class RegexpCollectionPrettyPrinter(PrettyPrinter): """Class for implementing a collection of regular-expression based pretty-printers. Intended usage: pretty_printer = RegexpCollectionPrettyPrinter("my_library") pretty_printer.add_printer("myclass1", "^myclass1$", MyClass1Printer) ... pretty_printer.add_printer("myclassN", "^myclassN$", MyClassNPrinter) register_pretty_printer(obj, pretty_printer) """ class RegexpSubprinter(SubPrettyPrinter): def __init__(self, name, regexp, gen_printer): super(RegexpCollectionPrettyPrinter.RegexpSubprinter, self).__init__(name) self.regexp = regexp self.gen_printer = gen_printer self.compiled_re = re.compile(regexp) def __init__(self, name): super(RegexpCollectionPrettyPrinter, self).__init__(name, []) def add_printer(self, name, regexp, gen_printer): """Add a printer to the list. The printer is added to the end of the list. Arguments: name: The name of the subprinter. regexp: The regular expression, as a string. gen_printer: A function/method that given a value returns an object to pretty-print it. Returns: Nothing. """ # NOTE: A previous version made the name of each printer the regexp. # That makes it awkward to pass to the enable/disable commands (it's # cumbersome to make a regexp of a regexp). So now the name is a # separate parameter. self.subprinters.append(self.RegexpSubprinter(name, regexp, gen_printer)) def __call__(self, val): """Lookup the pretty-printer for the provided value.""" # Get the type name. typename = gdb.types.get_basic_type(val.type).tag if not typename: return None # Iterate over table of type regexps to determine # if a printer is registered for that type. # Return an instantiation of the printer if found. for printer in self.subprinters: if printer.enabled and printer.compiled_re.search(typename): return printer.gen_printer(val) # Cannot find a pretty printer. Return None. return None # A helper class for printing enum types. This class is instantiated # with a list of enumerators to print a particular Value. class _EnumInstance: def __init__(self, enumerators, val): self.enumerators = enumerators self.val = val def to_string(self): flag_list = [] v = long(self.val) any_found = False for (e_name, e_value) in self.enumerators: if v & e_value != 0: flag_list.append(e_name) v = v & ~e_value any_found = True if not any_found or v != 0: # Leftover value. flag_list.append('' % v) return "0x%x [%s]" % (self.val, " | ".join(flag_list)) class FlagEnumerationPrinter(PrettyPrinter): """A pretty-printer which can be used to print a flag-style enumeration. A flag-style enumeration is one where the enumerators are or'd together to create values. The new printer will print these symbolically using '|' notation. The printer must be registered manually. This printer is most useful when an enum is flag-like, but has some overlap. GDB's built-in printing will not handle this case, but this printer will attempt to.""" def __init__(self, enum_type): super(FlagEnumerationPrinter, self).__init__(enum_type) self.initialized = False def __call__(self, val): if not self.initialized: self.initialized = True flags = gdb.lookup_type(self.name) self.enumerators = [] for field in flags.fields(): self.enumerators.append((field.name, field.enumval)) # Sorting the enumerators by value usually does the right # thing. self.enumerators.sort(key = lambda x: x.enumval) if self.enabled: return _EnumInstance(self.enumerators, val) else: return None PK!>´python/gdb/function/__init__.pynu[# Copyright (C) 2012-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PK!= python/gdb/function/caller_is.pynu[# Caller-is functions. # Copyright (C) 2008 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb import re class CallerIs (gdb.Function): """Return True if the calling function's name is equal to a string. This function takes one or two arguments. The first argument is the name of a function; if the calling function's name is equal to this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.""" def __init__ (self): super (CallerIs, self).__init__ ("caller_is") def invoke (self, name, nframes = 1): frame = gdb.selected_frame () while nframes > 0: frame = frame.older () nframes = nframes - 1 return frame.name () == name.string () class CallerMatches (gdb.Function): """Return True if the calling function's name matches a string. This function takes one or two arguments. The first argument is a regular expression; if the calling function's name is matched by this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.""" def __init__ (self): super (CallerMatches, self).__init__ ("caller_matches") def invoke (self, name, nframes = 1): frame = gdb.selected_frame () while nframes > 0: frame = frame.older () nframes = nframes - 1 return re.match (name.string (), frame.name ()) is not None CallerIs() CallerMatches() PK!.<| | python/gdb/function/strfns.pynu[# Useful gdb string convenience functions. # Copyright (C) 2012-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """$_memeq, $_strlen, $_streq, $_regex""" import gdb import re class _MemEq(gdb.Function): """$_memeq - compare bytes of memory Usage: $_memeq(a, b, len) Returns: True if len bytes at a and b compare equally. """ def __init__(self): super(_MemEq, self).__init__("_memeq") def invoke(self, a, b, length): if length < 0: raise ValueError("length must be non-negative") if length == 0: return True # The argument(s) to vector are [low_bound,]high_bound. byte_vector = gdb.lookup_type("char").vector(length - 1) ptr_byte_vector = byte_vector.pointer() a_ptr = a.reinterpret_cast(ptr_byte_vector) b_ptr = b.reinterpret_cast(ptr_byte_vector) return a_ptr.dereference() == b_ptr.dereference() class _StrLen(gdb.Function): """$_strlen - compute string length Usage: $_strlen(a) Returns: Length of string a, assumed to be a string in the current language. """ def __init__(self): super(_StrLen, self).__init__("_strlen") def invoke(self, a): s = a.string() return len(s) class _StrEq(gdb.Function): """$_streq - check string equality Usage: $_streq(a, b) Returns: True if a and b are identical strings in the current language. Example (amd64-linux): catch syscall open cond $bpnum $_streq((char*) $rdi, "foo") """ def __init__(self): super(_StrEq, self).__init__("_streq") def invoke(self, a, b): return a.string() == b.string() class _RegEx(gdb.Function): """$_regex - check if a string matches a regular expression Usage: $_regex(string, regex) Returns: True if string str (in the current language) matches the regular expression regex. """ def __init__(self): super(_RegEx, self).__init__("_regex") def invoke(self, string, regex): s = string.string() r = re.compile(regex.string()) return bool(r.match(s)) # GDB will import us automagically via gdb/__init__.py. _MemEq() _StrLen() _StrEq() _RegEx() PK!qg++python/gdb/function/strfns.pycnu[ Rc@sdZddlZddlZdejfdYZdejfdYZdejfdYZd ejfd YZeeeedS( s#$_memeq, $_strlen, $_streq, $_regexiNt_MemEqcBs eZdZdZdZRS(sy$_memeq - compare bytes of memory Usage: $_memeq(a, b, len) Returns: True if len bytes at a and b compare equally. cCstt|jddS(Nt_memeq(tsuperRt__init__(tself((s,/usr/share/gdb/python/gdb/function/strfns.pyR scCs|dkrtdn|dkr+tStjdj|d}|j}|j|}|j|}|j|jkS(Nislength must be non-negativetchari(t ValueErrortTruetgdbt lookup_typetvectortpointertreinterpret_castt dereference(Rtatbtlengtht byte_vectortptr_byte_vectorta_ptrtb_ptr((s,/usr/share/gdb/python/gdb/function/strfns.pytinvoke#s   (t__name__t __module__t__doc__RR(((s,/usr/share/gdb/python/gdb/function/strfns.pyRs t_StrLencBs eZdZdZdZRS(s$_strlen - compute string length Usage: $_strlen(a) Returns: Length of string a, assumed to be a string in the current language. cCstt|jddS(Nt_strlen(RRR(R((s,/usr/share/gdb/python/gdb/function/strfns.pyR9scCs|j}t|S(N(tstringtlen(RRts((s,/usr/share/gdb/python/gdb/function/strfns.pyR<s (RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyR0s t_StrEqcBs eZdZdZdZRS(s$_streq - check string equality Usage: $_streq(a, b) Returns: True if a and b are identical strings in the current language. Example (amd64-linux): catch syscall open cond $bpnum $_streq((char*) $rdi, "foo") cCstt|jddS(Nt_streq(RRR(R((s,/usr/share/gdb/python/gdb/function/strfns.pyRNscCs|j|jkS(N(R(RRR((s,/usr/share/gdb/python/gdb/function/strfns.pyRQs(RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyRAs  t_RegExcBs eZdZdZdZRS(s$_regex - check if a string matches a regular expression Usage: $_regex(string, regex) Returns: True if string str (in the current language) matches the regular expression regex. cCstt|jddS(Nt_regex(RR R(R((s,/usr/share/gdb/python/gdb/function/strfns.pyR_scCs4|j}tj|j}t|j|S(N(Rtretcompiletbooltmatch(RRtregexRtr((s,/usr/share/gdb/python/gdb/function/strfns.pyRbs (RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyR Us  (RRR"tFunctionRRRR (((s,/usr/share/gdb/python/gdb/function/strfns.pyts  PK!npython/gdb/function/in_scope.pynu[# In-scope function. # Copyright (C) 2008 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb class InScope (gdb.Function): """Return True if all the given variables or macros are in scope. Takes one argument for each variable name to be checked.""" def __init__ (self): super (InScope, self).__init__ ("in_scope") def invoke (self, *vars): if len (vars) == 0: raise TypeError, "in_scope takes at least one argument" # gdb.Value isn't hashable so it can't be put in a map. # Convert to string first. wanted = set (map (lambda x: x.string (), vars)) found = set () block = gdb.selected_frame ().block () while block: for sym in block: if (sym.is_argument or sym.is_constant or sym.is_function or sym.is_variable): if sym.name in wanted: found.add (sym.name) block = block.superblock return wanted == found InScope () PK!縤 python/gdb/function/__init__.pycnu[ Rc@sdS(N((((s./usr/share/gdb/python/gdb/function/__init__.pytsPK![Xj j !python/gdb/function/caller_is.pyonu[ Rc@s\ddlZddlZdejfdYZdejfdYZeedS(iNtCallerIscBs#eZdZdZddZRS(srReturn True if the calling function's name is equal to a string. This function takes one or two arguments. The first argument is the name of a function; if the calling function's name is equal to this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.cCstt|jddS(Nt caller_is(tsuperRt__init__(tself((s//usr/share/gdb/python/gdb/function/caller_is.pyRsicCsKtj}x&|dkr4|j}|d}qW|j|jkS(Nii(tgdbtselected_frametoldertnametstring(RRtnframestframe((s//usr/share/gdb/python/gdb/function/caller_is.pytinvoke s   (t__name__t __module__t__doc__RR (((s//usr/share/gdb/python/gdb/function/caller_is.pyRs t CallerMatchescBs#eZdZdZddZRS(snReturn True if the calling function's name matches a string. This function takes one or two arguments. The first argument is a regular expression; if the calling function's name is matched by this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.cCstt|jddS(Ntcaller_matches(RRR(R((s//usr/share/gdb/python/gdb/function/caller_is.pyR/sicCsWtj}x&|dkr4|j}|d}qWtj|j|jdk S(Nii(RRRtretmatchR RtNone(RRR R ((s//usr/share/gdb/python/gdb/function/caller_is.pyR 2s   (R RRRR (((s//usr/share/gdb/python/gdb/function/caller_is.pyR's (RRtFunctionRR(((s//usr/share/gdb/python/gdb/function/caller_is.pyts  PK!qg++python/gdb/function/strfns.pyonu[ Rc@sdZddlZddlZdejfdYZdejfdYZdejfdYZd ejfd YZeeeedS( s#$_memeq, $_strlen, $_streq, $_regexiNt_MemEqcBs eZdZdZdZRS(sy$_memeq - compare bytes of memory Usage: $_memeq(a, b, len) Returns: True if len bytes at a and b compare equally. cCstt|jddS(Nt_memeq(tsuperRt__init__(tself((s,/usr/share/gdb/python/gdb/function/strfns.pyR scCs|dkrtdn|dkr+tStjdj|d}|j}|j|}|j|}|j|jkS(Nislength must be non-negativetchari(t ValueErrortTruetgdbt lookup_typetvectortpointertreinterpret_castt dereference(Rtatbtlengtht byte_vectortptr_byte_vectorta_ptrtb_ptr((s,/usr/share/gdb/python/gdb/function/strfns.pytinvoke#s   (t__name__t __module__t__doc__RR(((s,/usr/share/gdb/python/gdb/function/strfns.pyRs t_StrLencBs eZdZdZdZRS(s$_strlen - compute string length Usage: $_strlen(a) Returns: Length of string a, assumed to be a string in the current language. cCstt|jddS(Nt_strlen(RRR(R((s,/usr/share/gdb/python/gdb/function/strfns.pyR9scCs|j}t|S(N(tstringtlen(RRts((s,/usr/share/gdb/python/gdb/function/strfns.pyR<s (RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyR0s t_StrEqcBs eZdZdZdZRS(s$_streq - check string equality Usage: $_streq(a, b) Returns: True if a and b are identical strings in the current language. Example (amd64-linux): catch syscall open cond $bpnum $_streq((char*) $rdi, "foo") cCstt|jddS(Nt_streq(RRR(R((s,/usr/share/gdb/python/gdb/function/strfns.pyRNscCs|j|jkS(N(R(RRR((s,/usr/share/gdb/python/gdb/function/strfns.pyRQs(RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyRAs  t_RegExcBs eZdZdZdZRS(s$_regex - check if a string matches a regular expression Usage: $_regex(string, regex) Returns: True if string str (in the current language) matches the regular expression regex. cCstt|jddS(Nt_regex(RR R(R((s,/usr/share/gdb/python/gdb/function/strfns.pyR_scCs4|j}tj|j}t|j|S(N(Rtretcompiletbooltmatch(RRtregexRtr((s,/usr/share/gdb/python/gdb/function/strfns.pyRbs (RRRRR(((s,/usr/share/gdb/python/gdb/function/strfns.pyR Us  (RRR"tFunctionRRRR (((s,/usr/share/gdb/python/gdb/function/strfns.pyts  PK!m python/gdb/function/in_scope.pyonu[ Rc@s0ddlZdejfdYZedS(iNtInScopecBs eZdZdZdZRS(swReturn True if all the given variables or macros are in scope. Takes one argument for each variable name to be checked.cCstt|jddS(Ntin_scope(tsuperRt__init__(tself((s./usr/share/gdb/python/gdb/function/in_scope.pyRscGst|dkrtdnttd|}t}tjj}xm|rxW|D]O}|js|js|j s|j ra|j |kr|j |j qqaqaW|j }qTW||kS(Nis$in_scope takes at least one argumentcSs |jS(N(tstring(tx((s./usr/share/gdb/python/gdb/function/in_scope.pyt!s(tlent TypeErrortsettmaptgdbtselected_frametblockt is_argumentt is_constantt is_functiont is_variabletnametaddt superblock(RtvarstwantedtfoundRtsym((s./usr/share/gdb/python/gdb/function/in_scope.pytinvokes     (t__name__t __module__t__doc__RR(((s./usr/share/gdb/python/gdb/function/in_scope.pyRs (R tFunctionR(((s./usr/share/gdb/python/gdb/function/in_scope.pyts PK!縤 python/gdb/function/__init__.pyonu[ Rc@sdS(N((((s./usr/share/gdb/python/gdb/function/__init__.pytsPK!m python/gdb/function/in_scope.pycnu[ Rc@s0ddlZdejfdYZedS(iNtInScopecBs eZdZdZdZRS(swReturn True if all the given variables or macros are in scope. Takes one argument for each variable name to be checked.cCstt|jddS(Ntin_scope(tsuperRt__init__(tself((s./usr/share/gdb/python/gdb/function/in_scope.pyRscGst|dkrtdnttd|}t}tjj}xm|rxW|D]O}|js|js|j s|j ra|j |kr|j |j qqaqaW|j }qTW||kS(Nis$in_scope takes at least one argumentcSs |jS(N(tstring(tx((s./usr/share/gdb/python/gdb/function/in_scope.pyt!s(tlent TypeErrortsettmaptgdbtselected_frametblockt is_argumentt is_constantt is_functiont is_variabletnametaddt superblock(RtvarstwantedtfoundRtsym((s./usr/share/gdb/python/gdb/function/in_scope.pytinvokes     (t__name__t __module__t__doc__RR(((s./usr/share/gdb/python/gdb/function/in_scope.pyRs (R tFunctionR(((s./usr/share/gdb/python/gdb/function/in_scope.pyts PK![Xj j !python/gdb/function/caller_is.pycnu[ Rc@s\ddlZddlZdejfdYZdejfdYZeedS(iNtCallerIscBs#eZdZdZddZRS(srReturn True if the calling function's name is equal to a string. This function takes one or two arguments. The first argument is the name of a function; if the calling function's name is equal to this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.cCstt|jddS(Nt caller_is(tsuperRt__init__(tself((s//usr/share/gdb/python/gdb/function/caller_is.pyRsicCsKtj}x&|dkr4|j}|d}qW|j|jkS(Nii(tgdbtselected_frametoldertnametstring(RRtnframestframe((s//usr/share/gdb/python/gdb/function/caller_is.pytinvoke s   (t__name__t __module__t__doc__RR (((s//usr/share/gdb/python/gdb/function/caller_is.pyRs t CallerMatchescBs#eZdZdZddZRS(snReturn True if the calling function's name matches a string. This function takes one or two arguments. The first argument is a regular expression; if the calling function's name is matched by this argument, this function returns True. The optional second argument tells this function how many stack frames to traverse to find the calling function. The default is 1.cCstt|jddS(Ntcaller_matches(RRR(R((s//usr/share/gdb/python/gdb/function/caller_is.pyR/sicCsWtj}x&|dkr4|j}|d}qWtj|j|jdk S(Nii(RRRtretmatchR RtNone(RRR R ((s//usr/share/gdb/python/gdb/function/caller_is.pyR 2s   (R RRRR (((s//usr/share/gdb/python/gdb/function/caller_is.pyR's (RRtFunctionRR(((s//usr/share/gdb/python/gdb/function/caller_is.pyts  PK!`gmrrpython/gdb/prompt.pynu[# Extended prompt utilities. # Copyright (C) 2011-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Extended prompt library functions.""" import gdb import os def _prompt_pwd(ignore): "The current working directory." return os.getcwdu() def _prompt_object_attr(func, what, attr, nattr): """Internal worker for fetching GDB attributes.""" if attr is None: attr = nattr try: obj = func() except gdb.error: return '' % what if hasattr(obj, attr): result = getattr(obj, attr) if callable(result): result = result() return result else: return '' % (attr, what) def _prompt_frame(attr): "The selected frame; an argument names a frame parameter." return _prompt_object_attr(gdb.selected_frame, 'frame', attr, 'name') def _prompt_thread(attr): "The selected thread; an argument names a thread parameter." return _prompt_object_attr(gdb.selected_thread, 'thread', attr, 'num') def _prompt_version(attr): "The version of GDB." return gdb.VERSION def _prompt_esc(attr): "The ESC character." return '\033' def _prompt_bs(attr): "A backslash." return '\\' def _prompt_n(attr): "A newline." return '\n' def _prompt_r(attr): "A carriage return." return '\r' def _prompt_param(attr): "A parameter's value; the argument names the parameter." return gdb.parameter(attr) def _prompt_noprint_begin(attr): "Begins a sequence of non-printing characters." return '\001' def _prompt_noprint_end(attr): "Ends a sequence of non-printing characters." return '\002' prompt_substitutions = { 'e': _prompt_esc, '\\': _prompt_bs, 'n': _prompt_n, 'r': _prompt_r, 'v': _prompt_version, 'w': _prompt_pwd, 'f': _prompt_frame, 't': _prompt_thread, 'p': _prompt_param, '[': _prompt_noprint_begin, ']': _prompt_noprint_end } def prompt_help(): """Generate help dynamically from the __doc__ strings of attribute functions.""" result = '' keys = sorted (prompt_substitutions.keys()) for key in keys: result += ' \\%s\t%s\n' % (key, prompt_substitutions[key].__doc__) result += """ A substitution can be used in a simple form, like "\\f". An argument can also be passed to it, like "\\f{name}". The meaning of the argument depends on the particular substitution.""" return result def substitute_prompt(prompt): "Perform substitutions on PROMPT." result = '' plen = len(prompt) i = 0 while i < plen: if prompt[i] == '\\': i = i + 1 if i >= plen: break cmdch = prompt[i] if cmdch in prompt_substitutions: cmd = prompt_substitutions[cmdch] if i + 1 < plen and prompt[i + 1] == '{': j = i + 1 while j < plen and prompt[j] != '}': j = j + 1 # Just ignore formatting errors. if j >= plen or prompt[j] != '}': arg = None else: arg = prompt[i + 2 : j] i = j else: arg = None result += str(cmd(arg)) else: # Unrecognized escapes are turned into the escaped # character itself. result += prompt[i] else: result += prompt[i] i = i + 1 return result PK! T--python/gdb/types.pynu[# Type utilities. # Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Utilities for working with gdb.Types.""" import gdb def get_basic_type(type_): """Return the "basic" type of a type. Arguments: type_: The type to reduce to its basic type. Returns: type_ with const/volatile is stripped away, and typedefs/references converted to the underlying type. """ while (type_.code == gdb.TYPE_CODE_REF or type_.code == gdb.TYPE_CODE_TYPEDEF): if type_.code == gdb.TYPE_CODE_REF: type_ = type_.target() else: type_ = type_.strip_typedefs() return type_.unqualified() def has_field(type_, field): """Return True if a type has the specified field. Arguments: type_: The type to examine. It must be one of gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION. field: The name of the field to look up. Returns: True if the field is present either in type_ or any baseclass. Raises: TypeError: The type is not a struct or union. """ type_ = get_basic_type(type_) if (type_.code != gdb.TYPE_CODE_STRUCT and type_.code != gdb.TYPE_CODE_UNION): raise TypeError("not a struct or union") for f in type_.fields(): if f.is_base_class: if has_field(f.type, field): return True else: # NOTE: f.name could be None if f.name == field: return True return False def make_enum_dict(enum_type): """Return a dictionary from a program's enum type. Arguments: enum_type: The enum to compute the dictionary for. Returns: The dictionary of the enum. Raises: TypeError: The type is not an enum. """ if enum_type.code != gdb.TYPE_CODE_ENUM: raise TypeError("not an enum type") enum_dict = {} for field in enum_type.fields(): # The enum's value is stored in "enumval". enum_dict[field.name] = field.enumval return enum_dict def deep_items (type_): """Return an iterator that recursively traverses anonymous fields. Arguments: type_: The type to traverse. It should be one of gdb.TYPE_CODE_STRUCT or gdb.TYPE_CODE_UNION. Returns: an iterator similar to gdb.Type.iteritems(), i.e., it returns pairs of key, value, but for any anonymous struct or union field that field is traversed recursively, depth-first. """ for k, v in type_.iteritems (): if k: yield k, v else: for i in deep_items (v.type): yield i class TypePrinter(object): """The base class for type printers. Instances of this type can be used to substitute type names during 'ptype'. A type printer must have at least 'name' and 'enabled' attributes, and supply an 'instantiate' method. The 'instantiate' method must either return None, or return an object which has a 'recognize' method. This method must accept a gdb.Type argument and either return None, meaning that the type was not recognized, or a string naming the type. """ def __init__(self, name): self.name = name self.enabled = True def instantiate(self): return None # Helper function for computing the list of type recognizers. def _get_some_type_recognizers(result, plist): for printer in plist: if printer.enabled: inst = printer.instantiate() if inst is not None: result.append(inst) return None def get_type_recognizers(): "Return a list of the enabled type recognizers for the current context." result = [] # First try the objfiles. for objfile in gdb.objfiles(): _get_some_type_recognizers(result, objfile.type_printers) # Now try the program space. _get_some_type_recognizers(result, gdb.current_progspace().type_printers) # Finally, globals. _get_some_type_recognizers(result, gdb.type_printers) return result def apply_type_recognizers(recognizers, type_obj): """Apply the given list of type recognizers to the type TYPE_OBJ. If any recognizer in the list recognizes TYPE_OBJ, returns the name given by the recognizer. Otherwise, this returns None.""" for r in recognizers: result = r.recognize(type_obj) if result is not None: return result return None def register_type_printer(locus, printer): """Register a type printer. PRINTER is the type printer instance. LOCUS is either an objfile, a program space, or None, indicating global registration.""" if locus is None: locus = gdb locus.type_printers.insert(0, printer) PK!V::python/gdb/prompt.pycnu[ Rc@sdZddlZddlZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZi ed6e d6e d6e d6ed6ed6ed6ed6e d6e d6ed6ZdZdZdS(s# Extended prompt library functions.iNcCs tjS(sThe current working directory.(tostgetcwdu(tignore((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_pwdscCs|dkr|}ny |}Wntjk r=d|SXt||rxt||}t|rt|}n|Sd||fSdS(s,Internal worker for fetching GDB attributes.ssN(tNonetgdbterrorthasattrtgetattrtcallable(tfunctwhattattrtnattrtobjtresult((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_object_attrs      cCsttjd|dS(s8The selected frame; an argument names a frame parameter.tframetname(RRtselected_frame(R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_frame*scCsttjd|dS(s:The selected thread; an argument names a thread parameter.tthreadtnum(RRtselected_thread(R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_thread.scCstjS(sThe version of GDB.(RtVERSION(R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_version2scCsdS(sThe ESC character.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_esc6scCsdS(s A backslash.s\((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_bs:scCsdS(s A newline.s ((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_n>scCsdS(sA carriage return.s ((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_rBscCs tj|S(s6A parameter's value; the argument names the parameter.(Rt parameter(R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_paramFscCsdS(s-Begins a sequence of non-printing characters.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_noprint_beginJscCsdS(s+Ends a sequence of non-printing characters.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_noprint_endNstes\tntrtvtwtftttpt[t]cCsRd}ttj}x)|D]!}|d|t|jf7}qW|d7}|S(sNGenerate help dynamically from the __doc__ strings of attribute functions.ts \%s %s s A substitution can be used in a simple form, like "\f". An argument can also be passed to it, like "\f{name}". The meaning of the argument depends on the particular substitution.(tsortedtprompt_substitutionstkeyst__doc__(RR0tkey((s#/usr/share/gdb/python/gdb/prompt.pyt prompt_help`s cCs[d}t|}d}x<||krV||dkr;|d}||krQPn||}|tkr*t|}|d|kr ||ddkr |d}x*||kr||dkr|d}qW||ks||dkrd}q||d|!}|}nd}|t||7}qI|||7}n|||7}|d}qW|S( s Perform substitutions on PROMPT.R-is\it{t}iN(tlenR/Rtstr(tpromptRtplentitcmdchtcmdtjtarg((s#/usr/share/gdb/python/gdb/prompt.pytsubstitute_promptns2      $   (R1RRRRRRRRRRRR R!R"R/R3R?(((s#/usr/share/gdb/python/gdb/prompt.pyts8                PK!uTYYpython/gdb/FrameIterator.pynu[# Copyright (C) 2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb import itertools class FrameIterator(object): """A gdb.Frame iterator. Iterates over gdb.Frames or objects that conform to that interface.""" def __init__(self, frame_obj): """Initialize a FrameIterator. Arguments: frame_obj the starting frame.""" super(FrameIterator, self).__init__() self.frame = frame_obj def __iter__(self): return self def next(self): """next implementation. Returns: The next oldest frame.""" result = self.frame if result is None: raise StopIteration self.frame = result.older() return result PK!~~~python/gdb/types.pyonu[ Rc@stdZddlZdZdZdZdZdefdYZd Zd Z d Z d Z dS( s%Utilities for working with gdb.Types.iNcCsbxU|jtjks'|jtjkrW|jtjkrH|j}q|j}qW|jS(sReturn the "basic" type of a type. Arguments: type_: The type to reduce to its basic type. Returns: type_ with const/volatile is stripped away, and typedefs/references converted to the underlying type. (tcodetgdbt TYPE_CODE_REFtTYPE_CODE_TYPEDEFttargettstrip_typedefst unqualified(ttype_((s"/usr/share/gdb/python/gdb/types.pytget_basic_types cCst|}|jtjkr?|jtjkr?tdnxI|jD];}|jrtt|j |rt SqL|j |krLt SqLWt S(syReturn True if a type has the specified field. Arguments: type_: The type to examine. It must be one of gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION. field: The name of the field to look up. Returns: True if the field is present either in type_ or any baseclass. Raises: TypeError: The type is not a struct or union. snot a struct or union( RRRtTYPE_CODE_STRUCTtTYPE_CODE_UNIONt TypeErrortfieldst is_base_classt has_fieldttypetTruetnametFalse(Rtfieldtf((s"/usr/share/gdb/python/gdb/types.pyR*s  cCsR|jtjkr!tdni}x$|jD]}|j||js        PK! python/gdb/__init__.pyonu[ Rc@s%ddlZddlZddlZddlZejddkrVddlmZnddlTdefdYZdefd YZ e e_ d efd YZ e e_ dZd ge_gZgZiZejjejjead dgZdZedZdS(iNii(treload(t*t_GdbFilecBs8eZdZdZdZdZdZdZRS(sUTF-8tstrictcCsdS(N(tNone(tself((s%/usr/share/gdb/python/gdb/__init__.pytclose scCstS(N(tFalse(R((s%/usr/share/gdb/python/gdb/__init__.pytisatty$scCs"x|D]}|j|qWdS(N(twrite(Rtiterabletline((s%/usr/share/gdb/python/gdb/__init__.pyt writelines's cCs tdS(N(tflush(R((s%/usr/share/gdb/python/gdb/__init__.pyR +s(t__name__t __module__tencodingterrorsRRR R (((s%/usr/share/gdb/python/gdb/__init__.pyRs    t GdbOutputFilecBseZdZRS(cCst|dtdS(Ntstream(R tSTDOUT(Rts((s%/usr/share/gdb/python/gdb/__init__.pyR /s(RRR (((s%/usr/share/gdb/python/gdb/__init__.pyR.stGdbOutputErrorFilecBseZdZRS(cCst|dtdS(NR(R tSTDERR(RR((s%/usr/share/gdb/python/gdb/__init__.pyR 5s(RRR (((s%/usr/share/gdb/python/gdb/__init__.pyR4sttfunctiontcommandcCsxtD]}tjjtjjt|}tjj|rtdtj|}x||D]q}dt ||d f}y0|t j krt t |n t |Wqbt jjtjdqbXqbWqqWdS(NcSs|jdo|dkS(Ns.pys __init__.py(tendswith(tx((s%/usr/share/gdb/python/gdb/__init__.pyt]ss%s.%s.%sis (tpackagestostpathtjointdirnamet__file__texiststfiltertlistdirRtsystmodulesRt __import__tstderrR t tracebackt format_exc(tpackagetlocationtpy_filestpy_filetmodname((s%/usr/share/gdb/python/gdb/__init__.pytauto_load_packagesYs !  cCs\ytjjtWntk r'nXtjjd||atttt dS(s3Update sys.path, reload gdb and auto-load packages.iN( R'R tremovet PYTHONDIRt ValueErrortinsertRR)RR2(tdir((s%/usr/share/gdb/python/gdb/__init__.pytGdbSetPythonDirectoryos (R+RR't_gdbt version_infotimpRtobjectRRtstdoutRR*Rt prompt_hooktargvtpretty_printerst type_printerst frame_filtersR R"R#R4RR2R8(((s%/usr/share/gdb/python/gdb/__init__.pyts,          PK!V::python/gdb/prompt.pyonu[ Rc@sdZddlZddlZdZdZdZdZdZdZd Z d Z d Z d Z d Z dZi ed6e d6e d6e d6ed6ed6ed6ed6e d6e d6ed6ZdZdZdS(s# Extended prompt library functions.iNcCs tjS(sThe current working directory.(tostgetcwdu(tignore((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_pwdscCs|dkr|}ny |}Wntjk r=d|SXt||rxt||}t|rt|}n|Sd||fSdS(s,Internal worker for fetching GDB attributes.ssN(tNonetgdbterrorthasattrtgetattrtcallable(tfunctwhattattrtnattrtobjtresult((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_object_attrs      cCsttjd|dS(s8The selected frame; an argument names a frame parameter.tframetname(RRtselected_frame(R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_frame*scCsttjd|dS(s:The selected thread; an argument names a thread parameter.tthreadtnum(RRtselected_thread(R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_thread.scCstjS(sThe version of GDB.(RtVERSION(R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_version2scCsdS(sThe ESC character.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_esc6scCsdS(s A backslash.s\((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_bs:scCsdS(s A newline.s ((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_n>scCsdS(sA carriage return.s ((R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_rBscCs tj|S(s6A parameter's value; the argument names the parameter.(Rt parameter(R ((s#/usr/share/gdb/python/gdb/prompt.pyt _prompt_paramFscCsdS(s-Begins a sequence of non-printing characters.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_noprint_beginJscCsdS(s+Ends a sequence of non-printing characters.s((R ((s#/usr/share/gdb/python/gdb/prompt.pyt_prompt_noprint_endNstes\tntrtvtwtftttpt[t]cCsRd}ttj}x)|D]!}|d|t|jf7}qW|d7}|S(sNGenerate help dynamically from the __doc__ strings of attribute functions.ts \%s %s s A substitution can be used in a simple form, like "\f". An argument can also be passed to it, like "\f{name}". The meaning of the argument depends on the particular substitution.(tsortedtprompt_substitutionstkeyst__doc__(RR0tkey((s#/usr/share/gdb/python/gdb/prompt.pyt prompt_help`s cCs[d}t|}d}x<||krV||dkr;|d}||krQPn||}|tkr*t|}|d|kr ||ddkr |d}x*||kr||dkr|d}qW||ks||dkrd}q||d|!}|}nd}|t||7}qI|||7}n|||7}|d}qW|S( s Perform substitutions on PROMPT.R-is\it{t}iN(tlenR/Rtstr(tpromptRtplentitcmdchtcmdtjtarg((s#/usr/share/gdb/python/gdb/prompt.pytsubstitute_promptns2      $   (R1RRRRRRRRRRRR R!R"R/R3R?(((s#/usr/share/gdb/python/gdb/prompt.pyts8                PK!?f'f'python/gdb/FrameDecorator.pynu[# Copyright (C) 2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb class FrameDecorator(object): """Basic implementation of a Frame Decorator""" """ This base frame decorator decorates a frame or another frame decorator, and provides convenience methods. If this object is wrapping a frame decorator, defer to that wrapped object's method if it has one. This allows for frame decorators that have sub-classed FrameDecorator object, but also wrap other frame decorators on the same frame to correctly execute. E.g If the result of frame filters running means we have one gdb.Frame wrapped by multiple frame decorators, all sub-classed from FrameDecorator, the resulting hierarchy will be: Decorator1 -- (wraps) Decorator2 -- (wraps) FrameDecorator -- (wraps) gdb.Frame In this case we have two frame decorators, both of which are sub-classed from FrameDecorator. If Decorator1 just overrides the 'function' method, then all of the other methods are carried out by the super-class FrameDecorator. But Decorator2 may have overriden other methods, so FrameDecorator will look at the 'base' parameter and defer to that class's methods. And so on, down the chain.""" # 'base' can refer to a gdb.Frame or another frame decorator. In # the latter case, the child class will have called the super # method and _base will be an object conforming to the Frame Filter # class. def __init__(self, base): self._base = base @staticmethod def _is_limited_frame(frame): """Internal utility to determine if the frame is special or limited.""" sal = frame.find_sal() if (not sal.symtab or not sal.symtab.filename or frame.type() == gdb.DUMMY_FRAME or frame.type() == gdb.SIGTRAMP_FRAME): return True return False def elided(self): """Return any elided frames that this class might be wrapping, or None.""" if hasattr(self._base, "elided"): return self._base.elided() return None def function(self): """ Return the name of the frame's function or an address of the function of the frame. First determine if this is a special frame. If not, try to determine filename from GDB's frame internal function API. Finally, if a name cannot be determined return the address. If this function returns an address, GDB will attempt to determine the function name from its internal minimal symbols store (for example, for inferiors without debug-info).""" # Both gdb.Frame, and FrameDecorator have a method called # "function", so determine which object this is. if not isinstance(self._base, gdb.Frame): if hasattr(self._base, "function"): # If it is not a gdb.Frame, and there is already a # "function" method, use that. return self._base.function() frame = self.inferior_frame() if frame.type() == gdb.DUMMY_FRAME: return "" elif frame.type() == gdb.SIGTRAMP_FRAME: return "" func = frame.function() # If we cannot determine the function name, return the # address. If GDB detects an integer value from this function # it will attempt to find the function name from minimal # symbols via its own internal functions. if func == None: pc = frame.pc() return pc return str(func) def address(self): """ Return the address of the frame's pc""" if hasattr(self._base, "address"): return self._base.address() frame = self.inferior_frame() return frame.pc() def filename(self): """ Return the filename associated with this frame, detecting and returning the appropriate library name is this is a shared library.""" if hasattr(self._base, "filename"): return self._base.filename() frame = self.inferior_frame() sal = frame.find_sal() if not sal.symtab or not sal.symtab.filename: pc = frame.pc() return gdb.solib_name(pc) else: return sal.symtab.filename def frame_args(self): """ Return an iterable of frame arguments for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame arguments, or if this frame is deemed to be a special case, return None.""" if hasattr(self._base, "frame_args"): return self._base.frame_args() frame = self.inferior_frame() if self._is_limited_frame(frame): return None args = FrameVars(frame) return args.fetch_frame_args() def frame_locals(self): """ Return an iterable of local variables for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame locals, or if this frame is deemed to be a special case, return None.""" if hasattr(self._base, "frame_locals"): return self._base.frame_locals() frame = self.inferior_frame() if self._is_limited_frame(frame): return None args = FrameVars(frame) return args.fetch_frame_locals() def line(self): """ Return line number information associated with the frame's pc. If symbol table/line information does not exist, or if this frame is deemed to be a special case, return None""" if hasattr(self._base, "line"): return self._base.line() frame = self.inferior_frame() if self._is_limited_frame(frame): return None sal = frame.find_sal() if (sal): return sal.line else: return None def inferior_frame(self): """ Return the gdb.Frame underpinning this frame decorator.""" # If 'base' is a frame decorator, we want to call its inferior # frame method. If '_base' is a gdb.Frame, just return that. if hasattr(self._base, "inferior_frame"): return self._base.inferior_frame() return self._base class SymValueWrapper(object): """A container class conforming to the Symbol/Value interface which holds frame locals or frame arguments.""" def __init__(self, symbol, value): self.sym = symbol self.val = value def value(self): """ Return the value associated with this symbol, or None""" return self.val def symbol(self): """ Return the symbol, or Python text, associated with this symbol, or None""" return self.sym class FrameVars(object): """Utility class to fetch and store frame local variables, or frame arguments.""" def __init__(self, frame): self.frame = frame self.symbol_class = { gdb.SYMBOL_LOC_STATIC: True, gdb.SYMBOL_LOC_REGISTER: True, gdb.SYMBOL_LOC_ARG: True, gdb.SYMBOL_LOC_REF_ARG: True, gdb.SYMBOL_LOC_LOCAL: True, gdb.SYMBOL_LOC_REGPARM_ADDR: True, gdb.SYMBOL_LOC_COMPUTED: True } def fetch_b(self, sym): """ Local utility method to determine if according to Symbol type whether it should be included in the iterator. Not all symbols are fetched, and only symbols that return True from this method should be fetched.""" # SYM may be a string instead of a symbol in the case of # synthetic local arguments or locals. If that is the case, # always fetch. if isinstance(sym, basestring): return True sym_type = sym.addr_class return self.symbol_class.get(sym_type, False) def fetch_frame_locals(self): """Public utility method to fetch frame local variables for the stored frame. Frame arguments are not fetched. If there are no frame local variables, return an empty list.""" lvars = [] try: block = self.frame.block() except RuntimeError: block = None while block != None: if block.is_global or block.is_static: break for sym in block: if sym.is_argument: continue; if self.fetch_b(sym): lvars.append(SymValueWrapper(sym, None)) block = block.superblock return lvars def fetch_frame_args(self): """Public utility method to fetch frame arguments for the stored frame. Frame arguments are the only type fetched. If there are no frame argument variables, return an empty list.""" args = [] try: block = self.frame.block() except RuntimeError: block = None while block != None: if block.function != None: break block = block.superblock if block != None: for sym in block: if not sym.is_argument: continue; args.append(SymValueWrapper(sym, None)) return args PK!kpython/gdb/command/__init__.pynu[# Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PK!N;cEcE$python/gdb/command/frame_filters.pyonu[ Rc@s^dZddlZddlZddlmZddlmZddlZddlZdej fdYZ dej fdYZ d ej fd YZ d Z d Zd ZdZdej fdYZdej fdYZdej fdYZdej fdYZe e e eeeedS(s,GDB commands for working with frame-filters.iN(t FrameIterator(tFrameDecoratortSetFilterPrefixCmdcBseZdZdZRS(s9Prefix command for 'set' frame-filter related operations.cCs)tt|jdtjtjtdS(Nsset frame-filter(tsuperRt__init__tgdbtCOMMAND_OBSCUREt COMPLETE_NONEtTrue(tself((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRs(t__name__t __module__t__doc__R(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRstShowFilterPrefixCmdcBseZdZdZRS(s:Prefix command for 'show' frame-filter related operations.cCs)tt|jdtjtjtdS(Nsshow frame-filter(RR RRRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR%s(R R R R(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR #stInfoFrameFiltercBsAeZdZdZedZdZdZdZRS(sMList all registered Python frame-filters. Usage: info frame-filters cCs tt|jdtjdS(Nsinfo frame-filter(RRRRt COMMAND_DATA(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR/scCs|r dSdSdS(s2Return "Yes" if filter is enabled, otherwise "No".tYestNoN((tstate((s2/usr/share/gdb/python/gdb/command/frame_filters.pytenabled_string2scCst|jdddt}t|dkr;dGHndGHx|D]}|d}yQdjttjj|d}d j|j tjj |d}Wn*t k r}d |d t|GHqGXd |||fGHqGWd S(s Internal worker function to list and print frame filters in a dictionary. Arguments: frame_filters: The name of the dictionary, as specified by GDB user commands. tkeycSstjj|dS(Ni(Rtframest get_priority(ti((s2/usr/share/gdb/python/gdb/command/frame_filters.pytDstreverseis No frame filters registered.s Priority Enabled Names{:<8}is{:<7}s Error printing filter 's': s %s %s %sN( tsortedtitemsRtlentformattstrRRRRt get_enabledt Exception(R t frame_filterstsorted_frame_filterst frame_filtertnametprioritytenabledte((s2/usr/share/gdb/python/gdb/command/frame_filters.pytlist_frame_filters:s     &cCs$|GH|j||r dGHndS(Nt(R((R ttitlet filter_listt blank_line((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt print_listWs cCsw|jdtjttj}|jd|j|jtx1tjD]#}|jd|j|jtqLWdS(Nsglobal frame-filters:sprogspace %s frame-filters:sobjfile %s frame-filters:(R-RR!Rtcurrent_progspacetfilenametobjfilestFalse(R targtfrom_ttytcptobjfile((s2/usr/share/gdb/python/gdb/command/frame_filters.pytinvoke]s  ( R R R Rt staticmethodRR(R-R6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR)s    cCstj|}t|}|ddkrM|dkrMtj|dn2|ddkr|dkrtj|dn|S(sa Internal worker function to take an argument from enable/disable and return a tuple of arguments. Arguments: cmd_name: Name of the command invoking this function. args: The argument as a string. Returns: A tuple containing the dictionary, and the argument, or just the dictionary in the case of "all". itallis*: with 'all' you may not specify a filter.is takes exactly two arguments.(Rtstring_to_argvRtGdbError(tcmd_nameR2targvtargc((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_enable_parse_argjs  cCs|d}tjj|}|dkrOx|D]}tjj||q/Wnb|d}y||}Wn4tk rdttd}tj|nXtjj||dS(s#Worker for enabling/disabling frame_filters. Arguments: command_type: A tuple with the first element being the frame filter dictionary, and the second being the frame filter name. flag: True for Enable, False for Disable. iR8isframe-filter 's ' not found.N(RRt return_listt set_enabledtKeyErrorRR$R:(t command_tupletflagtlist_optop_listtitemR#tfftmsg((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_do_enable_frame_filters     cCs|tkrdddg}n ddg}x$tjD]}|j|jq7W|dkra|St|d|}t|dkr|dt|t||dRIR(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s(R R R RRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR[s  tDisableFrameFiltercBs)eZdZdZdZdZRS(sGDB command to disable the specified frame-filter. Usage: disable frame-filter disable DICTIONARY [NAME] DICTIONARY is the name of the frame filter dictionary on which to operate. If dictionary is set to "all", perform operations on all dictionaries. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's frame filter dictionary. If either all, or the two named dictionaries are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. If DICTIONARY is "all", NAME is ignored. cCs tt|jdtjdS(Nsdisable frame-filter(RRbRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRscCsX|jddkr%t||tStjj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN( R]RVRRRR?R^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRa s"cCs td|}t|tdS(Nsdisable frame-filter(R>RIR1(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s(R R R RRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRbs  tSetFrameFilterPrioritycBs;eZdZdZdZdZdZdZRS(slGDB command to set the priority of the specified frame-filter. Usage: set frame-filter priority DICTIONARY NAME PRIORITY DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame filter to operate on. PRIORITY is the an integer to assign the new priority to the frame filter. cCs tt|jdtjdS(Nsset frame-filter priority(RRcRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR*scCs4tj|}t|}|dkr0dGHdS|S(sRInternal worker to parse a priority from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, name and priority from the arguments. Raises: gdb.GdbError: An error parsing the arguments. is8set frame-filter priority takes exactly three arguments.N(RR9RtNone(R R2R<R=((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_parse_pri_arg/s   cCs|d}|d}|d}tjj|}y||}Wn4tk rtdttd}tj|nXtjj||dS(sInternal worker for setting priority of frame-filters, by parsing a tuple and calling _set_priority with the parsed tuple. Arguments: command_tuple: Tuple which contains the arguments from the command. iiisframe-filter 's ' not found.N(RRR?RARR$R:t set_priority(R RBRDR#R%RERGRH((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_set_filter_priorityFs    cCsX|jddkr%t||tStjj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN( R]RVR1RRR?R^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRa^s"cCs/|j|}|dkr+|j|ndS(N(ReRdRg(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6gs (R R R RReRgRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRcs     tShowFrameFilterPrioritycBs;eZdZdZdZdZdZdZRS(sGDB command to show the priority of the specified frame-filter. Usage: show frame-filter priority DICTIONARY NAME DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. cCs tt|jdtjdS(Nsshow frame-filter priority(RRhRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRzscCs4tj|}t|}|dkr0dGHdS|S(sKInternal worker to parse a dictionary and name from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, and frame filter name. Raises: gdb.GdbError: An error parsing the arguments. is7show frame-filter priority takes exactly two arguments.N(RR9RRd(R R2R<R=((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRes   cCsgtjj|}y||}Wn4tk rVdt|d}tj|nXtjj|S(sEWorker for retrieving the priority of frame_filters. Arguments: frame_filters: Name of frame filter dictionary. name: object to select printers. Returns: The priority of the frame filter. Raises: gdb.GdbError: A frame filter cannot be found. sframe-filter 's ' not found.(RRR?RARR:R(R R!R$RERGRH((s2/usr/share/gdb/python/gdb/command/frame_filters.pytget_filter_prioritys cCsU|jddkr%t||tStj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN(R]RVR1tframet _return_listR^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRascCs|j|}|dkrdS|d}|d}y|j||}Wn*tk ru}dtdt|GHn Xd|d|dt|GHdS(Niis$Error printing filter priority for 's':sPriority of filter 's ' in list 's' is: (ReRdRiR R$R(R R2R3RBt filter_namet list_nameR%R'((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s   (R R R RReRiRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRhls      (R Rtcopytgdb.FrameIteratorRtgdb.FrameDecoratorRt gdb.framest itertoolstCommandRR RR>RIRVRZR[RbRcRh(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyts0    A   % !!S[PK!1; ; python/gdb/command/pahole.pycnu[ Rc@s0ddlZdejfdYZedS(iNtPaholecBs2eZdZdZdZdZdZRS(sShow the holes in a structure. This command takes a single argument, a type name. It prints the type and displays comments showing where holes are.cCs&tt|jdtjtjdS(Ntpahole(tsuperRt__init__tgdbt COMMAND_NONEtCOMPLETE_SYMBOL(tself((s+/usr/share/gdb/python/gdb/command/pahole.pyRscCs&||kr"||}d|GHndS(Ns$ /* XXX %d bit hole, try to pack */((Rtbitpost field_bitposthole((s+/usr/share/gdb/python/gdb/command/pahole.pytmaybe_print_holes  c Cs|dkrd}n|j}|dkr3d}nddd||fGHd}x|jD]}t|dsxq]n|jj}|j||j|j}|jdkr|j}n d|j }dt |dt |dfG||}|j t j kr&|j||d |jq]ddd|Gd t||jfGHq]W|dkrx|j|d|j ndd d|Gd |GHdS( Nts %sstruct %s {t iiRis /* %3d %3d */is%s %sis} %s(tNonettagtfieldsthasattrttypetstrip_typedefsR RtbitsizetsizeoftinttcodeRtTYPE_CODE_STRUCTRtnametstr( RRtlevelRRRtfieldtftypet fieldsize((s+/usr/share/gdb/python/gdb/command/pahole.pyR"s4        "  cCsXtj|}|j}|jtjkr=td|ndG|j|dddS(Ns%s is not a struct typeR iiR s (Rt lookup_typeRRRt TypeErrorR(Rtargtfrom_ttyR((s+/usr/share/gdb/python/gdb/command/pahole.pytinvokeIs  (t__name__t __module__t__doc__RR RR#(((s+/usr/share/gdb/python/gdb/command/pahole.pyRs    '(RtCommandR(((s+/usr/share/gdb/python/gdb/command/pahole.pyts =PK!Rq $python/gdb/command/type_printers.pycnu[ Rc@sddlZddlZdejfdYZdejfdYZdefdYZdefd YZeeedS( iNtInfoTypePrintercBs)eZdZdZdZdZRS(sUGDB command to list all registered type-printers. Usage: info type-printers cCs tt|jdtjdS(Nsinfo type-printers(tsuperRt__init__tgdbt COMMAND_DATA(tself((s2/usr/share/gdb/python/gdb/command/type_printers.pyRscCs]ttj|dd}x8|D]0}|jr=d}nd}d|j|fGHq%WdS(sPrint a list of type printers.tkeycSs|jS(N(tname(tx((s2/usr/share/gdb/python/gdb/command/type_printers.pyt%sts [disabled]s %s%sN(tsortedtcopytenabledR(Rt type_printerstsorted_type_printerstprinterR ((s2/usr/share/gdb/python/gdb/command/type_printers.pytlist_type_printers s    cCsd}xHtjD]:}|jrd||jfGH|j|jd}qqWtjjrd|GH|jtjjd}ntjrd|GH|jtjndS(s&GDB calls this to perform the command.R s%sType printers for %s:s s"%sType printers for program space:s%sGlobal type printers:N(RtobjfilesRtfilenameRtcurrent_progspace(Rtargtfrom_ttytseptobjfile((s2/usr/share/gdb/python/gdb/command/type_printers.pytinvoke-s      (t__name__t __module__t__doc__RRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyRs  t_EnableOrDisableCommandcBs5eZdZdZdZdZdZRS(cCs)tt|j|tj||_dS(N(RRRRRtsetting(RRR((s2/usr/share/gdb/python/gdb/command/type_printers.pyR>scCs?t}x2|D]*}||jkr |j|_t}q q W|S(N(tFalseRRR tTrue(RRtprinterstresulttp((s2/usr/share/gdb/python/gdb/command/type_printers.pytset_someBs    cCsx|jD]}t}x2tjD]$}|j||jr&t}q&q&W|j|tjjrrt}n|j|tjrt}n|s d|GHq q WdS(s&GDB calls this to perform the command.sNo type printer named '%s'N(tsplitRRRR$RR R(RRRRtokR((s2/usr/share/gdb/python/gdb/command/type_printers.pyRJs   cCs:x3|D]+}|jj|r|j|jqqWdS(N(Rt startswithtappend(RR"twordR!R#((s2/usr/share/gdb/python/gdb/command/type_printers.pytadd_someXs cCsig}x*tjD]}|j|||jqW|j||tjj|j||tj|S(N(RRR*RR(RttextR)R"R((s2/usr/share/gdb/python/gdb/command/type_printers.pytcomplete]s (RRRR$RR*R,(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR=s     tEnableTypePrintercBseZdZdZRS(sGDB command to enable the specified type printer. Usage: enable type-printer NAME NAME is the name of the type-printer. cCstt|jtddS(Nsenable type-printer(RR-RR (R((s2/usr/share/gdb/python/gdb/command/type_printers.pyRms(RRRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR-estDisableTypePrintercBseZdZdZRS(sGDB command to disable the specified type-printer. Usage: disable type-printer NAME NAME is the name of the type-printer. cCstt|jtddS(Nsdisable type-printer(RR.RR(R((s2/usr/share/gdb/python/gdb/command/type_printers.pyRxs(RRRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR.ps(R RtCommandRRR-R.(((s2/usr/share/gdb/python/gdb/command/type_printers.pyts  '(  PK! [ [python/gdb/command/explore.pyonu[ Rc@sXdZddlZddlZejddkr:eZndefdYZdefdYZd efd YZ d efd YZ d efdYZ defdYZ defdYZ defdYZdejfdYZdejfdYZdejfdYZejeeedS(sEImplementation of the GDB 'explore' command using the GDB Python API.iNiitExplorercBseZdZiZejejejejej ej fZ e dZ e dZe dZe dZe dZe dZe dZe dZe d ZRS( s-Internal class which invokes other explorers.c Cst|}t}|ddkr9||ddkr9nd}x||kr||}|dksd|kr||dksd|kr|d ksd |kr|d krnt}P|d7}qBW|rd|dS|SdS( Nit(it)t_tatztAtZt0t9(tlentFalsetTrue(texprtlengthtguardtitc((s,/usr/share/gdb/python/gdb/command/explore.pyt guard_expr)s  $ $0 cCs]|jj}|tjkrGtj|}x.|j|||rCq+Wndt|jGHdS(sMain function to explore an expression value. Arguments: expr: The expression string that is being explored. value: The gdb.Value value of the expression. is_child: Boolean value to indicate if the expression is a child. An expression is a child if it is derived from the main expression entered by the user. For example, if the user entered an expression which evaluates to a struct, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. s*Explorer for type '%s' not yet available. N(ttypetcodeRttype_code_to_explorer_mapt explore_exprtstr(R tvaluetis_childt type_codetexplorer_class((s,/usr/share/gdb/python/gdb/command/explore.pyRAs  cCsW|j}|tjkrDtj|}x+|j|||r@q(Wndt|GHdS(sMain function to explore a data type. Arguments: name: The string representing the path to the data type being explored. datatype: The gdb.Type value of the data type being explored. is_child: Boolean value to indicate if the name is a child. A name is a child if it is derived from the main name entered by the user. For example, if the user entered the name of struct type, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. s*Explorer for type '%s' not yet available. N(RRRt explore_typeR(tnametdatatypeRRR((s,/usr/share/gdb/python/gdb/command/explore.pyR[s  cCsi ttj6ttj6ttj6ttj6ttj6ttj6ttj 6ttj 6t tj 6t tj6ttj6ttj6t_dS(sInitializes the Explorer environment. This function should be invoked before starting any exploration. If invoked before an exploration, it need not be invoked for subsequent explorations. N(tScalarExplorertgdbtTYPE_CODE_CHARt TYPE_CODE_INTtTYPE_CODE_BOOLt TYPE_CODE_FLTtTYPE_CODE_VOIDtTYPE_CODE_ENUMtCompoundExplorertTYPE_CODE_STRUCTtTYPE_CODE_UNIONtPointerExplorert TYPE_CODE_PTRtReferenceExplorert TYPE_CODE_REFtTypedefExplorertTYPE_CODE_TYPEDEFt ArrayExplorertTYPE_CODE_ARRAYRR(((s,/usr/share/gdb/python/gdb/command/explore.pytinit_envus           cCs|jtjkS(sChecks whether a type is a scalar type. A type is a scalar type of its type is gdb.TYPE_CODE_CHAR or gdb.TYPE_CODE_INT or gdb.TYPE_CODE_BOOL or gdb.TYPE_CODE_FLT or gdb.TYPE_CODE_VOID or gdb.TYPE_CODE_ENUM. Arguments: type: The type to be checked. Returns: 'True' if 'type' is a scalar type. 'False' otherwise. (RRt_SCALAR_TYPE_LIST(R((s,/usr/share/gdb/python/gdb/command/explore.pytis_scalar_typescCs dGHdS(sA utility function which prints that the current exploration session is returning to the parent value. Useful when exploring values. s Returning to parent value... N((((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_parent_valuescCstddS(sA utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the parent value. Useful when exploring values. s( Press enter to return to parent value: N(t raw_input(((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_parent_value_promptscCs dGHdS(sA utility function which prints that the current exploration session is returning to the enclosing type. Useful when exploring types. s Returning to enclosing type... N((((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_enclosing_typescCstddS(sA utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the enclosing type. Useful when exploring types. s* Press enter to return to enclosing type: N(R6(((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_enclosing_type_prompts(t__name__t __module__t__doc__RR R!R"R#R$R%R&R3t staticmethodRRRR2R4R5R7R8R9(((s,/usr/share/gdb/python/gdb/command/explore.pyRs" RcBs,eZdZedZedZRS(s-Internal class used to explore scalar values.cCsHd||jfGHd|t|fGH|rDtjtjntS(sFunction to explore scalar values. See Explorer.explore_expr and Explorer.is_scalar_type for more information. s$'%s' is a scalar value of type '%s'.s%s = %s(RRRR7R5R (R RR((s,/usr/share/gdb/python/gdb/command/explore.pyRs  cCs|jtjkr<|r0d|t|fGHqcd|GHn'|rZd|t|fGHn d|GH|rtjtjntS(sFunction to explore scalar types. See Explorer.explore_type and Explorer.is_scalar_type for more information. s!%s is of an enumerated type '%s'.s'%s' is an enumerated type.s%s is of a scalar type '%s'.s'%s' is a scalar type.(RR R&RRR9R8R (RRR((s,/usr/share/gdb/python/gdb/command/explore.pyRs    (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyRsR*cBs,eZdZedZedZRS(s.Internal class used to explore pointer values.cCsd|t|jjfGHtd}|dkrd }y|j}t|Wn1tjk rd|GH|rtj nt SXtj dtj |||t Std}|dkrsxt rnd}yttd|}Wntk rPnXd tj ||f}||}yt|Wn tjk rWd |GHqnXtj ||t qWt S|rtjnt S( sdFunction to explore pointer values. See Explorer.explore_expr for more information. s)'%s' is a pointer to a value of type '%s's<Continue exploring it as a pointer to a single value [y/n]: tys6'%s' a pointer pointing to an invalid memory location.s*%ss6Continue exploring it as a pointer to an array [y/n]: is<Enter the index of the element you want to explore in '%s': s%s[%d]sCannot read value at index %d.N(RRttargetR6tNonet dereferenceR t MemoryErrorRR7R RRR tintt ValueErrorR5(R RRtoptiont deref_valuetindext element_exprtelement((s,/usr/share/gdb/python/gdb/command/explore.pyRsL             cCs<|j}d|t|fGHtjd|||tS(scFunction to explore pointer types. See Explorer.explore_type for more information. s) %s is a pointer to a value of type '%s'.sthe pointee type of %s(R?RRRR (RRRt target_type((s,/usr/share/gdb/python/gdb/command/explore.pyRs  (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR*s0R,cBs,eZdZedZedZRS(s@Internal class used to explore reference (TYPE_CODE_REF) values.cCs#|j}tj|||tS(sbFunction to explore array values. See Explorer.explore_expr for more information. (treferenced_valueRRR (R RRRK((s,/usr/share/gdb/python/gdb/command/explore.pyR/s cCs#|j}tj|||tS(scFunction to explore pointer types. See Explorer.explore_type for more information. (R?RRR (RRRRJ((s,/usr/share/gdb/python/gdb/command/explore.pyR8s (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR,,s R0cBs,eZdZedZedZRS(s&Internal class used to explore arrays.cCs|jj}d|t|fGHd}yttd|}Wn%tk rk|rgtjntSXd}y||}t|Wn(t j k rd|GHtdt SXtj dtj||f|t t S(sbFunction to explore array values. See Explorer.explore_expr for more information. s'%s' is an array of '%s'.is<Enter the index of the element you want to explore in '%s': sCannot read value at index %d.sPress enter to continue... s%s[%d]N(RR?RRCR6RDRR5R R@R RBR RR(R RRRJRGRI((s,/usr/share/gdb/python/gdb/command/explore.pyREs*       cCs<|j}d|t|fGHtjd|||tS(saFunction to explore array types. See Explorer.explore_type for more information. s%s is an array of '%s'.sthe array element of %s(R?RRRR (RRRRJ((s,/usr/share/gdb/python/gdb/command/explore.pyRbs  (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR0BsR'cBsJeZdZedZedZedZedZRS(s:Internal class used to explore struct, classes and unions.cCsod}x7|D]/}|t|dkr t|d}q q Wx(|D] }d||d|dfGHqGWdS(sKInternal function which prints the fields of a struct/class/union. is %*s = %siN(R (t print_listtmax_field_name_lengthtpair((s,/usr/share/gdb/python/gdb/command/explore.pyt _print_fieldsrs   cCs1d}x$|D]}|js |d}q q W|S(Nii(t artificial(tfieldstreal_field_counttfield((s,/usr/share/gdb/python/gdb/command/explore.pyt_get_real_field_count~s   cCsz|j}|j}|j}|tjkr6d}nd}tj|dkrd||t|jfGH|rtj nt Sd||t|jfGHt }i}d} g} x=|D]5} | j rqntj |d| j } | jr |j| j} n || j } d}|tjkrNd| t| jf}t}nntj| jrd t| t| jf}n:| jrd }nd }d | |t| jf}t}| | f|t| <| d } | j| j |fqWtj| dGH|rctd}||krMtj||d||d ttS|rvtjqvn|rvtj nt S(svFunction to explore structs/classes and union values. See Explorer.explore_expr for more information. s struct/classtunionis6The value of '%s' is a %s of type '%s' with no fields.sBThe value of '%s' is a %s of type '%s' with the following fields: t.ts-s%s .. (Value of type '%s')s base classRSs*is"Enter the field number of choice: (RRRQR R(R'RTRRR7R RPRRt is_base_classtcastR)R R4tappendROR6RR5(R RRRRRQt type_descthas_explorable_fieldstchoice_to_compound_field_maptcurrent_choiceRLRStfield_full_namet field_valuet literal_valuet field_desctchoice((s,/usr/share/gdb/python/gdb/command/explore.pyRsr                  cCs>|j}d}|tjkr'd}nd}|j}tj|dkr|ryd||t|fGHtjnd||fGHt S|rd||t|fGHnd||fGHt }d}i}g} x|D]} | j rqn| j rd } nd } d || t| j f} | j | j| f| j| j | f|t|<|d }qWtj| dGHt|dkr'td } | |kr|rd|| d|| d|f}n#d|| d|| d|f}tj||| d ttS|r:tjq:n|r:tjnt S(srFunction to explore struct/class and union types. See Explorer.explore_type for more information. RWs struct/classRUis'%s is a %s of type '%s' with no fields.s'%s' is a %s with no fields.s3%s is a %s of type '%s' with the following fields: s('%s' is a %s with the following fields: s base classRSs*is"Enter the field number of choice: s %s '%s' of %sis%s '%s' of '%s'(RR R(RQR'RTRRR9R RPRXRRZRROR R6RR R8(RRRRR[RQR\R^R]RLRSRbtrhsRctnew_name((s,/usr/share/gdb/python/gdb/command/explore.pyRsn                    (R:R;R<R=RORTRR(((s,/usr/share/gdb/python/gdb/command/explore.pyR'os   QR.cBs,eZdZedZedZRS(s>Internal class used to explore values whose type is a typedef.cCsP|jj}d|t|jt|fGHtj||j||tS(sdFunction to explore typedef values. See Explorer.explore_expr for more information. sAThe value of '%s' is of type '%s' which is a typedef of type '%s'(Rtstrip_typedefsRRRRYR (R RRt actual_type((s,/usr/share/gdb/python/gdb/command/explore.pyR)s cCsV|j}|r*d|t|fGHnd|t|fGHtj|||tS(scFunction to explore typedef types. See Explorer.explore_type for more information. s)The type of %s is a typedef of type '%s'.s(The type '%s' is a typedef of type '%s'.(RfRRRR (RRRRg((s,/usr/share/gdb/python/gdb/command/explore.pyR6s (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR.&s t ExploreUtilscBs;eZdZedZedZedZRS(sEInternal class which provides utilities for the main command classes.cCs1t|dkr)tjd|tStSdS(sUtility to check if adequate number of arguments are passed to an explore command. Arguments: name: The name of the explore command. arg_str: The argument string passed to the explore command. Returns: True if adequate arguments are passed, false otherwise. Raises: gdb.GdbError if adequate arguments are not passed. is!ERROR: '%s' requires an argument.N(R R tGdbErrorR R (Rtarg_str((s,/usr/share/gdb/python/gdb/command/explore.pyt check_argsJs   cCs\ytjd|jjSWn7tk rWytj|SWqXtk rSdSXnXdS(s<A utility function to deduce the gdb.Type value from a string representing the type. Arguments: type_str: The type string from which the gdb.Type value should be deduced. Returns: The deduced gdb.Type value if possible, None otherwise. s(%s *)0N(R tparse_and_evalRR?t RuntimeErrort lookup_typeR@(ttype_str((s,/usr/share/gdb/python/gdb/command/explore.pytget_type_from_str`s   cCs*ytj|SWntk r%dSXdS(sCA utility function to deduce the gdb.Value value from a string representing the value. Arguments: value_str: The value string from which the gdb.Value value should be deduced. Returns: The deduced gdb.Value value if possible, None otherwise. N(R RlRmR@(t value_str((s,/usr/share/gdb/python/gdb/command/explore.pytget_value_from_strws  (R:R;R<R=RkRpRr(((s,/usr/share/gdb/python/gdb/command/explore.pyRhGstExploreCommandcBs eZdZdZdZRS(s,Explore a value or a type valid in the current context. Usage: explore ARG - ARG is either a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type or value. cCs,tt|jdddtjdtdS(NRtexploret command_classtprefix(tsuperRst__init__R t COMMAND_DATAR (tself((s,/usr/share/gdb/python/gdb/command/explore.pyRxs cCstjd|tkrdStj|}|dk rNtj||tdStj|}|dk rtj||tdSt j d|dS(NRtsG'%s' neither evaluates to a value nor is a type in the current context.( RhRkR RrR@RRRpRR Ri(RzRjtfrom_ttyRR((s,/usr/share/gdb/python/gdb/command/explore.pytinvokes  (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyRss  tExploreValueCommandcBs eZdZdZdZRS(sExplore value of an expression valid in the current context. Usage: explore value ARG - ARG is a valid expression. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing value. cCs&tt|jdddtjdS(NRs explore valueRu(RwR}RxR Ry(Rz((s,/usr/share/gdb/python/gdb/command/explore.pyRxscCsetjd|tkrdStj|}|dkrNtjd|dStj||tdS(Ns explore values: '%s' does not evaluate to a value in the current context.( RhRkR RrR@R RiRR(RzRjR{R((s,/usr/share/gdb/python/gdb/command/explore.pyR|s  (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyR}s  tExploreTypeCommandcBs eZdZdZdZRS(s:Explore a type or the type of an expression valid in the current context. Usage: explore type ARG - ARG is a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type. cCs&tt|jdddtjdS(NRs explore typeRu(RwR~RxR Ry(Rz((s,/usr/share/gdb/python/gdb/command/explore.pyRxscCstjd|tkrdStj|}|dk rNtj||tdStj|}|dk rd|t|j fGHtjt|j |j tdSt j d|dS(Ns explore types'%s' is of type '%s'.s3'%s' is not a type or value in the current context.( RhRkR RpR@RRRrRRR Ri(RzRjR{RR((s,/usr/share/gdb/python/gdb/command/explore.pyR|s   (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyR~s  (R<R tsyst version_infotinputR6tobjectRRR*R,R0R'R.RhtCommandRsR}R~R2(((s,/usr/share/gdb/python/gdb/command/explore.pyts&   -B-!B($ PK!Pf6python/gdb/command/__init__.pycnu[ Rc@sdS(N((((s-/usr/share/gdb/python/gdb/command/__init__.pytsPK!1; ; python/gdb/command/pahole.pyonu[ Rc@s0ddlZdejfdYZedS(iNtPaholecBs2eZdZdZdZdZdZRS(sShow the holes in a structure. This command takes a single argument, a type name. It prints the type and displays comments showing where holes are.cCs&tt|jdtjtjdS(Ntpahole(tsuperRt__init__tgdbt COMMAND_NONEtCOMPLETE_SYMBOL(tself((s+/usr/share/gdb/python/gdb/command/pahole.pyRscCs&||kr"||}d|GHndS(Ns$ /* XXX %d bit hole, try to pack */((Rtbitpost field_bitposthole((s+/usr/share/gdb/python/gdb/command/pahole.pytmaybe_print_holes  c Cs|dkrd}n|j}|dkr3d}nddd||fGHd}x|jD]}t|dsxq]n|jj}|j||j|j}|jdkr|j}n d|j }dt |dt |dfG||}|j t j kr&|j||d |jq]ddd|Gd t||jfGHq]W|dkrx|j|d|j ndd d|Gd |GHdS( Nts %sstruct %s {t iiRis /* %3d %3d */is%s %sis} %s(tNonettagtfieldsthasattrttypetstrip_typedefsR RtbitsizetsizeoftinttcodeRtTYPE_CODE_STRUCTRtnametstr( RRtlevelRRRtfieldtftypet fieldsize((s+/usr/share/gdb/python/gdb/command/pahole.pyR"s4        "  cCsXtj|}|j}|jtjkr=td|ndG|j|dddS(Ns%s is not a struct typeR iiR s (Rt lookup_typeRRRt TypeErrorR(Rtargtfrom_ttyR((s+/usr/share/gdb/python/gdb/command/pahole.pytinvokeIs  (t__name__t __module__t__doc__RR RR#(((s+/usr/share/gdb/python/gdb/command/pahole.pyRs    '(RtCommandR(((s+/usr/share/gdb/python/gdb/command/pahole.pyts =PK! python/gdb/command/pahole.pynu[# pahole command for gdb # Copyright (C) 2008, 2009, 2012 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb class Pahole (gdb.Command): """Show the holes in a structure. This command takes a single argument, a type name. It prints the type and displays comments showing where holes are.""" def __init__ (self): super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE, gdb.COMPLETE_SYMBOL) def maybe_print_hole(self, bitpos, field_bitpos): if bitpos != field_bitpos: hole = field_bitpos - bitpos print ' /* XXX %d bit hole, try to pack */' % hole def pahole (self, type, level, name): if name is None: name = '' tag = type.tag if tag is None: tag = '' print '%sstruct %s {' % (' ' * (2 * level), tag) bitpos = 0 for field in type.fields (): # Skip static fields. if not hasattr (field, ('bitpos')): continue ftype = field.type.strip_typedefs() self.maybe_print_hole(bitpos, field.bitpos) bitpos = field.bitpos if field.bitsize > 0: fieldsize = field.bitsize else: # TARGET_CHAR_BIT here... fieldsize = 8 * ftype.sizeof # TARGET_CHAR_BIT print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), bitpos = bitpos + fieldsize if ftype.code == gdb.TYPE_CODE_STRUCT: self.pahole (ftype, level + 1, field.name) else: print ' ' * (2 + 2 * level), print '%s %s' % (str (ftype), field.name) if level == 0: self.maybe_print_hole(bitpos, 8 * type.sizeof) print ' ' * (14 + 2 * level), print '} %s' % name def invoke (self, arg, from_tty): type = gdb.lookup_type (arg) type = type.strip_typedefs () if type.code != gdb.TYPE_CODE_STRUCT: raise TypeError, '%s is not a struct type' % arg print ' ' * 14, self.pahole (type, 0, '') Pahole() PK!l++&python/gdb/command/pretty_printers.pycnu[ Rc@sdZddlZddlZddlZdZdZdejfdYZdZdZ d d Z d Z d 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|d k 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_argvtlentNonet SyntaxErrortsplittretcompile( targtargvtargct object_regexpt name_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 Csttj|d|j}x|D]}|j|}|j|}|j|r%d||fGHt|dr|jdk rttj|jd|j}xH|D]=} | s|j| jrd| j|j| fGHqqWqq%q%WdS(s Print a list of pretty-printers.tkeys %s%st subprinterss %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.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(RR1RR)tcurrent_progspacetfilenametobjfiles(RR tfrom_ttyRRRtcptobjfile((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvokes    ( R!t __module__t__doc__Rt staticmethodRR#R-R1R:(((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(R?RR)R4R6(t enabled_countt total_countt t_enabledtt_totalR9((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(RD(R@RA((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)RRtflagR>RR,((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.iR2R3Rtdisableds%d %s %sRN( RR(RLRR)R4R6R5RIRJ( R RKRRRR>R8R9tstate((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(RRPRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRJscCst|tdS(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 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(RRQRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRascCst|tdS(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  cCstttdS(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.pyts     4 S     : % PK!Rq $python/gdb/command/type_printers.pyonu[ Rc@sddlZddlZdejfdYZdejfdYZdefdYZdefd YZeeedS( iNtInfoTypePrintercBs)eZdZdZdZdZRS(sUGDB command to list all registered type-printers. Usage: info type-printers cCs tt|jdtjdS(Nsinfo type-printers(tsuperRt__init__tgdbt COMMAND_DATA(tself((s2/usr/share/gdb/python/gdb/command/type_printers.pyRscCs]ttj|dd}x8|D]0}|jr=d}nd}d|j|fGHq%WdS(sPrint a list of type printers.tkeycSs|jS(N(tname(tx((s2/usr/share/gdb/python/gdb/command/type_printers.pyt%sts [disabled]s %s%sN(tsortedtcopytenabledR(Rt type_printerstsorted_type_printerstprinterR ((s2/usr/share/gdb/python/gdb/command/type_printers.pytlist_type_printers s    cCsd}xHtjD]:}|jrd||jfGH|j|jd}qqWtjjrd|GH|jtjjd}ntjrd|GH|jtjndS(s&GDB calls this to perform the command.R s%sType printers for %s:s s"%sType printers for program space:s%sGlobal type printers:N(RtobjfilesRtfilenameRtcurrent_progspace(Rtargtfrom_ttytseptobjfile((s2/usr/share/gdb/python/gdb/command/type_printers.pytinvoke-s      (t__name__t __module__t__doc__RRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyRs  t_EnableOrDisableCommandcBs5eZdZdZdZdZdZRS(cCs)tt|j|tj||_dS(N(RRRRRtsetting(RRR((s2/usr/share/gdb/python/gdb/command/type_printers.pyR>scCs?t}x2|D]*}||jkr |j|_t}q q W|S(N(tFalseRRR tTrue(RRtprinterstresulttp((s2/usr/share/gdb/python/gdb/command/type_printers.pytset_someBs    cCsx|jD]}t}x2tjD]$}|j||jr&t}q&q&W|j|tjjrrt}n|j|tjrt}n|s d|GHq q WdS(s&GDB calls this to perform the command.sNo type printer named '%s'N(tsplitRRRR$RR R(RRRRtokR((s2/usr/share/gdb/python/gdb/command/type_printers.pyRJs   cCs:x3|D]+}|jj|r|j|jqqWdS(N(Rt startswithtappend(RR"twordR!R#((s2/usr/share/gdb/python/gdb/command/type_printers.pytadd_someXs cCsig}x*tjD]}|j|||jqW|j||tjj|j||tj|S(N(RRR*RR(RttextR)R"R((s2/usr/share/gdb/python/gdb/command/type_printers.pytcomplete]s (RRRR$RR*R,(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR=s     tEnableTypePrintercBseZdZdZRS(sGDB command to enable the specified type printer. Usage: enable type-printer NAME NAME is the name of the type-printer. cCstt|jtddS(Nsenable type-printer(RR-RR (R((s2/usr/share/gdb/python/gdb/command/type_printers.pyRms(RRRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR-estDisableTypePrintercBseZdZdZRS(sGDB command to disable the specified type-printer. Usage: disable type-printer NAME NAME is the name of the type-printer. cCstt|jtddS(Nsdisable type-printer(RR.RR(R((s2/usr/share/gdb/python/gdb/command/type_printers.pyRxs(RRRR(((s2/usr/share/gdb/python/gdb/command/type_printers.pyR.ps(R RtCommandRRR-R.(((s2/usr/share/gdb/python/gdb/command/type_printers.pyts  '(  PK!?WWpython/gdb/command/prompt.pynu[# Extended prompt. # Copyright (C) 2011-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """GDB command for working with extended prompts.""" import gdb import gdb.prompt class _ExtendedPrompt(gdb.Parameter): """Set the extended prompt. Usage: set extended-prompt VALUE Substitutions are applied to VALUE to compute the real prompt. The currently defined substitutions are: """ # Add the prompt library's dynamically generated help to the # __doc__ string. __doc__ = __doc__ + gdb.prompt.prompt_help() set_doc = "Set the extended prompt." show_doc = "Show the extended prompt." def __init__(self): super(_ExtendedPrompt, self).__init__("extended-prompt", gdb.COMMAND_SUPPORT, gdb.PARAM_STRING_NOESCAPE) self.value = '' self.hook_set = False def get_show_string (self, pvalue): if self.value is not '': return "The extended prompt is: " + self.value else: return "The extended prompt is not set." def get_set_string (self): if self.hook_set == False: gdb.prompt_hook = self.before_prompt_hook self.hook_set = True return "" def before_prompt_hook(self, current): if self.value is not '': newprompt = gdb.prompt.substitute_prompt(self.value) return newprompt.replace('\\', '\\\\') else: return None _ExtendedPrompt() PK!>6python/gdb/command/prompt.pycnu[ Rc@sBdZddlZddlZdejfdYZedS(s.GDB command for working with extended prompts.iNt_ExtendedPromptcBsQeZdZeejjZdZdZdZdZ dZ dZ RS(sSet the extended prompt. Usage: set extended-prompt VALUE Substitutions are applied to VALUE to compute the real prompt. The currently defined substitutions are: sSet the extended prompt.sShow the extended prompt.cCs8tt|jdtjtjd|_t|_dS(Nsextended-promptt( tsuperRt__init__tgdbtCOMMAND_SUPPORTtPARAM_STRING_NOESCAPEtvaluetFalsethook_set(tself((s+/usr/share/gdb/python/gdb/command/prompt.pyR(s   cCs"|jdk rd|jSdSdS(NRsThe extended prompt is: sThe extended prompt is not set.(R(R tpvalue((s+/usr/share/gdb/python/gdb/command/prompt.pytget_show_string/s cCs+|jtkr'|jt_t|_ndS(NR(R Rtbefore_prompt_hookRt prompt_hooktTrue(R ((s+/usr/share/gdb/python/gdb/command/prompt.pytget_set_string5s  cCs<|jdk r4tjj|j}|jddSdSdS(NRs\s\\(RRtprompttsubstitute_prompttreplacetNone(R tcurrentt newprompt((s+/usr/share/gdb/python/gdb/command/prompt.pyR ;s( t__name__t __module__t__doc__RRt prompt_helptset_doctshow_docRR RR (((s+/usr/share/gdb/python/gdb/command/prompt.pyRs    (RRt gdb.promptt ParameterR(((s+/usr/share/gdb/python/gdb/command/prompt.pyts  ,PK!LL#python/gdb/command/type_printers.pynu[# Type printer commands. # Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import copy import gdb """GDB commands for working with type-printers.""" class InfoTypePrinter(gdb.Command): """GDB command to list all registered type-printers. Usage: info type-printers """ def __init__ (self): super(InfoTypePrinter, self).__init__("info type-printers", gdb.COMMAND_DATA) def list_type_printers(self, type_printers): """Print a list of type printers.""" # A potential enhancement is to provide an option to list printers in # "lookup order" (i.e. unsorted). sorted_type_printers = sorted (copy.copy(type_printers), key = lambda x: x.name) for printer in sorted_type_printers: if printer.enabled: enabled = '' else: enabled = " [disabled]" print (" %s%s" % (printer.name, enabled)) def invoke(self, arg, from_tty): """GDB calls this to perform the command.""" sep = '' for objfile in gdb.objfiles(): if objfile.type_printers: print ("%sType printers for %s:" % (sep, objfile.filename)) self.list_type_printers(objfile.type_printers) sep = '\n' if gdb.current_progspace().type_printers: print ("%sType printers for program space:" % sep) self.list_type_printers(gdb.current_progspace().type_printers) sep = '\n' if gdb.type_printers: print ("%sGlobal type printers:" % sep) self.list_type_printers(gdb.type_printers) class _EnableOrDisableCommand(gdb.Command): def __init__(self, setting, name): super(_EnableOrDisableCommand, self).__init__(name, gdb.COMMAND_DATA) self.setting = setting def set_some(self, name, printers): result = False for p in printers: if name == p.name: p.enabled = self.setting result = True return result def invoke(self, arg, from_tty): """GDB calls this to perform the command.""" for name in arg.split(): ok = False for objfile in gdb.objfiles(): if self.set_some(name, objfile.type_printers): ok = True if self.set_some(name, gdb.current_progspace().type_printers): ok = True if self.set_some(name, gdb.type_printers): ok = True if not ok: print ("No type printer named '%s'" % name) def add_some(self, result, word, printers): for p in printers: if p.name.startswith(word): result.append(p.name) def complete(self, text, word): result = [] for objfile in gdb.objfiles(): self.add_some(result, word, objfile.type_printers) self.add_some(result, word, gdb.current_progspace().type_printers) self.add_some(result, word, gdb.type_printers) return result class EnableTypePrinter(_EnableOrDisableCommand): """GDB command to enable the specified type printer. Usage: enable type-printer NAME NAME is the name of the type-printer. """ def __init__(self): super(EnableTypePrinter, self).__init__(True, "enable type-printer") class DisableTypePrinter(_EnableOrDisableCommand): """GDB command to disable the specified type-printer. Usage: disable type-printer NAME NAME is the name of the type-printer. """ def __init__(self): super(DisableTypePrinter, self).__init__(False, "disable type-printer") InfoTypePrinter() EnableTypePrinter() DisableTypePrinter() PK!!zj$python/gdb/command/ignore_errors.pycnu[ Rc@s0ddlZdejfdYZedS(iNtIgnoreErrorsCommandcBs eZdZdZdZRS(syExecute a single command, ignoring all errors. Only one-line commands are supported. This is primarily useful in scripts.cCs&tt|jdtjtjdS(Ns ignore-errors(tsuperRt__init__tgdbtCOMMAND_OBSCUREtCOMPLETE_COMMAND(tself((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyRscCs"ytj||WnnXdS(N(Rtexecute(Rtargtfrom_tty((s2/usr/share/gdb/python/gdb/command/ignore_errors.pytinvokes(t__name__t __module__t__doc__RR (((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyRs (RtCommandR(((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyts PK!88%python/gdb/command/pretty_printers.pynu[# Pretty-printer commands. # Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """GDB commands for working with pretty-printers.""" import copy import gdb import re def parse_printer_regexps(arg): """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 """ argv = gdb.string_to_argv(arg); argc = len(argv) object_regexp = "" # match everything name_regexp = "" # match everything subname_regexp = None if argc > 3: raise SyntaxError("too many arguments") if argc >= 1: object_regexp = argv[0] if argc >= 2: name_subname = argv[1].split(";", 1) name_regexp = name_subname[0] if len(name_subname) == 2: subname_regexp = name_subname[1] # That re.compile raises SyntaxError was determined empirically. # We catch it and reraise it to provide a slightly more useful # error message for the user. try: object_re = re.compile(object_regexp) except SyntaxError: raise SyntaxError("invalid object regexp: %s" % object_regexp) try: name_re = re.compile (name_regexp) except SyntaxError: raise SyntaxError("invalid name regexp: %s" % name_regexp) if subname_regexp is not None: try: subname_re = re.compile(subname_regexp) except SyntaxError: raise SyntaxError("invalid subname regexp: %s" % subname_regexp) else: subname_re = None return(object_re, name_re, subname_re) def printer_enabled_p(printer): """Internal utility to see if printer (or subprinter) is enabled.""" if hasattr(printer, "enabled"): return printer.enabled else: return True class InfoPrettyPrinter(gdb.Command): """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. """ def __init__ (self): super(InfoPrettyPrinter, self).__init__("info pretty-printer", gdb.COMMAND_DATA) @staticmethod def enabled_string(printer): """Return "" if PRINTER is enabled, otherwise " [disabled]".""" if printer_enabled_p(printer): return "" else: return " [disabled]" @staticmethod def printer_name(printer): """Return the printer's name.""" if hasattr(printer, "name"): return printer.name if hasattr(printer, "__name__"): return printer.__name__ # This "shouldn't happen", but the public API allows for # direct additions to the pretty-printer list, and we shouldn't # crash because someone added a bogus printer. # Plus we want to give the user a way to list unknown printers. return "unknown" def list_pretty_printers(self, pretty_printers, name_re, subname_re): """Print a list of pretty-printers.""" # A potential enhancement is to provide an option to list printers in # "lookup order" (i.e. unsorted). sorted_pretty_printers = sorted (copy.copy(pretty_printers), key = self.printer_name) for printer in sorted_pretty_printers: name = self.printer_name(printer) enabled = self.enabled_string(printer) if name_re.match(name): print (" %s%s" % (name, enabled)) if (hasattr(printer, "subprinters") and printer.subprinters is not None): sorted_subprinters = sorted (copy.copy(printer.subprinters), key = self.printer_name) for subprinter in sorted_subprinters: if (not subname_re or subname_re.match(subprinter.name)): print (" %s%s" % (subprinter.name, self.enabled_string(subprinter))) def invoke1(self, title, printer_list, obj_name_to_match, object_re, name_re, subname_re): """Subroutine of invoke to simplify it.""" if printer_list and object_re.match(obj_name_to_match): print (title) self.list_pretty_printers(printer_list, name_re, subname_re) def invoke(self, arg, from_tty): """GDB calls this to perform the command.""" (object_re, name_re, subname_re) = parse_printer_regexps(arg) self.invoke1("global pretty-printers:", gdb.pretty_printers, "global", object_re, name_re, subname_re) cp = gdb.current_progspace() self.invoke1("progspace %s pretty-printers:" % cp.filename, cp.pretty_printers, "progspace", object_re, name_re, subname_re) for objfile in gdb.objfiles(): self.invoke1(" objfile %s pretty-printers:" % objfile.filename, objfile.pretty_printers, objfile.filename, object_re, name_re, subname_re) def count_enabled_printers(pretty_printers): """Return a 2-tuple of number of enabled and total printers.""" enabled = 0 total = 0 for printer in pretty_printers: if (hasattr(printer, "subprinters") and printer.subprinters is not None): if printer_enabled_p(printer): for subprinter in printer.subprinters: if printer_enabled_p(subprinter): enabled += 1 total += len(printer.subprinters) else: if printer_enabled_p(printer): enabled += 1 total += 1 return (enabled, total) def count_all_enabled_printers(): """Return a 2-tuble of the enabled state and total number of all printers. This includes subprinters. """ enabled_count = 0 total_count = 0 (t_enabled, t_total) = count_enabled_printers(gdb.pretty_printers) enabled_count += t_enabled total_count += t_total (t_enabled, t_total) = count_enabled_printers(gdb.current_progspace().pretty_printers) enabled_count += t_enabled total_count += t_total for objfile in gdb.objfiles(): (t_enabled, t_total) = count_enabled_printers(objfile.pretty_printers) enabled_count += t_enabled total_count += t_total return (enabled_count, total_count) def pluralize(text, n, suffix="s"): """Return TEXT pluralized if N != 1.""" if n != 1: return "%s%s" % (text, suffix) else: return text def show_pretty_printer_enabled_summary(): """Print the number of printers enabled/disabled. We count subprinters individually. """ (enabled_count, total_count) = count_all_enabled_printers() print ("%d of %d printers enabled" % (enabled_count, total_count)) def do_enable_pretty_printer_1 (pretty_printers, name_re, subname_re, flag): """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. """ total = 0 for printer in pretty_printers: if (hasattr(printer, "name") and name_re.match(printer.name) or hasattr(printer, "__name__") and name_re.match(printer.__name__)): if (hasattr(printer, "subprinters") and printer.subprinters is not None): if not subname_re: # Only record printers that change state. if printer_enabled_p(printer) != flag: for subprinter in printer.subprinters: if printer_enabled_p(subprinter): total += 1 # NOTE: We preserve individual subprinter settings. printer.enabled = flag else: # NOTE: Whether this actually disables the subprinter # depends on whether the printer's lookup function supports # the "enable" API. We can only assume it does. for subprinter in printer.subprinters: if subname_re.match(subprinter.name): # Only record printers that change state. if (printer_enabled_p(printer) and printer_enabled_p(subprinter) != flag): total += 1 subprinter.enabled = flag else: # This printer has no subprinters. # If the user does "disable pretty-printer .* .* foo" # should we disable printers that don't have subprinters? # How do we apply "foo" in this context? Since there is no # "foo" subprinter it feels like we should skip this printer. # There's still the issue of how to handle # "disable pretty-printer .* .* .*", and every other variation # that can match everything. For now punt and only support # "disable pretty-printer .* .*" (i.e. subname is elided) # to disable everything. if not subname_re: # Only record printers that change state. if printer_enabled_p(printer) != flag: total += 1 printer.enabled = flag return total def do_enable_pretty_printer (arg, flag): """Internal worker for enabling/disabling pretty-printers.""" (object_re, name_re, subname_re) = parse_printer_regexps(arg) total = 0 if object_re.match("global"): total += do_enable_pretty_printer_1(gdb.pretty_printers, name_re, subname_re, flag) cp = gdb.current_progspace() if object_re.match("progspace"): total += do_enable_pretty_printer_1(cp.pretty_printers, name_re, subname_re, flag) for objfile in gdb.objfiles(): if object_re.match(objfile.filename): total += do_enable_pretty_printer_1(objfile.pretty_printers, name_re, subname_re, flag) if flag: state = "enabled" else: state = "disabled" print ("%d %s %s" % (total, pluralize("printer", total), state)) # Print the total list of printers currently enabled/disabled. # This is to further assist the user in determining whether the result # is expected. Since we use regexps to select it's useful. show_pretty_printer_enabled_summary() # Enable/Disable one or more pretty-printers. # # This is intended for use when a broken pretty-printer is shipped/installed # and the user wants to disable that printer without disabling all the other # printers. # # A useful addition would be -v (verbose) to show each printer affected. class EnablePrettyPrinter (gdb.Command): """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. """ def __init__(self): super(EnablePrettyPrinter, self).__init__("enable pretty-printer", gdb.COMMAND_DATA) def invoke(self, arg, from_tty): """GDB calls this to perform the command.""" do_enable_pretty_printer(arg, True) class DisablePrettyPrinter (gdb.Command): """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. """ def __init__(self): super(DisablePrettyPrinter, self).__init__("disable pretty-printer", gdb.COMMAND_DATA) def invoke(self, arg, from_tty): """GDB calls this to perform the command.""" do_enable_pretty_printer(arg, False) def register_pretty_printer_commands(): """Call from a top level script to install the pretty-printer commands.""" InfoPrettyPrinter() EnablePrettyPrinter() DisablePrettyPrinter() register_pretty_printer_commands() PK!YeRR#python/gdb/command/ignore_errors.pynu[# Ignore errors in user commands. # Copyright (C) 2008 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import gdb class IgnoreErrorsCommand (gdb.Command): """Execute a single command, ignoring all errors. Only one-line commands are supported. This is primarily useful in scripts.""" def __init__ (self): super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", gdb.COMMAND_OBSCURE, # FIXME... gdb.COMPLETE_COMMAND) def invoke (self, arg, from_tty): try: gdb.execute (arg, from_tty) except: pass IgnoreErrorsCommand () PK!Pf6python/gdb/command/__init__.pyonu[ Rc@sdS(N((((s-/usr/share/gdb/python/gdb/command/__init__.pytsPK!>6python/gdb/command/prompt.pyonu[ Rc@sBdZddlZddlZdejfdYZedS(s.GDB command for working with extended prompts.iNt_ExtendedPromptcBsQeZdZeejjZdZdZdZdZ dZ dZ RS(sSet the extended prompt. Usage: set extended-prompt VALUE Substitutions are applied to VALUE to compute the real prompt. The currently defined substitutions are: sSet the extended prompt.sShow the extended prompt.cCs8tt|jdtjtjd|_t|_dS(Nsextended-promptt( tsuperRt__init__tgdbtCOMMAND_SUPPORTtPARAM_STRING_NOESCAPEtvaluetFalsethook_set(tself((s+/usr/share/gdb/python/gdb/command/prompt.pyR(s   cCs"|jdk rd|jSdSdS(NRsThe extended prompt is: sThe extended prompt is not set.(R(R tpvalue((s+/usr/share/gdb/python/gdb/command/prompt.pytget_show_string/s cCs+|jtkr'|jt_t|_ndS(NR(R Rtbefore_prompt_hookRt prompt_hooktTrue(R ((s+/usr/share/gdb/python/gdb/command/prompt.pytget_set_string5s  cCs<|jdk r4tjj|j}|jddSdSdS(NRs\s\\(RRtprompttsubstitute_prompttreplacetNone(R tcurrentt newprompt((s+/usr/share/gdb/python/gdb/command/prompt.pyR ;s( t__name__t __module__t__doc__RRt prompt_helptset_doctshow_docRR RR (((s+/usr/share/gdb/python/gdb/command/prompt.pyRs    (RRt gdb.promptt ParameterR(((s+/usr/share/gdb/python/gdb/command/prompt.pyts  ,PK!N;cEcE$python/gdb/command/frame_filters.pycnu[ Rc@s^dZddlZddlZddlmZddlmZddlZddlZdej fdYZ dej fdYZ d ej fd YZ d Z d Zd ZdZdej fdYZdej fdYZdej fdYZdej fdYZe e e eeeedS(s,GDB commands for working with frame-filters.iN(t FrameIterator(tFrameDecoratortSetFilterPrefixCmdcBseZdZdZRS(s9Prefix command for 'set' frame-filter related operations.cCs)tt|jdtjtjtdS(Nsset frame-filter(tsuperRt__init__tgdbtCOMMAND_OBSCUREt COMPLETE_NONEtTrue(tself((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRs(t__name__t __module__t__doc__R(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRstShowFilterPrefixCmdcBseZdZdZRS(s:Prefix command for 'show' frame-filter related operations.cCs)tt|jdtjtjtdS(Nsshow frame-filter(RR RRRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR%s(R R R R(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR #stInfoFrameFiltercBsAeZdZdZedZdZdZdZRS(sMList all registered Python frame-filters. Usage: info frame-filters cCs tt|jdtjdS(Nsinfo frame-filter(RRRRt COMMAND_DATA(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR/scCs|r dSdSdS(s2Return "Yes" if filter is enabled, otherwise "No".tYestNoN((tstate((s2/usr/share/gdb/python/gdb/command/frame_filters.pytenabled_string2scCst|jdddt}t|dkr;dGHndGHx|D]}|d}yQdjttjj|d}d j|j tjj |d}Wn*t k r}d |d t|GHqGXd |||fGHqGWd S(s Internal worker function to list and print frame filters in a dictionary. Arguments: frame_filters: The name of the dictionary, as specified by GDB user commands. tkeycSstjj|dS(Ni(Rtframest get_priority(ti((s2/usr/share/gdb/python/gdb/command/frame_filters.pytDstreverseis No frame filters registered.s Priority Enabled Names{:<8}is{:<7}s Error printing filter 's': s %s %s %sN( tsortedtitemsRtlentformattstrRRRRt get_enabledt Exception(R t frame_filterstsorted_frame_filterst frame_filtertnametprioritytenabledte((s2/usr/share/gdb/python/gdb/command/frame_filters.pytlist_frame_filters:s     &cCs$|GH|j||r dGHndS(Nt(R((R ttitlet filter_listt blank_line((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt print_listWs cCsw|jdtjttj}|jd|j|jtx1tjD]#}|jd|j|jtqLWdS(Nsglobal frame-filters:sprogspace %s frame-filters:sobjfile %s frame-filters:(R-RR!Rtcurrent_progspacetfilenametobjfilestFalse(R targtfrom_ttytcptobjfile((s2/usr/share/gdb/python/gdb/command/frame_filters.pytinvoke]s  ( R R R Rt staticmethodRR(R-R6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR)s    cCstj|}t|}|ddkrM|dkrMtj|dn2|ddkr|dkrtj|dn|S(sa Internal worker function to take an argument from enable/disable and return a tuple of arguments. Arguments: cmd_name: Name of the command invoking this function. args: The argument as a string. Returns: A tuple containing the dictionary, and the argument, or just the dictionary in the case of "all". itallis*: with 'all' you may not specify a filter.is takes exactly two arguments.(Rtstring_to_argvRtGdbError(tcmd_nameR2targvtargc((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_enable_parse_argjs  cCs|d}tjj|}|dkrOx|D]}tjj||q/Wnb|d}y||}Wn4tk rdttd}tj|nXtjj||dS(s#Worker for enabling/disabling frame_filters. Arguments: command_type: A tuple with the first element being the frame filter dictionary, and the second being the frame filter name. flag: True for Enable, False for Disable. iR8isframe-filter 's ' not found.N(RRt return_listt set_enabledtKeyErrorRR$R:(t command_tupletflagtlist_optop_listtitemR#tfftmsg((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_do_enable_frame_filters     cCs|tkrdddg}n ddg}x$tjD]}|j|jq7W|dkra|St|d|}t|dkr|dt|t||dRIR(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s(R R R RRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR[s  tDisableFrameFiltercBs)eZdZdZdZdZRS(sGDB command to disable the specified frame-filter. Usage: disable frame-filter disable DICTIONARY [NAME] DICTIONARY is the name of the frame filter dictionary on which to operate. If dictionary is set to "all", perform operations on all dictionaries. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's frame filter dictionary. If either all, or the two named dictionaries are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. If DICTIONARY is "all", NAME is ignored. cCs tt|jdtjdS(Nsdisable frame-filter(RRbRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRscCsX|jddkr%t||tStjj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN( R]RVRRRR?R^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRa s"cCs td|}t|tdS(Nsdisable frame-filter(R>RIR1(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s(R R R RRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRbs  tSetFrameFilterPrioritycBs;eZdZdZdZdZdZdZRS(slGDB command to set the priority of the specified frame-filter. Usage: set frame-filter priority DICTIONARY NAME PRIORITY DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame filter to operate on. PRIORITY is the an integer to assign the new priority to the frame filter. cCs tt|jdtjdS(Nsset frame-filter priority(RRcRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR*scCs4tj|}t|}|dkr0dGHdS|S(sRInternal worker to parse a priority from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, name and priority from the arguments. Raises: gdb.GdbError: An error parsing the arguments. is8set frame-filter priority takes exactly three arguments.N(RR9RtNone(R R2R<R=((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_parse_pri_arg/s   cCs|d}|d}|d}tjj|}y||}Wn4tk rtdttd}tj|nXtjj||dS(sInternal worker for setting priority of frame-filters, by parsing a tuple and calling _set_priority with the parsed tuple. Arguments: command_tuple: Tuple which contains the arguments from the command. iiisframe-filter 's ' not found.N(RRR?RARR$R:t set_priority(R RBRDR#R%RERGRH((s2/usr/share/gdb/python/gdb/command/frame_filters.pyt_set_filter_priorityFs    cCsX|jddkr%t||tStjj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN( R]RVR1RRR?R^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRa^s"cCs/|j|}|dkr+|j|ndS(N(ReRdRg(R R2R3RB((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6gs (R R R RReRgRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRcs     tShowFrameFilterPrioritycBs;eZdZdZdZdZdZdZRS(sGDB command to show the priority of the specified frame-filter. Usage: show frame-filter priority DICTIONARY NAME DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. cCs tt|jdtjdS(Nsshow frame-filter priority(RRhRRR(R ((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRzscCs4tj|}t|}|dkr0dGHdS|S(sKInternal worker to parse a dictionary and name from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, and frame filter name. Raises: gdb.GdbError: An error parsing the arguments. is7show frame-filter priority takes exactly two arguments.N(RR9RRd(R R2R<R=((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRes   cCsgtjj|}y||}Wn4tk rVdt|d}tj|nXtjj|S(sEWorker for retrieving the priority of frame_filters. Arguments: frame_filters: Name of frame filter dictionary. name: object to select printers. Returns: The priority of the frame filter. Raises: gdb.GdbError: A frame filter cannot be found. sframe-filter 's ' not found.(RRR?RARR:R(R R!R$RERGRH((s2/usr/share/gdb/python/gdb/command/frame_filters.pytget_filter_prioritys cCsU|jddkr%t||tStj|jdj}t||SdS(sTCompletion function for both frame filter dictionary, and frame filter name.R\iN(R]RVR1tframet _return_listR^R_RZ(R RQRRR`((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRascCs|j|}|dkrdS|d}|d}y|j||}Wn*tk ru}dtdt|GHn Xd|d|dt|GHdS(Niis$Error printing filter priority for 's':sPriority of filter 's ' in list 's' is: (ReRdRiR R$R(R R2R3RBt filter_namet list_nameR%R'((s2/usr/share/gdb/python/gdb/command/frame_filters.pyR6s   (R R R RReRiRaR6(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyRhls      (R Rtcopytgdb.FrameIteratorRtgdb.FrameDecoratorRt gdb.framest itertoolstCommandRR RR>RIRVRZR[RbRcRh(((s2/usr/share/gdb/python/gdb/command/frame_filters.pyts0    A   % !!S[PK!-@-@#python/gdb/command/frame_filters.pynu[# Frame-filter commands. # Copyright (C) 2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """GDB commands for working with frame-filters.""" import gdb import copy from gdb.FrameIterator import FrameIterator from gdb.FrameDecorator import FrameDecorator import gdb.frames import itertools # GDB Commands. class SetFilterPrefixCmd(gdb.Command): """Prefix command for 'set' frame-filter related operations.""" def __init__(self): super(SetFilterPrefixCmd, self).__init__("set frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE, True) class ShowFilterPrefixCmd(gdb.Command): """Prefix command for 'show' frame-filter related operations.""" def __init__(self): super(ShowFilterPrefixCmd, self).__init__("show frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE, True) class InfoFrameFilter(gdb.Command): """List all registered Python frame-filters. Usage: info frame-filters """ def __init__(self): super(InfoFrameFilter, self).__init__("info frame-filter", gdb.COMMAND_DATA) @staticmethod def enabled_string(state): """Return "Yes" if filter is enabled, otherwise "No".""" if state: return "Yes" else: return "No" def list_frame_filters(self, frame_filters): """ Internal worker function to list and print frame filters in a dictionary. Arguments: frame_filters: The name of the dictionary, as specified by GDB user commands. """ sorted_frame_filters = sorted(frame_filters.items(), key=lambda i: gdb.frames.get_priority(i[1]), reverse=True) if len(sorted_frame_filters) == 0: print(" No frame filters registered.") else: print(" Priority Enabled Name") for frame_filter in sorted_frame_filters: name = frame_filter[0] try: priority = '{:<8}'.format( str(gdb.frames.get_priority(frame_filter[1]))) enabled = '{:<7}'.format( self.enabled_string(gdb.frames.get_enabled(frame_filter[1]))) except Exception as e: print(" Error printing filter '"+name+"': "+str(e)) else: print(" %s %s %s" % (priority, enabled, name)) def print_list(self, title, filter_list, blank_line): print(title) self.list_frame_filters(filter_list) if blank_line: print("") def invoke(self, arg, from_tty): self.print_list("global frame-filters:", gdb.frame_filters, True) cp = gdb.current_progspace() self.print_list("progspace %s frame-filters:" % cp.filename, cp.frame_filters, True) for objfile in gdb.objfiles(): self.print_list("objfile %s frame-filters:" % objfile.filename, objfile.frame_filters, False) # Internal enable/disable functions. def _enable_parse_arg(cmd_name, arg): """ Internal worker function to take an argument from enable/disable and return a tuple of arguments. Arguments: cmd_name: Name of the command invoking this function. args: The argument as a string. Returns: A tuple containing the dictionary, and the argument, or just the dictionary in the case of "all". """ argv = gdb.string_to_argv(arg); argc = len(argv) if argv[0] == "all" and argc > 1: raise gdb.GdbError(cmd_name + ": with 'all' " \ "you may not specify a filter.") else: if argv[0] != "all" and argc != 2: raise gdb.GdbError(cmd_name + " takes exactly two arguments.") return argv def _do_enable_frame_filter(command_tuple, flag): """Worker for enabling/disabling frame_filters. Arguments: command_type: A tuple with the first element being the frame filter dictionary, and the second being the frame filter name. flag: True for Enable, False for Disable. """ list_op = command_tuple[0] op_list = gdb.frames.return_list(list_op) if list_op == "all": for item in op_list: gdb.frames.set_enabled(item, flag) else: frame_filter = command_tuple[1] try: ff = op_list[frame_filter] except KeyError: msg = "frame-filter '" + str(name) + "' not found." raise gdb.GdbError(msg) gdb.frames.set_enabled(ff, flag) def _complete_frame_filter_list(text, word, all_flag): """Worker for frame filter dictionary name completion. Arguments: text: The full text of the command line. word: The most recent word of the command line. all_flag: Whether to include the word "all" in completion. Returns: A list of suggested frame filter dictionary name completions from text/word analysis. This list can be empty when there are no suggestions for completion. """ if all_flag == True: filter_locations = ["all", "global", "progspace"] else: filter_locations = ["global", "progspace"] for objfile in gdb.objfiles(): filter_locations.append(objfile.filename) # If the user just asked for completions with no completion # hints, just return all the frame filter dictionaries we know # about. if (text == ""): return filter_locations # Otherwise filter on what we know. flist = filter(lambda x,y=text:x.startswith(y), filter_locations) # If we only have one completion, complete it and return it. if len(flist) == 1: flist[0] = flist[0][len(text)-len(word):] # Otherwise, return an empty list, or a list of frame filter # dictionaries that the previous filter operation returned. return flist def _complete_frame_filter_name(word, printer_dict): """Worker for frame filter name completion. Arguments: word: The most recent word of the command line. printer_dict: The frame filter dictionary to search for frame filter name completions. Returns: A list of suggested frame filter name completions from word analysis of the frame filter dictionary. This list can be empty when there are no suggestions for completion. """ printer_keys = printer_dict.keys() if (word == ""): return printer_keys flist = filter(lambda x,y=word:x.startswith(y), printer_keys) return flist class EnableFrameFilter(gdb.Command): """GDB command to disable the specified frame-filter. Usage: enable frame-filter enable DICTIONARY [NAME] DICTIONARY is the name of the frame filter dictionary on which to operate. If dictionary is set to "all", perform operations on all dictionaries. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's frame filter dictionary. If either all, or the two named dictionaries are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. If DICTIONARY is "all", NAME is ignored. """ def __init__(self): super(EnableFrameFilter, self).__init__("enable frame-filter", gdb.COMMAND_DATA) def complete(self, text, word): """Completion function for both frame filter dictionary, and frame filter name.""" if text.count(" ") == 0: return _complete_frame_filter_list(text, word, True) else: printer_list = gdb.frames.return_list(text.split()[0].rstrip()) return _complete_frame_filter_name(word, printer_list) def invoke(self, arg, from_tty): command_tuple = _enable_parse_arg("enable frame-filter", arg) _do_enable_frame_filter(command_tuple, True) class DisableFrameFilter(gdb.Command): """GDB command to disable the specified frame-filter. Usage: disable frame-filter disable DICTIONARY [NAME] DICTIONARY is the name of the frame filter dictionary on which to operate. If dictionary is set to "all", perform operations on all dictionaries. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's frame filter dictionary. If either all, or the two named dictionaries are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. If DICTIONARY is "all", NAME is ignored. """ def __init__(self): super(DisableFrameFilter, self).__init__("disable frame-filter", gdb.COMMAND_DATA) def complete(self, text, word): """Completion function for both frame filter dictionary, and frame filter name.""" if text.count(" ") == 0: return _complete_frame_filter_list(text, word, True) else: printer_list = gdb.frames.return_list(text.split()[0].rstrip()) return _complete_frame_filter_name(word, printer_list) def invoke(self, arg, from_tty): command_tuple = _enable_parse_arg("disable frame-filter", arg) _do_enable_frame_filter(command_tuple, False) class SetFrameFilterPriority(gdb.Command): """GDB command to set the priority of the specified frame-filter. Usage: set frame-filter priority DICTIONARY NAME PRIORITY DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame filter to operate on. PRIORITY is the an integer to assign the new priority to the frame filter. """ def __init__(self): super(SetFrameFilterPriority, self).__init__("set frame-filter " \ "priority", gdb.COMMAND_DATA) def _parse_pri_arg(self, arg): """Internal worker to parse a priority from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, name and priority from the arguments. Raises: gdb.GdbError: An error parsing the arguments. """ argv = gdb.string_to_argv(arg); argc = len(argv) if argc != 3: print("set frame-filter priority " \ "takes exactly three arguments.") return None return argv def _set_filter_priority(self, command_tuple): """Internal worker for setting priority of frame-filters, by parsing a tuple and calling _set_priority with the parsed tuple. Arguments: command_tuple: Tuple which contains the arguments from the command. """ list_op = command_tuple[0] frame_filter = command_tuple[1] priority = command_tuple[2] op_list = gdb.frames.return_list(list_op) try: ff = op_list[frame_filter] except KeyError: msg = "frame-filter '" + str(name) + "' not found." raise gdb.GdbError(msg) gdb.frames.set_priority(ff, priority) def complete(self, text, word): """Completion function for both frame filter dictionary, and frame filter name.""" if text.count(" ") == 0: return _complete_frame_filter_list(text, word, False) else: printer_list = gdb.frames.return_list(text.split()[0].rstrip()) return _complete_frame_filter_name(word, printer_list) def invoke(self, arg, from_tty): command_tuple = self._parse_pri_arg(arg) if command_tuple != None: self._set_filter_priority(command_tuple) class ShowFrameFilterPriority(gdb.Command): """GDB command to show the priority of the specified frame-filter. Usage: show frame-filter priority DICTIONARY NAME DICTIONARY is the name of the frame filter dictionary on which to operate. Named dictionaries are: "global" for the global frame filter dictionary, "progspace" for the program space's framefilter dictionary. If either of these two are not specified, the dictionary name is assumed to be the name of the object-file name. NAME matches the name of the frame-filter to operate on. """ def __init__(self): super(ShowFrameFilterPriority, self).__init__("show frame-filter " \ "priority", gdb.COMMAND_DATA) def _parse_pri_arg(self, arg): """Internal worker to parse a dictionary and name from a tuple. Arguments: arg: Tuple which contains the arguments from the command. Returns: A tuple containing the dictionary, and frame filter name. Raises: gdb.GdbError: An error parsing the arguments. """ argv = gdb.string_to_argv(arg); argc = len(argv) if argc != 2: print("show frame-filter priority " \ "takes exactly two arguments.") return None return argv def get_filter_priority(self, frame_filters, name): """Worker for retrieving the priority of frame_filters. Arguments: frame_filters: Name of frame filter dictionary. name: object to select printers. Returns: The priority of the frame filter. Raises: gdb.GdbError: A frame filter cannot be found. """ op_list = gdb.frames.return_list(frame_filters) try: ff = op_list[name] except KeyError: msg = "frame-filter '" + str(name) + "' not found." raise gdb.GdbError(msg) return gdb.frames.get_priority(ff) def complete(self, text, word): """Completion function for both frame filter dictionary, and frame filter name.""" if text.count(" ") == 0: return _complete_frame_filter_list(text, word, False) else: printer_list = frame._return_list(text.split()[0].rstrip()) return _complete_frame_filter_name(word, printer_list) def invoke(self, arg, from_tty): command_tuple = self._parse_pri_arg(arg) if command_tuple == None: return filter_name = command_tuple[1] list_name = command_tuple[0] try: priority = self.get_filter_priority(list_name, filter_name); except Exception as e: print("Error printing filter priority for '"+name+"':"+str(e)) else: print("Priority of filter '" + filter_name + "' in list '" \ + list_name + "' is: " + str(priority)) # Register commands SetFilterPrefixCmd() ShowFilterPrefixCmd() InfoFrameFilter() EnableFrameFilter() DisableFrameFilter() SetFrameFilterPriority() ShowFrameFilterPriority() PK!!zj$python/gdb/command/ignore_errors.pyonu[ Rc@s0ddlZdejfdYZedS(iNtIgnoreErrorsCommandcBs eZdZdZdZRS(syExecute a single command, ignoring all errors. Only one-line commands are supported. This is primarily useful in scripts.cCs&tt|jdtjtjdS(Ns ignore-errors(tsuperRt__init__tgdbtCOMMAND_OBSCUREtCOMPLETE_COMMAND(tself((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyRscCs"ytj||WnnXdS(N(Rtexecute(Rtargtfrom_tty((s2/usr/share/gdb/python/gdb/command/ignore_errors.pytinvokes(t__name__t __module__t__doc__RR (((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyRs (RtCommandR(((s2/usr/share/gdb/python/gdb/command/ignore_errors.pyts PK!l++&python/gdb/command/pretty_printers.pyonu[ Rc@sdZddlZddlZddlZdZdZdejfdYZdZdZ d d Z d Z d 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|d k 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_argvtlentNonet SyntaxErrortsplittretcompile( targtargvtargct object_regexpt name_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 Csttj|d|j}x|D]}|j|}|j|}|j|r%d||fGHt|dr|jdk rttj|jd|j}xH|D]=} | s|j| jrd| j|j| fGHqqWqq%q%WdS(s Print a list of pretty-printers.tkeys %s%st subprinterss %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.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(RR1RR)tcurrent_progspacetfilenametobjfiles(RR tfrom_ttyRRRtcptobjfile((s4/usr/share/gdb/python/gdb/command/pretty_printers.pytinvokes    ( R!t __module__t__doc__Rt staticmethodRR#R-R1R:(((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(R?RR)R4R6(t enabled_countt total_countt t_enabledtt_totalR9((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(RD(R@RA((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)RRtflagR>RR,((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.iR2R3Rtdisableds%d %s %sRN( RR(RLRR)R4R6R5RIRJ( R RKRRRR>R8R9tstate((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(RRPRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRJscCst|tdS(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 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(RRQRRR(R((s4/usr/share/gdb/python/gdb/command/pretty_printers.pyRascCst|tdS(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  cCstttdS(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.pyts     4 S     : % PK! [ [python/gdb/command/explore.pycnu[ Rc@sXdZddlZddlZejddkr:eZndefdYZdefdYZd efd YZ d efd YZ d efdYZ defdYZ defdYZ defdYZdejfdYZdejfdYZdejfdYZejeeedS(sEImplementation of the GDB 'explore' command using the GDB Python API.iNiitExplorercBseZdZiZejejejejej ej fZ e dZ e dZe dZe dZe dZe dZe dZe dZe d ZRS( s-Internal class which invokes other explorers.c Cst|}t}|ddkr9||ddkr9nd}x||kr||}|dksd|kr||dksd|kr|d ksd |kr|d krnt}P|d7}qBW|rd|dS|SdS( Nit(it)t_tatztAtZt0t9(tlentFalsetTrue(texprtlengthtguardtitc((s,/usr/share/gdb/python/gdb/command/explore.pyt guard_expr)s  $ $0 cCs]|jj}|tjkrGtj|}x.|j|||rCq+Wndt|jGHdS(sMain function to explore an expression value. Arguments: expr: The expression string that is being explored. value: The gdb.Value value of the expression. is_child: Boolean value to indicate if the expression is a child. An expression is a child if it is derived from the main expression entered by the user. For example, if the user entered an expression which evaluates to a struct, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. s*Explorer for type '%s' not yet available. N(ttypetcodeRttype_code_to_explorer_mapt explore_exprtstr(R tvaluetis_childt type_codetexplorer_class((s,/usr/share/gdb/python/gdb/command/explore.pyRAs  cCsW|j}|tjkrDtj|}x+|j|||r@q(Wndt|GHdS(sMain function to explore a data type. Arguments: name: The string representing the path to the data type being explored. datatype: The gdb.Type value of the data type being explored. is_child: Boolean value to indicate if the name is a child. A name is a child if it is derived from the main name entered by the user. For example, if the user entered the name of struct type, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. s*Explorer for type '%s' not yet available. N(RRRt explore_typeR(tnametdatatypeRRR((s,/usr/share/gdb/python/gdb/command/explore.pyR[s  cCsi ttj6ttj6ttj6ttj6ttj6ttj6ttj 6ttj 6t tj 6t tj6ttj6ttj6t_dS(sInitializes the Explorer environment. This function should be invoked before starting any exploration. If invoked before an exploration, it need not be invoked for subsequent explorations. N(tScalarExplorertgdbtTYPE_CODE_CHARt TYPE_CODE_INTtTYPE_CODE_BOOLt TYPE_CODE_FLTtTYPE_CODE_VOIDtTYPE_CODE_ENUMtCompoundExplorertTYPE_CODE_STRUCTtTYPE_CODE_UNIONtPointerExplorert TYPE_CODE_PTRtReferenceExplorert TYPE_CODE_REFtTypedefExplorertTYPE_CODE_TYPEDEFt ArrayExplorertTYPE_CODE_ARRAYRR(((s,/usr/share/gdb/python/gdb/command/explore.pytinit_envus           cCs|jtjkS(sChecks whether a type is a scalar type. A type is a scalar type of its type is gdb.TYPE_CODE_CHAR or gdb.TYPE_CODE_INT or gdb.TYPE_CODE_BOOL or gdb.TYPE_CODE_FLT or gdb.TYPE_CODE_VOID or gdb.TYPE_CODE_ENUM. Arguments: type: The type to be checked. Returns: 'True' if 'type' is a scalar type. 'False' otherwise. (RRt_SCALAR_TYPE_LIST(R((s,/usr/share/gdb/python/gdb/command/explore.pytis_scalar_typescCs dGHdS(sA utility function which prints that the current exploration session is returning to the parent value. Useful when exploring values. s Returning to parent value... N((((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_parent_valuescCstddS(sA utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the parent value. Useful when exploring values. s( Press enter to return to parent value: N(t raw_input(((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_parent_value_promptscCs dGHdS(sA utility function which prints that the current exploration session is returning to the enclosing type. Useful when exploring types. s Returning to enclosing type... N((((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_enclosing_typescCstddS(sA utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the enclosing type. Useful when exploring types. s* Press enter to return to enclosing type: N(R6(((s,/usr/share/gdb/python/gdb/command/explore.pytreturn_to_enclosing_type_prompts(t__name__t __module__t__doc__RR R!R"R#R$R%R&R3t staticmethodRRRR2R4R5R7R8R9(((s,/usr/share/gdb/python/gdb/command/explore.pyRs" RcBs,eZdZedZedZRS(s-Internal class used to explore scalar values.cCsHd||jfGHd|t|fGH|rDtjtjntS(sFunction to explore scalar values. See Explorer.explore_expr and Explorer.is_scalar_type for more information. s$'%s' is a scalar value of type '%s'.s%s = %s(RRRR7R5R (R RR((s,/usr/share/gdb/python/gdb/command/explore.pyRs  cCs|jtjkr<|r0d|t|fGHqcd|GHn'|rZd|t|fGHn d|GH|rtjtjntS(sFunction to explore scalar types. See Explorer.explore_type and Explorer.is_scalar_type for more information. s!%s is of an enumerated type '%s'.s'%s' is an enumerated type.s%s is of a scalar type '%s'.s'%s' is a scalar type.(RR R&RRR9R8R (RRR((s,/usr/share/gdb/python/gdb/command/explore.pyRs    (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyRsR*cBs,eZdZedZedZRS(s.Internal class used to explore pointer values.cCsd|t|jjfGHtd}|dkrd }y|j}t|Wn1tjk rd|GH|rtj nt SXtj dtj |||t Std}|dkrsxt rnd}yttd|}Wntk rPnXd tj ||f}||}yt|Wn tjk rWd |GHqnXtj ||t qWt S|rtjnt S( sdFunction to explore pointer values. See Explorer.explore_expr for more information. s)'%s' is a pointer to a value of type '%s's<Continue exploring it as a pointer to a single value [y/n]: tys6'%s' a pointer pointing to an invalid memory location.s*%ss6Continue exploring it as a pointer to an array [y/n]: is<Enter the index of the element you want to explore in '%s': s%s[%d]sCannot read value at index %d.N(RRttargetR6tNonet dereferenceR t MemoryErrorRR7R RRR tintt ValueErrorR5(R RRtoptiont deref_valuetindext element_exprtelement((s,/usr/share/gdb/python/gdb/command/explore.pyRsL             cCs<|j}d|t|fGHtjd|||tS(scFunction to explore pointer types. See Explorer.explore_type for more information. s) %s is a pointer to a value of type '%s'.sthe pointee type of %s(R?RRRR (RRRt target_type((s,/usr/share/gdb/python/gdb/command/explore.pyRs  (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR*s0R,cBs,eZdZedZedZRS(s@Internal class used to explore reference (TYPE_CODE_REF) values.cCs#|j}tj|||tS(sbFunction to explore array values. See Explorer.explore_expr for more information. (treferenced_valueRRR (R RRRK((s,/usr/share/gdb/python/gdb/command/explore.pyR/s cCs#|j}tj|||tS(scFunction to explore pointer types. See Explorer.explore_type for more information. (R?RRR (RRRRJ((s,/usr/share/gdb/python/gdb/command/explore.pyR8s (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR,,s R0cBs,eZdZedZedZRS(s&Internal class used to explore arrays.cCs|jj}d|t|fGHd}yttd|}Wn%tk rk|rgtjntSXd}y||}t|Wn(t j k rd|GHtdt SXtj dtj||f|t t S(sbFunction to explore array values. See Explorer.explore_expr for more information. s'%s' is an array of '%s'.is<Enter the index of the element you want to explore in '%s': sCannot read value at index %d.sPress enter to continue... s%s[%d]N(RR?RRCR6RDRR5R R@R RBR RR(R RRRJRGRI((s,/usr/share/gdb/python/gdb/command/explore.pyREs*       cCs<|j}d|t|fGHtjd|||tS(saFunction to explore array types. See Explorer.explore_type for more information. s%s is an array of '%s'.sthe array element of %s(R?RRRR (RRRRJ((s,/usr/share/gdb/python/gdb/command/explore.pyRbs  (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR0BsR'cBsJeZdZedZedZedZedZRS(s:Internal class used to explore struct, classes and unions.cCsod}x7|D]/}|t|dkr t|d}q q Wx(|D] }d||d|dfGHqGWdS(sKInternal function which prints the fields of a struct/class/union. is %*s = %siN(R (t print_listtmax_field_name_lengthtpair((s,/usr/share/gdb/python/gdb/command/explore.pyt _print_fieldsrs   cCs1d}x$|D]}|js |d}q q W|S(Nii(t artificial(tfieldstreal_field_counttfield((s,/usr/share/gdb/python/gdb/command/explore.pyt_get_real_field_count~s   cCsz|j}|j}|j}|tjkr6d}nd}tj|dkrd||t|jfGH|rtj nt Sd||t|jfGHt }i}d} g} x=|D]5} | j rqntj |d| j } | jr |j| j} n || j } d}|tjkrNd| t| jf}t}nntj| jrd t| t| jf}n:| jrd }nd }d | |t| jf}t}| | f|t| <| d } | j| j |fqWtj| dGH|rctd}||krMtj||d||d ttS|rvtjqvn|rvtj nt S(svFunction to explore structs/classes and union values. See Explorer.explore_expr for more information. s struct/classtunionis6The value of '%s' is a %s of type '%s' with no fields.sBThe value of '%s' is a %s of type '%s' with the following fields: t.ts-s%s .. (Value of type '%s')s base classRSs*is"Enter the field number of choice: (RRRQR R(R'RTRRR7R RPRRt is_base_classtcastR)R R4tappendROR6RR5(R RRRRRQt type_descthas_explorable_fieldstchoice_to_compound_field_maptcurrent_choiceRLRStfield_full_namet field_valuet literal_valuet field_desctchoice((s,/usr/share/gdb/python/gdb/command/explore.pyRsr                  cCs>|j}d}|tjkr'd}nd}|j}tj|dkr|ryd||t|fGHtjnd||fGHt S|rd||t|fGHnd||fGHt }d}i}g} x|D]} | j rqn| j rd } nd } d || t| j f} | j | j| f| j| j | f|t|<|d }qWtj| dGHt|dkr'td } | |kr|rd|| d|| d|f}n#d|| d|| d|f}tj||| d ttS|r:tjq:n|r:tjnt S(srFunction to explore struct/class and union types. See Explorer.explore_type for more information. RWs struct/classRUis'%s is a %s of type '%s' with no fields.s'%s' is a %s with no fields.s3%s is a %s of type '%s' with the following fields: s('%s' is a %s with the following fields: s base classRSs*is"Enter the field number of choice: s %s '%s' of %sis%s '%s' of '%s'(RR R(RQR'RTRRR9R RPRXRRZRROR R6RR R8(RRRRR[RQR\R^R]RLRSRbtrhsRctnew_name((s,/usr/share/gdb/python/gdb/command/explore.pyRsn                    (R:R;R<R=RORTRR(((s,/usr/share/gdb/python/gdb/command/explore.pyR'os   QR.cBs,eZdZedZedZRS(s>Internal class used to explore values whose type is a typedef.cCsP|jj}d|t|jt|fGHtj||j||tS(sdFunction to explore typedef values. See Explorer.explore_expr for more information. sAThe value of '%s' is of type '%s' which is a typedef of type '%s'(Rtstrip_typedefsRRRRYR (R RRt actual_type((s,/usr/share/gdb/python/gdb/command/explore.pyR)s cCsV|j}|r*d|t|fGHnd|t|fGHtj|||tS(scFunction to explore typedef types. See Explorer.explore_type for more information. s)The type of %s is a typedef of type '%s'.s(The type '%s' is a typedef of type '%s'.(RfRRRR (RRRRg((s,/usr/share/gdb/python/gdb/command/explore.pyR6s (R:R;R<R=RR(((s,/usr/share/gdb/python/gdb/command/explore.pyR.&s t ExploreUtilscBs;eZdZedZedZedZRS(sEInternal class which provides utilities for the main command classes.cCs1t|dkr)tjd|tStSdS(sUtility to check if adequate number of arguments are passed to an explore command. Arguments: name: The name of the explore command. arg_str: The argument string passed to the explore command. Returns: True if adequate arguments are passed, false otherwise. Raises: gdb.GdbError if adequate arguments are not passed. is!ERROR: '%s' requires an argument.N(R R tGdbErrorR R (Rtarg_str((s,/usr/share/gdb/python/gdb/command/explore.pyt check_argsJs   cCs\ytjd|jjSWn7tk rWytj|SWqXtk rSdSXnXdS(s<A utility function to deduce the gdb.Type value from a string representing the type. Arguments: type_str: The type string from which the gdb.Type value should be deduced. Returns: The deduced gdb.Type value if possible, None otherwise. s(%s *)0N(R tparse_and_evalRR?t RuntimeErrort lookup_typeR@(ttype_str((s,/usr/share/gdb/python/gdb/command/explore.pytget_type_from_str`s   cCs*ytj|SWntk r%dSXdS(sCA utility function to deduce the gdb.Value value from a string representing the value. Arguments: value_str: The value string from which the gdb.Value value should be deduced. Returns: The deduced gdb.Value value if possible, None otherwise. N(R RlRmR@(t value_str((s,/usr/share/gdb/python/gdb/command/explore.pytget_value_from_strws  (R:R;R<R=RkRpRr(((s,/usr/share/gdb/python/gdb/command/explore.pyRhGstExploreCommandcBs eZdZdZdZRS(s,Explore a value or a type valid in the current context. Usage: explore ARG - ARG is either a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type or value. cCs,tt|jdddtjdtdS(NRtexploret command_classtprefix(tsuperRst__init__R t COMMAND_DATAR (tself((s,/usr/share/gdb/python/gdb/command/explore.pyRxs cCstjd|tkrdStj|}|dk rNtj||tdStj|}|dk rtj||tdSt j d|dS(NRtsG'%s' neither evaluates to a value nor is a type in the current context.( RhRkR RrR@RRRpRR Ri(RzRjtfrom_ttyRR((s,/usr/share/gdb/python/gdb/command/explore.pytinvokes  (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyRss  tExploreValueCommandcBs eZdZdZdZRS(sExplore value of an expression valid in the current context. Usage: explore value ARG - ARG is a valid expression. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing value. cCs&tt|jdddtjdS(NRs explore valueRu(RwR}RxR Ry(Rz((s,/usr/share/gdb/python/gdb/command/explore.pyRxscCsetjd|tkrdStj|}|dkrNtjd|dStj||tdS(Ns explore values: '%s' does not evaluate to a value in the current context.( RhRkR RrR@R RiRR(RzRjR{R((s,/usr/share/gdb/python/gdb/command/explore.pyR|s  (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyR}s  tExploreTypeCommandcBs eZdZdZdZRS(s:Explore a type or the type of an expression valid in the current context. Usage: explore type ARG - ARG is a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type. cCs&tt|jdddtjdS(NRs explore typeRu(RwR~RxR Ry(Rz((s,/usr/share/gdb/python/gdb/command/explore.pyRxscCstjd|tkrdStj|}|dk rNtj||tdStj|}|dk rd|t|j fGHtjt|j |j tdSt j d|dS(Ns explore types'%s' is of type '%s'.s3'%s' is not a type or value in the current context.( RhRkR RpR@RRRrRRR Ri(RzRjR{RR((s,/usr/share/gdb/python/gdb/command/explore.pyR|s   (R:R;R<RxR|(((s,/usr/share/gdb/python/gdb/command/explore.pyR~s  (R<R tsyst version_infotinputR6tobjectRRR*R,R0R'R.RhtCommandRsR}R~R2(((s,/usr/share/gdb/python/gdb/command/explore.pyts&   -B-!B($ PK!{hhpython/gdb/command/explore.pynu[# GDB 'explore' command. # Copyright (C) 2012-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Implementation of the GDB 'explore' command using the GDB Python API.""" import gdb import sys if sys.version_info[0] > 2: # Python 3 renamed raw_input to input raw_input = input class Explorer(object): """Internal class which invokes other explorers.""" # This map is filled by the Explorer.init_env() function type_code_to_explorer_map = { } _SCALAR_TYPE_LIST = ( gdb.TYPE_CODE_CHAR, gdb.TYPE_CODE_INT, gdb.TYPE_CODE_BOOL, gdb.TYPE_CODE_FLT, gdb.TYPE_CODE_VOID, gdb.TYPE_CODE_ENUM, ) @staticmethod def guard_expr(expr): length = len(expr) guard = False if expr[0] == '(' and expr[length-1] == ')': pass else: i = 0 while i < length: c = expr[i] if (c == '_' or ('a' <= c and c <= 'z') or ('A' <= c and c <= 'Z') or ('0' <= c and c <= '9')): pass else: guard = True break i += 1 if guard: return "(" + expr + ")" else: return expr @staticmethod def explore_expr(expr, value, is_child): """Main function to explore an expression value. Arguments: expr: The expression string that is being explored. value: The gdb.Value value of the expression. is_child: Boolean value to indicate if the expression is a child. An expression is a child if it is derived from the main expression entered by the user. For example, if the user entered an expression which evaluates to a struct, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. """ type_code = value.type.code if type_code in Explorer.type_code_to_explorer_map: explorer_class = Explorer.type_code_to_explorer_map[type_code] while explorer_class.explore_expr(expr, value, is_child): pass else: print ("Explorer for type '%s' not yet available.\n" % str(value.type)) @staticmethod def explore_type(name, datatype, is_child): """Main function to explore a data type. Arguments: name: The string representing the path to the data type being explored. datatype: The gdb.Type value of the data type being explored. is_child: Boolean value to indicate if the name is a child. A name is a child if it is derived from the main name entered by the user. For example, if the user entered the name of struct type, then when exploring the fields of the struct, is_child is set to True internally. Returns: No return value. """ type_code = datatype.code if type_code in Explorer.type_code_to_explorer_map: explorer_class = Explorer.type_code_to_explorer_map[type_code] while explorer_class.explore_type(name, datatype, is_child): pass else: print ("Explorer for type '%s' not yet available.\n" % str(datatype)) @staticmethod def init_env(): """Initializes the Explorer environment. This function should be invoked before starting any exploration. If invoked before an exploration, it need not be invoked for subsequent explorations. """ Explorer.type_code_to_explorer_map = { gdb.TYPE_CODE_CHAR : ScalarExplorer, gdb.TYPE_CODE_INT : ScalarExplorer, gdb.TYPE_CODE_BOOL : ScalarExplorer, gdb.TYPE_CODE_FLT : ScalarExplorer, gdb.TYPE_CODE_VOID : ScalarExplorer, gdb.TYPE_CODE_ENUM : ScalarExplorer, gdb.TYPE_CODE_STRUCT : CompoundExplorer, gdb.TYPE_CODE_UNION : CompoundExplorer, gdb.TYPE_CODE_PTR : PointerExplorer, gdb.TYPE_CODE_REF : ReferenceExplorer, gdb.TYPE_CODE_TYPEDEF : TypedefExplorer, gdb.TYPE_CODE_ARRAY : ArrayExplorer } @staticmethod def is_scalar_type(type): """Checks whether a type is a scalar type. A type is a scalar type of its type is gdb.TYPE_CODE_CHAR or gdb.TYPE_CODE_INT or gdb.TYPE_CODE_BOOL or gdb.TYPE_CODE_FLT or gdb.TYPE_CODE_VOID or gdb.TYPE_CODE_ENUM. Arguments: type: The type to be checked. Returns: 'True' if 'type' is a scalar type. 'False' otherwise. """ return type.code in Explorer._SCALAR_TYPE_LIST @staticmethod def return_to_parent_value(): """A utility function which prints that the current exploration session is returning to the parent value. Useful when exploring values. """ print ("\nReturning to parent value...\n") @staticmethod def return_to_parent_value_prompt(): """A utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the parent value. Useful when exploring values. """ raw_input("\nPress enter to return to parent value: ") @staticmethod def return_to_enclosing_type(): """A utility function which prints that the current exploration session is returning to the enclosing type. Useful when exploring types. """ print ("\nReturning to enclosing type...\n") @staticmethod def return_to_enclosing_type_prompt(): """A utility function which prompts the user to press the 'enter' key so that the exploration session can shift back to the enclosing type. Useful when exploring types. """ raw_input("\nPress enter to return to enclosing type: ") class ScalarExplorer(object): """Internal class used to explore scalar values.""" @staticmethod def explore_expr(expr, value, is_child): """Function to explore scalar values. See Explorer.explore_expr and Explorer.is_scalar_type for more information. """ print ("'%s' is a scalar value of type '%s'." % (expr, value.type)) print ("%s = %s" % (expr, str(value))) if is_child: Explorer.return_to_parent_value_prompt() Explorer.return_to_parent_value() return False @staticmethod def explore_type(name, datatype, is_child): """Function to explore scalar types. See Explorer.explore_type and Explorer.is_scalar_type for more information. """ if datatype.code == gdb.TYPE_CODE_ENUM: if is_child: print ("%s is of an enumerated type '%s'." % (name, str(datatype))) else: print ("'%s' is an enumerated type." % name) else: if is_child: print ("%s is of a scalar type '%s'." % (name, str(datatype))) else: print ("'%s' is a scalar type." % name) if is_child: Explorer.return_to_enclosing_type_prompt() Explorer.return_to_enclosing_type() return False class PointerExplorer(object): """Internal class used to explore pointer values.""" @staticmethod def explore_expr(expr, value, is_child): """Function to explore pointer values. See Explorer.explore_expr for more information. """ print ("'%s' is a pointer to a value of type '%s'" % (expr, str(value.type.target()))) option = raw_input("Continue exploring it as a pointer to a single " "value [y/n]: ") if option == "y": deref_value = None try: deref_value = value.dereference() str(deref_value) except gdb.MemoryError: print ("'%s' a pointer pointing to an invalid memory " "location." % expr) if is_child: Explorer.return_to_parent_value_prompt() return False Explorer.explore_expr("*%s" % Explorer.guard_expr(expr), deref_value, is_child) return False option = raw_input("Continue exploring it as a pointer to an " "array [y/n]: ") if option == "y": while True: index = 0 try: index = int(raw_input("Enter the index of the element you " "want to explore in '%s': " % expr)) except ValueError: break element_expr = "%s[%d]" % (Explorer.guard_expr(expr), index) element = value[index] try: str(element) except gdb.MemoryError: print ("Cannot read value at index %d." % index) continue Explorer.explore_expr(element_expr, element, True) return False if is_child: Explorer.return_to_parent_value() return False @staticmethod def explore_type(name, datatype, is_child): """Function to explore pointer types. See Explorer.explore_type for more information. """ target_type = datatype.target() print ("\n%s is a pointer to a value of type '%s'." % (name, str(target_type))) Explorer.explore_type("the pointee type of %s" % name, target_type, is_child) return False class ReferenceExplorer(object): """Internal class used to explore reference (TYPE_CODE_REF) values.""" @staticmethod def explore_expr(expr, value, is_child): """Function to explore array values. See Explorer.explore_expr for more information. """ referenced_value = value.referenced_value() Explorer.explore_expr(expr, referenced_value, is_child) return False @staticmethod def explore_type(name, datatype, is_child): """Function to explore pointer types. See Explorer.explore_type for more information. """ target_type = datatype.target() Explorer.explore_type(name, target_type, is_child) return False class ArrayExplorer(object): """Internal class used to explore arrays.""" @staticmethod def explore_expr(expr, value, is_child): """Function to explore array values. See Explorer.explore_expr for more information. """ target_type = value.type.target() print ("'%s' is an array of '%s'." % (expr, str(target_type))) index = 0 try: index = int(raw_input("Enter the index of the element you want to " "explore in '%s': " % expr)) except ValueError: if is_child: Explorer.return_to_parent_value() return False element = None try: element = value[index] str(element) except gdb.MemoryError: print ("Cannot read value at index %d." % index) raw_input("Press enter to continue... ") return True Explorer.explore_expr("%s[%d]" % (Explorer.guard_expr(expr), index), element, True) return True @staticmethod def explore_type(name, datatype, is_child): """Function to explore array types. See Explorer.explore_type for more information. """ target_type = datatype.target() print ("%s is an array of '%s'." % (name, str(target_type))) Explorer.explore_type("the array element of %s" % name, target_type, is_child) return False class CompoundExplorer(object): """Internal class used to explore struct, classes and unions.""" @staticmethod def _print_fields(print_list): """Internal function which prints the fields of a struct/class/union. """ max_field_name_length = 0 for pair in print_list: if max_field_name_length < len(pair[0]): max_field_name_length = len(pair[0]) for pair in print_list: print (" %*s = %s" % (max_field_name_length, pair[0], pair[1])) @staticmethod def _get_real_field_count(fields): real_field_count = 0; for field in fields: if not field.artificial: real_field_count = real_field_count + 1 return real_field_count @staticmethod def explore_expr(expr, value, is_child): """Function to explore structs/classes and union values. See Explorer.explore_expr for more information. """ datatype = value.type type_code = datatype.code fields = datatype.fields() if type_code == gdb.TYPE_CODE_STRUCT: type_desc = "struct/class" else: type_desc = "union" if CompoundExplorer._get_real_field_count(fields) == 0: print ("The value of '%s' is a %s of type '%s' with no fields." % (expr, type_desc, str(value.type))) if is_child: Explorer.return_to_parent_value_prompt() return False print ("The value of '%s' is a %s of type '%s' with the following " "fields:\n" % (expr, type_desc, str(value.type))) has_explorable_fields = False choice_to_compound_field_map = { } current_choice = 0 print_list = [ ] for field in fields: if field.artificial: continue field_full_name = Explorer.guard_expr(expr) + "." + field.name if field.is_base_class: field_value = value.cast(field.type) else: field_value = value[field.name] literal_value = "" if type_code == gdb.TYPE_CODE_UNION: literal_value = ("" % (current_choice, str(field.type))) has_explorable_fields = True else: if Explorer.is_scalar_type(field.type): literal_value = ("%s .. (Value of type '%s')" % (str(field_value), str(field.type))) else: if field.is_base_class: field_desc = "base class" else: field_desc = "field" literal_value = ("" % (current_choice, field_desc, str(field.type))) has_explorable_fields = True choice_to_compound_field_map[str(current_choice)] = ( field_full_name, field_value) current_choice = current_choice + 1 print_list.append((field.name, literal_value)) CompoundExplorer._print_fields(print_list) print ("") if has_explorable_fields: choice = raw_input("Enter the field number of choice: ") if choice in choice_to_compound_field_map: Explorer.explore_expr(choice_to_compound_field_map[choice][0], choice_to_compound_field_map[choice][1], True) return True else: if is_child: Explorer.return_to_parent_value() else: if is_child: Explorer.return_to_parent_value_prompt() return False @staticmethod def explore_type(name, datatype, is_child): """Function to explore struct/class and union types. See Explorer.explore_type for more information. """ type_code = datatype.code type_desc = "" if type_code == gdb.TYPE_CODE_STRUCT: type_desc = "struct/class" else: type_desc = "union" fields = datatype.fields() if CompoundExplorer._get_real_field_count(fields) == 0: if is_child: print ("%s is a %s of type '%s' with no fields." % (name, type_desc, str(datatype))) Explorer.return_to_enclosing_type_prompt() else: print ("'%s' is a %s with no fields." % (name, type_desc)) return False if is_child: print ("%s is a %s of type '%s' " "with the following fields:\n" % (name, type_desc, str(datatype))) else: print ("'%s' is a %s with the following " "fields:\n" % (name, type_desc)) has_explorable_fields = False current_choice = 0 choice_to_compound_field_map = { } print_list = [ ] for field in fields: if field.artificial: continue if field.is_base_class: field_desc = "base class" else: field_desc = "field" rhs = ("" % (current_choice, field_desc, str(field.type))) print_list.append((field.name, rhs)) choice_to_compound_field_map[str(current_choice)] = ( field.name, field.type, field_desc) current_choice = current_choice + 1 CompoundExplorer._print_fields(print_list) print ("") if len(choice_to_compound_field_map) > 0: choice = raw_input("Enter the field number of choice: ") if choice in choice_to_compound_field_map: if is_child: new_name = ("%s '%s' of %s" % (choice_to_compound_field_map[choice][2], choice_to_compound_field_map[choice][0], name)) else: new_name = ("%s '%s' of '%s'" % (choice_to_compound_field_map[choice][2], choice_to_compound_field_map[choice][0], name)) Explorer.explore_type(new_name, choice_to_compound_field_map[choice][1], True) return True else: if is_child: Explorer.return_to_enclosing_type() else: if is_child: Explorer.return_to_enclosing_type_prompt() return False class TypedefExplorer(object): """Internal class used to explore values whose type is a typedef.""" @staticmethod def explore_expr(expr, value, is_child): """Function to explore typedef values. See Explorer.explore_expr for more information. """ actual_type = value.type.strip_typedefs() print ("The value of '%s' is of type '%s' " "which is a typedef of type '%s'" % (expr, str(value.type), str(actual_type))) Explorer.explore_expr(expr, value.cast(actual_type), is_child) return False @staticmethod def explore_type(name, datatype, is_child): """Function to explore typedef types. See Explorer.explore_type for more information. """ actual_type = datatype.strip_typedefs() if is_child: print ("The type of %s is a typedef of type '%s'." % (name, str(actual_type))) else: print ("The type '%s' is a typedef of type '%s'." % (name, str(actual_type))) Explorer.explore_type(name, actual_type, is_child) return False class ExploreUtils(object): """Internal class which provides utilities for the main command classes.""" @staticmethod def check_args(name, arg_str): """Utility to check if adequate number of arguments are passed to an explore command. Arguments: name: The name of the explore command. arg_str: The argument string passed to the explore command. Returns: True if adequate arguments are passed, false otherwise. Raises: gdb.GdbError if adequate arguments are not passed. """ if len(arg_str) < 1: raise gdb.GdbError("ERROR: '%s' requires an argument." % name) return False else: return True @staticmethod def get_type_from_str(type_str): """A utility function to deduce the gdb.Type value from a string representing the type. Arguments: type_str: The type string from which the gdb.Type value should be deduced. Returns: The deduced gdb.Type value if possible, None otherwise. """ try: # Assume the current language to be C/C++ and make a try. return gdb.parse_and_eval("(%s *)0" % type_str).type.target() except RuntimeError: # If assumption of current language to be C/C++ was wrong, then # lookup the type using the API. try: return gdb.lookup_type(type_str) except RuntimeError: return None @staticmethod def get_value_from_str(value_str): """A utility function to deduce the gdb.Value value from a string representing the value. Arguments: value_str: The value string from which the gdb.Value value should be deduced. Returns: The deduced gdb.Value value if possible, None otherwise. """ try: return gdb.parse_and_eval(value_str) except RuntimeError: return None class ExploreCommand(gdb.Command): """Explore a value or a type valid in the current context. Usage: explore ARG - ARG is either a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type or value. """ def __init__(self): super(ExploreCommand, self).__init__(name = "explore", command_class = gdb.COMMAND_DATA, prefix = True) def invoke(self, arg_str, from_tty): if ExploreUtils.check_args("explore", arg_str) == False: return # Check if it is a value value = ExploreUtils.get_value_from_str(arg_str) if value is not None: Explorer.explore_expr(arg_str, value, False) return # If it is not a value, check if it is a type datatype = ExploreUtils.get_type_from_str(arg_str) if datatype is not None: Explorer.explore_type(arg_str, datatype, False) return # If it is neither a value nor a type, raise an error. raise gdb.GdbError( ("'%s' neither evaluates to a value nor is a type " "in the current context." % arg_str)) class ExploreValueCommand(gdb.Command): """Explore value of an expression valid in the current context. Usage: explore value ARG - ARG is a valid expression. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing value. """ def __init__(self): super(ExploreValueCommand, self).__init__( name = "explore value", command_class = gdb.COMMAND_DATA) def invoke(self, arg_str, from_tty): if ExploreUtils.check_args("explore value", arg_str) == False: return value = ExploreUtils.get_value_from_str(arg_str) if value is None: raise gdb.GdbError( (" '%s' does not evaluate to a value in the current " "context." % arg_str)) return Explorer.explore_expr(arg_str, value, False) class ExploreTypeCommand(gdb.Command): """Explore a type or the type of an expression valid in the current context. Usage: explore type ARG - ARG is a valid expression or a type name. - At any stage of exploration, hit the return key (instead of a choice, if any) to return to the enclosing type. """ def __init__(self): super(ExploreTypeCommand, self).__init__( name = "explore type", command_class = gdb.COMMAND_DATA) def invoke(self, arg_str, from_tty): if ExploreUtils.check_args("explore type", arg_str) == False: return datatype = ExploreUtils.get_type_from_str(arg_str) if datatype is not None: Explorer.explore_type(arg_str, datatype, False) return value = ExploreUtils.get_value_from_str(arg_str) if value is not None: print ("'%s' is of type '%s'." % (arg_str, str(value.type))) Explorer.explore_type(str(value.type), value.type, False) return raise gdb.GdbError(("'%s' is not a type or value in the current " "context." % arg_str)) Explorer.init_env() ExploreCommand() ExploreValueCommand() ExploreTypeCommand() PK!\v python/gdb/FrameDecorator.pyonu[ Rc@sRddlZdefdYZdefdYZdefdYZdS(iNtFrameDecoratorcBsneZdZdZedZdZdZdZdZ dZ dZ d Z d Z RS( s)Basic implementation of a Frame DecoratorcCs ||_dS(N(t_base(tselftbase((s+/usr/share/gdb/python/gdb/FrameDecorator.pyt__init__3scCsU|j}|j sM|jj sM|jtjksM|jtjkrQtStS(sIInternal utility to determine if the frame is special or limited.( tfind_saltsymtabtfilenamettypetgdbt DUMMY_FRAMEtSIGTRAMP_FRAMEtTruetFalse(tframetsal((s+/usr/share/gdb/python/gdb/FrameDecorator.pyt_is_limited_frame6s  cCs#t|jdr|jjSdS(sLReturn any elided frames that this class might be wrapping, or None.telidedN(thasattrRRtNone(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRDs cCst|jtjs7t|jdr7|jjSn|j}|jtjkr\dS|jtj krudS|j}|dkr|j }|St |S(s Return the name of the frame's function or an address of the function of the frame. First determine if this is a special frame. If not, try to determine filename from GDB's frame internal function API. Finally, if a name cannot be determined return the address. If this function returns an address, GDB will attempt to determine the function name from its internal minimal symbols store (for example, for inferiors without debug-info).tfunctionssN( t isinstanceRR tFrameRRtinferior_frameRR R Rtpctstr(RRtfuncR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRLs     cCs5t|jdr|jjS|j}|jS(s% Return the address of the frame's pctaddress(RRRRR(RR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRqs  cCsut|jdr|jjS|j}|j}|j sN|jj rg|j}tj|S|jjSdS(s Return the filename associated with this frame, detecting and returning the appropriate library name is this is a shared library.RN( RRRRRRRR t solib_name(RRRR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRzs     cCsTt|jdr|jjS|j}|j|r>dSt|}|jS(s Return an iterable of frame arguments for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame arguments, or if this frame is deemed to be a special case, return None.t frame_argsN(RRRRRRt FrameVarstfetch_frame_args(RRtargs((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   cCsTt|jdr|jjS|j}|j|r>dSt|}|jS(s Return an iterable of local variables for this frame, if any. The iterable object contains objects conforming with the Symbol/Value interface. If there are no frame locals, or if this frame is deemed to be a special case, return None.t frame_localsN(RRR!RRRRtfetch_frame_locals(RRR ((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR!s   cCs_t|jdr|jjS|j}|j|r>dS|j}|rW|jSdSdS(s Return line number information associated with the frame's pc. If symbol table/line information does not exist, or if this frame is deemed to be a special case, return NonetlineN(RRR#RRRR(RRR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR#s   cCs&t|jdr|jjS|jS(s8 Return the gdb.Frame underpinning this frame decorator.R(RRR(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs (t__name__t __module__t__doc__Rt staticmethodRRRRRRR!R#R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   %    tSymValueWrappercBs)eZdZdZdZdZRS(skA container class conforming to the Symbol/Value interface which holds frame locals or frame arguments.cCs||_||_dS(N(tsymtval(Rtsymboltvalue((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs cCs|jS(s6 Return the value associated with this symbol, or None(R*(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR,scCs|jS(sP Return the symbol, or Python text, associated with this symbol, or None(R)(R((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR+s(R$R%R&RR,R+(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR(s  RcBs2eZdZdZdZdZdZRS(sOUtility class to fetch and store frame local variables, or frame arguments.cCs\||_ittj6ttj6ttj6ttj6ttj6ttj6ttj 6|_ dS(N( RR R tSYMBOL_LOC_STATICtSYMBOL_LOC_REGISTERtSYMBOL_LOC_ARGtSYMBOL_LOC_REF_ARGtSYMBOL_LOC_LOCALtSYMBOL_LOC_REGPARM_ADDRtSYMBOL_LOC_COMPUTEDt symbol_class(RR((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs       cCs/t|trtS|j}|jj|tS(s Local utility method to determine if according to Symbol type whether it should be included in the iterator. Not all symbols are fetched, and only symbols that return True from this method should be fetched.(Rt basestringR t addr_classR4tgetR (RR)tsym_type((s+/usr/share/gdb/python/gdb/FrameDecorator.pytfetch_bs  cCsg}y|jj}Wntk r2d}nXxw|dkr|jsT|jrXPnxE|D]=}|jrtq_n|j|r_|jt |dq_q_W|j }q6W|S(sPublic utility method to fetch frame local variables for the stored frame. Frame arguments are not fetched. If there are no frame local variables, return an empty list.N( Rtblockt RuntimeErrorRt is_globalt is_statict is_argumentR9tappendR(t superblock(RtlvarsR:R)((s+/usr/share/gdb/python/gdb/FrameDecorator.pyR"s     cCsg}y|jj}Wntk r2d}nXx,|dkra|jdkrUPn|j}q6W|dkrx6|D]+}|jsqun|jt|dquWn|S(sPublic utility method to fetch frame arguments for the stored frame. Frame arguments are the only type fetched. If there are no frame argument variables, return an empty list.N( RR:R;RRR@R>R?R((RR R:R)((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs      (R$R%R&RR9R"R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyRs   (R tobjectRR(R(((s+/usr/share/gdb/python/gdb/FrameDecorator.pyts PK!Ɂ$$python/gdb/printing.pyonu[ Rc@sdZddlZddlZddlZddlZejddkrXeZeZ nde fdYZ de fdYZ e d Zd e fd YZd dd YZde fdYZdS(s+Utilities for working with pretty-printers.iNiit PrettyPrintercBs#eZdZddZdZRS(sA basic pretty-printer. Attributes: name: A unique string among all printers for the context in which it is defined (objfile, progspace, or global(gdb)), and should meaningfully describe what can be pretty-printed. E.g., "StringPiece" or "protobufs". subprinters: An iterable object with each element having a `name' attribute, and, potentially, "enabled" attribute. Or this is None if there are no subprinters. enabled: A boolean indicating if the printer is enabled. Subprinters are for situations where "one" pretty-printer is actually a collection of several printers. E.g., The libstdc++ pretty-printer has a pretty-printer for each of several different types, based on regexps. cCs||_||_t|_dS(N(tnamet subprinterstTruetenabled(tselfRR((s%/usr/share/gdb/python/gdb/printing.pyt__init__3s  cCstddS(NsPrettyPrinter __call__(tNotImplementedError(Rtval((s%/usr/share/gdb/python/gdb/printing.pyt__call__8sN(t__name__t __module__t__doc__tNoneRR (((s%/usr/share/gdb/python/gdb/printing.pyRs tSubPrettyPrintercBseZdZdZRS(sBaseclass for sub-pretty-printers. Sub-pretty-printers needn't use this, but it formalizes what's needed. Attributes: name: The name of the subprinter. enabled: A boolean indicating if the subprinter is enabled. cCs||_t|_dS(N(RRR(RR((s%/usr/share/gdb/python/gdb/printing.pyRGs (R R R R(((s%/usr/share/gdb/python/gdb/printing.pyR=scCst|d r/t|d r/tdnt|dr]t|d r]tdnt|ds{tdn|dkrtjdrtjd tnt}n/tjdrtjd |j|jfnt|drt|jt std n|jj d d kr9t dnd }xi|j D][}t|dr|j|jkr|r|j |=Pqt d|jn|d}qIWn|j jd |dS(sRegister pretty-printer PRINTER with OBJ. The printer is added to the front of the search list, thus one can override an existing printer if one needs to. Use a different name when overriding an existing printer, otherwise an exception will be raised; multiple printers with the same name are disallowed. Arguments: obj: Either an objfile, progspace, or None (in which case the printer is registered globally). printer: Either a function of one argument (old way) or any object which has attributes: name, enabled, __call__. replace: If True replace any existing copy of the printer. Otherwise if the printer already exists raise an exception. Returns: Nothing. Raises: TypeError: A problem with the type of the printer. ValueError: The printer's name contains a semicolon ";". RuntimeError: A printer with the same name is already registered. If the caller wants the printer to be listable and disableable, it must follow the PrettyPrinter API. This applies to the old way (functions) too. If printer is an object, __call__ is a method of two arguments: self, and the value to be pretty-printed. See PrettyPrinter. R Rsprinter missing attribute: nameRs"printer missing attribute: enabledR s#printer missing attribute: __call__tverboses)Registering global %s pretty-printer ... s)Registering %s pretty-printer for %s ... sprinter name is not a stringt;issemicolon ';' in printer names%pretty-printer already registered: %siN(thasattrt TypeErrorR tgdbt parametertwriteRtfilenamet isinstancet basestringtfindt ValueErrortpretty_printerst RuntimeErrortinsert(tobjtprintertreplacetitp((s%/usr/share/gdb/python/gdb/printing.pytregister_pretty_printerLs8"    ! tRegexpCollectionPrettyPrintercBs?eZdZdefdYZdZdZdZRS(syClass for implementing a collection of regular-expression based pretty-printers. Intended usage: pretty_printer = RegexpCollectionPrettyPrinter("my_library") pretty_printer.add_printer("myclass1", "^myclass1$", MyClass1Printer) ... pretty_printer.add_printer("myclassN", "^myclassN$", MyClassNPrinter) register_pretty_printer(obj, pretty_printer) tRegexpSubprintercBseZdZRS(cCsAttj|j|||_||_tj||_dS(N( tsuperR$R%Rtregexpt gen_printertretcompilet compiled_re(RRR'R(((s%/usr/share/gdb/python/gdb/printing.pyRs  (R R R(((s%/usr/share/gdb/python/gdb/printing.pyR%scCstt|j|gdS(N(R&R$R(RR((s%/usr/share/gdb/python/gdb/printing.pyRscCs#|jj|j|||dS(soAdd a printer to the list. The printer is added to the end of the list. Arguments: name: The name of the subprinter. regexp: The regular expression, as a string. gen_printer: A function/method that given a value returns an object to pretty-print it. Returns: Nothing. N(RtappendR%(RRR'R(((s%/usr/share/gdb/python/gdb/printing.pyt add_printerscCsbtjj|jj}|s"dSx9|jD].}|jr,|jj |r,|j |Sq,WdS(s1Lookup the pretty-printer for the provided value.N( Rttypestget_basic_typettypettagR RRR+tsearchR((RRttypenameR((s%/usr/share/gdb/python/gdb/printing.pyR s(R R R RR%RR-R (((s%/usr/share/gdb/python/gdb/printing.pyR$s    t _EnumInstancecBseZdZdZRS(cCs||_||_dS(N(t enumeratorsR(RR5R((s%/usr/share/gdb/python/gdb/printing.pyRs cCsg}t|j}t}xH|jD]=\}}||@dkr%|j|||@}t}q%q%W| sy|dkr|jd|nd|jdj|fS(Niss 0x%x [%s]s | (tlongRtFalseR5R,Rtjoin(Rt flag_listtvt any_foundte_namete_value((s%/usr/share/gdb/python/gdb/printing.pyt to_strings   (R R RR>(((s%/usr/share/gdb/python/gdb/printing.pyR4s tFlagEnumerationPrintercBs eZdZdZdZRS(sA pretty-printer which can be used to print a flag-style enumeration. A flag-style enumeration is one where the enumerators are or'd together to create values. The new printer will print these symbolically using '|' notation. The printer must be registered manually. This printer is most useful when an enum is flag-like, but has some overlap. GDB's built-in printing will not handle this case, but this printer will attempt to.cCs#tt|j|t|_dS(N(R&R?RR7t initialized(Rt enum_type((s%/usr/share/gdb/python/gdb/printing.pyRscCs|jsyt|_tj|j}g|_x0|jD]"}|jj|j|jfq:W|jj ddn|j rt |j|SdSdS(NtkeycSs|jS(N(tenumval(tx((s%/usr/share/gdb/python/gdb/printing.pyts( R@RRt lookup_typeRR5tfieldsR,RCtsortRR4R (RRtflagstfield((s%/usr/share/gdb/python/gdb/printing.pyR s     (R R R RR (((s%/usr/share/gdb/python/gdb/printing.pyR?s ((R Rt gdb.typesR)tsyst version_infotstrRtintR6tobjectRRR7R#R$R4R?(((s%/usr/share/gdb/python/gdb/printing.pyts       LAPK!auto-load/usr/lib64nuȯPK!Cauto-load/usr/sbinnuȯPK!auto-load/usr/binnuȯPK!La/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyonu[PK!|.auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pynu[PK!La/1auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pycnu[PK!Aauto-load/usr/libnuȯPK!t?7?7syscalls/i386-linux.xmlnu[PK!33Jsyscalls/amd64-linux.xmlnu[PK!_ES}syscalls/gdb-syscalls.dtdnu[PK!~~~cpython/gdb/types.pycnu[PK! v| | %python/gdb/__init__.pynu[PK!$cz  python/gdb/frames.pyonu[PK!0ߕ6python/gdb/FrameIterator.pyonu[PK!$cz  python/gdb/frames.pycnu[PK!Ɂ$$python/gdb/printing.pycnu[PK!\v python/gdb/FrameDecorator.pycnu[PK!0ߕ2python/gdb/FrameIterator.pycnu[PK! $python/gdb/__init__.pycnu[PK!B*!%%L2python/gdb/frames.pynu[PK!*:''Qpython/gdb/printing.pynu[PK!>´ypython/gdb/function/__init__.pynu[PK!= |python/gdb/function/caller_is.pynu[PK!.<| | Ѕpython/gdb/function/strfns.pynu[PK!qg++python/gdb/function/strfns.pycnu[PK!npython/gdb/function/in_scope.pynu[PK!縤 Ppython/gdb/function/__init__.pycnu[PK![Xj j !%python/gdb/function/caller_is.pyonu[PK!qg++python/gdb/function/strfns.pyonu[PK!m Ypython/gdb/function/in_scope.pyonu[PK!縤 python/gdb/function/__init__.pyonu[PK!m Wpython/gdb/function/in_scope.pycnu[PK![Xj j !python/gdb/function/caller_is.pycnu[PK!`gmrr;python/gdb/prompt.pynu[PK! T--python/gdb/types.pynu[PK!V::apython/gdb/prompt.pycnu[PK!uTYY python/gdb/FrameIterator.pynu[PK!~~~python/gdb/types.pyonu[PK! F(python/gdb/__init__.pyonu[PK!V:: 6python/gdb/prompt.pyonu[PK!?f'f'Gpython/gdb/FrameDecorator.pynu[PK!k>opython/gdb/command/__init__.pynu[PK!N;cEcE$Brpython/gdb/command/frame_filters.pyonu[PK!1; ; python/gdb/command/pahole.pycnu[PK!Rq $python/gdb/command/type_printers.pycnu[PK! [ [python/gdb/command/explore.pyonu[PK!Pf6)0python/gdb/command/__init__.pycnu[PK!1; ; 0python/gdb/command/pahole.pyonu[PK! :python/gdb/command/pahole.pynu[PK!l++&Epython/gdb/command/pretty_printers.pycnu[PK!Rq $qpython/gdb/command/type_printers.pyonu[PK!?WWpython/gdb/command/prompt.pynu[PK!>6python/gdb/command/prompt.pycnu[PK!LL#python/gdb/command/type_printers.pynu[PK!!zj$Lpython/gdb/command/ignore_errors.pycnu[PK!88%python/gdb/command/pretty_printers.pynu[PK!YeRR#python/gdb/command/ignore_errors.pynu[PK!Pf63python/gdb/command/__init__.pyonu[PK!>6python/gdb/command/prompt.pyonu[PK!N;cEcE$python/gdb/command/frame_filters.pycnu[PK!-@-@#8python/gdb/command/frame_filters.pynu[PK!!zj$Mypython/gdb/command/ignore_errors.pyonu[PK!l++&}python/gdb/command/pretty_printers.pyonu[PK! [ [python/gdb/command/explore.pycnu[PK!{hh'python/gdb/command/explore.pynu[PK!\v