�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PKr1]3,xexe=python/libstdcxx/v6/__pycache__/printers.cpython-36.opt-1.pycnu[3 h@sddlZddlZddlZddlZddlZddlZejddkrXeZe Z e Z e ZejjZn6GdddZddlm Z m Z GdddejZeZday ddlZWnek rd aYnXd ayddlZeejd rdaWnek rYnXeed rejZneZd d ZdaddZddZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&Gdd d eZ'Gd!d"d"eZ(d#d$Z)d%d&Z*d'd(Z+Gd)d*d*eZ,d+d,Z-d-d.Z.Gd/d0d0eZ/Gd1d2d2eZ0Gd3d4d4e0Z1Gd5d6d6e0Z2Gd7d8d8eZ3Gd9d:d:eZ4Gd;d<dd>eZ6Gd?d@d@eZ7GdAdBdBeZ8GdCdDdDeZ9GdEdFdFeZ:GdGdHdHeZ;dIdJZdOdPZ?GdQdRdReZ@GdSdTdTeZAGdUdVdVeZBGdWdXdXeZCGdYdZdZeZDGd[d\d\eZEd]d^ZFGd_d`d`eZGGdadbdbeZHGdcddddeZIGdedfdfeZJGdgdhdheZKGdidjdjeZLGdkdldleZMGdmdndneZNdodpZOGdqdrdreNZPGdsdtdteNZQGdudvdveNZRGdwdxdxeNZSGdydzdzeZTGd{d|d|eZUGd}d~d~eZVGdddeZWGdddeZXGdddeZYGdddeZZGdddeZ[GdddeZ\GdddeZ]GdddeZ^GdddeZ_GdddeZ`GdddeZadddddddddddddg ZbddddddddgZcGdddeZdGdddeZeGdddeZfGdddeZgGdddeZhGdddeZiGdddeZjGdddeZkGdddeZlGdddeZmdanGdddeZoddZpGdddeZqdddÄZrddńZsddDŽZtddɄZueudS)Nc@seZdZdZddZdS)Iteratora:Compatibility mixin for iterators Instead of writing next() methods for iterators, write __next__() methods and use this mixin to make them work in Python 2 as well as Python 3. Idea stolen from the "six" documentation: cCs|jS)N)__next__)selfr0/usr/share/gcc-8/python/libstdcxx/v6/printers.pynext?sz Iterator.nextN)__name__ __module__ __qualname____doc__rrrrrr4s r)imapizipc@s(eZdZdZddZddZddZdS) UTCz5Concrete tzinfo class representing the UTC time zone.cCs tjdS)Nr)datetime timedelta)rdtrrr utcoffsetIsz UTC.utcoffsetcCsdS)Nrr)rrrrrtznameLsz UTC.tznamecCs tjdS)Nr)rr)rrrrrdstOszUTC.dstN)r r r r rrrrrrrrFsrTFZ TypePrinter ValuePrinterc Csz|j}xld|j|f}y tj|Stk r6YnX|j}t|r^|djr^|dj}q t dt ||fq WdS)Nz%s::%srzCannot find type %s::%s) strip_typedefstaggdb lookup_type RuntimeErrorfieldslen is_base_classtype ValueErrorstr)Zorignametypsearchrrrr find_typens  r%z__8::cGsdj|djdd|D}y tj|Stjk r}zFt|krv|jddtd}y tj|Stjk rtYnX|WYdd}~XnXdS)z8 Lookup template specialization templ. z{}<{}>z, cSsg|] }t|qSr)r!).0arrr sz%lookup_templ_spec..z::N)formatjoinrrerror_versioned_namespacereplace)Ztemplargsterrrlookup_templ_specs  r2cCsd|krd|}yt|d}Wn|jd}YnX|j}y t||Stjk rt|drt|dddr|jdd d }y t||Stjk rYnXd SXd S) a Lookup specialization of template nodename corresponding to containertype. nodename - The name of a class template, as a String containertype - The container, as a gdb.Type Return a gdb.Type for the corresponding specialization of nodename, or None if the type cannot be found. e.g. lookup_node_type('_List_node', gdb.lookup_type('std::list')) will return a gdb.Type for the type std::_List_node. z::zstd:: value_typerZstdzstd::__cxx1998z std::__debugZ __gnu_debugz ::__cxx1998::r)N)r%template_argumentrr2rr,is_member_of_namespacer.)nodenameZ containertypevaltyperrrlookup_node_types&   r8cGs@t|tjrt|}t|}x|D]}|j|dr"dSq"WdS)z Test whether a type is a member of one of the specified namespaces. The type can be specified as a string or a gdb.Type object. z::TF) isinstancerTyper!strip_versioned_namespace startswith)r#Z namespaces namespacerrrr5s  r5cCs2t|tjr|j}dt|f}tjd||dk S)z Test whether a type is a specialization of the named class template. The type can be specified as a string or a gdb.Type object. The template should be the name of a class template as a string, without any 'std' qualification. z(%s)?%sz ^std::%s<.*>$N)r9rr:rr-rematch)x template_namerrris_specialization_ofs  rBcCs |jtdS)N)r.r-)typenamerrrr;sr;cCs<d}d}tjddkr&tj|||dStj|||ddSdS)zCRemove "fundamentals_vN" inline namespace from qualified type name.z&^std::experimental::fundamentals_v\d::zstd::experimental::rrr))countN)sys version_infor>sub)r#patternreplrrrstrip_fundts_namespaces rKcCsVt|}|jdd}d}x d D]}|j||d|}qW|d}|j|d|}|S) zARemove known inline namespaces from the canonical name of a type.zstd::__cxx11::zstd::zstd::experimental::fundamentals_v1fundamentals_v2z::z filesystem::zv1::)rLrM)r;r.)type_strZexpt_nsZlfts_nsZfs_nsrrrstrip_inline_namespacess  rOc Cs:d}g}x,y|j|j|Wn |S|d7}q WdS)z-Return a type's template arguments as a list.rr)N)appendr4)type_objn template_argsrrrget_template_arg_listsrTc@s(eZdZdZddZddZddZdS) SmartPtrIteratorz@An iterator for smart pointer types with a single 'child' value.cCs ||_dS)N)_val)rvalrrr__init__szSmartPtrIterator.__init__cCs|S)Nr)rrrr__iter__szSmartPtrIterator.__iter__cCs$|jdkrtd|j|_}d|fS)Nzget())rV StopIteration)rrWrrrr s zSmartPtrIterator.__next__N)r r r r rXrYrrrrrrUsrUc@s0eZdZdZddZddZddZdd Zd S) SharedPointerPrinterzP Print a shared_ptr, weak_ptr, atomic, or atomic. cCst||_||_|d|_dS)N_M_ptr)r; _typenamerV_pointer)rrDrWrrrrXs zSharedPointerPrinter.__init__cCs t|jS)N)rUr^)rrrrchildrenszSharedPointerPrinter.childrencCsR|jdkrD|jddd}||d}t|jdjd}|j|S|jddS)Nz std::atomicZ _M_refcountZ_M_val_M_irpointerZ_M_pi)r]rVr%rcast)rZptr_valZptr_typerrr_get_refcountss    z#SharedPointerPrinter._get_refcountscCspd}|j}|jjjd}tt|}|dkr`|d}|d}|dkrPd|}nd||df}d|j||fS) NemptyrZ _M_use_countZ _M_weak_countzexpired, weak count %dzuse count %d, weak count %dr)z %s<%s> (%s))rcrVrr4r;r!r])rstateZ refcountstargZusecountZ weakcountrrr to_string(s  zSharedPointerPrinter.to_stringN)r r r r rXr_rcrgrrrrr[s  r[cCs|jj}|djs&tdt|j|j|dj}|jj}t|dkr^tdt|j|djdkrt|dS|djr|j|djStdt|jdS)zBReturn the tuple element stored in a _Tuple_impl base class.r)z-Unsupported implementation for std::tuple: %sr _M_head_implNri)rrrr r!rbrr")rWbasesZ head_baserrrr_tuple_impl_get9s     rkcCshtt|j}||krtd|j|jjdj}x*|dkr^|j|jjdj}|d8}q6Wt|S)z6Return the result of std::get(val) on a std::tuple.z0Out of range index for std::get on std::tuplerr))rrTrr rbrrk)rRrWZ tuple_sizenoderrr tuple_getQs  rmcCsd|jjdjj}t|ds(t|dr6|dd}n$t|drJ|d}ntdt|td|S)z4Return the result of val.get() on a std::unique_ptr.rZ__uniq_ptr_dataZ__uniq_ptr_impl_M_ttuplez-Unsupported implementation for unique_ptr: %s)rrrrBr r!rm)rWZ impl_typeZ tuple_memberrrrunique_ptr_get_s    rpc@s(eZdZdZddZddZddZdS) UniquePointerPrinterzPrint a unique_ptr.cCs ||_dS)N)rV)rrDrWrrrrXtszUniquePointerPrinter.__init__cCstt|jS)N)rUrprV)rrrrr_wszUniquePointerPrinter.childrencCs|jjjd}djt|S)Nrzstd::unique_ptr<{}>)rVrr4r*r!)rr0rrrrgzszUniquePointerPrinter.to_stringN)r r r r rXr_rgrrrrrqqsrqcCs|djj|jjS)z7Return the value held in a __gnu_cxx::__aligned_membuf. _M_storage)addressrbra dereference)Zbufr7rrrget_value_from_aligned_membufsruc CsjyF|jjdj}|dkr"|dS|dkrD|jjd}t|d|SWn YnXtdt|jdS)z-Return the value held in an _List_node<_Val>.r)_M_datarrrz!Unsupported implementation for %sN)rrr"r4rur r!)rlmemberr7rrrget_value_from_list_nodes rxc@s8eZdZdZGdddeZddZddZdd Zd S) StdListPrinterzPrint a std::list.c@s$eZdZddZddZddZdS)zStdListPrinter._iteratorcCs"||_|d|_|j|_d|_dS)N_M_nextr) _nodetype_basers_head_count)rnodetypeheadrrrrXs z!StdListPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz!StdListPrinter._iterator.__iter__cCsR|j|jkrt|jj|jj}|d|_|j}|jd|_t|}d||fS)Nrzr)z[%d])r|r}rZrbr{rtr~rx)reltrErWrrrrs   z!StdListPrinter._iterator.__next__N)r r r rXrYrrrrr _iteratorsrcCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdListPrinter.__init__cCs(td|jjj}|j||jddS)N _List_node_M_impl_M_node)r8rVrrar)rrrrrr_szStdListPrinter.childrencCs0|jdd}|d|jkr&d|jSd|jS)Nrrrzzempty %sz%s)rVrsr])rZheadnoderrrrgs zStdListPrinter.to_stringN) r r r r rrrXr_rgrrrrrys ryc@seZdZddZddZdS)NodeIteratorPrintercCs$||_||_||_t||j|_dS)N)rVr] _contnamer8rr{)rrDrWZcontnamer6rrrrXszNodeIteratorPrinter.__init__cCs:|jdsd|jS|jdj|jjj}tt|S)Nrz(non-dereferenceable iterator for std::%s)rVrrbr{rartr!rx)rrlrrrrgs    zNodeIteratorPrinter.to_stringN)r r r rXrgrrrrrsrc@seZdZdZddZdS)StdListIteratorPrinterzPrint std::list::iterator.cCstj|||dddS)Nlistr)rrX)rrDrWrrrrXszStdListIteratorPrinter.__init__N)r r r r rXrrrrrsrc@seZdZdZddZdS)StdFwdListIteratorPrinterz"Print std::forward_list::iterator.cCstj|||dddS)N forward_list_Fwd_list_node)rrX)rrDrWrrrrXs z"StdFwdListIteratorPrinter.__init__N)r r r r rXrrrrrsrc@s8eZdZdZGdddeZddZddZdd Zd S) StdSlistPrinterzPrint a __gnu_cxx::slist.c@s$eZdZddZddZddZdS)zStdSlistPrinter._iteratorcCs||_|dd|_d|_dS)N_M_headrzr)r{r|r~)rrrrrrrXsz"StdSlistPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz"StdSlistPrinter._iterator.__iter__cCsL|jdkrt|jj|jj}|d|_|j}|jd|_d||dfS)Nrrzr)z[%d]rv)r|rZrbr{rtr~)rrrErrrrs   z"StdSlistPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs ||_dS)N)rV)rrDrWrrrrXszStdSlistPrinter.__init__cCs td|jj}|j|j|jS)Nz__gnu_cxx::_Slist_node)r8rVrrra)rrrrrr_szStdSlistPrinter.childrencCs|jdddkrdSdS)Nrrzrzempty __gnu_cxx::slistz__gnu_cxx::slist)rV)rrrrrgszStdSlistPrinter.to_stringN) r r r r rrrXr_rgrrrrrs rc@s eZdZdZddZddZdS)StdSlistIteratorPrinterz!Print __gnu_cxx::slist::iterator.cCs ||_dS)N)rV)rrDrWrrrrXsz StdSlistIteratorPrinter.__init__cCs<|jdsdStd|jjj}t|jdj|jdS)Nrz1non-dereferenceable iterator for __gnu_cxx::slistz__gnu_cxx::_Slist_noderv)rVr8rrar!rbrt)rrrrrrgs  z!StdSlistIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s@eZdZdZGdddeZddZddZdd Zd d Z d S) StdVectorPrinterzPrint a std::vector.c@s$eZdZddZddZddZdS)zStdVectorPrinter._iteratorcCs^||_|rH|d|_d|_|d|_|d|_|jjj}d|j|_n ||_||_d|_ dS)N_M_pr _M_offset) _bitvec_item_so_finish_fortrsizeof_isizer~)rstartfinishZbitvecityperrrrX s    z#StdVectorPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz#StdVectorPrinter._iterator.__iter__cCs|j}|jd|_|jr|j|jkr4|j|jkr4tt|jjd|j>@}|jd|_|j|j krv|jd|_d|_d||fS|j|jkrt|jj}|jd|_d||fSdS)Nr)rz[%d]) r~rrrrrrZboolrtr)rrErrrrrs         z#StdVectorPrinter._iterator.__next__N)r r r rXrYrrrrrr srcCs*t||_||_|jjdjtjk|_dS)Nr) r;r]rVrr4coderTYPE_CODE_BOOL_is_bool)rrDrWrrrrX0s zStdVectorPrinter.__init__cCs$|j|jdd|jdd|jS)Nr_M_start _M_finish)rrVr)rrrrr_6s zStdVectorPrinter.childrenc Cs|jdd}|jdd}|jdd}|jr|jddd}|jddd}|jddd}|jj}d|j}||||}|||}d|jt|t|fSd |jt||t||fSdS) NrrrZ_M_end_of_storagerrrz"%s of length %d, capacity %dz%s of length %d, capacity %d)rVrrtrrr]int) rrrendZforZbllengthZcapacityrrrrg;s   zStdVectorPrinter.to_stringcCsdS)Narrayr)rrrr display_hintMszStdVectorPrinter.display_hintN) r r r r rrrXr_rgrrrrrrs %rc@s eZdZdZddZddZdS)StdVectorIteratorPrinterzPrint std::vector::iterator.cCs ||_dS)N)rV)rrDrWrrrrXTsz!StdVectorIteratorPrinter.__init__cCs |jdsdSt|jdjS)NZ _M_currentz,non-dereferenceable iterator for std::vector)rVr!rt)rrrrrgWs z"StdVectorIteratorPrinter.to_stringN)r r r r rXrgrrrrrQsrc@s eZdZdZddZddZdS)StdBitIteratorPrinterz@Print std::vector's _Bit_iterator and _Bit_const_iterator.cCs ||_dS)N)rV)rrDrWrrrrX`szStdBitIteratorPrinter.__init__cCs.|jdsdSt|jdjd|jd>@S)Nrz2non-dereferenceable iterator for std::vectorr)r)rVrrt)rrrrrgcs zStdBitIteratorPrinter.to_stringN)r r r r rXrgrrrrr]src@s eZdZdZddZddZdS)StdBitReferencePrinterz#Print std::vector::reference.cCs ||_dS)N)rV)rrDrWrrrrXmszStdBitReferencePrinter.__init__cCs*|jdsdSt|jdj|jd@S)Nrz$invalid std::vector::referenceZ_M_mask)rVrrt)rrrrrgps z StdBitReferencePrinter.to_stringN)r r r r rXrgrrrrrjsrc@s8eZdZdZGdddeZddZddZdd Zd S) StdTuplePrinterzPrint a std::tuple.c@s0eZdZeddZddZddZddZd S) zStdTuplePrinter._iteratorcCsNt|dkr"t|djdrBdSn t|dkr2dSt|dkrBdStddS)Nrr)Z __tuple_baseTrFz4Top of tuple tree does not consist of a single node.)rrBrr )nodesrrr_is_nonempty_tuple}s   z,StdTuplePrinter._iterator._is_nonempty_tuplecCs:||_|jjj}|j|r0|jj|dj|_d|_dS)Nr)r}rrrrbr~)rrrrrrrXs   z"StdTuplePrinter._iterator.__init__cCs|S)Nr)rrrrrYsz"StdTuplePrinter._iterator.__iter__cCs|js t|jjj}t|dkr&tt|dkr:tdt|dkr`|jj|dj}d|_n&|jj|dj}|jj|dj|_|jd|_|jj}t|dks|djdkrd|jd|fSd|jd|dfSdS)Nrrz/Cannot parse more than 2 nodes in a tuple tree.r)rhz[%d]) r}rZrrrr rbr~r")rrimplrrrrrs$       z"StdTuplePrinter._iterator.__next__N)r r r staticmethodrrXrYrrrrrr|s  rcCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdTuplePrinter.__init__cCs |j|jS)N)rrV)rrrrr_szStdTuplePrinter.childrencCs(t|jjjdkrd|jSd|jS)Nrzempty %sz %s containing)rrVrrr])rrrrrgs zStdTuplePrinter.to_stringN) r r r r rrrXr_rgrrrrrys Erc@s0eZdZdZddZddZddZdd Zd S) StdStackOrQueuePrinterz!Print a std::stack or std::queue.cCst||_tj|d|_dS)Nc)r;r]rdefault_visualizer _visualizer)rrDrWrrrrXs zStdStackOrQueuePrinter.__init__cCs |jjS)N)rr_)rrrrr_szStdStackOrQueuePrinter.childrencCsd|j|jjfS)Nz%s wrapping: %s)r]rrg)rrrrrgsz StdStackOrQueuePrinter.to_stringcCst|jdr|jjSdS)Nr)hasattrrr)rrrrrs  z#StdStackOrQueuePrinter.display_hintN)r r r r rXr_rgrrrrrrs rc@s0eZdZdZddZddZddZdd Zd S) RbtreeIteratorzf Turn an RB-tree-based container (std::map, std::set etc.) into a Python iterable object. cCs2|ddd|_|dddd|_d|_dS)NrnrZ _M_node_countZ _M_header_M_leftr)_size_noder~)rZrbtreerrrrXszRbtreeIterator.__init__cCs|S)Nr)rrrrrYszRbtreeIterator.__iter__cCs t|jS)N)rr)rrrr__len__szRbtreeIterator.__len__cCs|j|jkrt|j}|jd|_|j|jkr|j}|jdrl|jd}xd|jdrh|jd}qNWnF|jd}x$||jdkr|}|jd}qzW|jd|kr|}||_|S)Nr)Z_M_rightrZ _M_parent)r~rrZrrt)rresultrlparentrrrrs$      zRbtreeIterator.__next__N)r r r r rXrYrrrrrrrs rc CsjyF|jjdj}|dkr"|dS|dkrD|jjd}t|d|SWn YnXtdt|jdS)z0Return the value held in an _Rb_tree_node<_Val>.r)Z_M_value_fieldrrrz!Unsupported implementation for %sN)rrr"r4rur r!)rlrwr7rrrget_value_from_Rb_tree_node s rc@s eZdZdZddZddZdS)StdRbtreeIteratorPrinterz2Print std::map::iterator, std::set::iterator, etc.cCs"||_td|jj}|j|_dS)N _Rb_tree_node)rVr8rra _link_type)rrDrWrrrrrX!sz!StdRbtreeIteratorPrinter.__init__cCs0|jdsdS|jdj|jj}tt|S)Nrz6non-dereferenceable iterator for associative container)rVrbrrtr!r)rrlrrrrg&s z"StdRbtreeIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdDebugIteratorPrinterz-Print a debug enabled version of an iterator.cCs ||_dS)N)rV)rrDrWrrrrX0sz StdDebugIteratorPrinter.__init__cCsbtjd}|jjjd}|jj|d}|std||_nd|_dS)Nrir)) r;r]rVrr4Z_elttyperrr)rrDrWsizerrrrXs zStdDequePrinter.__init__cCsx|jdd}|jdd}|d|dd}|d|d}|d|d}|j|||}d |jtt|fS) Nrrrrr)_M_last_M_cur_M_firstz %s with %s)rVrr]rlong)rrrZdelta_nZdelta_sZdelta_errrrrgszStdDequePrinter.to_stringcCs@|jdd}|jdd}|j|d|d|d|d|jS)Nrrrrrr)rVrr)rrrrrrr_szStdDequePrinter.childrencCsdS)Nrr)rrrrrszStdDequePrinter.display_hintN) r r r r rrrXrgr_rrrrrrs   rc@s eZdZdZddZddZdS)StdDequeIteratorPrinterzPrint std::deque::iterator.cCs ||_dS)N)rV)rrDrWrrrrXsz StdDequeIteratorPrinter.__init__cCs |jdsdSt|jdjS)Nrz+non-dereferenceable iterator for std::deque)rVr!rt)rrrrrg s z!StdDequeIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s(eZdZdZddZddZddZdS) StdStringPrinterz'Print a std::basic_string of some kind.cCs||_|jddk|_dS)Nz::__cxx11::basic_stringr)ri)rVfind _new_string)rrDrWrrrrXszStdStringPrinter.__init__cCs|jj}|jtjkr|j}|jdd}|jrL|jd}|j|jj}n<|j j}tj t |dj }|j|d}|j d}t|dr|j|dS|j|dS) NZ _M_dataplusrZ_M_string_lengthz::_Repr)Z _M_length lazy_string)r)rVrrr TYPE_CODE_REFrrrbr unqualifiedrr!rartrrstring)rrptrrZrealtypeZreptypeheaderrrrrgs      zStdStringPrinter.to_stringcCsdS)Nrr)rrrrr-szStdStringPrinter.display_hintN)r r r r rXrgrrrrrrsrcCs"|d}|d}|d}|||fS)z'Access the streambuf put area pointers.Z _M_out_begZ _M_out_curZ _M_in_endr) streambufpbasepptregptrrrraccess_streambuf_ptrs1src@s(eZdZdZddZddZddZdS) StdStringBufPrinterzPrint a std::basic_stringbuf.cCs ||_dS)N)rV)r_rWrrrrX<szStdStringBufPrinter.__init__cCsLt|j\}}}|rB| s"||kr2|j||dS|j||dS|jdS)N)rZ _M_string)rrVr)rrrrrrrrg?s zStdStringBufPrinter.to_stringcCsdS)Nrr)rrrrrIsz StdStringBufPrinter.display_hintN)r r r r rXrgrrrrrr9s rc@s(eZdZdZddZddZddZdS) StdStringStreamPrinterz Print a std::basic_stringstream.cCsZ||_||_dd|jjDd}tjd|j|jtjd|_ |j |djk|_ dS)NcSsg|]}|jr|jqSr)rr)r&frrrr(Xsz3StdStringStreamPrinter.__init__..rZ__streamz$__stream->rdbuf() _M_stringbuf) rVr]rrrZset_convenience_variablerbrsparse_and_eval _streambuf_was_redirected)rrDrWZbasetyperrrrXPs  zStdStringStreamPrinter.__init__cCs$|jrd|j|jjfS|jdS)Nz%s redirected to %sr)rr]rrtrV)rrrrrg]sz StdStringStreamPrinter.to_stringcCs|jr dSdS)Nr)r)rrrrrcsz#StdStringStreamPrinter.display_hintN)r r r r rXrgrrrrrrMs rc@s$eZdZddZddZddZdS)Tr1HashtableIteratorcCsj|d|_d|_|d|_t|jdj|_d|_x2|j|jkrd|j|j|_|jrVP|jd|_q4WdS)NZ _M_bucketsrZ_M_bucket_countZ_Noder))_buckets_bucket _bucket_countr%rra _node_typer)r hashtablerrrrXjs  zTr1HashtableIterator.__init__cCs|S)Nr)rrrrrYvszTr1HashtableIterator.__iter__cCs|jdkrt|jj|j}|jd}|jd|_|jdkr|jd|_x2|j|jkr~|j|j|_|jrpP|jd|_qNW|S)NrZ_M_vrzr))rrZrbrrtrrr)rrlrrrrrys    zTr1HashtableIterator.__next__N)r r r rXrYrrrrrris rc@s$eZdZddZddZddZdS)StdHashtableIteratorcCsR|dd|_|jjd}|jjdjd}tdt||r>dnd}|j|_dS) NZ_M_before_begin_M_nxtr) rzstd::__detail::_Hash_nodetrueZfalse)rrr4r2r!rar)rrr7cachedZ node_typerrrrXs   zStdHashtableIterator.__init__cCs|S)Nr)rrrrrYszStdHashtableIterator.__iter__cCsR|jdkrt|jj|jj}|d|_|dj}|j|jjdj}|jS)Nrrrr) rrZrbrrtrsrr4ra)rrvalptrrrrrs   zStdHashtableIterator.__next__N)r r r rXrYrrrrrrsrc@s<eZdZdZddZddZddZedd Zd d Z d S) Tr1UnorderedSetPrinterz1Print a std::unordered_set or tr1::unordered_set.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zTr1UnorderedSetPrinter.__init__cCs|jjdr|jS|jdS)Nzstd::tr1_M_h)r]r<rV)rrrr _hashtables z!Tr1UnorderedSetPrinter._hashtablecCs|jd}d|jt|fS)N_M_element_countz %s with %s)rr]r)rrErrrrgs z Tr1UnorderedSetPrinter.to_stringcCsd|S)Nz[%d]r)irrr _format_countsz$Tr1UnorderedSetPrinter._format_countcCs@t|jtj}|jjdr.t|t|jSt|t |jS)Nzstd::tr1) r r itertoolsrEr]r<rrrr)rcounterrrrr_s zTr1UnorderedSetPrinter.childrenN) r r r r rXrrgrrr_rrrrrs  rc@s\eZdZdZddZddZddZedd Zed d Z ed d Z ddZ ddZ dS)Tr1UnorderedMapPrinterz1Print a std::unordered_map or tr1::unordered_map.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zTr1UnorderedMapPrinter.__init__cCs|jjdr|jS|jdS)Nzstd::tr1r)r]r<rV)rrrrrs z!Tr1UnorderedMapPrinter._hashtablecCs|jd}d|jt|fS)Nrz %s with %s)rr]r)rrErrrrgs z Tr1UnorderedMapPrinter.to_stringccs&x |D]}x|D] }|VqWqWdS)Nr)rrrrrr_flattens  zTr1UnorderedMapPrinter._flattencCs|d|dfS)Nrrr)rrrr _format_onesz"Tr1UnorderedMapPrinter._format_onecCsd|S)Nz[%d]r)rrrrrsz$Tr1UnorderedMapPrinter._format_countcCsdt|jtj}|jjdr@|jt|jt|j }t ||S|jt|jt |j }t ||S)Nzstd::tr1) r rrrEr]r<r r rrrr)rr datarrrr_s  zTr1UnorderedMapPrinter.childrencCsdS)Nrr)rrrrrsz#Tr1UnorderedMapPrinter.display_hintN) r r r r rXrrgrr r rr_rrrrrr s    r c@s8eZdZdZGdddeZddZddZdd Zd S) StdForwardListPrinterzPrint a std::forward_list.c@s$eZdZddZddZddZdS)zStdForwardListPrinter._iteratorcCs||_|d|_d|_dS)Nrzr)r{r|r~)rrrrrrrXs z(StdForwardListPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz(StdForwardListPrinter._iterator.__iter__cCsl|jdkrt|jj|jj}|d|_|j}|jd|_|dj}|j|jjdj }d||jfS)Nrrzr)rrz[%d]) r|rZrbr{rtr~rsrr4ra)rrrErrrrrs    z(StdForwardListPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs||_t||_dS)N)rVr;r])rrDrWrrrrXszStdForwardListPrinter.__init__cCs(td|jjj}|j||jddS)Nrrr)r8rVrrar)rrrrrr_szStdForwardListPrinter.childrencCs*|jddddkr d|jSd|jS)Nrrrzrzempty %sz%s)rVr])rrrrrgs zStdForwardListPrinter.to_stringN) r r r r rrrXr_rgrrrrrs rc@sBeZdZdZd ddZddZGdddeZd d Zd d Z dS)SingleObjContainerPrinterz8Base class for printers of containers of single objects.NcCs||_||_||_dS)N)_contained_valuer_hint)rrWZvizZhintrrrrXsz"SingleObjContainerPrinter.__init__cCs(ts t|Stjjtjj|p&t|S)z5Return type as a string after applying type printers.)_use_type_printingr!rtypesapply_type_recognizersget_type_recognizers)rrrrr _recognizesz$SingleObjContainerPrinter._recognizec@s$eZdZddZddZddZdS)z$SingleObjContainerPrinter._containedcCs ||_dS)N)rV)rrWrrrrXsz-SingleObjContainerPrinter._contained.__init__cCs|S)Nr)rrrrrY"sz-SingleObjContainerPrinter._contained.__iter__cCs"|jdkrt|j}d|_d|fS)Nz[contained value])rVrZ)rZretvalrrrr%s  z-SingleObjContainerPrinter._contained.__next__N)r r r rXrYrrrrr _containedsrcCs6|jdkr|jdSt|jdr*|jjS|j|jS)Nr_)rrrrr_)rrrrr_,s     z"SingleObjContainerPrinter.childrencCs(t|jdr"t|jdr"|jjS|jS)Nr_r)rrrr)rrrrr3s   z&SingleObjContainerPrinter.display_hint)N) r r r r rXrrrr_rrrrrrs  rc CsH|jj}tjddkr"t|}nt|}ytj|jj SdSdS)z{Find the name of the function referred to by the gdb.Value f, which should contain a function pointer from the program.rrN) rtrsrFrGrrrZ block_for_pcfunctionr")rrrrfunction_pointer_to_name;s  rcs4eZdZdZfddZddZeddZZS)StdExpAnyPrinterz+Print a std::any or std::experimental::any.c st||_t|j|_||_d|_d}d}|jd}|dkrt|}|sXtd|jdj|}tj ||}|std|j|j d} d| kr g} xPt j D]D} y(tj d| |j d} | jtj| Wqtjk rYqXqWt| dkrtd | d} n tj| } | jd|_d}d | kr@|jd d j}n(d | krZ|jd d}ntd|j|j|jjj}tj|}tt |j||dS)NZ _M_managerrzInvalid function pointer in %szi({0}::_Manager_\w+<.*>)::_S_manage\((enum )?{0}::_Op, (const {0}|{0} const) ?\*, (union )?{0}::_Arg ?\*\)zUnknown manager function in %sr)z std::stringzstd::string(?!\w)z;Cannot uniquely determine std::string type used in std::anyz::_Manager_internalrrZ _M_bufferz::_Manager_externalr\)r;r]rKrV_contained_typerr r*r>r?groupr _string_typesrHrPrrr,rr4rsrbrartrsuperrX)rrDrWcontained_value visualizerZmgrfuncZrxmZmgrnameZmgrtypessr@Zmgrtyper) __class__rrrXVsX                 zStdExpAnyPrinter.__init__cCsT|jdkrd|jSd|j}t|jdr8||jjS|j|j}|tt|S)Nz%s [no contained value]z%s containing r_)rr]rrrgrr;r!)rdescr7rrrrgs     zStdExpAnyPrinter.to_stringcs@ttjdjh}ddddtg}|fdd|DO}|S)Nz std::stringzAbasic_string, std::allocator >zstd::zstd::__cxx11::csh|] }|qSrr)r&q)r#rr sz1StdExpAnyPrinter._string_types..)r!rrrr-)ZstringsZqualsr)r#rrs  zStdExpAnyPrinter._string_types) r r r r rXrgrr __classcell__rr)r$rrSs D rcs(eZdZdZfddZddZZS)StdExpOptionalPrinterz5Print a std::optional or std::experimental::optional.c st||_t|j|_|d}|jjdr8|d}|}n*|d}|d}y |d}Wn YnXtj|}|std}tt|j||dS)N _M_payloadzstd::experimental _M_engaged_M_value) r;r]rKr<rrrr)rX)rrDrWZpayloadZengagedrr )r$rrrXs"      zStdExpOptionalPrinter.__init__cCs:|jdkrd|jSt|jdr4d|j|jjfS|jS)Nz%s [no contained value]r_z%s containing %s)rr]rrrg)rrrrrgs    zStdExpOptionalPrinter.to_string)r r r r rXrgr(rr)r$rr)s r)cs(eZdZdZfddZddZZS)StdVariantPrinterzPrint a std::variant.cst|j}t||_|d|_|jt|krz[%s])rrrZrtr~r7r@r=)rrrEr?r0rrrrRs    z$StdExpPathPrinter._iterator.__next__N)r r r rXrYrrrrrrHsrcCs|j|jd|jS)Nr8)rrVr])rrrrr__szStdExpPathPrinter.childrenN) r r r r rXr=rgrrr_rrrrr7.s r7c@s@eZdZdZddZddZddZGdd d eZd d Z d S) StdPathPrinterzPrint a std::filesystem::path.cCsP||_||_t|jdd}|jtjdd@|_|jdkrF||_nd|_dS)Nr8rZ uintptr_tr)rVr]rprbrrr_impl)rrDrWrrrrrXfs zStdPathPrinter.__init__cCsHt|jjtj|jd}|dddkr0dS|d ddkrDdSdS) Nz::_Typerr:zroot-directoryr;r<z root-nameii)r!rrbrrr])rr0rrrr=ps zStdPathPrinter._path_typecCs8d|jd}|jdkr0|j}|r0d||f}d|S)Nz%sr>rz%s [%s]zfilesystem::path %s)rVrr=)rr?r0rrrrgxs   zStdPathPrinter.to_stringc@s$eZdZddZddZddZdS)zStdPathPrinter._iteratorc Cs||_|rtjd}tj|d}tjd}|j|j}|j}ttjdrbtd|j |j }n d|j }|j|j|}|j|j|_ |j ||_ d|_ n d|_ d|_ dS)Nrz::_Cmptcharalignofrr)r@rrrbrartrr:maxrrFrrr~) rrrAZint_typeZ cmpt_type char_typerZ sizeof_ImplbeginrrrrXs      z!StdPathPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz!StdPathPrinter._iterator.__iter__cCsd|j|jkrt|jj}|j}|jd|_|jd|_|d}t|j|j}|sX|}d||fS)Nr)r>z[%s])rrrZrtr~rBr@r=)rrrEr?r0rrrrs    z!StdPathPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs|j|j|jS)N)rrDr])rrrrr_szStdPathPrinter.childrenN) r r r r rXr=rgrrr_rrrrrBcs  (rBc@s8eZdZdZddZGdddeZddZdd Zd S) StdPairPrinterz@Print a std::pair object, with 'first' and 'second' as children.cCs ||_dS)N)rV)rrDrWrrrrXszStdPairPrinter.__init__c@s(eZdZdZddZddZddZdS) zStdPairPrinter._iterz?An iterator for std::pair types. Returns 'first' then 'second'.cCs||_d|_dS)Nr)rV_which)rrWrrrrXszStdPairPrinter._iter.__init__cCs|S)Nr)rrrrrYszStdPairPrinter._iter.__iter__cCs8|jdkrt|j}|dkr$d|_nd|_||j|fS)Nrr)rKrZrV)rZwhichrrrrs zStdPairPrinter._iter.__next__N)r r r r rXrYrrrrrrsrcCs |j|jS)N)rrV)rrrrr_szStdPairPrinter.childrencCsdS)Nr)rrrrrgszStdPairPrinter.to_stringN) r r r r rXrrr_rgrrrrrJs rJc@s eZdZdZddZddZdS)StdCmpCatPrinterz#Print a comparison category object.cCs&||jddd|_|d|_dS)N:r)r,)rfindr]rV)rrDrWrrrrXszStdCmpCatPrinter.__init__cCsJ|jdkr|jdkrd}n"ddd ddddd i}|t|j}d j|j|S) Nstrong_orderingrZequalrZ unorderedr)ZlessZ equivalentZgreaterz std::{}::{}ri)r]rVrr*)rr"namesrrrrgs zStdCmpCatPrinter.to_stringN)r r r r rXrgrrrrrLsrLc@s`eZdZdZdZddZeddZeddZ ed d Z ed d Z ed dZ ddZ dS)StdErrorCodePrinterz0Print a std::error_code or std::error_condition.Nc CsL||_t||_tjdkrHyddl}dt_Wntk rFdt_YnXdS)NrTF)rVr;r]rQ_system_is_posixposix ImportError)rrDrWrSrrrrXs   zStdErrorCodePrinter.__init__cCs&tj|}|dk r"|jtjkr"|SdS)N)rrrZTYPE_CODE_ENUM)r"r#rrr_find_errc_enums z#StdErrorCodePrinter._find_errc_enumc CsBxs(     zStdErrorCodePrinter.to_string)r r r r rRrXrrU classmethodrXr]rdrfrgrrrrrQs   + rQc@s eZdZdZddZddZdS)StdRegexStatePrinterz/Print a state node in the NFA for a std::regex.cCs||_||_dS)N)rVr])rrDrWrrrrX[szStdRegexStatePrinter.__init__cCst|jd}|r|dd}|jd}dddddddddddddd }||}d j||}|dk r|jd |dk rd j|||jd |}d |S) NZ _M_opcoderzZaltZsubexprnegZ backref_index) repeat alternativeZ subexpr_beginZ subexpr_endZline_begin_assertionZline_end_assertionZ word_boundaryZsubexpr_lookaheadZbackrefr?ZacceptZdummyunknownzopcode={}, next={}Z_M_z {}, {}={}z{%s})r!rVr*)rZopcodeZnext_idZvariantsvr#rrrrg_s     zStdRegexStatePrinter.to_stringN)r r r r rXrgrrrrrlXsrlc@s@eZdZdZGdddeZddZddZdd Zd d Z d S) StdSpanPrinterzPrint a std::span.c@s$eZdZddZddZddZdS)zStdSpanPrinter._iteratorcCsd|_||_||_dS)Nr)r~_beginr)rrIrrrrrXysz!StdSpanPrinter._iterator.__init__cCs|S)Nr)rrrrrY~sz!StdSpanPrinter._iterator.__iter__cCs8|j|jkrt|j}|jd|_d||j|jfS)Nr)z[%d])r~rrZrtrt)rrErrrrs   z!StdSpanPrinter._iterator.__next__N)r r r rXrYrrrrrrxsrcCsLt||_||_tjd}|jjd|kr:|dd|_n|jjd|_dS)Nzstatic_cast(-1)r)Z _M_extentZ_M_extent_value)r;r]rVrrrr4r)rrDrWZsize_maxrrrrXs   zStdSpanPrinter.__init__cCsd|j|jfS)Nz%s of length %d)r]r)rrrrrgszStdSpanPrinter.to_stringcCs|j|jd|jS)Nr\)rrVr)rrrrr_szStdSpanPrinter.childrencCsdS)Nrr)rrrrrszStdSpanPrinter.display_hintN) r r r r rrrXrgr_rrrrrrsus  rsc@s0eZdZdZddZddZddZdd Zd S) StdInitializerListPrinterzPrint a std::initializer_list.cCs||_||_|d|_dS)Nr6)r]rVr)rrDrWrrrrXsz"StdInitializerListPrinter.__init__cCsd|j|jfS)Nz%s of length %d)r]r)rrrrrgsz#StdInitializerListPrinter.to_stringcCstj|jd|jS)NZ_M_array)rsrrVr)rrrrr_sz"StdInitializerListPrinter.childrencCsdS)Nrr)rrrrrsz&StdInitializerListPrinter.display_hintN)r r r r rXrgr_rrrrrrus ruc@s(eZdZdZddZddZddZdS) StdAtomicPrinterzPrint a std:atomic.cCsrt||_||_d|_|jjjd|_|jjdk rnt|jj}|jdsR|jdrn|d}t |||_|j |_ dS)Nrzstd::shared_ptr = { %s }) rwrgr1rrZ TYPE_CODE_INTrV TYPE_CODE_FLT TYPE_CODE_PTRrr]r!)rrWrrrrgs     zStdAtomicPrinter.to_stringN)r r r r rXrxrgrrrrrvs rvc@s eZdZdZddZddZdS)StdFormatArgsPrinterzPrint a std::basic_format_args.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdFormatArgsPrinter.__init__cCst|jj}t|dd}|tjdkr0d}n|tjdkrDd}nd}|jd}|dkrbd |S|dkrt|jd }d ||fS) Nrr)rEzstd::format_argswchar_tzstd::wformat_argszstd::basic_format_argsZ_M_packed_sizez%s with 1 argumentZ_M_unpacked_sizez%s with %d arguments)rTrVrrr)rZtargsrHr#rrrrrgs   zStdFormatArgsPrinter.to_stringN)r r r r rXrgrrrrr{sr{c@s0eZdZdZddZddZddZdd Zd S) StdChronoDurationPrinterzPrint a std::chrono::duration.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z!StdChronoDurationPrinter.__init__cCs*|jjjd}|jd}|jd}||fS)Nr)r)rVrr4)rZperiodrdenrrr_ratios  zStdChronoDurationPrinter._ratiocCs|j\}}|dkrF|dkr dS|dkr,dS|dkr8dS|dkr|dSn6|dkr||d krZd S|d krfd S|d krrdSdj|Sdj||S)Nr)r#iZmsi@Busiʚ;rW<minihiQdz[{}]sz[{}/{}]s)rr*)rrr~rrr_suffixs&  z StdChronoDurationPrinter._suffixcCs4|jd}|jjjtjkr$d|}dj||jS)N__rz%gz"std::chrono::duration = {{ {}{} }})rVrrrrryr*r)rrrrrrgs z"StdChronoDurationPrinter.to_stringN)r r r r rXrrrgrrrrr}s r}c@s*eZdZdZddZddZd ddZd S) StdChronoTimePointPrinterz Print a std::chrono::time_point.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z"StdChronoTimePointPrinter.__init__cCsv|jjjd}t|j}|dks(|dkr,dS|dkr8dS|dkrDdS|d krPdS|d kr\dS|dkrhdSdj|dfS)Nrzstd::chrono::_V2::system_clockzstd::chrono::system_clockstd::chrono::sys_timezstd::chrono::utc_clockstd::chrono::utc_timezstd::chrono::gps_clockstd::chrono::gps_timezstd::chrono::tai_clockstd::chrono::tai_timezstd::filesystem::__file_clockstd::chrono::file_timeumzstd::chrono::local_tstd::chrono::local_timez {} time_point)rr)rN)rN)rN)rr)rr)rVrr4r;r"r*)rclockr"rrr_clocks  z StdChronoTimePointPrinter._clockFc Cs|j\}}|jd}|d}t|jj|}|j}d}|dk r|j\} } || | |} ytjj| t } dj | }Wn YnXd|||f} |r| Sd|| fS)NZ__drrCz [{:%Y-%m-%d %H:%M:%S}]z%d%s%sz %s = { %s }) rrVr}rr"rrrZ fromtimestamp _utc_timezoner*)rZabbrevroffsetrrprintersuffixtimerr~Zsecsrr#rrrrg1s$   z#StdChronoTimePointPrinter.to_stringN)F)r r r r rXrrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoZonedTimePrinterz Print a std::chrono::zoned_time.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXIs z"StdChronoZonedTimePrinter.__init__cCs@|jdjd}|jd}t|jj|}|jd}dj||S)NZ_M_zone_M_nameZ_M_tpTz%std::chrono::zoned_time = {{ {} {} }})rVrtrrr"rgr*)rZzonerrrrrrgMs   z#StdChronoZonedTimePrinter.to_stringN)r r r r rXrgrrrrrFsrZJanuaryZFebruaryZMarchZAprilZMayZJuneZJulyZAugustZ SeptemberZOctoberZNovemberZDecemberZSundayZMondayZTuesdayZ WednesdayZThursdayZFridayZSaturdayc@s eZdZdZddZddZdS)StdChronoCalendarPrinterzDPrint a std::chrono::day, std::chrono::month, std::chrono::year etc.cCst||_||_dS)N)r;r]rV)rrDrWrrrrX_s z!StdChronoCalendarPrinter.__init__c Csv|j}|j}d|kr$|dkr$|d}|jdr6|d}|dkrPdjt|dS|d kr||d ksl|ttkrtd |St|S|dkrd j|S|d kr|d}|dks|ttkrd|Sdjt|S|dkrdj|dt|dS|dkrdj|dS|dkrdj||dS|dkr,dj|S|dkrFdj||dS|dkr`dj||dS|dkrvdj||S|dkrd j|||dS|dkrdj||d!S|d"krd j|||dS|d#krd j|||dS|jd$rrd%}|d&dkr"d'jt|d(d)t|d&}t|d*d+}t|dd+}t|d,d+}|d-rb| }d.j||||SdS)/Nmonthz std::chrono::year_month_day_lastZ_M_mzstd::chrono::yearZ_M_yzstd::chrono::dayz{}Z_M_dzstd::chrono::monthr)z%d is not a valid monthz{}yzstd::chrono::weekdayZ_M_wdrz%d is not a valid weekdayzstd::chrono::weekday_indexedz{}[{}]r.zstd::chrono::weekday_lastz{}[last]zstd::chrono::month_dayz{}/{}zstd::chrono::month_day_lastz{}/lastzstd::chrono::month_weekdayZ_M_wdizstd::chrono::month_weekday_lastZ_M_wdlzstd::chrono::year_monthzstd::chrono::year_month_dayz{}/{}/{}Z_M_mdlzstd::chrono::year_month_weekdayz$std::chrono::year_month_weekday_lastzstd::chrono::hh_mm_ssrCZfractional_widthz.{:0{}d}Z_M_ssZ_M_rrr_M_sZ _M_is_negz{:02}:{:02}:{:02}{})rVr]r<r*rrmonthsweekdays) rrWr#r"yZwdZfractrr#rrrrgcsh               z"StdChronoCalendarPrinter.to_stringN)r r r r rXrgrrrrr\src@s eZdZdZddZddZdS)StdChronoTimeZonePrinterz4Print a chrono::time_zone or chrono::time_zone_link.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z!StdChronoTimeZonePrinter.__init__cCs6d|j|jdf}|jjdr2|d|jd7}|S)Nz%s = %srZ_linkz -> %sZ _M_target)r]rVrb)rr!rrrrgs z"StdChronoTimeZonePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoLeapSecondPrinterzPrint a chrono::leap_second.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z#StdChronoLeapSecondPrinter.__init__cCs.|jdd}d|dk}d|jt||fS)Nrrz+-rz %s %d (%c))rVr]abs)rZdaternrrrrgs z$StdChronoLeapSecondPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoTzdbPrinterzPrint a chrono::tzdb.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdChronoTzdbPrinter.__init__cCsd|j|jdfS)Nz%s %sversion)r]rV)rrrrrgszStdChronoTzdbPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoTimeZoneRulePrinterzPrint a chrono::time_zone rule.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z%StdChronoTimeZoneRulePrinter.__init__c Cs|jd}|d}t|d}dddddddd}|d}d j||j|d }|d krdd j||}nVt|d }|dkrdj||}n4|dkrd} nd} |d}dj| d || d||}dj|jd|jd|jd|S)NonkindrstZndZrd)r)rrCZ day_of_monthz{}{}Zthrz{} {}Z day_of_weekr)z last {} in {}rr<=r>=z{} {} {} {} {}z.time_zone rule {} from {} to {} starting on {}r"fromZto)rr)rr)rVrr*getr) rrrrsuffixesdayZ ordinal_dayrweekday directionrrrrgs*    z&StdChronoTimeZoneRulePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdLocalePrinterzPrint a std::locale.cCs||_||_dS)N)rVr])rrDrWrrrrXszStdLocalePrinter.__init__csx|jdd}d}|ddkr&d}nFtj|jd}tj|jd}|dj}|dj}dj||}||i}d } xN| |kr|| dkr|| j}|| j}d j|||}|||<| d } qxWt|j} t| d kr|}nt| d krl| \} } t |j} d| j | d kr$| }| n| j | d kr<| }| dk rlt fd d |j D}dj|}dj||S)NrZ_M_namesrCr*z::_S_categoriesz::_S_categories_sizez{}={}r)z{};{}={}rc3s|]\}}|kr|VqdS)Nr)r&rrR)otherrr sz-StdLocalePrinter.to_string..z with "{}={}"zstd::locale = "{}"{}) rVrrr]rr*r4valuesrrrEritems)rrPmodr"ZcatsZncatrRr[Z cat_namesrZ uniq_namesZn1Zn2Z name_listr)rrrgsD            zStdLocalePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdIntegralConstantPrinterz*Print a std::true_type or std::false_type.cCs||_||_dS)N)rVr])rrDrWrrrrX sz#StdIntegralConstantPrinter.__init__cCsL|jjjd}|jjjd}|jtjkr4|r0dSdSt|j}dj|||S)Nrr)zstd::true_typezstd::false_typez {}<{}, {}>) rVrr4rrrr;r]r*)rr3rZrDrrrrg s  z$StdIntegralConstantPrinter.to_stringN)r r r r rXrgrrrrr src@s eZdZdZddZddZdS)StdTextEncodingPrinterzPrint a std::text_encoding.cCs||_||_dS)N)rVr])rrDrWrrrrX$ szStdTextEncodingPrinter.__init__cCs<|jdj}|ddkr$|jdS|ddkr4dS|dS)NZ_M_repZ_M_idr)rrrq)rVrt)rZreprrrrg( s    z StdTextEncodingPrinter.to_stringN)r r r r rXrgrrrrr! srcs$eZdZfddZddZZS) RxPrintercs$tt|j||_||_d|_dS)NT)rrrXr" _functionenabled)rr"r)r$rrrX3 szRxPrinter.__init__cCs:|js dS|jjtjkr,ttjdr,|j}|j|j |S)Nreferenced_value) rrrrrrValuerrr")rrZrrrinvoke9 s  zRxPrinter.invoke)r r r rXrr(rr)r$rr2 s rcsHeZdZfddZddZddZddZed d Zd d Z Z S) Printercs6tt|j||_g|_i|_d|_tjd|_ dS)NTz^([a-zA-Z0-9_:]+)(<.*>)?$) rrrXr" _subprinters_lookuprr>compile _compiled_rx)rr")r$rrrXH s zPrinter.__init__cCs<|jj|std|t||}|jj|||j|<dS)Nz0libstdc++ programming error: "%s" does not match)rr?r rrrPr)rr"rrrrraddP s     z Printer.addcCs>|j|||d|kr:tjddt|}|j|||dS)N__cxx11z^(std|__gnu_cxx)::z\g<0>%s)rr>rHr-)rbaser"rZvbaserrr add_version[ s  zPrinter.add_versioncCs$|j||||j|d||dS)Nz __cxx1998::)r)rrr"rrrr add_containerc szPrinter.add_containercCs&|jtjkr|j}|jj}|jS)N)rrrrrrr)rrrrget_basic_typeg s  zPrinter.get_basic_typecCsr|j|j}|sdS|jj|}|s(dS|jd}|jjtjkrTttj drT|j }||j krn|j |j |SdS)Nr)r) rrrr?rrrrrrrrr)rrWrDr?basenamerrr__call__r s     zPrinter.__call__) r r r rXrrrrrrr(rr)r$rrG s    rc@s0eZdZdZddZGdddeZddZdS) TemplateTypePrinteral A type printer for class templates with default template arguments. Recognizes specializations of class templates and prints them without any template arguments that use a default template argument. Type printers are recursively applied to the template arguments. e.g. replace 'std::vector >' with 'std::vector'. cCs||_||_d|_dS)NT)r"_defargsr)rr"defargsrrrrX szTemplateTypePrinter.__init__c@s(eZdZdZddZddZddZdS) zTemplateTypePrinter._recognizerz-The recognizer class for TemplateTypePrinter.cCs||_||_dS)N)r"r)rr"rrrrrX sz(TemplateTypePrinter._recognizer.__init__c Cs|jdkrdS|jj|js dSt|}g}d}xtt|D]}||}|jj|}|dk r|j|}y|t j |kr|dSWn$t j k r|j|krdSYnXd}q>|rdS|j |j |q>W|jd|jjd}t|}|ddj|dS)a If type_obj is a specialization of self.name that uses all the default template arguments for the class template, then return a string representation of the type without default arguments. Otherwise, return None. NFTr)rr<r"rTrangerrrr*rrr,rP_recognize_subtyperrOr+) rrQrSZdisplayed_argsZrequire_defaultedrRrfZdefargrArrr recognize s2     z)TemplateTypePrinter._recognizer.recognizecCs|jtjkr|j|jdS|jtjkrj|j|j}t|jjdrR|dSd||j ddfS|jtj kr|j|jdSt tdr|jtj kr|j|jdStj jtj j|}|r|St|S)zxConvert a gdb.Type to a string by applying recognizers, or if that fails then simply converting to a string.rz[]z%s[%d]r)&TYPE_CODE_RVALUE_REFz&&)rrrzrrrr!rrbrrrrrrr)rrQrNrrrr s"     z2TemplateTypePrinter._recognizer._recognize_subtypeN)r r r r rXrrrrrr _recognizer s1rcCs|j|j|jS)z1Return a recognizer object for this type printer.)rr"r)rrrr instantiate szTemplateTypePrinter.instantiateN)r r r r rXobjectrrrrrrr s Prcstd||}tjj||td||}tjj||d|krdttfdd|jD}t||}tjj||td||}tjj||dS)a Add a type printer for a class template with default template arguments. Args: name (str): The template-name of the class template. defargs (dict int:string) The default template arguments. Types in defargs can refer to the Nth template-argument using {N} (with zero-based indices). e.g. 'unordered_map' has these defargs: { 2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator >' } zstd::zstd::__debug::rc3s"|]\}}||jdfVqdS)zstd::N)r.)r&rRr)rWrrr sz0add_one_template_type_printer..N)rrrregister_type_printerr-dictr)objr"rrr)rWradd_one_template_type_printer s rc@s2eZdZdZd ddZGdddeZddZdS) FilteringTypePrintera A type printer that uses typedef names for common template specializations. Args: template (str): The class template to recognize. name (str): The typedef-name that will be used instead. targ1 (str, optional): The first template argument. Defaults to None. Checks if a specialization of the class template 'template' is the same type as the typedef 'name', and prints it as 'name' instead. e.g. if an instantiation of std::basic_istream is the same type as std::istream then print it as std::istream. If targ1 is provided (not None), match only template specializations with this type as the first template argument, e.g. if template='basic_string' and targ1='char' then only match 'basic_string' and not 'basic_string'. This rejects non-matching specializations more quickly, without needing to do GDB type lookups. NcCs||_||_||_d|_dS)NT) _templater"_targ1r)rtemplater"targ1rrrrX- szFilteringTypePrinter.__init__c@s eZdZdZddZddZdS)z FilteringTypePrinter._recognizerz.The recognizer class for FilteringTypePrinter.cCs||_||_||_d|_dS)N)rr"r _type_obj)rrr"rrrrrX6 sz)FilteringTypePrinter._recognizer.__init__c Cs|jdkrdS|jdkrz|jdk rDdj|j|j}|jj|sVdSn|jj|jsVdSytj|jj |_Wn YnX|jdkrdStj j |j}tj j |}||krt |jS|jj dddkr|jjjdd}|jjdd}||krt |jSdS) z If type_obj starts with self._template and is the same type as self.name then return self.name, otherwise None. Nz{}<{}z::r) basic_stringz __cxx11::rCri)rrrr*rr<rrr"rrrrOrer.)rrQr#Zt1Zt2s1s2rrrr< s4        z*FilteringTypePrinter._recognizer.recognizeN)r r r r rXrrrrrr3 srcCs|j|j|j|jS)z1Return a recognizer object for this type printer.)rrr"r)rrrrrf sz FilteringTypePrinter.instantiate)N)r r r r rXrrrrrrrr s 3rcCsXtd|d||}tjj||d|krTdt}t|||||}tjj||dS)Nzstd::r)rrrrr-)rrr"rrrWrrradd_one_type_printerk s rc CsdtsdSxxdgD]p}t|d |d d |dt|d|d d |dt|dd|d d |dt|d|d d|dqWxdjD]|}x*dkD]"}t|d||d ||dqWxJdlD]B}t|d||d ||dt|d!||d ||dqWqWxdmD]}x0dpD](}t||d"||d d#|dqWxNdqD]F}t||d(||d)x&drD]}t||||||qlWqJWqWt|d-d.xdsD]}t|d9d:|qWt|d;d<t|d;d=t|d>d?t|d>d@t|dAdBt|dAdCt|dDdEt|dDdFt|dGdHdI}x0dyD](}t||d||d d|dqdequezstd::allocator<{0}>rrz __cxx11::listvectorrzstd::less<{0}>z)std::allocator>)rrCmultimapr4)r)rmultiset unordered_mapzstd::hash<{0}>zstd::equal_to<{0}>)rrCunordered_multimap unordered_set)r)rrCunordered_multisetrCrErr|rrrrrr)rrrrrrCrErr|)rr) rrrrrrrrr)rrrr)rCrrCrErr|)rr )rr#rr)rrr) rrrrr r r r r rrCrErr|rrrrrr)r!r"r#r$r%)rrr)rZchr@abiZdurrWrrrregister_type_printerst s "(     *                   r'cCs8trtjj|tn|dkr t}|jjtt|dS)z4Register libstdc++ pretty-printers with objfile Obj.N) _use_gdb_pprZprintingZregister_pretty_printerlibstdcxx_printerZpretty_printersrPr')rrrrregister_libstdcxx_printers s  r*cCsXtdatjddttjddttjddttjddttjddttjddttjddttjdd ttjdd t tjdd t tjdd t tjdd t tjddt tjddt tjddt tjddt tjddttjddtttjdr.tjddttjddttjdttjdttjdttjdttjdttjdt tjdt tjdttjddttjdd ttjdd!ttjdd"ttjdd#ttjdd$ttjdd%ttjd&dttjd&d ttjd&d!ttjd&d"ttjd&d#ttjd&d$ttjdd'ttjdd(ttjdd)ttjdd)tx2doD]*}tjdd-|ttjdd-|tqWtjd.d/ttjd.d0ttjdd1ttjd2d3t tjd4ttjd5ttjd6ttjd7ttjd8ttjd9d:t!tjd9d;t"tjd9dt$tjd?d>t$tjd@d>t%tjdAd>t%tjdd:t!tjdd;t"tjddrFrirrGrrrr ziprrrZtimezoneZutcrZtzinforr(Z gdb.printingrTrZ gdb.typesrrrZ printer_baser%r-r2r8r5rBr;rKrOrTrUr[rkrmrprqrurxryrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrr)r-r0r5r7rBrJrLrQrlrsrurvr{r}rrrrrrrrrrrrrrr)rrrrr'r*r;rrrrs      %   (&"I  U(*$/A " /%-^!,5I!{'$*/ ?  ",Ce%T oTPKr1]e7python/libstdcxx/v6/__pycache__/xmethods.cpython-36.pycnu[3 hq@sddlZddlZddlZdZddZddZdZdd ZGd d d ejj Z Gd d d ejj Z Gddde Z Gddde ZGddde ZGddde ZGddde ZGddde ZGdddejjZGdddejj ZGdddeZGd d!d!eZGd"d#d#eZGd$d%d%eZGd&d'd'eZGd(d)d)eZGd*d+d+ejjZGd,d-d-ejjZGd.d/d/eZGd0d1d1eZGd2d3d3ejjZ Gd4d5d5ejj Z!Gd6d7d7e!Z"Gd8d9d9e!Z#Gd:d;d;e!Z$Gdd?d?ejjZ&Gd@dAdAejj Z'GdBdCdCe'Z(GdDdEdEe'Z)GdFdGdGe'Z*GdHdIdIe'Z+GdJdKdKe'Z,GdLdMdMe'Z-GdNdOdOejjZ.GdPdQdQejj Z/GdRdSdSe/Z0GdTdUdUe/Z1GdVdWdWejjZ2GdXdYdYejj Z3GdZd[d[e3Z4Gd\d]d]e3Z5Gd^d_d_ejjZ6Gd`dadaejj Z7Gdbdcdce7Z8Gdddedee7Z9Gdfdgdgejj Z:Gdhdidie:Z;GdjdkdkejjZ$N) isinstancerZTypetag_versioned_namespacerematch)xZ template_namerrris_specialization_of!s  rc@seZdZddZdS)LibStdCxxXMethodcCstjjj||||_dS)N)rxmethodXMethod__init__ worker_class)selfnamerrrrr.szLibStdCxxXMethod.__init__N)__name__ __module__ __qualname__rrrrrr-src@seZdZddZddZdS)ArrayWorkerBasecCs||_||_dS)N) _val_type_size)rval_typesizerrrr6szArrayWorkerBase.__init__cCstjd}|j|jjjS)Nz (void *) 0)rZparse_and_evalcastrpointer dereference)rZnullptrrrr null_value:s zArrayWorkerBase.null_valueN)rrrrr"rrrrr5src@s,eZdZddZddZddZddZd S) ArraySizeWorkercCstj|||dS)N)rr)rrrrrrr@szArraySizeWorker.__init__cCsdS)Nr)rrrr get_arg_typesCszArraySizeWorker.get_arg_typescCstS)N)r)robjrrrget_result_typeFszArraySizeWorker.get_result_typecCs|jS)N)r)rr%rrr__call__IszArraySizeWorker.__call__N)rrrrr$r&r'rrrrr#?sr#c@s,eZdZddZddZddZddZd S) ArrayEmptyWorkercCstj|||dS)N)rr)rrrrrrrNszArrayEmptyWorker.__init__cCsdS)Nr)rrrrr$QszArrayEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&Tsz ArrayEmptyWorker.get_result_typecCst|jdkS)Nr)intr)rr%rrrr'WszArrayEmptyWorker.__call__N)rrrrr$r&r'rrrrr(Msr(c@s,eZdZddZddZddZddZd S) ArrayFrontWorkercCstj|||dS)N)rr)rrrrrrr\szArrayFrontWorker.__init__cCsdS)Nr)rrrrr$_szArrayFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&bsz ArrayFrontWorker.get_result_typecCs&t|jdkr|ddS|jSdS)Nr_M_elems)r)rr")rr%rrrr'es zArrayFrontWorker.__call__N)rrrrr$r&r'rrrrr*[sr*c@s,eZdZddZddZddZddZd S) ArrayBackWorkercCstj|||dS)N)rr)rrrrrrrmszArrayBackWorker.__init__cCsdS)Nr)rrrrr$pszArrayBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sszArrayBackWorker.get_result_typecCs,t|jdkr |d|jdS|jSdS)Nrr+)r)rr")rr%rrrr'vszArrayBackWorker.__call__N)rrrrr$r&r'rrrrr,lsr,c@s,eZdZddZddZddZddZd S) ArrayAtWorkercCstj|||dS)N)rr)rrrrrrr~szArrayAtWorker.__init__cCstS)N)r)rrrrr$szArrayAtWorker.get_arg_typescCs|jS)N)r)rr%indexrrrr&szArrayAtWorker.get_result_typecCs4t|t|jkr(tdt||jf|d|S)Nz%Array index "%d" should not be >= %d.r+)r)r IndexError)rr%r/rrrr'szArrayAtWorker.__call__N)rrrrr$r&r'rrrrr.}sr.c@s,eZdZddZddZddZddZd S) ArraySubscriptWorkercCstj|||dS)N)rr)rrrrrrrszArraySubscriptWorker.__init__cCstS)N)r)rrrrr$sz"ArraySubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz$ArraySubscriptWorker.get_result_typecCs&t|jdkr|d|S|jSdS)Nrr+)r)rr")rr%r/rrrr's zArraySubscriptWorker.__call__N)rrrrr$r&r'rrrrr1sr1c@seZdZddZddZdS)ArrayMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Narrayremptyfrontbackatz operator[])rr4r5r6r7z operator[]csg|]}j|qSr) _method_dict).0m)rrr sz0ArrayMethodsMatcher.__init__..)rrXMethodMatcherrmatcher_name_prefixrr#r(r*r,r.r1r8methods)rr)rrrs  zArrayMethodsMatcher.__init__c Cs^t|dsdS|jj|}|dks*|j r.dSy|jd}|jd}Wn dS|j||S)Nr3rr-)rr8getenabledtemplate_argumentr)r class_type method_namemethodZ value_typerrrrr s   zArrayMethodsMatcher.matchN)rrrrr rrrrr2s r2c@s$eZdZddZddZddZdS)DequeWorkerBasecCs||_d|jpd|_dS)Nir-)rsizeof_bufsize)rrrrrrszDequeWorkerBase.__init__cCsf|dd}|dd}|d|dkr,dS|j|d|dd|d|d|d |dS) N_M_impl_M_start _M_finish_M_curr_M_noder-_M_first_M_last)rG)rr%startfinishrrrrs   zDequeWorkerBase.sizecCs`|dd}|d|d}||kr0|d|S||}|ddt||j}|||jS)NrHrIrNrKrLr-)r)rG)rr%idxrOZfirst_node_sizeZ index_noderrrr/s  zDequeWorkerBase.indexN)rrrrrr/rrrrrEs rEc@s$eZdZddZddZddZdS)DequeEmptyWorkercCsdS)Nr)rrrrr$szDequeEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&sz DequeEmptyWorker.get_result_typecCs |ddd|dddkS)NrHrIrKrJr)rr%rrrr'szDequeEmptyWorker.__call__N)rrrr$r&r'rrrrrRsrRc@s$eZdZddZddZddZdS)DequeSizeWorkercCsdS)Nr)rrrrr$szDequeSizeWorker.get_arg_typescCstS)N)r)rr%rrrr&szDequeSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'szDequeSizeWorker.__call__N)rrrr$r&r'rrrrrSsrSc@s$eZdZddZddZddZdS)DequeFrontWorkercCsdS)Nr)rrrrr$szDequeFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz DequeFrontWorker.get_result_typecCs|ddddS)NrHrIrKrr)rr%rrrr'szDequeFrontWorker.__call__N)rrrr$r&r'rrrrrTsrTc@s$eZdZddZddZddZdS)DequeBackWorkercCsdS)Nr)rrrrr$szDequeBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&szDequeBackWorker.get_result_typecCs^|ddd|dddkrF|dddd}|d|jdS|ddddSdS) NrHrJrKrMrLr-r)rG)rr% prev_noderrrr's zDequeBackWorker.__call__N)rrrr$r&r'rrrrrUsrUc@s$eZdZddZddZddZdS)DequeSubscriptWorkercCstS)N)r)rrrrr$ sz"DequeSubscriptWorker.get_arg_typescCs|jS)N)r)rr% subscriptrrrr& sz$DequeSubscriptWorker.get_result_typecCs |j||S)N)r/)rr%rYrrrr'szDequeSubscriptWorker.__call__N)rrrr$r&r'rrrrrX srXc@s$eZdZddZddZddZdS) DequeAtWorkercCstS)N)r)rrrrr$szDequeAtWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&szDequeAtWorker.get_result_typecCs@t|j|}t||kr0tdt||fn |j||SdS)Nz%Deque index "%d" should not be >= %d.)r)rr0r/)rr%r/Z deque_sizerrrr's  zDequeAtWorker.__call__N)rrrr$r&r'rrrrrZsrZc@seZdZddZddZdS)DequeMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Ndequer4rr5r6z operator[]r7)r4rr5r6z operator[]r7csg|]}j|qSr)r8)r9r:)rrrr;0sz0DequeMethodsMatcher.__init__..)rrr<rr=rrRrSrTrUrXrZr8r>)rr)rrr%s  zDequeMethodsMatcher.__init__cCs>t|dsdS|jj|}|dks*|j r.dS|j|jdS)Nr\r)rr8r?r@rrA)rrBrCrDrrrr 2s   zDequeMethodsMatcher.matchN)rrrrr rrrrr[$s r[c@seZdZddZddZdS)ForwardListWorkerBasecCs||_||_dS)N)r _node_type)rr node_typerrrr>szForwardListWorkerBase.__init__cCsdS)Nr)rrrrr$Bsz#ForwardListWorkerBase.get_arg_typesN)rrrrr$rrrrr]=sr]c@seZdZddZddZdS)ForwardListEmptyWorkercCstS)N)r)rr%rrrr&Gsz&ForwardListEmptyWorker.get_result_typecCs|ddddkS)NrH_M_head_M_nextrr)rr%rrrr'JszForwardListEmptyWorker.__call__N)rrrr&r'rrrrr`Fsr`c@seZdZddZddZdS)ForwardListFrontWorkercCs|jS)N)r)rr%rrrr&Osz&ForwardListFrontWorker.get_result_typecCs:|dddj|j}|ddj}|j|jjjS)NrHrarb _M_storage)rr^addressrr r!)rr%nodeZ val_addressrrrr'RszForwardListFrontWorker.__call__N)rrrr&r'rrrrrcNsrcc@seZdZddZddZdS)ForwardListMethodsMatchercsJtd}tjjj|tdttdtd_fddjD_ dS)N forward_listr4r5)r4r5csg|]}j|qSr)r8)r9r:)rrrr;`sz6ForwardListMethodsMatcher.__init__..) r=rrr<rrr`rcr8r>)rZ matcher_namer)rrrYs z"ForwardListMethodsMatcher.__init__cCsZt|dsdS|jj|}|dks*|j r.dS|jd}tjt|dj}|j ||S)Nrhrz::_Node) rr8r?r@rArrstrr r)rrBrCrDrr_rrrr bs   zForwardListMethodsMatcher.matchN)rrrrr rrrrrgXs rgc@s$eZdZddZddZddZdS)ListWorkerBasecCs||_||_dS)N)rr^)rrr_rrrrpszListWorkerBase.__init__cCsdS)Nr)rrrrr$tszListWorkerBase.get_arg_typescCsB|j}|jjdjdkr$|dS|dj}|j|jjjS)Nr-Z_M_datard)r!typefieldsrrerrr )rrfZaddrrrrget_value_from_nodews  z"ListWorkerBase.get_value_from_nodeN)rrrrr$rmrrrrrjosrjc@seZdZddZddZdS)ListEmptyWorkercCstS)N)r)rr%rrrr&szListEmptyWorker.get_result_typecCs&|dd}|d|jkrdSdSdS)NrHrLrbTF)re)rr%Z base_noderrrr's zListEmptyWorker.__call__N)rrrr&r'rrrrrnsrnc@seZdZddZddZdS)ListSizeWorkercCstS)N)r)rr%rrrr&szListSizeWorker.get_result_typecCsD|ddd}|ddj}d}x||kr>|d}|d7}q$W|S)NrHrLrbrr-)re)rr%Z begin_nodeZend_noderrrrr's  zListSizeWorker.__call__N)rrrr&r'rrrrrosroc@seZdZddZddZdS)ListFrontWorkercCs|jS)N)r)rr%rrrr&szListFrontWorker.get_result_typecCs"|dddj|j}|j|S)NrHrLrb)rr^rm)rr%rfrrrr'szListFrontWorker.__call__N)rrrr&r'rrrrrpsrpc@seZdZddZddZdS)ListBackWorkercCs|jS)N)r)rr%rrrr&szListBackWorker.get_result_typecCs"|dddj|j}|j|S)NrHrLZ_M_prev)rr^rm)rr%rWrrrr'szListBackWorker.__call__N)rrrr&r'rrrrrqsrqc@seZdZddZddZdS)ListMethodsMatchercsVtjjjtdtdttdttdttdt d_ fddj D_ dS) Nlistr4rr5r6)r4rr5r6csg|]}j|qSr)r8)r9r:)rrrr;sz/ListMethodsMatcher.__init__..) rrr<rr=rrnrorprqr8r>)rr)rrrs  zListMethodsMatcher.__init__cCsZt|dsdS|jj|}|dks*|j r.dS|jd}tjt|dj}|j ||S)Nz(__cxx11::)?listrz::_Node) rr8r?r@rArrrir r)rrBrCrDrr_rrrr s   zListMethodsMatcher.matchN)rrrrr rrrrrrs rrc@s$eZdZddZddZddZdS)VectorWorkerBasecCs ||_dS)N)r)rrrrrrszVectorWorkerBase.__init__cCsz|jjtjkr^|ddd}|ddd}|ddd}|jjjd}||||S|dd|ddSdS)NrHrI_M_prJZ _M_offset)rcoderTYPE_CODE_BOOLr!rkrF)rr%rOrPZ finish_offsetbit_sizerrrrszVectorWorkerBase.sizecCsj|jjtjkrV|ddd}|jjjd}|||}||}|jd|>@dkS|dd|SdS)NrHrIrurvr-r)rrwrrxr!rkrF)rr%r/rOryZvalpoffsetrrrr?s zVectorWorkerBase.getN)rrrrrr?rrrrrts rtc@s$eZdZddZddZddZdS)VectorEmptyWorkercCsdS)Nr)rrrrr$szVectorEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&sz!VectorEmptyWorker.get_result_typecCst|j|dkS)Nr)r)r)rr%rrrr'szVectorEmptyWorker.__call__N)rrrr$r&r'rrrrr{sr{c@s$eZdZddZddZddZdS)VectorSizeWorkercCsdS)Nr)rrrrr$szVectorSizeWorker.get_arg_typescCstS)N)r)rr%rrrr&sz VectorSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'szVectorSizeWorker.__call__N)rrrr$r&r'rrrrr|sr|c@s$eZdZddZddZddZdS)VectorFrontWorkercCsdS)Nr)rrrrr$szVectorFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz!VectorFrontWorker.get_result_typecCs |j|dS)Nr)r?)rr%rrrr'szVectorFrontWorker.__call__N)rrrr$r&r'rrrrr}sr}c@s$eZdZddZddZddZdS)VectorBackWorkercCsdS)Nr)rrrrr$szVectorBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz VectorBackWorker.get_result_typecCs|j|t|j|dS)Nr-)r?r)r)rr%rrrr'szVectorBackWorker.__call__N)rrrr$r&r'rrrrr~sr~c@s$eZdZddZddZddZdS)VectorAtWorkercCstS)N)r)rrrrr$ szVectorAtWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&szVectorAtWorker.get_result_typecCs>t|j|}t||kr.tdt||f|j|t|S)Nz&Vector index "%d" should not be >= %d.)r)rr0r?)rr%r/rrrrr's  zVectorAtWorker.__call__N)rrrr$r&r'rrrrr src@s$eZdZddZddZddZdS)VectorSubscriptWorkercCstS)N)r)rrrrr$sz#VectorSubscriptWorker.get_arg_typescCs|jS)N)r)rr%rYrrrr&sz%VectorSubscriptWorker.get_result_typecCs|j|t|S)N)r?r))rr%rYrrrr'!szVectorSubscriptWorker.__call__N)rrrr$r&r'rrrrrsrc@seZdZddZddZdS)VectorMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Nvectorrr4r5r6r7z operator[])rr4r5r6r7z operator[]csg|]}j|qSr)r8)r9r:)rrrr;2sz1VectorMethodsMatcher.__init__..)rrr<rr=rr|r{r}r~rrr8r>)rr)rrr&s   zVectorMethodsMatcher.__init__cCs>t|dsdS|jj|}|dks*|j r.dS|j|jdS)Nrr)rr8r?r@rrA)rrBrCrDrrrr 4s   zVectorMethodsMatcher.matchN)rrrrr rrrrr%src@s$eZdZddZddZddZdS)AssociativeContainerWorkerBasecCs ||_dS)N) _unordered)r unorderedrrrr@sz'AssociativeContainerWorkerBase.__init__cCs&|jr|ddS|dddSdS)NZ_M_hZ_M_element_count_M_trHZ _M_node_count)r)rr%rrr node_countCs z)AssociativeContainerWorkerBase.node_countcCsdS)Nr)rrrrr$Isz,AssociativeContainerWorkerBase.get_arg_typesN)rrrrrr$rrrrr?src@seZdZddZddZdS)AssociativeContainerEmptyWorkercCstS)N)r)rr%rrrr&Nsz/AssociativeContainerEmptyWorker.get_result_typecCst|j|dkS)Nr)r)r)rr%rrrr'Qsz(AssociativeContainerEmptyWorker.__call__N)rrrr&r'rrrrrMsrc@seZdZddZddZdS)AssociativeContainerSizeWorkercCstS)N)r)rr%rrrr&Vsz.AssociativeContainerSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'Ysz'AssociativeContainerSizeWorker.__call__N)rrrr&r'rrrrrUsrc@seZdZddZddZdS)"AssociativeContainerMethodsMatchercsLtjjjt||_tdttdtd_ fddj D_ dS)Nrr4)rr4csg|]}j|qSr)r8)r9r:)rrrr;gsz?AssociativeContainerMethodsMatcher.__init__..) rrr<rr=_namerrrr8r>)rrr)rrr^s   z+AssociativeContainerMethodsMatcher.__init__cCsDt||jsdS|jj|}|dks,|j r0dSd|jk}|j|S)Nr)rrr8r?r@r)rrBrCrDrrrrr is   z(AssociativeContainerMethodsMatcher.matchN)rrrrr rrrrr]s rc@s8eZdZdZddZddZddZdd Zd d Zd S) UniquePtrGetWorkerzS Implement std::unique_ptr::get() and std::unique_ptr::operator->(). cCs*|jtjk|_|jr |j|_n||_dS)N)rwrTYPE_CODE_ARRAY _is_arraytarget _elem_type)r elem_typerrrrzs zUniquePtrGetWorker.__init__cCsdS)Nr)rrrrr$sz UniquePtrGetWorker.get_arg_typescCs |jjS)N)rr )rr%rrrr&sz"UniquePtrGetWorker.get_result_typecCs|dkp|j S)Nr?)r)rrCrrr _supportsszUniquePtrGetWorker._supportscCs|jjjdjj}t|dr.|dd}nt|drB|d}ndS|jjdj}|jdj}|jd}|jdkr|j|dS|jr|j|jSdSdS)Nrz__uniq_ptr_(data|impl)rtupler-Z _M_head_impl)r!rkrlr rrrZ is_base_class)rr%Z impl_typeZ tuple_memberZtuple_impl_typeZtuple_head_typeZ head_fieldrrrr's      zUniquePtrGetWorker.__call__N) rrr__doc__rr$r&rr'rrrrrus rc@s0eZdZdZddZddZddZdd Zd S) UniquePtrDerefWorkerz*Implement std::unique_ptr::operator*().cCstj||dS)N)rr)rrrrrrszUniquePtrDerefWorker.__init__cCs|jS)N)r)rr%rrrr&sz$UniquePtrDerefWorker.get_result_typecCs|j S)N)r)rrCrrrrszUniquePtrDerefWorker._supportscCstj||jS)N)rr'r!)rr%rrrr'szUniquePtrDerefWorker.__call__N)rrrrrr&rr'rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) UniquePtrSubscriptWorkerz1Implement std::unique_ptr::operator[](size_t).cCstj||dS)N)rr)rrrrrrsz!UniquePtrSubscriptWorker.__init__cCstS)N)r)rrrrr$sz&UniquePtrSubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz(UniquePtrSubscriptWorker.get_result_typecCs|jS)N)r)rrCrrrrsz"UniquePtrSubscriptWorker._supportscCstj|||S)N)rr')rr%r/rrrr'sz!UniquePtrSubscriptWorker.__call__N) rrrrrr$r&rr'rrrrrs rc@seZdZddZddZdS)UniquePtrMethodsMatchercsVtjjjtdtdttdttdttdtd_ fddj D_ dS) N unique_ptrr?z operator->z operator*z operator[])r?z operator->z operator*z operator[]csg|]}j|qSr)r8)r9r:)rrrr;sz4UniquePtrMethodsMatcher.__init__..) rrr<rr=rrrrr8r>)rr)rrrs  z UniquePtrMethodsMatcher.__init__cCsPt|dsdS|jj|}|dks*|j r.dS|j|jd}|j|rL|SdS)Nrr)rr8r?r@rrAr)rrBrCrDworkerrrrr s   zUniquePtrMethodsMatcher.matchN)rrrrr rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrGetWorkerzT Implements std::shared_ptr::get() and std::shared_ptr::operator->(). cCs*|jtjk|_|jr |j|_n||_dS)N)rwrrrrr)rrrrrrs zSharedPtrGetWorker.__init__cCsdS)Nr)rrrrr$sz SharedPtrGetWorker.get_arg_typescCs |jjS)N)rr )rr%rrrr&sz"SharedPtrGetWorker.get_result_typecCs|dkp|j S)Nr?)r)rrCrrrrszSharedPtrGetWorker._supportscCs|dS)NZ_M_ptrr)rr%rrrr'szSharedPtrGetWorker.__call__N) rrrrrr$r&rr'rrrrrs rc@s0eZdZdZddZddZddZdd Zd S) SharedPtrDerefWorkerz*Implement std::shared_ptr::operator*().cCstj||dS)N)rr)rrrrrrszSharedPtrDerefWorker.__init__cCs|jS)N)r)rr%rrrr&sz$SharedPtrDerefWorker.get_result_typecCs|j S)N)r)rrCrrrrszSharedPtrDerefWorker._supportscCstj||jS)N)rr'r!)rr%rrrr'szSharedPtrDerefWorker.__call__N)rrrrrr&rr'rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrSubscriptWorkerz1Implement std::shared_ptr::operator[](size_t).cCstj||dS)N)rr)rrrrrr sz!SharedPtrSubscriptWorker.__init__cCstS)N)r)rrrrr$sz&SharedPtrSubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz(SharedPtrSubscriptWorker.get_result_typecCs|jS)N)r)rrCrrrrsz"SharedPtrSubscriptWorker._supportscCsZtjdt|j}|rJ|t|jdkrJtd|jt|t|jdftj|||S)Nz .*\[(\d+)]$r-z.shared_ptr<%s> index "%d" should not be >= %d.) r r rirr)groupr0rr')rr%r/r:rrrr's z!SharedPtrSubscriptWorker.__call__N) rrrrrr$r&rr'rrrrr s rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrUseCountWorkerz*Implement std::shared_ptr::use_count().cCsdS)Nr)rrrrrr%sz SharedPtrUseCountWorker.__init__cCsdS)Nr)rrrrr$(sz%SharedPtrUseCountWorker.get_arg_typescCs tjdS)NZlong)rr)rr%rrrr&+sz'SharedPtrUseCountWorker.get_result_typecCsdS)NTr)rrCrrrr.sz!SharedPtrUseCountWorker._supportscCs|dd}|r|dSdS)NZ _M_refcountZ_M_piZ _M_use_countrr)rr%Z refcountsrrrr'1s z SharedPtrUseCountWorker.__call__N) rrrrrr$r&rr'rrrrr"s rc@s(eZdZdZddZddZddZdS) SharedPtrUniqueWorkerz'Implement std::shared_ptr::unique().cCstj||dS)N)rr)rrrrrr9szSharedPtrUniqueWorker.__init__cCs tjdS)Nr)rr)rr%rrrr&<sz%SharedPtrUniqueWorker.get_result_typecCstj||dkS)Nr-)rr')rr%rrrr'?szSharedPtrUniqueWorker.__call__N)rrrrrr&r'rrrrr6src@seZdZddZddZdS)SharedPtrMethodsMatchercsftjjjtdtdttdttdttdttdt tdt d_ fd d j D_ dS) N shared_ptrr?z operator->z operator*z operator[] use_countunique)r?z operator->z operator*z operator[]rrcsg|]}j|qSr)r8)r9r:)rrrr;Osz4SharedPtrMethodsMatcher.__init__..) rrr<rr=rrrrrrr8r>)rr)rrrDs  z SharedPtrMethodsMatcher.__init__cCsPt|dsdS|jj|}|dks*|j r.dS|j|jd}|j|rL|SdS)Nrr)rr8r?r@rrAr)rrBrCrDrrrrr Qs   zSharedPtrMethodsMatcher.matchN)rrrrr rrrrrCs rcCstjj|ttjj|ttjj|ttjj|ttjj|ttjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|t tjj|t dS) NsetmapZmultisetZmultimapZ unordered_setZ unordered_mapZunordered_multisetZunordered_multimap) rrZregister_xmethod_matcherr2rgr[rrrrrr)Zlocusrrrregister_libstdcxx_xmethods]s.        r)>rZ gdb.xmethodr r=rrr rrrrZ XMethodWorkerrr#r(r*r,r.r1r<r2rErRrSrTrUrXrZr[r]r`rcrgrjrnrorprqrrrtr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrsr                * PKr1] B66=python/libstdcxx/v6/__pycache__/__init__.cpython-36.opt-1.pycnu[3 h}@sddZddZdS)c Cs&y ddl}dStk r dSXdS)NTF)Z gdb.xmethod ImportError)Zgdbr0/usr/share/gcc-8/python/libstdcxx/v6/__init__.pygdb_has_xmethodss rcCs2ddlm}||tr.ddlm}||dS)N)register_libstdcxx_printers)register_libstdcxx_xmethods)ZprintersrrZxmethodsr)objrrrrrrs   rN)rrrrrrsPKr1]3,xexe7python/libstdcxx/v6/__pycache__/printers.cpython-36.pycnu[3 h@sddlZddlZddlZddlZddlZddlZejddkrXeZe Z e Z e ZejjZn6GdddZddlm Z m Z GdddejZeZday ddlZWnek rd aYnXd ayddlZeejd rdaWnek rYnXeed rejZneZd d ZdaddZddZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&Gdd d eZ'Gd!d"d"eZ(d#d$Z)d%d&Z*d'd(Z+Gd)d*d*eZ,d+d,Z-d-d.Z.Gd/d0d0eZ/Gd1d2d2eZ0Gd3d4d4e0Z1Gd5d6d6e0Z2Gd7d8d8eZ3Gd9d:d:eZ4Gd;d<dd>eZ6Gd?d@d@eZ7GdAdBdBeZ8GdCdDdDeZ9GdEdFdFeZ:GdGdHdHeZ;dIdJZdOdPZ?GdQdRdReZ@GdSdTdTeZAGdUdVdVeZBGdWdXdXeZCGdYdZdZeZDGd[d\d\eZEd]d^ZFGd_d`d`eZGGdadbdbeZHGdcddddeZIGdedfdfeZJGdgdhdheZKGdidjdjeZLGdkdldleZMGdmdndneZNdodpZOGdqdrdreNZPGdsdtdteNZQGdudvdveNZRGdwdxdxeNZSGdydzdzeZTGd{d|d|eZUGd}d~d~eZVGdddeZWGdddeZXGdddeZYGdddeZZGdddeZ[GdddeZ\GdddeZ]GdddeZ^GdddeZ_GdddeZ`GdddeZadddddddddddddg ZbddddddddgZcGdddeZdGdddeZeGdddeZfGdddeZgGdddeZhGdddeZiGdddeZjGdddeZkGdddeZlGdddeZmdanGdddeZoddZpGdddeZqdddÄZrddńZsddDŽZtddɄZueudS)Nc@seZdZdZddZdS)Iteratora:Compatibility mixin for iterators Instead of writing next() methods for iterators, write __next__() methods and use this mixin to make them work in Python 2 as well as Python 3. Idea stolen from the "six" documentation: cCs|jS)N)__next__)selfr0/usr/share/gcc-8/python/libstdcxx/v6/printers.pynext?sz Iterator.nextN)__name__ __module__ __qualname____doc__rrrrrr4s r)imapizipc@s(eZdZdZddZddZddZdS) UTCz5Concrete tzinfo class representing the UTC time zone.cCs tjdS)Nr)datetime timedelta)rdtrrr utcoffsetIsz UTC.utcoffsetcCsdS)Nrr)rrrrrtznameLsz UTC.tznamecCs tjdS)Nr)rr)rrrrrdstOszUTC.dstN)r r r r rrrrrrrrFsrTFZ TypePrinter ValuePrinterc Csz|j}xld|j|f}y tj|Stk r6YnX|j}t|r^|djr^|dj}q t dt ||fq WdS)Nz%s::%srzCannot find type %s::%s) strip_typedefstaggdb lookup_type RuntimeErrorfieldslen is_base_classtype ValueErrorstr)Zorignametypsearchrrrr find_typens  r%z__8::cGsdj|djdd|D}y tj|Stjk r}zFt|krv|jddtd}y tj|Stjk rtYnX|WYdd}~XnXdS)z8 Lookup template specialization templ. z{}<{}>z, cSsg|] }t|qSr)r!).0arrr sz%lookup_templ_spec..z::N)formatjoinrrerror_versioned_namespacereplace)Ztemplargsterrrlookup_templ_specs  r2cCsd|krd|}yt|d}Wn|jd}YnX|j}y t||Stjk rt|drt|dddr|jdd d }y t||Stjk rYnXd SXd S) a Lookup specialization of template nodename corresponding to containertype. nodename - The name of a class template, as a String containertype - The container, as a gdb.Type Return a gdb.Type for the corresponding specialization of nodename, or None if the type cannot be found. e.g. lookup_node_type('_List_node', gdb.lookup_type('std::list')) will return a gdb.Type for the type std::_List_node. z::zstd:: value_typerZstdzstd::__cxx1998z std::__debugZ __gnu_debugz ::__cxx1998::r)N)r%template_argumentrr2rr,is_member_of_namespacer.)nodenameZ containertypevaltyperrrlookup_node_types&   r8cGs@t|tjrt|}t|}x|D]}|j|dr"dSq"WdS)z Test whether a type is a member of one of the specified namespaces. The type can be specified as a string or a gdb.Type object. z::TF) isinstancerTyper!strip_versioned_namespace startswith)r#Z namespaces namespacerrrr5s  r5cCs2t|tjr|j}dt|f}tjd||dk S)z Test whether a type is a specialization of the named class template. The type can be specified as a string or a gdb.Type object. The template should be the name of a class template as a string, without any 'std' qualification. z(%s)?%sz ^std::%s<.*>$N)r9rr:rr-rematch)x template_namerrris_specialization_ofs  rBcCs |jtdS)N)r.r-)typenamerrrr;sr;cCs<d}d}tjddkr&tj|||dStj|||ddSdS)zCRemove "fundamentals_vN" inline namespace from qualified type name.z&^std::experimental::fundamentals_v\d::zstd::experimental::rrr))countN)sys version_infor>sub)r#patternreplrrrstrip_fundts_namespaces rKcCsVt|}|jdd}d}x d D]}|j||d|}qW|d}|j|d|}|S) zARemove known inline namespaces from the canonical name of a type.zstd::__cxx11::zstd::zstd::experimental::fundamentals_v1fundamentals_v2z::z filesystem::zv1::)rLrM)r;r.)type_strZexpt_nsZlfts_nsZfs_nsrrrstrip_inline_namespacess  rOc Cs:d}g}x,y|j|j|Wn |S|d7}q WdS)z-Return a type's template arguments as a list.rr)N)appendr4)type_objn template_argsrrrget_template_arg_listsrTc@s(eZdZdZddZddZddZdS) SmartPtrIteratorz@An iterator for smart pointer types with a single 'child' value.cCs ||_dS)N)_val)rvalrrr__init__szSmartPtrIterator.__init__cCs|S)Nr)rrrr__iter__szSmartPtrIterator.__iter__cCs$|jdkrtd|j|_}d|fS)Nzget())rV StopIteration)rrWrrrr s zSmartPtrIterator.__next__N)r r r r rXrYrrrrrrUsrUc@s0eZdZdZddZddZddZdd Zd S) SharedPointerPrinterzP Print a shared_ptr, weak_ptr, atomic, or atomic. cCst||_||_|d|_dS)N_M_ptr)r; _typenamerV_pointer)rrDrWrrrrXs zSharedPointerPrinter.__init__cCs t|jS)N)rUr^)rrrrchildrenszSharedPointerPrinter.childrencCsR|jdkrD|jddd}||d}t|jdjd}|j|S|jddS)Nz std::atomicZ _M_refcountZ_M_val_M_irpointerZ_M_pi)r]rVr%rcast)rZptr_valZptr_typerrr_get_refcountss    z#SharedPointerPrinter._get_refcountscCspd}|j}|jjjd}tt|}|dkr`|d}|d}|dkrPd|}nd||df}d|j||fS) NemptyrZ _M_use_countZ _M_weak_countzexpired, weak count %dzuse count %d, weak count %dr)z %s<%s> (%s))rcrVrr4r;r!r])rstateZ refcountstargZusecountZ weakcountrrr to_string(s  zSharedPointerPrinter.to_stringN)r r r r rXr_rcrgrrrrr[s  r[cCs|jj}|djs&tdt|j|j|dj}|jj}t|dkr^tdt|j|djdkrt|dS|djr|j|djStdt|jdS)zBReturn the tuple element stored in a _Tuple_impl base class.r)z-Unsupported implementation for std::tuple: %sr _M_head_implNri)rrrr r!rbrr")rWbasesZ head_baserrrr_tuple_impl_get9s     rkcCshtt|j}||krtd|j|jjdj}x*|dkr^|j|jjdj}|d8}q6Wt|S)z6Return the result of std::get(val) on a std::tuple.z0Out of range index for std::get on std::tuplerr))rrTrr rbrrk)rRrWZ tuple_sizenoderrr tuple_getQs  rmcCsd|jjdjj}t|ds(t|dr6|dd}n$t|drJ|d}ntdt|td|S)z4Return the result of val.get() on a std::unique_ptr.rZ__uniq_ptr_dataZ__uniq_ptr_impl_M_ttuplez-Unsupported implementation for unique_ptr: %s)rrrrBr r!rm)rWZ impl_typeZ tuple_memberrrrunique_ptr_get_s    rpc@s(eZdZdZddZddZddZdS) UniquePointerPrinterzPrint a unique_ptr.cCs ||_dS)N)rV)rrDrWrrrrXtszUniquePointerPrinter.__init__cCstt|jS)N)rUrprV)rrrrr_wszUniquePointerPrinter.childrencCs|jjjd}djt|S)Nrzstd::unique_ptr<{}>)rVrr4r*r!)rr0rrrrgzszUniquePointerPrinter.to_stringN)r r r r rXr_rgrrrrrqqsrqcCs|djj|jjS)z7Return the value held in a __gnu_cxx::__aligned_membuf. _M_storage)addressrbra dereference)Zbufr7rrrget_value_from_aligned_membufsruc CsjyF|jjdj}|dkr"|dS|dkrD|jjd}t|d|SWn YnXtdt|jdS)z-Return the value held in an _List_node<_Val>.r)_M_datarrrz!Unsupported implementation for %sN)rrr"r4rur r!)rlmemberr7rrrget_value_from_list_nodes rxc@s8eZdZdZGdddeZddZddZdd Zd S) StdListPrinterzPrint a std::list.c@s$eZdZddZddZddZdS)zStdListPrinter._iteratorcCs"||_|d|_|j|_d|_dS)N_M_nextr) _nodetype_basers_head_count)rnodetypeheadrrrrXs z!StdListPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz!StdListPrinter._iterator.__iter__cCsR|j|jkrt|jj|jj}|d|_|j}|jd|_t|}d||fS)Nrzr)z[%d])r|r}rZrbr{rtr~rx)reltrErWrrrrs   z!StdListPrinter._iterator.__next__N)r r r rXrYrrrrr _iteratorsrcCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdListPrinter.__init__cCs(td|jjj}|j||jddS)N _List_node_M_impl_M_node)r8rVrrar)rrrrrr_szStdListPrinter.childrencCs0|jdd}|d|jkr&d|jSd|jS)Nrrrzzempty %sz%s)rVrsr])rZheadnoderrrrgs zStdListPrinter.to_stringN) r r r r rrrXr_rgrrrrrys ryc@seZdZddZddZdS)NodeIteratorPrintercCs$||_||_||_t||j|_dS)N)rVr] _contnamer8rr{)rrDrWZcontnamer6rrrrXszNodeIteratorPrinter.__init__cCs:|jdsd|jS|jdj|jjj}tt|S)Nrz(non-dereferenceable iterator for std::%s)rVrrbr{rartr!rx)rrlrrrrgs    zNodeIteratorPrinter.to_stringN)r r r rXrgrrrrrsrc@seZdZdZddZdS)StdListIteratorPrinterzPrint std::list::iterator.cCstj|||dddS)Nlistr)rrX)rrDrWrrrrXszStdListIteratorPrinter.__init__N)r r r r rXrrrrrsrc@seZdZdZddZdS)StdFwdListIteratorPrinterz"Print std::forward_list::iterator.cCstj|||dddS)N forward_list_Fwd_list_node)rrX)rrDrWrrrrXs z"StdFwdListIteratorPrinter.__init__N)r r r r rXrrrrrsrc@s8eZdZdZGdddeZddZddZdd Zd S) StdSlistPrinterzPrint a __gnu_cxx::slist.c@s$eZdZddZddZddZdS)zStdSlistPrinter._iteratorcCs||_|dd|_d|_dS)N_M_headrzr)r{r|r~)rrrrrrrXsz"StdSlistPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz"StdSlistPrinter._iterator.__iter__cCsL|jdkrt|jj|jj}|d|_|j}|jd|_d||dfS)Nrrzr)z[%d]rv)r|rZrbr{rtr~)rrrErrrrs   z"StdSlistPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs ||_dS)N)rV)rrDrWrrrrXszStdSlistPrinter.__init__cCs td|jj}|j|j|jS)Nz__gnu_cxx::_Slist_node)r8rVrrra)rrrrrr_szStdSlistPrinter.childrencCs|jdddkrdSdS)Nrrzrzempty __gnu_cxx::slistz__gnu_cxx::slist)rV)rrrrrgszStdSlistPrinter.to_stringN) r r r r rrrXr_rgrrrrrs rc@s eZdZdZddZddZdS)StdSlistIteratorPrinterz!Print __gnu_cxx::slist::iterator.cCs ||_dS)N)rV)rrDrWrrrrXsz StdSlistIteratorPrinter.__init__cCs<|jdsdStd|jjj}t|jdj|jdS)Nrz1non-dereferenceable iterator for __gnu_cxx::slistz__gnu_cxx::_Slist_noderv)rVr8rrar!rbrt)rrrrrrgs  z!StdSlistIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s@eZdZdZGdddeZddZddZdd Zd d Z d S) StdVectorPrinterzPrint a std::vector.c@s$eZdZddZddZddZdS)zStdVectorPrinter._iteratorcCs^||_|rH|d|_d|_|d|_|d|_|jjj}d|j|_n ||_||_d|_ dS)N_M_pr _M_offset) _bitvec_item_so_finish_fortrsizeof_isizer~)rstartfinishZbitvecityperrrrX s    z#StdVectorPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz#StdVectorPrinter._iterator.__iter__cCs|j}|jd|_|jr|j|jkr4|j|jkr4tt|jjd|j>@}|jd|_|j|j krv|jd|_d|_d||fS|j|jkrt|jj}|jd|_d||fSdS)Nr)rz[%d]) r~rrrrrrZboolrtr)rrErrrrrs         z#StdVectorPrinter._iterator.__next__N)r r r rXrYrrrrrr srcCs*t||_||_|jjdjtjk|_dS)Nr) r;r]rVrr4coderTYPE_CODE_BOOL_is_bool)rrDrWrrrrX0s zStdVectorPrinter.__init__cCs$|j|jdd|jdd|jS)Nr_M_start _M_finish)rrVr)rrrrr_6s zStdVectorPrinter.childrenc Cs|jdd}|jdd}|jdd}|jr|jddd}|jddd}|jddd}|jj}d|j}||||}|||}d|jt|t|fSd |jt||t||fSdS) NrrrZ_M_end_of_storagerrrz"%s of length %d, capacity %dz%s of length %d, capacity %d)rVrrtrrr]int) rrrendZforZbllengthZcapacityrrrrg;s   zStdVectorPrinter.to_stringcCsdS)Narrayr)rrrr display_hintMszStdVectorPrinter.display_hintN) r r r r rrrXr_rgrrrrrrs %rc@s eZdZdZddZddZdS)StdVectorIteratorPrinterzPrint std::vector::iterator.cCs ||_dS)N)rV)rrDrWrrrrXTsz!StdVectorIteratorPrinter.__init__cCs |jdsdSt|jdjS)NZ _M_currentz,non-dereferenceable iterator for std::vector)rVr!rt)rrrrrgWs z"StdVectorIteratorPrinter.to_stringN)r r r r rXrgrrrrrQsrc@s eZdZdZddZddZdS)StdBitIteratorPrinterz@Print std::vector's _Bit_iterator and _Bit_const_iterator.cCs ||_dS)N)rV)rrDrWrrrrX`szStdBitIteratorPrinter.__init__cCs.|jdsdSt|jdjd|jd>@S)Nrz2non-dereferenceable iterator for std::vectorr)r)rVrrt)rrrrrgcs zStdBitIteratorPrinter.to_stringN)r r r r rXrgrrrrr]src@s eZdZdZddZddZdS)StdBitReferencePrinterz#Print std::vector::reference.cCs ||_dS)N)rV)rrDrWrrrrXmszStdBitReferencePrinter.__init__cCs*|jdsdSt|jdj|jd@S)Nrz$invalid std::vector::referenceZ_M_mask)rVrrt)rrrrrgps z StdBitReferencePrinter.to_stringN)r r r r rXrgrrrrrjsrc@s8eZdZdZGdddeZddZddZdd Zd S) StdTuplePrinterzPrint a std::tuple.c@s0eZdZeddZddZddZddZd S) zStdTuplePrinter._iteratorcCsNt|dkr"t|djdrBdSn t|dkr2dSt|dkrBdStddS)Nrr)Z __tuple_baseTrFz4Top of tuple tree does not consist of a single node.)rrBrr )nodesrrr_is_nonempty_tuple}s   z,StdTuplePrinter._iterator._is_nonempty_tuplecCs:||_|jjj}|j|r0|jj|dj|_d|_dS)Nr)r}rrrrbr~)rrrrrrrXs   z"StdTuplePrinter._iterator.__init__cCs|S)Nr)rrrrrYsz"StdTuplePrinter._iterator.__iter__cCs|js t|jjj}t|dkr&tt|dkr:tdt|dkr`|jj|dj}d|_n&|jj|dj}|jj|dj|_|jd|_|jj}t|dks|djdkrd|jd|fSd|jd|dfSdS)Nrrz/Cannot parse more than 2 nodes in a tuple tree.r)rhz[%d]) r}rZrrrr rbr~r")rrimplrrrrrs$       z"StdTuplePrinter._iterator.__next__N)r r r staticmethodrrXrYrrrrrr|s  rcCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdTuplePrinter.__init__cCs |j|jS)N)rrV)rrrrr_szStdTuplePrinter.childrencCs(t|jjjdkrd|jSd|jS)Nrzempty %sz %s containing)rrVrrr])rrrrrgs zStdTuplePrinter.to_stringN) r r r r rrrXr_rgrrrrrys Erc@s0eZdZdZddZddZddZdd Zd S) StdStackOrQueuePrinterz!Print a std::stack or std::queue.cCst||_tj|d|_dS)Nc)r;r]rdefault_visualizer _visualizer)rrDrWrrrrXs zStdStackOrQueuePrinter.__init__cCs |jjS)N)rr_)rrrrr_szStdStackOrQueuePrinter.childrencCsd|j|jjfS)Nz%s wrapping: %s)r]rrg)rrrrrgsz StdStackOrQueuePrinter.to_stringcCst|jdr|jjSdS)Nr)hasattrrr)rrrrrs  z#StdStackOrQueuePrinter.display_hintN)r r r r rXr_rgrrrrrrs rc@s0eZdZdZddZddZddZdd Zd S) RbtreeIteratorzf Turn an RB-tree-based container (std::map, std::set etc.) into a Python iterable object. cCs2|ddd|_|dddd|_d|_dS)NrnrZ _M_node_countZ _M_header_M_leftr)_size_noder~)rZrbtreerrrrXszRbtreeIterator.__init__cCs|S)Nr)rrrrrYszRbtreeIterator.__iter__cCs t|jS)N)rr)rrrr__len__szRbtreeIterator.__len__cCs|j|jkrt|j}|jd|_|j|jkr|j}|jdrl|jd}xd|jdrh|jd}qNWnF|jd}x$||jdkr|}|jd}qzW|jd|kr|}||_|S)Nr)Z_M_rightrZ _M_parent)r~rrZrrt)rresultrlparentrrrrs$      zRbtreeIterator.__next__N)r r r r rXrYrrrrrrrs rc CsjyF|jjdj}|dkr"|dS|dkrD|jjd}t|d|SWn YnXtdt|jdS)z0Return the value held in an _Rb_tree_node<_Val>.r)Z_M_value_fieldrrrz!Unsupported implementation for %sN)rrr"r4rur r!)rlrwr7rrrget_value_from_Rb_tree_node s rc@s eZdZdZddZddZdS)StdRbtreeIteratorPrinterz2Print std::map::iterator, std::set::iterator, etc.cCs"||_td|jj}|j|_dS)N _Rb_tree_node)rVr8rra _link_type)rrDrWrrrrrX!sz!StdRbtreeIteratorPrinter.__init__cCs0|jdsdS|jdj|jj}tt|S)Nrz6non-dereferenceable iterator for associative container)rVrbrrtr!r)rrlrrrrg&s z"StdRbtreeIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdDebugIteratorPrinterz-Print a debug enabled version of an iterator.cCs ||_dS)N)rV)rrDrWrrrrX0sz StdDebugIteratorPrinter.__init__cCsbtjd}|jjjd}|jj|d}|std||_nd|_dS)Nrir)) r;r]rVrr4Z_elttyperrr)rrDrWsizerrrrXs zStdDequePrinter.__init__cCsx|jdd}|jdd}|d|dd}|d|d}|d|d}|j|||}d |jtt|fS) Nrrrrr)_M_last_M_cur_M_firstz %s with %s)rVrr]rlong)rrrZdelta_nZdelta_sZdelta_errrrrgszStdDequePrinter.to_stringcCs@|jdd}|jdd}|j|d|d|d|d|jS)Nrrrrrr)rVrr)rrrrrrr_szStdDequePrinter.childrencCsdS)Nrr)rrrrrszStdDequePrinter.display_hintN) r r r r rrrXrgr_rrrrrrs   rc@s eZdZdZddZddZdS)StdDequeIteratorPrinterzPrint std::deque::iterator.cCs ||_dS)N)rV)rrDrWrrrrXsz StdDequeIteratorPrinter.__init__cCs |jdsdSt|jdjS)Nrz+non-dereferenceable iterator for std::deque)rVr!rt)rrrrrg s z!StdDequeIteratorPrinter.to_stringN)r r r r rXrgrrrrrsrc@s(eZdZdZddZddZddZdS) StdStringPrinterz'Print a std::basic_string of some kind.cCs||_|jddk|_dS)Nz::__cxx11::basic_stringr)ri)rVfind _new_string)rrDrWrrrrXszStdStringPrinter.__init__cCs|jj}|jtjkr|j}|jdd}|jrL|jd}|j|jj}n<|j j}tj t |dj }|j|d}|j d}t|dr|j|dS|j|dS) NZ _M_dataplusrZ_M_string_lengthz::_Repr)Z _M_length lazy_string)r)rVrrr TYPE_CODE_REFrrrbr unqualifiedrr!rartrrstring)rrptrrZrealtypeZreptypeheaderrrrrgs      zStdStringPrinter.to_stringcCsdS)Nrr)rrrrr-szStdStringPrinter.display_hintN)r r r r rXrgrrrrrrsrcCs"|d}|d}|d}|||fS)z'Access the streambuf put area pointers.Z _M_out_begZ _M_out_curZ _M_in_endr) streambufpbasepptregptrrrraccess_streambuf_ptrs1src@s(eZdZdZddZddZddZdS) StdStringBufPrinterzPrint a std::basic_stringbuf.cCs ||_dS)N)rV)r_rWrrrrX<szStdStringBufPrinter.__init__cCsLt|j\}}}|rB| s"||kr2|j||dS|j||dS|jdS)N)rZ _M_string)rrVr)rrrrrrrrg?s zStdStringBufPrinter.to_stringcCsdS)Nrr)rrrrrIsz StdStringBufPrinter.display_hintN)r r r r rXrgrrrrrr9s rc@s(eZdZdZddZddZddZdS) StdStringStreamPrinterz Print a std::basic_stringstream.cCsZ||_||_dd|jjDd}tjd|j|jtjd|_ |j |djk|_ dS)NcSsg|]}|jr|jqSr)rr)r&frrrr(Xsz3StdStringStreamPrinter.__init__..rZ__streamz$__stream->rdbuf() _M_stringbuf) rVr]rrrZset_convenience_variablerbrsparse_and_eval _streambuf_was_redirected)rrDrWZbasetyperrrrXPs  zStdStringStreamPrinter.__init__cCs$|jrd|j|jjfS|jdS)Nz%s redirected to %sr)rr]rrtrV)rrrrrg]sz StdStringStreamPrinter.to_stringcCs|jr dSdS)Nr)r)rrrrrcsz#StdStringStreamPrinter.display_hintN)r r r r rXrgrrrrrrMs rc@s$eZdZddZddZddZdS)Tr1HashtableIteratorcCsj|d|_d|_|d|_t|jdj|_d|_x2|j|jkrd|j|j|_|jrVP|jd|_q4WdS)NZ _M_bucketsrZ_M_bucket_countZ_Noder))_buckets_bucket _bucket_countr%rra _node_typer)r hashtablerrrrXjs  zTr1HashtableIterator.__init__cCs|S)Nr)rrrrrYvszTr1HashtableIterator.__iter__cCs|jdkrt|jj|j}|jd}|jd|_|jdkr|jd|_x2|j|jkr~|j|j|_|jrpP|jd|_qNW|S)NrZ_M_vrzr))rrZrbrrtrrr)rrlrrrrrys    zTr1HashtableIterator.__next__N)r r r rXrYrrrrrris rc@s$eZdZddZddZddZdS)StdHashtableIteratorcCsR|dd|_|jjd}|jjdjd}tdt||r>dnd}|j|_dS) NZ_M_before_begin_M_nxtr) rzstd::__detail::_Hash_nodetrueZfalse)rrr4r2r!rar)rrr7cachedZ node_typerrrrXs   zStdHashtableIterator.__init__cCs|S)Nr)rrrrrYszStdHashtableIterator.__iter__cCsR|jdkrt|jj|jj}|d|_|dj}|j|jjdj}|jS)Nrrrr) rrZrbrrtrsrr4ra)rrvalptrrrrrs   zStdHashtableIterator.__next__N)r r r rXrYrrrrrrsrc@s<eZdZdZddZddZddZedd Zd d Z d S) Tr1UnorderedSetPrinterz1Print a std::unordered_set or tr1::unordered_set.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zTr1UnorderedSetPrinter.__init__cCs|jjdr|jS|jdS)Nzstd::tr1_M_h)r]r<rV)rrrr _hashtables z!Tr1UnorderedSetPrinter._hashtablecCs|jd}d|jt|fS)N_M_element_countz %s with %s)rr]r)rrErrrrgs z Tr1UnorderedSetPrinter.to_stringcCsd|S)Nz[%d]r)irrr _format_countsz$Tr1UnorderedSetPrinter._format_countcCs@t|jtj}|jjdr.t|t|jSt|t |jS)Nzstd::tr1) r r itertoolsrEr]r<rrrr)rcounterrrrr_s zTr1UnorderedSetPrinter.childrenN) r r r r rXrrgrrr_rrrrrs  rc@s\eZdZdZddZddZddZedd Zed d Z ed d Z ddZ ddZ dS)Tr1UnorderedMapPrinterz1Print a std::unordered_map or tr1::unordered_map.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zTr1UnorderedMapPrinter.__init__cCs|jjdr|jS|jdS)Nzstd::tr1r)r]r<rV)rrrrrs z!Tr1UnorderedMapPrinter._hashtablecCs|jd}d|jt|fS)Nrz %s with %s)rr]r)rrErrrrgs z Tr1UnorderedMapPrinter.to_stringccs&x |D]}x|D] }|VqWqWdS)Nr)rrrrrr_flattens  zTr1UnorderedMapPrinter._flattencCs|d|dfS)Nrrr)rrrr _format_onesz"Tr1UnorderedMapPrinter._format_onecCsd|S)Nz[%d]r)rrrrrsz$Tr1UnorderedMapPrinter._format_countcCsdt|jtj}|jjdr@|jt|jt|j }t ||S|jt|jt |j }t ||S)Nzstd::tr1) r rrrEr]r<r r rrrr)rr datarrrr_s  zTr1UnorderedMapPrinter.childrencCsdS)Nrr)rrrrrsz#Tr1UnorderedMapPrinter.display_hintN) r r r r rXrrgrr r rr_rrrrrr s    r c@s8eZdZdZGdddeZddZddZdd Zd S) StdForwardListPrinterzPrint a std::forward_list.c@s$eZdZddZddZddZdS)zStdForwardListPrinter._iteratorcCs||_|d|_d|_dS)Nrzr)r{r|r~)rrrrrrrXs z(StdForwardListPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz(StdForwardListPrinter._iterator.__iter__cCsl|jdkrt|jj|jj}|d|_|j}|jd|_|dj}|j|jjdj }d||jfS)Nrrzr)rrz[%d]) r|rZrbr{rtr~rsrr4ra)rrrErrrrrs    z(StdForwardListPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs||_t||_dS)N)rVr;r])rrDrWrrrrXszStdForwardListPrinter.__init__cCs(td|jjj}|j||jddS)Nrrr)r8rVrrar)rrrrrr_szStdForwardListPrinter.childrencCs*|jddddkr d|jSd|jS)Nrrrzrzempty %sz%s)rVr])rrrrrgs zStdForwardListPrinter.to_stringN) r r r r rrrXr_rgrrrrrs rc@sBeZdZdZd ddZddZGdddeZd d Zd d Z dS)SingleObjContainerPrinterz8Base class for printers of containers of single objects.NcCs||_||_||_dS)N)_contained_valuer_hint)rrWZvizZhintrrrrXsz"SingleObjContainerPrinter.__init__cCs(ts t|Stjjtjj|p&t|S)z5Return type as a string after applying type printers.)_use_type_printingr!rtypesapply_type_recognizersget_type_recognizers)rrrrr _recognizesz$SingleObjContainerPrinter._recognizec@s$eZdZddZddZddZdS)z$SingleObjContainerPrinter._containedcCs ||_dS)N)rV)rrWrrrrXsz-SingleObjContainerPrinter._contained.__init__cCs|S)Nr)rrrrrY"sz-SingleObjContainerPrinter._contained.__iter__cCs"|jdkrt|j}d|_d|fS)Nz[contained value])rVrZ)rZretvalrrrr%s  z-SingleObjContainerPrinter._contained.__next__N)r r r rXrYrrrrr _containedsrcCs6|jdkr|jdSt|jdr*|jjS|j|jS)Nr_)rrrrr_)rrrrr_,s     z"SingleObjContainerPrinter.childrencCs(t|jdr"t|jdr"|jjS|jS)Nr_r)rrrr)rrrrr3s   z&SingleObjContainerPrinter.display_hint)N) r r r r rXrrrr_rrrrrrs  rc CsH|jj}tjddkr"t|}nt|}ytj|jj SdSdS)z{Find the name of the function referred to by the gdb.Value f, which should contain a function pointer from the program.rrN) rtrsrFrGrrrZ block_for_pcfunctionr")rrrrfunction_pointer_to_name;s  rcs4eZdZdZfddZddZeddZZS)StdExpAnyPrinterz+Print a std::any or std::experimental::any.c st||_t|j|_||_d|_d}d}|jd}|dkrt|}|sXtd|jdj|}tj ||}|std|j|j d} d| kr g} xPt j D]D} y(tj d| |j d} | jtj| Wqtjk rYqXqWt| dkrtd | d} n tj| } | jd|_d}d | kr@|jd d j}n(d | krZ|jd d}ntd|j|j|jjj}tj|}tt |j||dS)NZ _M_managerrzInvalid function pointer in %szi({0}::_Manager_\w+<.*>)::_S_manage\((enum )?{0}::_Op, (const {0}|{0} const) ?\*, (union )?{0}::_Arg ?\*\)zUnknown manager function in %sr)z std::stringzstd::string(?!\w)z;Cannot uniquely determine std::string type used in std::anyz::_Manager_internalrrZ _M_bufferz::_Manager_externalr\)r;r]rKrV_contained_typerr r*r>r?groupr _string_typesrHrPrrr,rr4rsrbrartrsuperrX)rrDrWcontained_value visualizerZmgrfuncZrxmZmgrnameZmgrtypessr@Zmgrtyper) __class__rrrXVsX                 zStdExpAnyPrinter.__init__cCsT|jdkrd|jSd|j}t|jdr8||jjS|j|j}|tt|S)Nz%s [no contained value]z%s containing r_)rr]rrrgrr;r!)rdescr7rrrrgs     zStdExpAnyPrinter.to_stringcs@ttjdjh}ddddtg}|fdd|DO}|S)Nz std::stringzAbasic_string, std::allocator >zstd::zstd::__cxx11::csh|] }|qSrr)r&q)r#rr sz1StdExpAnyPrinter._string_types..)r!rrrr-)ZstringsZqualsr)r#rrs  zStdExpAnyPrinter._string_types) r r r r rXrgrr __classcell__rr)r$rrSs D rcs(eZdZdZfddZddZZS)StdExpOptionalPrinterz5Print a std::optional or std::experimental::optional.c st||_t|j|_|d}|jjdr8|d}|}n*|d}|d}y |d}Wn YnXtj|}|std}tt|j||dS)N _M_payloadzstd::experimental _M_engaged_M_value) r;r]rKr<rrrr)rX)rrDrWZpayloadZengagedrr )r$rrrXs"      zStdExpOptionalPrinter.__init__cCs:|jdkrd|jSt|jdr4d|j|jjfS|jS)Nz%s [no contained value]r_z%s containing %s)rr]rrrg)rrrrrgs    zStdExpOptionalPrinter.to_string)r r r r rXrgr(rr)r$rr)s r)cs(eZdZdZfddZddZZS)StdVariantPrinterzPrint a std::variant.cst|j}t||_|d|_|jt|krz[%s])rrrZrtr~r7r@r=)rrrEr?r0rrrrRs    z$StdExpPathPrinter._iterator.__next__N)r r r rXrYrrrrrrHsrcCs|j|jd|jS)Nr8)rrVr])rrrrr__szStdExpPathPrinter.childrenN) r r r r rXr=rgrrr_rrrrr7.s r7c@s@eZdZdZddZddZddZGdd d eZd d Z d S) StdPathPrinterzPrint a std::filesystem::path.cCsP||_||_t|jdd}|jtjdd@|_|jdkrF||_nd|_dS)Nr8rZ uintptr_tr)rVr]rprbrrr_impl)rrDrWrrrrrXfs zStdPathPrinter.__init__cCsHt|jjtj|jd}|dddkr0dS|d ddkrDdSdS) Nz::_Typerr:zroot-directoryr;r<z root-nameii)r!rrbrrr])rr0rrrr=ps zStdPathPrinter._path_typecCs8d|jd}|jdkr0|j}|r0d||f}d|S)Nz%sr>rz%s [%s]zfilesystem::path %s)rVrr=)rr?r0rrrrgxs   zStdPathPrinter.to_stringc@s$eZdZddZddZddZdS)zStdPathPrinter._iteratorc Cs||_|rtjd}tj|d}tjd}|j|j}|j}ttjdrbtd|j |j }n d|j }|j|j|}|j|j|_ |j ||_ d|_ n d|_ d|_ dS)Nrz::_Cmptcharalignofrr)r@rrrbrartrr:maxrrFrrr~) rrrAZint_typeZ cmpt_type char_typerZ sizeof_ImplbeginrrrrXs      z!StdPathPrinter._iterator.__init__cCs|S)Nr)rrrrrYsz!StdPathPrinter._iterator.__iter__cCsd|j|jkrt|jj}|j}|jd|_|jd|_|d}t|j|j}|sX|}d||fS)Nr)r>z[%s])rrrZrtr~rBr@r=)rrrEr?r0rrrrs    z!StdPathPrinter._iterator.__next__N)r r r rXrYrrrrrrsrcCs|j|j|jS)N)rrDr])rrrrr_szStdPathPrinter.childrenN) r r r r rXr=rgrrr_rrrrrBcs  (rBc@s8eZdZdZddZGdddeZddZdd Zd S) StdPairPrinterz@Print a std::pair object, with 'first' and 'second' as children.cCs ||_dS)N)rV)rrDrWrrrrXszStdPairPrinter.__init__c@s(eZdZdZddZddZddZdS) zStdPairPrinter._iterz?An iterator for std::pair types. Returns 'first' then 'second'.cCs||_d|_dS)Nr)rV_which)rrWrrrrXszStdPairPrinter._iter.__init__cCs|S)Nr)rrrrrYszStdPairPrinter._iter.__iter__cCs8|jdkrt|j}|dkr$d|_nd|_||j|fS)Nrr)rKrZrV)rZwhichrrrrs zStdPairPrinter._iter.__next__N)r r r r rXrYrrrrrrsrcCs |j|jS)N)rrV)rrrrr_szStdPairPrinter.childrencCsdS)Nr)rrrrrgszStdPairPrinter.to_stringN) r r r r rXrrr_rgrrrrrJs rJc@s eZdZdZddZddZdS)StdCmpCatPrinterz#Print a comparison category object.cCs&||jddd|_|d|_dS)N:r)r,)rfindr]rV)rrDrWrrrrXszStdCmpCatPrinter.__init__cCsJ|jdkr|jdkrd}n"ddd ddddd i}|t|j}d j|j|S) Nstrong_orderingrZequalrZ unorderedr)ZlessZ equivalentZgreaterz std::{}::{}ri)r]rVrr*)rr"namesrrrrgs zStdCmpCatPrinter.to_stringN)r r r r rXrgrrrrrLsrLc@s`eZdZdZdZddZeddZeddZ ed d Z ed d Z ed dZ ddZ dS)StdErrorCodePrinterz0Print a std::error_code or std::error_condition.Nc CsL||_t||_tjdkrHyddl}dt_Wntk rFdt_YnXdS)NrTF)rVr;r]rQ_system_is_posixposix ImportError)rrDrWrSrrrrXs   zStdErrorCodePrinter.__init__cCs&tj|}|dk r"|jtjkr"|SdS)N)rrrZTYPE_CODE_ENUM)r"r#rrr_find_errc_enums z#StdErrorCodePrinter._find_errc_enumc CsBxs(     zStdErrorCodePrinter.to_string)r r r r rRrXrrU classmethodrXr]rdrfrgrrrrrQs   + rQc@s eZdZdZddZddZdS)StdRegexStatePrinterz/Print a state node in the NFA for a std::regex.cCs||_||_dS)N)rVr])rrDrWrrrrX[szStdRegexStatePrinter.__init__cCst|jd}|r|dd}|jd}dddddddddddddd }||}d j||}|dk r|jd |dk rd j|||jd |}d |S) NZ _M_opcoderzZaltZsubexprnegZ backref_index) repeat alternativeZ subexpr_beginZ subexpr_endZline_begin_assertionZline_end_assertionZ word_boundaryZsubexpr_lookaheadZbackrefr?ZacceptZdummyunknownzopcode={}, next={}Z_M_z {}, {}={}z{%s})r!rVr*)rZopcodeZnext_idZvariantsvr#rrrrg_s     zStdRegexStatePrinter.to_stringN)r r r r rXrgrrrrrlXsrlc@s@eZdZdZGdddeZddZddZdd Zd d Z d S) StdSpanPrinterzPrint a std::span.c@s$eZdZddZddZddZdS)zStdSpanPrinter._iteratorcCsd|_||_||_dS)Nr)r~_beginr)rrIrrrrrXysz!StdSpanPrinter._iterator.__init__cCs|S)Nr)rrrrrY~sz!StdSpanPrinter._iterator.__iter__cCs8|j|jkrt|j}|jd|_d||j|jfS)Nr)z[%d])r~rrZrtrt)rrErrrrs   z!StdSpanPrinter._iterator.__next__N)r r r rXrYrrrrrrxsrcCsLt||_||_tjd}|jjd|kr:|dd|_n|jjd|_dS)Nzstatic_cast(-1)r)Z _M_extentZ_M_extent_value)r;r]rVrrrr4r)rrDrWZsize_maxrrrrXs   zStdSpanPrinter.__init__cCsd|j|jfS)Nz%s of length %d)r]r)rrrrrgszStdSpanPrinter.to_stringcCs|j|jd|jS)Nr\)rrVr)rrrrr_szStdSpanPrinter.childrencCsdS)Nrr)rrrrrszStdSpanPrinter.display_hintN) r r r r rrrXrgr_rrrrrrsus  rsc@s0eZdZdZddZddZddZdd Zd S) StdInitializerListPrinterzPrint a std::initializer_list.cCs||_||_|d|_dS)Nr6)r]rVr)rrDrWrrrrXsz"StdInitializerListPrinter.__init__cCsd|j|jfS)Nz%s of length %d)r]r)rrrrrgsz#StdInitializerListPrinter.to_stringcCstj|jd|jS)NZ_M_array)rsrrVr)rrrrr_sz"StdInitializerListPrinter.childrencCsdS)Nrr)rrrrrsz&StdInitializerListPrinter.display_hintN)r r r r rXrgr_rrrrrrus ruc@s(eZdZdZddZddZddZdS) StdAtomicPrinterzPrint a std:atomic.cCsrt||_||_d|_|jjjd|_|jjdk rnt|jj}|jdsR|jdrn|d}t |||_|j |_ dS)Nrzstd::shared_ptr = { %s }) rwrgr1rrZ TYPE_CODE_INTrV TYPE_CODE_FLT TYPE_CODE_PTRrr]r!)rrWrrrrgs     zStdAtomicPrinter.to_stringN)r r r r rXrxrgrrrrrvs rvc@s eZdZdZddZddZdS)StdFormatArgsPrinterzPrint a std::basic_format_args.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdFormatArgsPrinter.__init__cCst|jj}t|dd}|tjdkr0d}n|tjdkrDd}nd}|jd}|dkrbd |S|dkrt|jd }d ||fS) Nrr)rEzstd::format_argswchar_tzstd::wformat_argszstd::basic_format_argsZ_M_packed_sizez%s with 1 argumentZ_M_unpacked_sizez%s with %d arguments)rTrVrrr)rZtargsrHr#rrrrrgs   zStdFormatArgsPrinter.to_stringN)r r r r rXrgrrrrr{sr{c@s0eZdZdZddZddZddZdd Zd S) StdChronoDurationPrinterzPrint a std::chrono::duration.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z!StdChronoDurationPrinter.__init__cCs*|jjjd}|jd}|jd}||fS)Nr)r)rVrr4)rZperiodrdenrrr_ratios  zStdChronoDurationPrinter._ratiocCs|j\}}|dkrF|dkr dS|dkr,dS|dkr8dS|dkr|dSn6|dkr||d krZd S|d krfd S|d krrdSdj|Sdj||S)Nr)r#iZmsi@Busiʚ;rW<minihiQdz[{}]sz[{}/{}]s)rr*)rrr~rrr_suffixs&  z StdChronoDurationPrinter._suffixcCs4|jd}|jjjtjkr$d|}dj||jS)N__rz%gz"std::chrono::duration = {{ {}{} }})rVrrrrryr*r)rrrrrrgs z"StdChronoDurationPrinter.to_stringN)r r r r rXrrrgrrrrr}s r}c@s*eZdZdZddZddZd ddZd S) StdChronoTimePointPrinterz Print a std::chrono::time_point.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z"StdChronoTimePointPrinter.__init__cCsv|jjjd}t|j}|dks(|dkr,dS|dkr8dS|dkrDdS|d krPdS|d kr\dS|dkrhdSdj|dfS)Nrzstd::chrono::_V2::system_clockzstd::chrono::system_clockstd::chrono::sys_timezstd::chrono::utc_clockstd::chrono::utc_timezstd::chrono::gps_clockstd::chrono::gps_timezstd::chrono::tai_clockstd::chrono::tai_timezstd::filesystem::__file_clockstd::chrono::file_timeumzstd::chrono::local_tstd::chrono::local_timez {} time_point)rr)rN)rN)rN)rr)rr)rVrr4r;r"r*)rclockr"rrr_clocks  z StdChronoTimePointPrinter._clockFc Cs|j\}}|jd}|d}t|jj|}|j}d}|dk r|j\} } || | |} ytjj| t } dj | }Wn YnXd|||f} |r| Sd|| fS)NZ__drrCz [{:%Y-%m-%d %H:%M:%S}]z%d%s%sz %s = { %s }) rrVr}rr"rrrZ fromtimestamp _utc_timezoner*)rZabbrevroffsetrrprintersuffixtimerr~Zsecsrr#rrrrg1s$   z#StdChronoTimePointPrinter.to_stringN)F)r r r r rXrrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoZonedTimePrinterz Print a std::chrono::zoned_time.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXIs z"StdChronoZonedTimePrinter.__init__cCs@|jdjd}|jd}t|jj|}|jd}dj||S)NZ_M_zone_M_nameZ_M_tpTz%std::chrono::zoned_time = {{ {} {} }})rVrtrrr"rgr*)rZzonerrrrrrgMs   z#StdChronoZonedTimePrinter.to_stringN)r r r r rXrgrrrrrFsrZJanuaryZFebruaryZMarchZAprilZMayZJuneZJulyZAugustZ SeptemberZOctoberZNovemberZDecemberZSundayZMondayZTuesdayZ WednesdayZThursdayZFridayZSaturdayc@s eZdZdZddZddZdS)StdChronoCalendarPrinterzDPrint a std::chrono::day, std::chrono::month, std::chrono::year etc.cCst||_||_dS)N)r;r]rV)rrDrWrrrrX_s z!StdChronoCalendarPrinter.__init__c Csv|j}|j}d|kr$|dkr$|d}|jdr6|d}|dkrPdjt|dS|d kr||d ksl|ttkrtd |St|S|dkrd j|S|d kr|d}|dks|ttkrd|Sdjt|S|dkrdj|dt|dS|dkrdj|dS|dkrdj||dS|dkr,dj|S|dkrFdj||dS|dkr`dj||dS|dkrvdj||S|dkrd j|||dS|dkrdj||d!S|d"krd j|||dS|d#krd j|||dS|jd$rrd%}|d&dkr"d'jt|d(d)t|d&}t|d*d+}t|dd+}t|d,d+}|d-rb| }d.j||||SdS)/Nmonthz std::chrono::year_month_day_lastZ_M_mzstd::chrono::yearZ_M_yzstd::chrono::dayz{}Z_M_dzstd::chrono::monthr)z%d is not a valid monthz{}yzstd::chrono::weekdayZ_M_wdrz%d is not a valid weekdayzstd::chrono::weekday_indexedz{}[{}]r.zstd::chrono::weekday_lastz{}[last]zstd::chrono::month_dayz{}/{}zstd::chrono::month_day_lastz{}/lastzstd::chrono::month_weekdayZ_M_wdizstd::chrono::month_weekday_lastZ_M_wdlzstd::chrono::year_monthzstd::chrono::year_month_dayz{}/{}/{}Z_M_mdlzstd::chrono::year_month_weekdayz$std::chrono::year_month_weekday_lastzstd::chrono::hh_mm_ssrCZfractional_widthz.{:0{}d}Z_M_ssZ_M_rrr_M_sZ _M_is_negz{:02}:{:02}:{:02}{})rVr]r<r*rrmonthsweekdays) rrWr#r"yZwdZfractrr#rrrrgcsh               z"StdChronoCalendarPrinter.to_stringN)r r r r rXrgrrrrr\src@s eZdZdZddZddZdS)StdChronoTimeZonePrinterz4Print a chrono::time_zone or chrono::time_zone_link.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z!StdChronoTimeZonePrinter.__init__cCs6d|j|jdf}|jjdr2|d|jd7}|S)Nz%s = %srZ_linkz -> %sZ _M_target)r]rVrb)rr!rrrrgs z"StdChronoTimeZonePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoLeapSecondPrinterzPrint a chrono::leap_second.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z#StdChronoLeapSecondPrinter.__init__cCs.|jdd}d|dk}d|jt||fS)Nrrz+-rz %s %d (%c))rVr]abs)rZdaternrrrrgs z$StdChronoLeapSecondPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoTzdbPrinterzPrint a chrono::tzdb.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs zStdChronoTzdbPrinter.__init__cCsd|j|jdfS)Nz%s %sversion)r]rV)rrrrrgszStdChronoTzdbPrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdChronoTimeZoneRulePrinterzPrint a chrono::time_zone rule.cCst||_||_dS)N)r;r]rV)rrDrWrrrrXs z%StdChronoTimeZoneRulePrinter.__init__c Cs|jd}|d}t|d}dddddddd}|d}d j||j|d }|d krdd j||}nVt|d }|dkrdj||}n4|dkrd} nd} |d}dj| d || d||}dj|jd|jd|jd|S)NonkindrstZndZrd)r)rrCZ day_of_monthz{}{}Zthrz{} {}Z day_of_weekr)z last {} in {}rr<=r>=z{} {} {} {} {}z.time_zone rule {} from {} to {} starting on {}r"fromZto)rr)rr)rVrr*getr) rrrrsuffixesdayZ ordinal_dayrweekday directionrrrrgs*    z&StdChronoTimeZoneRulePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdLocalePrinterzPrint a std::locale.cCs||_||_dS)N)rVr])rrDrWrrrrXszStdLocalePrinter.__init__csx|jdd}d}|ddkr&d}nFtj|jd}tj|jd}|dj}|dj}dj||}||i}d } xN| |kr|| dkr|| j}|| j}d j|||}|||<| d } qxWt|j} t| d kr|}nt| d krl| \} } t |j} d| j | d kr$| }| n| j | d kr<| }| dk rlt fd d |j D}dj|}dj||S)NrZ_M_namesrCr*z::_S_categoriesz::_S_categories_sizez{}={}r)z{};{}={}rc3s|]\}}|kr|VqdS)Nr)r&rrR)otherrr sz-StdLocalePrinter.to_string..z with "{}={}"zstd::locale = "{}"{}) rVrrr]rr*r4valuesrrrEritems)rrPmodr"ZcatsZncatrRr[Z cat_namesrZ uniq_namesZn1Zn2Z name_listr)rrrgsD            zStdLocalePrinter.to_stringN)r r r r rXrgrrrrrsrc@s eZdZdZddZddZdS)StdIntegralConstantPrinterz*Print a std::true_type or std::false_type.cCs||_||_dS)N)rVr])rrDrWrrrrX sz#StdIntegralConstantPrinter.__init__cCsL|jjjd}|jjjd}|jtjkr4|r0dSdSt|j}dj|||S)Nrr)zstd::true_typezstd::false_typez {}<{}, {}>) rVrr4rrrr;r]r*)rr3rZrDrrrrg s  z$StdIntegralConstantPrinter.to_stringN)r r r r rXrgrrrrr src@s eZdZdZddZddZdS)StdTextEncodingPrinterzPrint a std::text_encoding.cCs||_||_dS)N)rVr])rrDrWrrrrX$ szStdTextEncodingPrinter.__init__cCs<|jdj}|ddkr$|jdS|ddkr4dS|dS)NZ_M_repZ_M_idr)rrrq)rVrt)rZreprrrrg( s    z StdTextEncodingPrinter.to_stringN)r r r r rXrgrrrrr! srcs$eZdZfddZddZZS) RxPrintercs$tt|j||_||_d|_dS)NT)rrrXr" _functionenabled)rr"r)r$rrrX3 szRxPrinter.__init__cCs:|js dS|jjtjkr,ttjdr,|j}|j|j |S)Nreferenced_value) rrrrrrValuerrr")rrZrrrinvoke9 s  zRxPrinter.invoke)r r r rXrr(rr)r$rr2 s rcsHeZdZfddZddZddZddZed d Zd d Z Z S) Printercs6tt|j||_g|_i|_d|_tjd|_ dS)NTz^([a-zA-Z0-9_:]+)(<.*>)?$) rrrXr" _subprinters_lookuprr>compile _compiled_rx)rr")r$rrrXH s zPrinter.__init__cCs<|jj|std|t||}|jj|||j|<dS)Nz0libstdc++ programming error: "%s" does not match)rr?r rrrPr)rr"rrrrraddP s     z Printer.addcCs>|j|||d|kr:tjddt|}|j|||dS)N__cxx11z^(std|__gnu_cxx)::z\g<0>%s)rr>rHr-)rbaser"rZvbaserrr add_version[ s  zPrinter.add_versioncCs$|j||||j|d||dS)Nz __cxx1998::)r)rrr"rrrr add_containerc szPrinter.add_containercCs&|jtjkr|j}|jj}|jS)N)rrrrrrr)rrrrget_basic_typeg s  zPrinter.get_basic_typecCsr|j|j}|sdS|jj|}|s(dS|jd}|jjtjkrTttj drT|j }||j krn|j |j |SdS)Nr)r) rrrr?rrrrrrrrr)rrWrDr?basenamerrr__call__r s     zPrinter.__call__) r r r rXrrrrrrr(rr)r$rrG s    rc@s0eZdZdZddZGdddeZddZdS) TemplateTypePrinteral A type printer for class templates with default template arguments. Recognizes specializations of class templates and prints them without any template arguments that use a default template argument. Type printers are recursively applied to the template arguments. e.g. replace 'std::vector >' with 'std::vector'. cCs||_||_d|_dS)NT)r"_defargsr)rr"defargsrrrrX szTemplateTypePrinter.__init__c@s(eZdZdZddZddZddZdS) zTemplateTypePrinter._recognizerz-The recognizer class for TemplateTypePrinter.cCs||_||_dS)N)r"r)rr"rrrrrX sz(TemplateTypePrinter._recognizer.__init__c Cs|jdkrdS|jj|js dSt|}g}d}xtt|D]}||}|jj|}|dk r|j|}y|t j |kr|dSWn$t j k r|j|krdSYnXd}q>|rdS|j |j |q>W|jd|jjd}t|}|ddj|dS)a If type_obj is a specialization of self.name that uses all the default template arguments for the class template, then return a string representation of the type without default arguments. Otherwise, return None. NFTr)rr<r"rTrangerrrr*rrr,rP_recognize_subtyperrOr+) rrQrSZdisplayed_argsZrequire_defaultedrRrfZdefargrArrr recognize s2     z)TemplateTypePrinter._recognizer.recognizecCs|jtjkr|j|jdS|jtjkrj|j|j}t|jjdrR|dSd||j ddfS|jtj kr|j|jdSt tdr|jtj kr|j|jdStj jtj j|}|r|St|S)zxConvert a gdb.Type to a string by applying recognizers, or if that fails then simply converting to a string.rz[]z%s[%d]r)&TYPE_CODE_RVALUE_REFz&&)rrrzrrrr!rrbrrrrrrr)rrQrNrrrr s"     z2TemplateTypePrinter._recognizer._recognize_subtypeN)r r r r rXrrrrrr _recognizer s1rcCs|j|j|jS)z1Return a recognizer object for this type printer.)rr"r)rrrr instantiate szTemplateTypePrinter.instantiateN)r r r r rXobjectrrrrrrr s Prcstd||}tjj||td||}tjj||d|krdttfdd|jD}t||}tjj||td||}tjj||dS)a Add a type printer for a class template with default template arguments. Args: name (str): The template-name of the class template. defargs (dict int:string) The default template arguments. Types in defargs can refer to the Nth template-argument using {N} (with zero-based indices). e.g. 'unordered_map' has these defargs: { 2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator >' } zstd::zstd::__debug::rc3s"|]\}}||jdfVqdS)zstd::N)r.)r&rRr)rWrrr sz0add_one_template_type_printer..N)rrrregister_type_printerr-dictr)objr"rrr)rWradd_one_template_type_printer s rc@s2eZdZdZd ddZGdddeZddZdS) FilteringTypePrintera A type printer that uses typedef names for common template specializations. Args: template (str): The class template to recognize. name (str): The typedef-name that will be used instead. targ1 (str, optional): The first template argument. Defaults to None. Checks if a specialization of the class template 'template' is the same type as the typedef 'name', and prints it as 'name' instead. e.g. if an instantiation of std::basic_istream is the same type as std::istream then print it as std::istream. If targ1 is provided (not None), match only template specializations with this type as the first template argument, e.g. if template='basic_string' and targ1='char' then only match 'basic_string' and not 'basic_string'. This rejects non-matching specializations more quickly, without needing to do GDB type lookups. NcCs||_||_||_d|_dS)NT) _templater"_targ1r)rtemplater"targ1rrrrX- szFilteringTypePrinter.__init__c@s eZdZdZddZddZdS)z FilteringTypePrinter._recognizerz.The recognizer class for FilteringTypePrinter.cCs||_||_||_d|_dS)N)rr"r _type_obj)rrr"rrrrrX6 sz)FilteringTypePrinter._recognizer.__init__c Cs|jdkrdS|jdkrz|jdk rDdj|j|j}|jj|sVdSn|jj|jsVdSytj|jj |_Wn YnX|jdkrdStj j |j}tj j |}||krt |jS|jj dddkr|jjjdd}|jjdd}||krt |jSdS) z If type_obj starts with self._template and is the same type as self.name then return self.name, otherwise None. Nz{}<{}z::r) basic_stringz __cxx11::rCri)rrrr*rr<rrr"rrrrOrer.)rrQr#Zt1Zt2s1s2rrrr< s4        z*FilteringTypePrinter._recognizer.recognizeN)r r r r rXrrrrrr3 srcCs|j|j|j|jS)z1Return a recognizer object for this type printer.)rrr"r)rrrrrf sz FilteringTypePrinter.instantiate)N)r r r r rXrrrrrrrr s 3rcCsXtd|d||}tjj||d|krTdt}t|||||}tjj||dS)Nzstd::r)rrrrr-)rrr"rrrWrrradd_one_type_printerk s rc CsdtsdSxxdgD]p}t|d |d d |dt|d|d d |dt|dd|d d |dt|d|d d|dqWxdjD]|}x*dkD]"}t|d||d ||dqWxJdlD]B}t|d||d ||dt|d!||d ||dqWqWxdmD]}x0dpD](}t||d"||d d#|dqWxNdqD]F}t||d(||d)x&drD]}t||||||qlWqJWqWt|d-d.xdsD]}t|d9d:|qWt|d;d<t|d;d=t|d>d?t|d>d@t|dAdBt|dAdCt|dDdEt|dDdFt|dGdHdI}x0dyD](}t||d||d d|dqdequezstd::allocator<{0}>rrz __cxx11::listvectorrzstd::less<{0}>z)std::allocator>)rrCmultimapr4)r)rmultiset unordered_mapzstd::hash<{0}>zstd::equal_to<{0}>)rrCunordered_multimap unordered_set)r)rrCunordered_multisetrCrErr|rrrrrr)rrrrrrCrErr|)rr) rrrrrrrrr)rrrr)rCrrCrErr|)rr )rr#rr)rrr) rrrrr r r r r rrCrErr|rrrrrr)r!r"r#r$r%)rrr)rZchr@abiZdurrWrrrregister_type_printerst s "(     *                   r'cCs8trtjj|tn|dkr t}|jjtt|dS)z4Register libstdc++ pretty-printers with objfile Obj.N) _use_gdb_pprZprintingZregister_pretty_printerlibstdcxx_printerZpretty_printersrPr')rrrrregister_libstdcxx_printers s  r*cCsXtdatjddttjddttjddttjddttjddttjddttjddttjdd ttjdd t tjdd t tjdd t tjdd t tjddt tjddt tjddt tjddt tjddttjddtttjdr.tjddttjddttjdttjdttjdttjdttjdttjdt tjdt tjdttjddttjdd ttjdd!ttjdd"ttjdd#ttjdd$ttjdd%ttjd&dttjd&d ttjd&d!ttjd&d"ttjd&d#ttjd&d$ttjdd'ttjdd(ttjdd)ttjdd)tx2doD]*}tjdd-|ttjdd-|tqWtjd.d/ttjd.d0ttjdd1ttjd2d3t tjd4ttjd5ttjd6ttjd7ttjd8ttjd9d:t!tjd9d;t"tjd9dt$tjd?d>t$tjd@d>t%tjdAd>t%tjdd:t!tjdd;t"tjddrFrirrGrrrr ziprrrZtimezoneZutcrZtzinforr(Z gdb.printingrTrZ gdb.typesrrrZ printer_baser%r-r2r8r5rBr;rKrOrTrUr[rkrmrprqrurxryrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrr)r-r0r5r7rBrJrLrQrlrsrurvr{r}rrrrrrrrrrrrrrr)rrrrr'r*r;rrrrs      %   (&"I  U(*$/A " /%-^!,5I!{'$*/ ?  ",Ce%T oTPKr1]e=python/libstdcxx/v6/__pycache__/xmethods.cpython-36.opt-1.pycnu[3 hq@sddlZddlZddlZdZddZddZdZdd ZGd d d ejj Z Gd d d ejj Z Gddde Z Gddde ZGddde ZGddde ZGddde ZGddde ZGdddejjZGdddejj ZGdddeZGd d!d!eZGd"d#d#eZGd$d%d%eZGd&d'd'eZGd(d)d)eZGd*d+d+ejjZGd,d-d-ejjZGd.d/d/eZGd0d1d1eZGd2d3d3ejjZ Gd4d5d5ejj Z!Gd6d7d7e!Z"Gd8d9d9e!Z#Gd:d;d;e!Z$Gdd?d?ejjZ&Gd@dAdAejj Z'GdBdCdCe'Z(GdDdEdEe'Z)GdFdGdGe'Z*GdHdIdIe'Z+GdJdKdKe'Z,GdLdMdMe'Z-GdNdOdOejjZ.GdPdQdQejj Z/GdRdSdSe/Z0GdTdUdUe/Z1GdVdWdWejjZ2GdXdYdYejj Z3GdZd[d[e3Z4Gd\d]d]e3Z5Gd^d_d_ejjZ6Gd`dadaejj Z7Gdbdcdce7Z8Gdddedee7Z9Gdfdgdgejj Z:Gdhdidie:Z;GdjdkdkejjZ$N) isinstancerZTypetag_versioned_namespacerematch)xZ template_namerrris_specialization_of!s  rc@seZdZddZdS)LibStdCxxXMethodcCstjjj||||_dS)N)rxmethodXMethod__init__ worker_class)selfnamerrrrr.szLibStdCxxXMethod.__init__N)__name__ __module__ __qualname__rrrrrr-src@seZdZddZddZdS)ArrayWorkerBasecCs||_||_dS)N) _val_type_size)rval_typesizerrrr6szArrayWorkerBase.__init__cCstjd}|j|jjjS)Nz (void *) 0)rZparse_and_evalcastrpointer dereference)rZnullptrrrr null_value:s zArrayWorkerBase.null_valueN)rrrrr"rrrrr5src@s,eZdZddZddZddZddZd S) ArraySizeWorkercCstj|||dS)N)rr)rrrrrrr@szArraySizeWorker.__init__cCsdS)Nr)rrrr get_arg_typesCszArraySizeWorker.get_arg_typescCstS)N)r)robjrrrget_result_typeFszArraySizeWorker.get_result_typecCs|jS)N)r)rr%rrr__call__IszArraySizeWorker.__call__N)rrrrr$r&r'rrrrr#?sr#c@s,eZdZddZddZddZddZd S) ArrayEmptyWorkercCstj|||dS)N)rr)rrrrrrrNszArrayEmptyWorker.__init__cCsdS)Nr)rrrrr$QszArrayEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&Tsz ArrayEmptyWorker.get_result_typecCst|jdkS)Nr)intr)rr%rrrr'WszArrayEmptyWorker.__call__N)rrrrr$r&r'rrrrr(Msr(c@s,eZdZddZddZddZddZd S) ArrayFrontWorkercCstj|||dS)N)rr)rrrrrrr\szArrayFrontWorker.__init__cCsdS)Nr)rrrrr$_szArrayFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&bsz ArrayFrontWorker.get_result_typecCs&t|jdkr|ddS|jSdS)Nr_M_elems)r)rr")rr%rrrr'es zArrayFrontWorker.__call__N)rrrrr$r&r'rrrrr*[sr*c@s,eZdZddZddZddZddZd S) ArrayBackWorkercCstj|||dS)N)rr)rrrrrrrmszArrayBackWorker.__init__cCsdS)Nr)rrrrr$pszArrayBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sszArrayBackWorker.get_result_typecCs,t|jdkr |d|jdS|jSdS)Nrr+)r)rr")rr%rrrr'vszArrayBackWorker.__call__N)rrrrr$r&r'rrrrr,lsr,c@s,eZdZddZddZddZddZd S) ArrayAtWorkercCstj|||dS)N)rr)rrrrrrr~szArrayAtWorker.__init__cCstS)N)r)rrrrr$szArrayAtWorker.get_arg_typescCs|jS)N)r)rr%indexrrrr&szArrayAtWorker.get_result_typecCs4t|t|jkr(tdt||jf|d|S)Nz%Array index "%d" should not be >= %d.r+)r)r IndexError)rr%r/rrrr'szArrayAtWorker.__call__N)rrrrr$r&r'rrrrr.}sr.c@s,eZdZddZddZddZddZd S) ArraySubscriptWorkercCstj|||dS)N)rr)rrrrrrrszArraySubscriptWorker.__init__cCstS)N)r)rrrrr$sz"ArraySubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz$ArraySubscriptWorker.get_result_typecCs&t|jdkr|d|S|jSdS)Nrr+)r)rr")rr%r/rrrr's zArraySubscriptWorker.__call__N)rrrrr$r&r'rrrrr1sr1c@seZdZddZddZdS)ArrayMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Narrayremptyfrontbackatz operator[])rr4r5r6r7z operator[]csg|]}j|qSr) _method_dict).0m)rrr sz0ArrayMethodsMatcher.__init__..)rrXMethodMatcherrmatcher_name_prefixrr#r(r*r,r.r1r8methods)rr)rrrs  zArrayMethodsMatcher.__init__c Cs^t|dsdS|jj|}|dks*|j r.dSy|jd}|jd}Wn dS|j||S)Nr3rr-)rr8getenabledtemplate_argumentr)r class_type method_namemethodZ value_typerrrrr s   zArrayMethodsMatcher.matchN)rrrrr rrrrr2s r2c@s$eZdZddZddZddZdS)DequeWorkerBasecCs||_d|jpd|_dS)Nir-)rsizeof_bufsize)rrrrrrszDequeWorkerBase.__init__cCsf|dd}|dd}|d|dkr,dS|j|d|dd|d|d|d |dS) N_M_impl_M_start _M_finish_M_curr_M_noder-_M_first_M_last)rG)rr%startfinishrrrrs   zDequeWorkerBase.sizecCs`|dd}|d|d}||kr0|d|S||}|ddt||j}|||jS)NrHrIrNrKrLr-)r)rG)rr%idxrOZfirst_node_sizeZ index_noderrrr/s  zDequeWorkerBase.indexN)rrrrrr/rrrrrEs rEc@s$eZdZddZddZddZdS)DequeEmptyWorkercCsdS)Nr)rrrrr$szDequeEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&sz DequeEmptyWorker.get_result_typecCs |ddd|dddkS)NrHrIrKrJr)rr%rrrr'szDequeEmptyWorker.__call__N)rrrr$r&r'rrrrrRsrRc@s$eZdZddZddZddZdS)DequeSizeWorkercCsdS)Nr)rrrrr$szDequeSizeWorker.get_arg_typescCstS)N)r)rr%rrrr&szDequeSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'szDequeSizeWorker.__call__N)rrrr$r&r'rrrrrSsrSc@s$eZdZddZddZddZdS)DequeFrontWorkercCsdS)Nr)rrrrr$szDequeFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz DequeFrontWorker.get_result_typecCs|ddddS)NrHrIrKrr)rr%rrrr'szDequeFrontWorker.__call__N)rrrr$r&r'rrrrrTsrTc@s$eZdZddZddZddZdS)DequeBackWorkercCsdS)Nr)rrrrr$szDequeBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&szDequeBackWorker.get_result_typecCs^|ddd|dddkrF|dddd}|d|jdS|ddddSdS) NrHrJrKrMrLr-r)rG)rr% prev_noderrrr's zDequeBackWorker.__call__N)rrrr$r&r'rrrrrUsrUc@s$eZdZddZddZddZdS)DequeSubscriptWorkercCstS)N)r)rrrrr$ sz"DequeSubscriptWorker.get_arg_typescCs|jS)N)r)rr% subscriptrrrr& sz$DequeSubscriptWorker.get_result_typecCs |j||S)N)r/)rr%rYrrrr'szDequeSubscriptWorker.__call__N)rrrr$r&r'rrrrrX srXc@s$eZdZddZddZddZdS) DequeAtWorkercCstS)N)r)rrrrr$szDequeAtWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&szDequeAtWorker.get_result_typecCs@t|j|}t||kr0tdt||fn |j||SdS)Nz%Deque index "%d" should not be >= %d.)r)rr0r/)rr%r/Z deque_sizerrrr's  zDequeAtWorker.__call__N)rrrr$r&r'rrrrrZsrZc@seZdZddZddZdS)DequeMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Ndequer4rr5r6z operator[]r7)r4rr5r6z operator[]r7csg|]}j|qSr)r8)r9r:)rrrr;0sz0DequeMethodsMatcher.__init__..)rrr<rr=rrRrSrTrUrXrZr8r>)rr)rrr%s  zDequeMethodsMatcher.__init__cCs>t|dsdS|jj|}|dks*|j r.dS|j|jdS)Nr\r)rr8r?r@rrA)rrBrCrDrrrr 2s   zDequeMethodsMatcher.matchN)rrrrr rrrrr[$s r[c@seZdZddZddZdS)ForwardListWorkerBasecCs||_||_dS)N)r _node_type)rr node_typerrrr>szForwardListWorkerBase.__init__cCsdS)Nr)rrrrr$Bsz#ForwardListWorkerBase.get_arg_typesN)rrrrr$rrrrr]=sr]c@seZdZddZddZdS)ForwardListEmptyWorkercCstS)N)r)rr%rrrr&Gsz&ForwardListEmptyWorker.get_result_typecCs|ddddkS)NrH_M_head_M_nextrr)rr%rrrr'JszForwardListEmptyWorker.__call__N)rrrr&r'rrrrr`Fsr`c@seZdZddZddZdS)ForwardListFrontWorkercCs|jS)N)r)rr%rrrr&Osz&ForwardListFrontWorker.get_result_typecCs:|dddj|j}|ddj}|j|jjjS)NrHrarb _M_storage)rr^addressrr r!)rr%nodeZ val_addressrrrr'RszForwardListFrontWorker.__call__N)rrrr&r'rrrrrcNsrcc@seZdZddZddZdS)ForwardListMethodsMatchercsJtd}tjjj|tdttdtd_fddjD_ dS)N forward_listr4r5)r4r5csg|]}j|qSr)r8)r9r:)rrrr;`sz6ForwardListMethodsMatcher.__init__..) r=rrr<rrr`rcr8r>)rZ matcher_namer)rrrYs z"ForwardListMethodsMatcher.__init__cCsZt|dsdS|jj|}|dks*|j r.dS|jd}tjt|dj}|j ||S)Nrhrz::_Node) rr8r?r@rArrstrr r)rrBrCrDrr_rrrr bs   zForwardListMethodsMatcher.matchN)rrrrr rrrrrgXs rgc@s$eZdZddZddZddZdS)ListWorkerBasecCs||_||_dS)N)rr^)rrr_rrrrpszListWorkerBase.__init__cCsdS)Nr)rrrrr$tszListWorkerBase.get_arg_typescCsB|j}|jjdjdkr$|dS|dj}|j|jjjS)Nr-Z_M_datard)r!typefieldsrrerrr )rrfZaddrrrrget_value_from_nodews  z"ListWorkerBase.get_value_from_nodeN)rrrrr$rmrrrrrjosrjc@seZdZddZddZdS)ListEmptyWorkercCstS)N)r)rr%rrrr&szListEmptyWorker.get_result_typecCs&|dd}|d|jkrdSdSdS)NrHrLrbTF)re)rr%Z base_noderrrr's zListEmptyWorker.__call__N)rrrr&r'rrrrrnsrnc@seZdZddZddZdS)ListSizeWorkercCstS)N)r)rr%rrrr&szListSizeWorker.get_result_typecCsD|ddd}|ddj}d}x||kr>|d}|d7}q$W|S)NrHrLrbrr-)re)rr%Z begin_nodeZend_noderrrrr's  zListSizeWorker.__call__N)rrrr&r'rrrrrosroc@seZdZddZddZdS)ListFrontWorkercCs|jS)N)r)rr%rrrr&szListFrontWorker.get_result_typecCs"|dddj|j}|j|S)NrHrLrb)rr^rm)rr%rfrrrr'szListFrontWorker.__call__N)rrrr&r'rrrrrpsrpc@seZdZddZddZdS)ListBackWorkercCs|jS)N)r)rr%rrrr&szListBackWorker.get_result_typecCs"|dddj|j}|j|S)NrHrLZ_M_prev)rr^rm)rr%rWrrrr'szListBackWorker.__call__N)rrrr&r'rrrrrqsrqc@seZdZddZddZdS)ListMethodsMatchercsVtjjjtdtdttdttdttdt d_ fddj D_ dS) Nlistr4rr5r6)r4rr5r6csg|]}j|qSr)r8)r9r:)rrrr;sz/ListMethodsMatcher.__init__..) rrr<rr=rrnrorprqr8r>)rr)rrrs  zListMethodsMatcher.__init__cCsZt|dsdS|jj|}|dks*|j r.dS|jd}tjt|dj}|j ||S)Nz(__cxx11::)?listrz::_Node) rr8r?r@rArrrir r)rrBrCrDrr_rrrr s   zListMethodsMatcher.matchN)rrrrr rrrrrrs rrc@s$eZdZddZddZddZdS)VectorWorkerBasecCs ||_dS)N)r)rrrrrrszVectorWorkerBase.__init__cCsz|jjtjkr^|ddd}|ddd}|ddd}|jjjd}||||S|dd|ddSdS)NrHrI_M_prJZ _M_offset)rcoderTYPE_CODE_BOOLr!rkrF)rr%rOrPZ finish_offsetbit_sizerrrrszVectorWorkerBase.sizecCsj|jjtjkrV|ddd}|jjjd}|||}||}|jd|>@dkS|dd|SdS)NrHrIrurvr-r)rrwrrxr!rkrF)rr%r/rOryZvalpoffsetrrrr?s zVectorWorkerBase.getN)rrrrrr?rrrrrts rtc@s$eZdZddZddZddZdS)VectorEmptyWorkercCsdS)Nr)rrrrr$szVectorEmptyWorker.get_arg_typescCstS)N)r)rr%rrrr&sz!VectorEmptyWorker.get_result_typecCst|j|dkS)Nr)r)r)rr%rrrr'szVectorEmptyWorker.__call__N)rrrr$r&r'rrrrr{sr{c@s$eZdZddZddZddZdS)VectorSizeWorkercCsdS)Nr)rrrrr$szVectorSizeWorker.get_arg_typescCstS)N)r)rr%rrrr&sz VectorSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'szVectorSizeWorker.__call__N)rrrr$r&r'rrrrr|sr|c@s$eZdZddZddZddZdS)VectorFrontWorkercCsdS)Nr)rrrrr$szVectorFrontWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz!VectorFrontWorker.get_result_typecCs |j|dS)Nr)r?)rr%rrrr'szVectorFrontWorker.__call__N)rrrr$r&r'rrrrr}sr}c@s$eZdZddZddZddZdS)VectorBackWorkercCsdS)Nr)rrrrr$szVectorBackWorker.get_arg_typescCs|jS)N)r)rr%rrrr&sz VectorBackWorker.get_result_typecCs|j|t|j|dS)Nr-)r?r)r)rr%rrrr'szVectorBackWorker.__call__N)rrrr$r&r'rrrrr~sr~c@s$eZdZddZddZddZdS)VectorAtWorkercCstS)N)r)rrrrr$ szVectorAtWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&szVectorAtWorker.get_result_typecCs>t|j|}t||kr.tdt||f|j|t|S)Nz&Vector index "%d" should not be >= %d.)r)rr0r?)rr%r/rrrrr's  zVectorAtWorker.__call__N)rrrr$r&r'rrrrr src@s$eZdZddZddZddZdS)VectorSubscriptWorkercCstS)N)r)rrrrr$sz#VectorSubscriptWorker.get_arg_typescCs|jS)N)r)rr%rYrrrr&sz%VectorSubscriptWorker.get_result_typecCs|j|t|S)N)r?r))rr%rYrrrr'!szVectorSubscriptWorker.__call__N)rrrr$r&r'rrrrrsrc@seZdZddZddZdS)VectorMethodsMatchercsftjjjtdtdttdttdttdt tdt tdt d_ fd d j D_ dS) Nvectorrr4r5r6r7z operator[])rr4r5r6r7z operator[]csg|]}j|qSr)r8)r9r:)rrrr;2sz1VectorMethodsMatcher.__init__..)rrr<rr=rr|r{r}r~rrr8r>)rr)rrr&s   zVectorMethodsMatcher.__init__cCs>t|dsdS|jj|}|dks*|j r.dS|j|jdS)Nrr)rr8r?r@rrA)rrBrCrDrrrr 4s   zVectorMethodsMatcher.matchN)rrrrr rrrrr%src@s$eZdZddZddZddZdS)AssociativeContainerWorkerBasecCs ||_dS)N) _unordered)r unorderedrrrr@sz'AssociativeContainerWorkerBase.__init__cCs&|jr|ddS|dddSdS)NZ_M_hZ_M_element_count_M_trHZ _M_node_count)r)rr%rrr node_countCs z)AssociativeContainerWorkerBase.node_countcCsdS)Nr)rrrrr$Isz,AssociativeContainerWorkerBase.get_arg_typesN)rrrrrr$rrrrr?src@seZdZddZddZdS)AssociativeContainerEmptyWorkercCstS)N)r)rr%rrrr&Nsz/AssociativeContainerEmptyWorker.get_result_typecCst|j|dkS)Nr)r)r)rr%rrrr'Qsz(AssociativeContainerEmptyWorker.__call__N)rrrr&r'rrrrrMsrc@seZdZddZddZdS)AssociativeContainerSizeWorkercCstS)N)r)rr%rrrr&Vsz.AssociativeContainerSizeWorker.get_result_typecCs |j|S)N)r)rr%rrrr'Ysz'AssociativeContainerSizeWorker.__call__N)rrrr&r'rrrrrUsrc@seZdZddZddZdS)"AssociativeContainerMethodsMatchercsLtjjjt||_tdttdtd_ fddj D_ dS)Nrr4)rr4csg|]}j|qSr)r8)r9r:)rrrr;gsz?AssociativeContainerMethodsMatcher.__init__..) rrr<rr=_namerrrr8r>)rrr)rrr^s   z+AssociativeContainerMethodsMatcher.__init__cCsDt||jsdS|jj|}|dks,|j r0dSd|jk}|j|S)Nr)rrr8r?r@r)rrBrCrDrrrrr is   z(AssociativeContainerMethodsMatcher.matchN)rrrrr rrrrr]s rc@s8eZdZdZddZddZddZdd Zd d Zd S) UniquePtrGetWorkerzS Implement std::unique_ptr::get() and std::unique_ptr::operator->(). cCs*|jtjk|_|jr |j|_n||_dS)N)rwrTYPE_CODE_ARRAY _is_arraytarget _elem_type)r elem_typerrrrzs zUniquePtrGetWorker.__init__cCsdS)Nr)rrrrr$sz UniquePtrGetWorker.get_arg_typescCs |jjS)N)rr )rr%rrrr&sz"UniquePtrGetWorker.get_result_typecCs|dkp|j S)Nr?)r)rrCrrr _supportsszUniquePtrGetWorker._supportscCs|jjjdjj}t|dr.|dd}nt|drB|d}ndS|jjdj}|jdj}|jd}|jdkr|j|dS|jr|j|jSdSdS)Nrz__uniq_ptr_(data|impl)rtupler-Z _M_head_impl)r!rkrlr rrrZ is_base_class)rr%Z impl_typeZ tuple_memberZtuple_impl_typeZtuple_head_typeZ head_fieldrrrr's      zUniquePtrGetWorker.__call__N) rrr__doc__rr$r&rr'rrrrrus rc@s0eZdZdZddZddZddZdd Zd S) UniquePtrDerefWorkerz*Implement std::unique_ptr::operator*().cCstj||dS)N)rr)rrrrrrszUniquePtrDerefWorker.__init__cCs|jS)N)r)rr%rrrr&sz$UniquePtrDerefWorker.get_result_typecCs|j S)N)r)rrCrrrrszUniquePtrDerefWorker._supportscCstj||jS)N)rr'r!)rr%rrrr'szUniquePtrDerefWorker.__call__N)rrrrrr&rr'rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) UniquePtrSubscriptWorkerz1Implement std::unique_ptr::operator[](size_t).cCstj||dS)N)rr)rrrrrrsz!UniquePtrSubscriptWorker.__init__cCstS)N)r)rrrrr$sz&UniquePtrSubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz(UniquePtrSubscriptWorker.get_result_typecCs|jS)N)r)rrCrrrrsz"UniquePtrSubscriptWorker._supportscCstj|||S)N)rr')rr%r/rrrr'sz!UniquePtrSubscriptWorker.__call__N) rrrrrr$r&rr'rrrrrs rc@seZdZddZddZdS)UniquePtrMethodsMatchercsVtjjjtdtdttdttdttdtd_ fddj D_ dS) N unique_ptrr?z operator->z operator*z operator[])r?z operator->z operator*z operator[]csg|]}j|qSr)r8)r9r:)rrrr;sz4UniquePtrMethodsMatcher.__init__..) rrr<rr=rrrrr8r>)rr)rrrs  z UniquePtrMethodsMatcher.__init__cCsPt|dsdS|jj|}|dks*|j r.dS|j|jd}|j|rL|SdS)Nrr)rr8r?r@rrAr)rrBrCrDworkerrrrr s   zUniquePtrMethodsMatcher.matchN)rrrrr rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrGetWorkerzT Implements std::shared_ptr::get() and std::shared_ptr::operator->(). cCs*|jtjk|_|jr |j|_n||_dS)N)rwrrrrr)rrrrrrs zSharedPtrGetWorker.__init__cCsdS)Nr)rrrrr$sz SharedPtrGetWorker.get_arg_typescCs |jjS)N)rr )rr%rrrr&sz"SharedPtrGetWorker.get_result_typecCs|dkp|j S)Nr?)r)rrCrrrrszSharedPtrGetWorker._supportscCs|dS)NZ_M_ptrr)rr%rrrr'szSharedPtrGetWorker.__call__N) rrrrrr$r&rr'rrrrrs rc@s0eZdZdZddZddZddZdd Zd S) SharedPtrDerefWorkerz*Implement std::shared_ptr::operator*().cCstj||dS)N)rr)rrrrrrszSharedPtrDerefWorker.__init__cCs|jS)N)r)rr%rrrr&sz$SharedPtrDerefWorker.get_result_typecCs|j S)N)r)rrCrrrrszSharedPtrDerefWorker._supportscCstj||jS)N)rr'r!)rr%rrrr'szSharedPtrDerefWorker.__call__N)rrrrrr&rr'rrrrrs rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrSubscriptWorkerz1Implement std::shared_ptr::operator[](size_t).cCstj||dS)N)rr)rrrrrr sz!SharedPtrSubscriptWorker.__init__cCstS)N)r)rrrrr$sz&SharedPtrSubscriptWorker.get_arg_typescCs|jS)N)r)rr%r/rrrr&sz(SharedPtrSubscriptWorker.get_result_typecCs|jS)N)r)rrCrrrrsz"SharedPtrSubscriptWorker._supportscCsZtjdt|j}|rJ|t|jdkrJtd|jt|t|jdftj|||S)Nz .*\[(\d+)]$r-z.shared_ptr<%s> index "%d" should not be >= %d.) r r rirr)groupr0rr')rr%r/r:rrrr's z!SharedPtrSubscriptWorker.__call__N) rrrrrr$r&rr'rrrrr s rc@s8eZdZdZddZddZddZdd Zd d Zd S) SharedPtrUseCountWorkerz*Implement std::shared_ptr::use_count().cCsdS)Nr)rrrrrr%sz SharedPtrUseCountWorker.__init__cCsdS)Nr)rrrrr$(sz%SharedPtrUseCountWorker.get_arg_typescCs tjdS)NZlong)rr)rr%rrrr&+sz'SharedPtrUseCountWorker.get_result_typecCsdS)NTr)rrCrrrr.sz!SharedPtrUseCountWorker._supportscCs|dd}|r|dSdS)NZ _M_refcountZ_M_piZ _M_use_countrr)rr%Z refcountsrrrr'1s z SharedPtrUseCountWorker.__call__N) rrrrrr$r&rr'rrrrr"s rc@s(eZdZdZddZddZddZdS) SharedPtrUniqueWorkerz'Implement std::shared_ptr::unique().cCstj||dS)N)rr)rrrrrr9szSharedPtrUniqueWorker.__init__cCs tjdS)Nr)rr)rr%rrrr&<sz%SharedPtrUniqueWorker.get_result_typecCstj||dkS)Nr-)rr')rr%rrrr'?szSharedPtrUniqueWorker.__call__N)rrrrrr&r'rrrrr6src@seZdZddZddZdS)SharedPtrMethodsMatchercsftjjjtdtdttdttdttdttdt tdt d_ fd d j D_ dS) N shared_ptrr?z operator->z operator*z operator[] use_countunique)r?z operator->z operator*z operator[]rrcsg|]}j|qSr)r8)r9r:)rrrr;Osz4SharedPtrMethodsMatcher.__init__..) rrr<rr=rrrrrrr8r>)rr)rrrDs  z SharedPtrMethodsMatcher.__init__cCsPt|dsdS|jj|}|dks*|j r.dS|j|jd}|j|rL|SdS)Nrr)rr8r?r@rrAr)rrBrCrDrrrrr Qs   zSharedPtrMethodsMatcher.matchN)rrrrr rrrrrCs rcCstjj|ttjj|ttjj|ttjj|ttjj|ttjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|tdtjj|t tjj|t dS) NsetmapZmultisetZmultimapZ unordered_setZ unordered_mapZunordered_multisetZunordered_multimap) rrZregister_xmethod_matcherr2rgr[rrrrrr)Zlocusrrrregister_libstdcxx_xmethods]s.        r)>rZ gdb.xmethodr r=rrr rrrrZ XMethodWorkerrr#r(r*r,r.r1r<r2rErRrSrTrUrXrZr[r]r`rcrgrjrnrorprqrrrtr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrsr                * PKr1] B667python/libstdcxx/v6/__pycache__/__init__.cpython-36.pycnu[3 h}@sddZddZdS)c Cs&y ddl}dStk r dSXdS)NTF)Z gdb.xmethod ImportError)Zgdbr0/usr/share/gcc-8/python/libstdcxx/v6/__init__.pygdb_has_xmethodss rcCs2ddlm}||tr.ddlm}||dS)N)register_libstdcxx_printers)register_libstdcxx_xmethods)ZprintersrrZxmethodsr)objrrrrrrs   rN)rrrrrrsPKr1]qqpython/libstdcxx/v6/xmethods.pynu[# Xmethods for libstdc++. # Copyright (C) 2014-2025 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 gdb.xmethod import re matcher_name_prefix = 'libstdc++::' def get_bool_type(): return gdb.lookup_type('bool') def get_std_size_type(): return gdb.lookup_type('std::size_t') _versioned_namespace = '__8::' def is_specialization_of(x, template_name): """ Test whether a type is a specialization of the named class template. The type can be specified as a string or a gdb.Type object. The template should be the name of a class template as a string, without any 'std' qualification. """ if isinstance(x, gdb.Type): x = x.tag template_name = '(%s)?%s' % (_versioned_namespace, template_name) return re.match(r'^std::(__\d::)?%s<.*>$' % template_name, x) is not None class LibStdCxxXMethod(gdb.xmethod.XMethod): def __init__(self, name, worker_class): gdb.xmethod.XMethod.__init__(self, name) self.worker_class = worker_class # Xmethods for std::array class ArrayWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type, size): self._val_type = val_type self._size = size def null_value(self): nullptr = gdb.parse_and_eval('(void *) 0') return nullptr.cast(self._val_type.pointer()).dereference() class ArraySizeWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return None def get_result_type(self, obj): return get_std_size_type() def __call__(self, obj): return self._size class ArrayEmptyWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return None def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): return (int(self._size) == 0) class ArrayFrontWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): if int(self._size) > 0: return obj['_M_elems'][0] else: return self.null_value() class ArrayBackWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): if int(self._size) > 0: return obj['_M_elems'][self._size - 1] else: return self.null_value() class ArrayAtWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._val_type def __call__(self, obj, index): if int(index) >= int(self._size): raise IndexError('Array index "%d" should not be >= %d.' % ((int(index), self._size))) return obj['_M_elems'][index] class ArraySubscriptWorker(ArrayWorkerBase): def __init__(self, val_type, size): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._val_type def __call__(self, obj, index): if int(self._size) > 0: return obj['_M_elems'][index] else: return self.null_value() class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'array') self._method_dict = { 'size': LibStdCxxXMethod('size', ArraySizeWorker), 'empty': LibStdCxxXMethod('empty', ArrayEmptyWorker), 'front': LibStdCxxXMethod('front', ArrayFrontWorker), 'back': LibStdCxxXMethod('back', ArrayBackWorker), 'at': LibStdCxxXMethod('at', ArrayAtWorker), 'operator[]': LibStdCxxXMethod('operator[]', ArraySubscriptWorker), } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'array'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None try: value_type = class_type.template_argument(0) size = class_type.template_argument(1) except: return None return method.worker_class(value_type, size) # Xmethods for std::deque class DequeWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type): self._val_type = val_type self._bufsize = 512 // val_type.sizeof or 1 def size(self, obj): start = obj['_M_impl']['_M_start'] finish = obj['_M_impl']['_M_finish'] if start['_M_cur'] == finish['_M_cur']: return 0 return (self._bufsize * (finish['_M_node'] - start['_M_node'] - 1) + (finish['_M_cur'] - finish['_M_first']) + (start['_M_last'] - start['_M_cur'])) def index(self, obj, idx): start = obj['_M_impl']['_M_start'] first_node_size = start['_M_last'] - start['_M_cur'] if idx < first_node_size: return start['_M_cur'][idx] idx = idx - first_node_size index_node = start['_M_node'][1 + int(idx) // self._bufsize] return index_node[idx % self._bufsize] class DequeEmptyWorker(DequeWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): return (obj['_M_impl']['_M_start']['_M_cur'] == obj['_M_impl']['_M_finish']['_M_cur']) class DequeSizeWorker(DequeWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return get_std_size_type() def __call__(self, obj): return self.size(obj) class DequeFrontWorker(DequeWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): return obj['_M_impl']['_M_start']['_M_cur'][0] class DequeBackWorker(DequeWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): if (obj['_M_impl']['_M_finish']['_M_cur'] == obj['_M_impl']['_M_finish']['_M_first']): prev_node = obj['_M_impl']['_M_finish']['_M_node'] - 1 return prev_node[0][self._bufsize - 1] else: return obj['_M_impl']['_M_finish']['_M_cur'][-1] class DequeSubscriptWorker(DequeWorkerBase): def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, subscript): return self._val_type def __call__(self, obj, subscript): return self.index(obj, subscript) class DequeAtWorker(DequeWorkerBase): def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._val_type def __call__(self, obj, index): deque_size = int(self.size(obj)) if int(index) >= deque_size: raise IndexError('Deque index "%d" should not be >= %d.' % (int(index), deque_size)) else: return self.index(obj, index) class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'deque') self._method_dict = { 'empty': LibStdCxxXMethod('empty', DequeEmptyWorker), 'size': LibStdCxxXMethod('size', DequeSizeWorker), 'front': LibStdCxxXMethod('front', DequeFrontWorker), 'back': LibStdCxxXMethod('back', DequeBackWorker), 'operator[]': LibStdCxxXMethod('operator[]', DequeSubscriptWorker), 'at': LibStdCxxXMethod('at', DequeAtWorker) } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'deque'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None return method.worker_class(class_type.template_argument(0)) # Xmethods for std::forward_list class ForwardListWorkerBase(gdb.xmethod.XMethodMatcher): def __init__(self, val_type, node_type): self._val_type = val_type self._node_type = node_type def get_arg_types(self): return None class ForwardListEmptyWorker(ForwardListWorkerBase): def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): return obj['_M_impl']['_M_head']['_M_next'] == 0 class ForwardListFrontWorker(ForwardListWorkerBase): def get_result_type(self, obj): return self._val_type def __call__(self, obj): node = obj['_M_impl']['_M_head']['_M_next'].cast(self._node_type) val_address = node['_M_storage']['_M_storage'].address return val_address.cast(self._val_type.pointer()).dereference() class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): matcher_name = matcher_name_prefix + 'forward_list' gdb.xmethod.XMethodMatcher.__init__(self, matcher_name) self._method_dict = { 'empty': LibStdCxxXMethod('empty', ForwardListEmptyWorker), 'front': LibStdCxxXMethod('front', ForwardListFrontWorker) } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'forward_list'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None val_type = class_type.template_argument(0) node_type = gdb.lookup_type(str(class_type) + '::_Node').pointer() return method.worker_class(val_type, node_type) # Xmethods for std::list class ListWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type, node_type): self._val_type = val_type self._node_type = node_type def get_arg_types(self): return None def get_value_from_node(self, node): node = node.dereference() if node.type.fields()[1].name == '_M_data': # C++03 implementation, node contains the value as a member return node['_M_data'] # C++11 implementation, node stores value in __aligned_membuf addr = node['_M_storage'].address return addr.cast(self._val_type.pointer()).dereference() class ListEmptyWorker(ListWorkerBase): def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): base_node = obj['_M_impl']['_M_node'] if base_node['_M_next'] == base_node.address: return True else: return False class ListSizeWorker(ListWorkerBase): def get_result_type(self, obj): return get_std_size_type() def __call__(self, obj): begin_node = obj['_M_impl']['_M_node']['_M_next'] end_node = obj['_M_impl']['_M_node'].address size = 0 while begin_node != end_node: begin_node = begin_node['_M_next'] size += 1 return size class ListFrontWorker(ListWorkerBase): def get_result_type(self, obj): return self._val_type def __call__(self, obj): node = obj['_M_impl']['_M_node']['_M_next'].cast(self._node_type) return self.get_value_from_node(node) class ListBackWorker(ListWorkerBase): def get_result_type(self, obj): return self._val_type def __call__(self, obj): prev_node = obj['_M_impl']['_M_node']['_M_prev'].cast(self._node_type) return self.get_value_from_node(prev_node) class ListMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'list') self._method_dict = { 'empty': LibStdCxxXMethod('empty', ListEmptyWorker), 'size': LibStdCxxXMethod('size', ListSizeWorker), 'front': LibStdCxxXMethod('front', ListFrontWorker), 'back': LibStdCxxXMethod('back', ListBackWorker) } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, '(__cxx11::)?list'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None val_type = class_type.template_argument(0) node_type = gdb.lookup_type(str(class_type) + '::_Node').pointer() return method.worker_class(val_type, node_type) # Xmethods for std::vector class VectorWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type): self._val_type = val_type def size(self, obj): if self._val_type.code == gdb.TYPE_CODE_BOOL: start = obj['_M_impl']['_M_start']['_M_p'] finish = obj['_M_impl']['_M_finish']['_M_p'] finish_offset = obj['_M_impl']['_M_finish']['_M_offset'] bit_size = start.dereference().type.sizeof * 8 return (finish - start) * bit_size + finish_offset else: return obj['_M_impl']['_M_finish'] - obj['_M_impl']['_M_start'] def get(self, obj, index): if self._val_type.code == gdb.TYPE_CODE_BOOL: start = obj['_M_impl']['_M_start']['_M_p'] bit_size = start.dereference().type.sizeof * 8 valp = start + index // bit_size offset = index % bit_size return (valp.dereference() & (1 << offset)) > 0 else: return obj['_M_impl']['_M_start'][index] class VectorEmptyWorker(VectorWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): return int(self.size(obj)) == 0 class VectorSizeWorker(VectorWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return get_std_size_type() def __call__(self, obj): return self.size(obj) class VectorFrontWorker(VectorWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): return self.get(obj, 0) class VectorBackWorker(VectorWorkerBase): def get_arg_types(self): return None def get_result_type(self, obj): return self._val_type def __call__(self, obj): return self.get(obj, int(self.size(obj)) - 1) class VectorAtWorker(VectorWorkerBase): def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._val_type def __call__(self, obj, index): size = int(self.size(obj)) if int(index) >= size: raise IndexError('Vector index "%d" should not be >= %d.' % ((int(index), size))) return self.get(obj, int(index)) class VectorSubscriptWorker(VectorWorkerBase): def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, subscript): return self._val_type def __call__(self, obj, subscript): return self.get(obj, int(subscript)) class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'vector') self._method_dict = { 'size': LibStdCxxXMethod('size', VectorSizeWorker), 'empty': LibStdCxxXMethod('empty', VectorEmptyWorker), 'front': LibStdCxxXMethod('front', VectorFrontWorker), 'back': LibStdCxxXMethod('back', VectorBackWorker), 'at': LibStdCxxXMethod('at', VectorAtWorker), 'operator[]': LibStdCxxXMethod('operator[]', VectorSubscriptWorker), } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'vector'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None return method.worker_class(class_type.template_argument(0)) # Xmethods for associative containers class AssociativeContainerWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, unordered): self._unordered = unordered def node_count(self, obj): if self._unordered: return obj['_M_h']['_M_element_count'] else: return obj['_M_t']['_M_impl']['_M_node_count'] def get_arg_types(self): return None class AssociativeContainerEmptyWorker(AssociativeContainerWorkerBase): def get_result_type(self, obj): return get_bool_type() def __call__(self, obj): return int(self.node_count(obj)) == 0 class AssociativeContainerSizeWorker(AssociativeContainerWorkerBase): def get_result_type(self, obj): return get_std_size_type() def __call__(self, obj): return self.node_count(obj) class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self, name): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + name) self._name = name self._method_dict = { 'size': LibStdCxxXMethod('size', AssociativeContainerSizeWorker), 'empty': LibStdCxxXMethod('empty', AssociativeContainerEmptyWorker), } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, self._name): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None unordered = 'unordered' in self._name return method.worker_class(unordered) # Xmethods for std::unique_ptr class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): """ Implement std::unique_ptr::get() and std::unique_ptr::operator->(). """ def __init__(self, elem_type): self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY if self._is_array: self._elem_type = elem_type.target() else: self._elem_type = elem_type def get_arg_types(self): return None def get_result_type(self, obj): return self._elem_type.pointer() def _supports(self, method_name): # operator-> is not supported for unique_ptr return method_name == 'get' or not self._is_array def __call__(self, obj): impl_type = obj.dereference().type.fields()[0].type.tag # Check for new implementations first: if is_specialization_of(impl_type, '__uniq_ptr_(data|impl)'): tuple_member = obj['_M_t']['_M_t'] elif is_specialization_of(impl_type, 'tuple'): tuple_member = obj['_M_t'] else: return None tuple_impl_type = tuple_member.type.fields()[0].type # _Tuple_impl tuple_head_type = tuple_impl_type.fields()[1].type # _Head_base head_field = tuple_head_type.fields()[0] if head_field.name == '_M_head_impl': return tuple_member.cast(tuple_head_type)['_M_head_impl'] elif head_field.is_base_class: return tuple_member.cast(head_field.type) else: return None class UniquePtrDerefWorker(UniquePtrGetWorker): """Implement std::unique_ptr::operator*().""" def __init__(self, elem_type): UniquePtrGetWorker.__init__(self, elem_type) def get_result_type(self, obj): return self._elem_type def _supports(self, method_name): # operator* is not supported for unique_ptr return not self._is_array def __call__(self, obj): return UniquePtrGetWorker.__call__(self, obj).dereference() class UniquePtrSubscriptWorker(UniquePtrGetWorker): """Implement std::unique_ptr::operator[](size_t).""" def __init__(self, elem_type): UniquePtrGetWorker.__init__(self, elem_type) def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._elem_type def _supports(self, method_name): # operator[] is only supported for unique_ptr return self._is_array def __call__(self, obj, index): return UniquePtrGetWorker.__call__(self, obj)[index] class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'unique_ptr') self._method_dict = { 'get': LibStdCxxXMethod('get', UniquePtrGetWorker), 'operator->': LibStdCxxXMethod('operator->', UniquePtrGetWorker), 'operator*': LibStdCxxXMethod('operator*', UniquePtrDerefWorker), 'operator[]': LibStdCxxXMethod('operator[]', UniquePtrSubscriptWorker), } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'unique_ptr'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None worker = method.worker_class(class_type.template_argument(0)) if worker._supports(method_name): return worker return None # Xmethods for std::shared_ptr class SharedPtrGetWorker(gdb.xmethod.XMethodWorker): """ Implements std::shared_ptr::get() and std::shared_ptr::operator->(). """ def __init__(self, elem_type): self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY if self._is_array: self._elem_type = elem_type.target() else: self._elem_type = elem_type def get_arg_types(self): return None def get_result_type(self, obj): return self._elem_type.pointer() def _supports(self, method_name): # operator-> is not supported for shared_ptr return method_name == 'get' or not self._is_array def __call__(self, obj): return obj['_M_ptr'] class SharedPtrDerefWorker(SharedPtrGetWorker): """Implement std::shared_ptr::operator*().""" def __init__(self, elem_type): SharedPtrGetWorker.__init__(self, elem_type) def get_result_type(self, obj): return self._elem_type def _supports(self, method_name): # operator* is not supported for shared_ptr return not self._is_array def __call__(self, obj): return SharedPtrGetWorker.__call__(self, obj).dereference() class SharedPtrSubscriptWorker(SharedPtrGetWorker): """Implement std::shared_ptr::operator[](size_t).""" def __init__(self, elem_type): SharedPtrGetWorker.__init__(self, elem_type) def get_arg_types(self): return get_std_size_type() def get_result_type(self, obj, index): return self._elem_type def _supports(self, method_name): # operator[] is only supported for shared_ptr return self._is_array def __call__(self, obj, index): # Check bounds if _elem_type is an array of known bound m = re.match(r'.*\[(\d+)]$', str(self._elem_type)) if m and index >= int(m.group(1)): raise IndexError('shared_ptr<%s> index "%d" should not be >= %d.' % (self._elem_type, int(index), int(m.group(1)))) return SharedPtrGetWorker.__call__(self, obj)[index] class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker): """Implement std::shared_ptr::use_count().""" def __init__(self, elem_type): pass def get_arg_types(self): return None def get_result_type(self, obj): return gdb.lookup_type('long') def _supports(self, method_name): return True def __call__(self, obj): refcounts = obj['_M_refcount']['_M_pi'] return refcounts['_M_use_count'] if refcounts else 0 class SharedPtrUniqueWorker(SharedPtrUseCountWorker): """Implement std::shared_ptr::unique().""" def __init__(self, elem_type): SharedPtrUseCountWorker.__init__(self, elem_type) def get_result_type(self, obj): return gdb.lookup_type('bool') def __call__(self, obj): return SharedPtrUseCountWorker.__call__(self, obj) == 1 class SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'shared_ptr') self._method_dict = { 'get': LibStdCxxXMethod('get', SharedPtrGetWorker), 'operator->': LibStdCxxXMethod('operator->', SharedPtrGetWorker), 'operator*': LibStdCxxXMethod('operator*', SharedPtrDerefWorker), 'operator[]': LibStdCxxXMethod('operator[]', SharedPtrSubscriptWorker), 'use_count': LibStdCxxXMethod('use_count', SharedPtrUseCountWorker), 'unique': LibStdCxxXMethod('unique', SharedPtrUniqueWorker), } self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): if not is_specialization_of(class_type, 'shared_ptr'): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: return None worker = method.worker_class(class_type.template_argument(0)) if worker._supports(method_name): return worker return None def register_libstdcxx_xmethods(locus): gdb.xmethod.register_xmethod_matcher(locus, ArrayMethodsMatcher()) gdb.xmethod.register_xmethod_matcher(locus, ForwardListMethodsMatcher()) gdb.xmethod.register_xmethod_matcher(locus, DequeMethodsMatcher()) gdb.xmethod.register_xmethod_matcher(locus, ListMethodsMatcher()) gdb.xmethod.register_xmethod_matcher(locus, VectorMethodsMatcher()) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('set')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('map')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('multiset')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('multimap')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('unordered_set')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('unordered_map')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('unordered_multiset')) gdb.xmethod.register_xmethod_matcher( locus, AssociativeContainerMethodsMatcher('unordered_multimap')) gdb.xmethod.register_xmethod_matcher(locus, UniquePtrMethodsMatcher()) gdb.xmethod.register_xmethod_matcher(locus, SharedPtrMethodsMatcher()) PKr1]ܯ}}python/libstdcxx/v6/__init__.pynu[# Copyright (C) 2014-2025 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 . # Load the xmethods if GDB supports them. def gdb_has_xmethods(): try: import gdb.xmethod return True except ImportError: return False def register_libstdcxx_printers(obj): # Load the pretty-printers. from .printers import register_libstdcxx_printers register_libstdcxx_printers(obj) if gdb_has_xmethods(): from .xmethods import register_libstdcxx_xmethods register_libstdcxx_xmethods(obj) PKr1]CBpython/libstdcxx/v6/printers.pynu[# Pretty-printers for libstdc++. # Copyright (C) 2008-2025 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 import re import sys import errno import datetime # Python 2 + Python 3 compatibility code # Resources about compatibility: # # * : Documentation of the "six" module # FIXME: The handling of e.g. std::basic_string (at least on char) # probably needs updating to work with Python 3's new string rules. # # In particular, Python 3 has a separate type (called byte) for # bytestrings, and a special b"" syntax for the byte literals; the old # str() type has been redefined to always store Unicode text. # # We probably can't do much about this until this GDB PR is addressed: # if sys.version_info[0] > 2: # Python 3 stuff Iterator = object # Python 3 folds these into the normal functions. imap = map izip = zip # Also, int subsumes long long = int _utc_timezone = datetime.timezone.utc else: # Python 2 stuff class Iterator: """Compatibility mixin for iterators Instead of writing next() methods for iterators, write __next__() methods and use this mixin to make them work in Python 2 as well as Python 3. Idea stolen from the "six" documentation: """ def next(self): return self.__next__() # In Python 2, we still need these from itertools from itertools import imap, izip # Python 2 does not provide the datetime.UTC singleton. class UTC(datetime.tzinfo): """Concrete tzinfo class representing the UTC time zone.""" def utcoffset(self, dt): return datetime.timedelta(0) def tzname(self, dt): return "UTC" def dst(self, dt): return datetime.timedelta(0) _utc_timezone = UTC() # Try to use the new-style pretty-printing if available. _use_gdb_pp = True try: import gdb.printing except ImportError: _use_gdb_pp = False # Try to install type-printers. _use_type_printing = False try: import gdb.types if hasattr(gdb.types, 'TypePrinter'): _use_type_printing = True except ImportError: pass # Use the base class if available. if hasattr(gdb, 'ValuePrinter'): printer_base = gdb.ValuePrinter else: printer_base = object # Starting with the type ORIG, search for the member type NAME. This # handles searching upward through superclasses. This is needed to # work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615. def find_type(orig, name): typ = orig.strip_typedefs() while True: # Use Type.tag to ignore cv-qualifiers. PR 67440. search = '%s::%s' % (typ.tag, name) try: return gdb.lookup_type(search) except RuntimeError: pass # The type was not found, so try the superclass. We only need # to check the first superclass, so we don't bother with # anything fancier here. fields = typ.fields() if len(fields) and fields[0].is_base_class: typ = fields[0].type else: raise ValueError("Cannot find type %s::%s" % (str(orig), name)) _versioned_namespace = '__8::' def lookup_templ_spec(templ, *args): """ Lookup template specialization templ. """ t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args])) try: return gdb.lookup_type(t) except gdb.error as e: # Type not found, try again in versioned namespace. global _versioned_namespace if _versioned_namespace not in templ: t = t.replace('::', '::' + _versioned_namespace, 1) try: return gdb.lookup_type(t) except gdb.error: # If that also fails, rethrow the original exception pass raise e # Use this to find container node types instead of find_type, # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997 for details. def lookup_node_type(nodename, containertype): """ Lookup specialization of template nodename corresponding to containertype. nodename - The name of a class template, as a String containertype - The container, as a gdb.Type Return a gdb.Type for the corresponding specialization of nodename, or None if the type cannot be found. e.g. lookup_node_type('_List_node', gdb.lookup_type('std::list')) will return a gdb.Type for the type std::_List_node. """ # If nodename is unqualified, assume it's in namespace std. if '::' not in nodename: nodename = 'std::' + nodename # Use either containertype's value_type or its first template argument. try: valtype = find_type(containertype, 'value_type') except: valtype = containertype.template_argument(0) valtype = valtype.strip_typedefs() try: return lookup_templ_spec(nodename, valtype) except gdb.error: # For debug mode containers the node is in std::__cxx1998. if is_member_of_namespace(nodename, 'std'): if is_member_of_namespace(containertype, 'std::__cxx1998', 'std::__debug', '__gnu_debug'): nodename = nodename.replace('::', '::__cxx1998::', 1) try: return lookup_templ_spec(nodename, valtype) except gdb.error: pass return None def is_member_of_namespace(typ, *namespaces): """ Test whether a type is a member of one of the specified namespaces. The type can be specified as a string or a gdb.Type object. """ if isinstance(typ, gdb.Type): typ = str(typ) typ = strip_versioned_namespace(typ) for namespace in namespaces: if typ.startswith(namespace + '::'): return True return False def is_specialization_of(x, template_name): """ Test whether a type is a specialization of the named class template. The type can be specified as a string or a gdb.Type object. The template should be the name of a class template as a string, without any 'std' qualification. """ global _versioned_namespace if isinstance(x, gdb.Type): x = x.tag template_name = '(%s)?%s' % (_versioned_namespace, template_name) return re.match('^std::%s<.*>$' % template_name, x) is not None def strip_versioned_namespace(typename): global _versioned_namespace return typename.replace(_versioned_namespace, '') def strip_fundts_namespace(typ): """Remove "fundamentals_vN" inline namespace from qualified type name.""" pattern = r'^std::experimental::fundamentals_v\d::' repl = 'std::experimental::' if sys.version_info[0] == 2: return re.sub(pattern, repl, typ, 1) else: # Technically this needs Python 3.1 but nobody should be using 3.0 return re.sub(pattern, repl, typ, count=1) def strip_inline_namespaces(type_str): """Remove known inline namespaces from the canonical name of a type.""" type_str = strip_versioned_namespace(type_str) type_str = type_str.replace('std::__cxx11::', 'std::') expt_ns = 'std::experimental::' for lfts_ns in ('fundamentals_v1', 'fundamentals_v2'): type_str = type_str.replace(expt_ns + lfts_ns + '::', expt_ns) fs_ns = expt_ns + 'filesystem::' type_str = type_str.replace(fs_ns + 'v1::', fs_ns) return type_str def get_template_arg_list(type_obj): """Return a type's template arguments as a list.""" n = 0 template_args = [] while True: try: template_args.append(type_obj.template_argument(n)) except: return template_args n += 1 class SmartPtrIterator(Iterator): """An iterator for smart pointer types with a single 'child' value.""" def __init__(self, val): self._val = val def __iter__(self): return self def __next__(self): if self._val is None: raise StopIteration self._val, val = None, self._val return ('get()', val) class SharedPointerPrinter(printer_base): """ Print a shared_ptr, weak_ptr, atomic, or atomic. """ def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val self._pointer = val['_M_ptr'] def children(self): return SmartPtrIterator(self._pointer) # Return the _Sp_counted_base<>* that holds the refcounts. def _get_refcounts(self): if self._typename == 'std::atomic': # A tagged pointer is stored as uintptr_t. ptr_val = self._val['_M_refcount']['_M_val']['_M_i'] ptr_val = ptr_val - (ptr_val % 2) # clear lock bit ptr_type = find_type(self._val['_M_refcount'].type, 'pointer') return ptr_val.cast(ptr_type) return self._val['_M_refcount']['_M_pi'] def to_string(self): state = 'empty' refcounts = self._get_refcounts() targ = self._val.type.template_argument(0) targ = strip_versioned_namespace(str(targ)) if refcounts != 0: usecount = refcounts['_M_use_count'] weakcount = refcounts['_M_weak_count'] if usecount == 0: state = 'expired, weak count %d' % weakcount else: state = 'use count %d, weak count %d' % ( usecount, weakcount - 1) return '%s<%s> (%s)' % (self._typename, targ, state) def _tuple_impl_get(val): """Return the tuple element stored in a _Tuple_impl base class.""" bases = val.type.fields() if not bases[-1].is_base_class: raise ValueError( "Unsupported implementation for std::tuple: %s" % str(val.type)) # Get the _Head_base base class: head_base = val.cast(bases[-1].type) fields = head_base.type.fields() if len(fields) == 0: raise ValueError( "Unsupported implementation for std::tuple: %s" % str(val.type)) if fields[0].name == '_M_head_impl': # The tuple element is the _Head_base::_M_head_impl data member. return head_base['_M_head_impl'] elif fields[0].is_base_class: # The tuple element is an empty base class of _Head_base. # Cast to that empty base class. return head_base.cast(fields[0].type) else: raise ValueError( "Unsupported implementation for std::tuple: %s" % str(val.type)) def tuple_get(n, val): """Return the result of std::get(val) on a std::tuple.""" tuple_size = len(get_template_arg_list(val.type)) if n > tuple_size: raise ValueError("Out of range index for std::get on std::tuple") # Get the first _Tuple_impl<0, T...> base class: node = val.cast(val.type.fields()[0].type) while n > 0: # Descend through the base classes until the Nth one. node = node.cast(node.type.fields()[0].type) n -= 1 return _tuple_impl_get(node) def unique_ptr_get(val): """Return the result of val.get() on a std::unique_ptr.""" # std::unique_ptr contains a std::tuple, # either as a direct data member _M_t (the old implementation) # or within a data member of type __uniq_ptr_data. impl_type = val.type.fields()[0].type.strip_typedefs() # Check for new implementations first: if is_specialization_of(impl_type, '__uniq_ptr_data') \ or is_specialization_of(impl_type, '__uniq_ptr_impl'): tuple_member = val['_M_t']['_M_t'] elif is_specialization_of(impl_type, 'tuple'): tuple_member = val['_M_t'] else: raise ValueError( "Unsupported implementation for unique_ptr: %s" % str(impl_type)) return tuple_get(0, tuple_member) class UniquePointerPrinter(printer_base): """Print a unique_ptr.""" def __init__(self, typename, val): self._val = val def children(self): return SmartPtrIterator(unique_ptr_get(self._val)) def to_string(self): t = self._val.type.template_argument(0) return 'std::unique_ptr<{}>'.format(str(t)) def get_value_from_aligned_membuf(buf, valtype): """Return the value held in a __gnu_cxx::__aligned_membuf.""" return buf['_M_storage'].address.cast(valtype.pointer()).dereference() def get_value_from_list_node(node): """Return the value held in an _List_node<_Val>.""" try: member = node.type.fields()[1].name if member == '_M_data': # C++03 implementation, node contains the value as a member return node['_M_data'] elif member == '_M_storage': # C++11 implementation, node stores value in __aligned_membuf valtype = node.type.template_argument(0) return get_value_from_aligned_membuf(node['_M_storage'], valtype) except: pass raise ValueError("Unsupported implementation for %s" % str(node.type)) class StdListPrinter(printer_base): """Print a std::list.""" class _iterator(Iterator): def __init__(self, nodetype, head): self._nodetype = nodetype self._base = head['_M_next'] self._head = head.address self._count = 0 def __iter__(self): return self def __next__(self): if self._base == self._head: raise StopIteration elt = self._base.cast(self._nodetype).dereference() self._base = elt['_M_next'] count = self._count self._count = self._count + 1 val = get_value_from_list_node(elt) return ('[%d]' % count, val) def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def children(self): nodetype = lookup_node_type('_List_node', self._val.type).pointer() return self._iterator(nodetype, self._val['_M_impl']['_M_node']) def to_string(self): headnode = self._val['_M_impl']['_M_node'] if headnode['_M_next'] == headnode.address: return 'empty %s' % (self._typename) return '%s' % (self._typename) class NodeIteratorPrinter(printer_base): def __init__(self, typename, val, contname, nodename): self._val = val self._typename = typename self._contname = contname self._nodetype = lookup_node_type(nodename, val.type) def to_string(self): if not self._val['_M_node']: return 'non-dereferenceable iterator for std::%s' % (self._contname) node = self._val['_M_node'].cast( self._nodetype.pointer()).dereference() return str(get_value_from_list_node(node)) class StdListIteratorPrinter(NodeIteratorPrinter): """Print std::list::iterator.""" def __init__(self, typename, val): NodeIteratorPrinter.__init__(self, typename, val, 'list', '_List_node') class StdFwdListIteratorPrinter(NodeIteratorPrinter): """Print std::forward_list::iterator.""" def __init__(self, typename, val): NodeIteratorPrinter.__init__(self, typename, val, 'forward_list', '_Fwd_list_node') class StdSlistPrinter(printer_base): """Print a __gnu_cxx::slist.""" class _iterator(Iterator): def __init__(self, nodetype, head): self._nodetype = nodetype self._base = head['_M_head']['_M_next'] self._count = 0 def __iter__(self): return self def __next__(self): if self._base == 0: raise StopIteration elt = self._base.cast(self._nodetype).dereference() self._base = elt['_M_next'] count = self._count self._count = self._count + 1 return ('[%d]' % count, elt['_M_data']) def __init__(self, typename, val): self._val = val def children(self): nodetype = lookup_node_type('__gnu_cxx::_Slist_node', self._val.type) return self._iterator(nodetype.pointer(), self._val) def to_string(self): if self._val['_M_head']['_M_next'] == 0: return 'empty __gnu_cxx::slist' return '__gnu_cxx::slist' class StdSlistIteratorPrinter(printer_base): """Print __gnu_cxx::slist::iterator.""" def __init__(self, typename, val): self._val = val def to_string(self): if not self._val['_M_node']: return 'non-dereferenceable iterator for __gnu_cxx::slist' nodetype = lookup_node_type( '__gnu_cxx::_Slist_node', self._val.type).pointer() return str(self._val['_M_node'].cast(nodetype).dereference()['_M_data']) class StdVectorPrinter(printer_base): """Print a std::vector.""" class _iterator(Iterator): def __init__(self, start, finish, bitvec): self._bitvec = bitvec if bitvec: self._item = start['_M_p'] self._so = 0 self._finish = finish['_M_p'] self._fo = finish['_M_offset'] itype = self._item.dereference().type self._isize = 8 * itype.sizeof else: self._item = start self._finish = finish self._count = 0 def __iter__(self): return self def __next__(self): count = self._count self._count = self._count + 1 if self._bitvec: if self._item == self._finish and self._so >= self._fo: raise StopIteration elt = bool(self._item.dereference() & (1 << self._so)) self._so = self._so + 1 if self._so >= self._isize: self._item = self._item + 1 self._so = 0 return ('[%d]' % count, elt) else: if self._item == self._finish: raise StopIteration elt = self._item.dereference() self._item = self._item + 1 return ('[%d]' % count, elt) def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val self._is_bool = val.type.template_argument( 0).code == gdb.TYPE_CODE_BOOL def children(self): return self._iterator(self._val['_M_impl']['_M_start'], self._val['_M_impl']['_M_finish'], self._is_bool) def to_string(self): start = self._val['_M_impl']['_M_start'] finish = self._val['_M_impl']['_M_finish'] end = self._val['_M_impl']['_M_end_of_storage'] if self._is_bool: start = self._val['_M_impl']['_M_start']['_M_p'] finish = self._val['_M_impl']['_M_finish']['_M_p'] fo = self._val['_M_impl']['_M_finish']['_M_offset'] itype = start.dereference().type bl = 8 * itype.sizeof length = bl * (finish - start) + fo capacity = bl * (end - start) return ('%s of length %d, capacity %d' % (self._typename, int(length), int(capacity))) else: return ('%s of length %d, capacity %d' % (self._typename, int(finish - start), int(end - start))) def display_hint(self): return 'array' class StdVectorIteratorPrinter(printer_base): """Print std::vector::iterator.""" def __init__(self, typename, val): self._val = val def to_string(self): if not self._val['_M_current']: return 'non-dereferenceable iterator for std::vector' return str(self._val['_M_current'].dereference()) class StdBitIteratorPrinter(printer_base): """Print std::vector's _Bit_iterator and _Bit_const_iterator.""" def __init__(self, typename, val): self._val = val def to_string(self): if not self._val['_M_p']: return 'non-dereferenceable iterator for std::vector' return bool(self._val['_M_p'].dereference() & (1 << self._val['_M_offset'])) class StdBitReferencePrinter(printer_base): """Print std::vector::reference.""" def __init__(self, typename, val): self._val = val def to_string(self): if not self._val['_M_p']: # PR libstdc++/115098 removed the reference default constructor # that this case relates to. New code should never need this, # but we still handle it for compatibility with old binaries. return 'invalid std::vector::reference' return bool(self._val['_M_p'].dereference() & (self._val['_M_mask'])) class StdTuplePrinter(printer_base): """Print a std::tuple.""" class _iterator(Iterator): @staticmethod def _is_nonempty_tuple(nodes): if len(nodes) == 2: if is_specialization_of(nodes[1].type, '__tuple_base'): return True elif len(nodes) == 1: return True elif len(nodes) == 0: return False raise ValueError( "Top of tuple tree does not consist of a single node.") def __init__(self, head): self._head = head # Set the base class as the initial head of the # tuple. nodes = self._head.type.fields() if self._is_nonempty_tuple(nodes): # Set the actual head to the first pair. self._head = self._head.cast(nodes[0].type) self._count = 0 def __iter__(self): return self def __next__(self): # Check for further recursions in the inheritance tree. # For a GCC 5+ tuple self._head is None after visiting all nodes: if not self._head: raise StopIteration nodes = self._head.type.fields() # For a GCC 4.x tuple there is a final node with no fields: if len(nodes) == 0: raise StopIteration # Check that this iteration has an expected structure. if len(nodes) > 2: raise ValueError( "Cannot parse more than 2 nodes in a tuple tree.") if len(nodes) == 1: # This is the last node of a GCC 5+ std::tuple. impl = self._head.cast(nodes[0].type) self._head = None else: # Either a node before the last node, or the last node of # a GCC 4.x tuple (which has an empty parent). # - Left node is the next recursion parent. # - Right node is the actual class contained in the tuple. # Process right node. impl = self._head.cast(nodes[1].type) # Process left node and set it as head. self._head = self._head.cast(nodes[0].type) self._count = self._count + 1 # Finally, check the implementation. If it is # wrapped in _M_head_impl return that, otherwise return # the value "as is". fields = impl.type.fields() if len(fields) < 1 or fields[0].name != "_M_head_impl": return ('[%d]' % (self._count - 1), impl) else: return ('[%d]' % (self._count - 1), impl['_M_head_impl']) def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def children(self): return self._iterator(self._val) def to_string(self): if len(self._val.type.fields()) == 0: return 'empty %s' % (self._typename) return '%s containing' % (self._typename) class StdStackOrQueuePrinter(printer_base): """Print a std::stack or std::queue.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._visualizer = gdb.default_visualizer(val['c']) def children(self): return self._visualizer.children() def to_string(self): return '%s wrapping: %s' % (self._typename, self._visualizer.to_string()) def display_hint(self): if hasattr(self._visualizer, 'display_hint'): return self._visualizer.display_hint() return None class RbtreeIterator(Iterator): """ Turn an RB-tree-based container (std::map, std::set etc.) into a Python iterable object. """ def __init__(self, rbtree): self._size = rbtree['_M_t']['_M_impl']['_M_node_count'] self._node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left'] self._count = 0 def __iter__(self): return self def __len__(self): return int(self._size) def __next__(self): if self._count == self._size: raise StopIteration result = self._node self._count = self._count + 1 if self._count < self._size: # Compute the next node. node = self._node if node.dereference()['_M_right']: node = node.dereference()['_M_right'] while node.dereference()['_M_left']: node = node.dereference()['_M_left'] else: parent = node.dereference()['_M_parent'] while node == parent.dereference()['_M_right']: node = parent parent = parent.dereference()['_M_parent'] if node.dereference()['_M_right'] != parent: node = parent self._node = node return result def get_value_from_Rb_tree_node(node): """Return the value held in an _Rb_tree_node<_Val>.""" try: member = node.type.fields()[1].name if member == '_M_value_field': # C++03 implementation, node contains the value as a member return node['_M_value_field'] elif member == '_M_storage': # C++11 implementation, node stores value in __aligned_membuf valtype = node.type.template_argument(0) return get_value_from_aligned_membuf(node['_M_storage'], valtype) except: pass raise ValueError("Unsupported implementation for %s" % str(node.type)) # This is a pretty printer for std::_Rb_tree_iterator (which is # std::map::iterator), and has nothing to do with the RbtreeIterator # class above. class StdRbtreeIteratorPrinter(printer_base): """Print std::map::iterator, std::set::iterator, etc.""" def __init__(self, typename, val): self._val = val nodetype = lookup_node_type('_Rb_tree_node', self._val.type) self._link_type = nodetype.pointer() def to_string(self): if not self._val['_M_node']: return 'non-dereferenceable iterator for associative container' node = self._val['_M_node'].cast(self._link_type).dereference() return str(get_value_from_Rb_tree_node(node)) class StdDebugIteratorPrinter(printer_base): """Print a debug enabled version of an iterator.""" def __init__(self, typename, val): self._val = val # Just strip away the encapsulating __gnu_debug::_Safe_iterator # and return the wrapped iterator value. def to_string(self): base_type = gdb.lookup_type('__gnu_debug::_Safe_iterator_base') itype = self._val.type.template_argument(0) safe_seq = self._val.cast(base_type)['_M_sequence'] if not safe_seq: return str(self._val.cast(itype)) if self._val['_M_version'] != safe_seq['_M_version']: return "invalid iterator" return str(self._val.cast(itype)) def num_elements(num): """Return either "1 element" or "N elements" depending on the argument.""" return '1 element' if num == 1 else '%d elements' % num class StdMapPrinter(printer_base): """Print a std::map or std::multimap.""" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): def __init__(self, rbiter, type): self._rbiter = rbiter self._count = 0 self._type = type def __iter__(self): return self def __next__(self): if self._count % 2 == 0: n = next(self._rbiter) n = n.cast(self._type).dereference() n = get_value_from_Rb_tree_node(n) self._pair = n item = n['first'] else: item = self._pair['second'] result = ('[%d]' % self._count, item) self._count = self._count + 1 return result def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): return '%s with %s' % (self._typename, num_elements(len(RbtreeIterator(self._val)))) def children(self): node = lookup_node_type('_Rb_tree_node', self._val.type).pointer() return self._iter(RbtreeIterator(self._val), node) def display_hint(self): return 'map' class StdSetPrinter(printer_base): """Print a std::set or std::multiset.""" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): def __init__(self, rbiter, type): self._rbiter = rbiter self._count = 0 self._type = type def __iter__(self): return self def __next__(self): item = next(self._rbiter) item = item.cast(self._type).dereference() item = get_value_from_Rb_tree_node(item) # FIXME: this is weird ... what to do? # Maybe a 'set' display hint? result = ('[%d]' % self._count, item) self._count = self._count + 1 return result def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): return '%s with %s' % (self._typename, num_elements(len(RbtreeIterator(self._val)))) def children(self): node = lookup_node_type('_Rb_tree_node', self._val.type).pointer() return self._iter(RbtreeIterator(self._val), node) class StdBitsetPrinter(printer_base): """Print a std::bitset.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): # If template_argument handled values, we could print the # size. Or we could use a regexp on the type. return '%s' % (self._typename) def children(self): try: # An empty bitset may not have any members which will # result in an exception being thrown. words = self._val['_M_w'] except: return [] wtype = words.type # The _M_w member can be either an unsigned long, or an # array. This depends on the template specialization used. # If it is a single long, convert to a single element list. if wtype.code == gdb.TYPE_CODE_ARRAY: tsize = wtype.target().sizeof else: words = [words] tsize = wtype.sizeof nwords = wtype.sizeof / tsize result = [] byte = 0 while byte < nwords: w = words[byte] bit = 0 while w != 0: if (w & 1) != 0: # Another spot where we could use 'set'? result.append(('[%d]' % (byte * tsize * 8 + bit), 1)) bit = bit + 1 w = w >> 1 byte = byte + 1 return result class StdDequePrinter(printer_base): """Print a std::deque.""" class _iter(Iterator): def __init__(self, node, start, end, last, buffer_size): self._node = node self._p = start self._end = end self._last = last self._buffer_size = buffer_size self._count = 0 def __iter__(self): return self def __next__(self): if self._p == self._last: raise StopIteration result = ('[%d]' % self._count, self._p.dereference()) self._count = self._count + 1 # Advance the 'cur' pointer. self._p = self._p + 1 if self._p == self._end: # If we got to the end of this bucket, move to the # next bucket. self._node = self._node + 1 self._p = self._node[0] self._end = self._p + self._buffer_size return result def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val self._elttype = val.type.template_argument(0) size = self._elttype.sizeof if size < 512: self._buffer_size = int(512 / size) else: self._buffer_size = 1 def to_string(self): start = self._val['_M_impl']['_M_start'] end = self._val['_M_impl']['_M_finish'] delta_n = end['_M_node'] - start['_M_node'] - 1 delta_s = start['_M_last'] - start['_M_cur'] delta_e = end['_M_cur'] - end['_M_first'] size = self._buffer_size * delta_n + delta_s + delta_e return '%s with %s' % (self._typename, num_elements(long(size))) def children(self): start = self._val['_M_impl']['_M_start'] end = self._val['_M_impl']['_M_finish'] return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'], end['_M_cur'], self._buffer_size) def display_hint(self): return 'array' class StdDequeIteratorPrinter(printer_base): """Print std::deque::iterator.""" def __init__(self, typename, val): self._val = val def to_string(self): if not self._val['_M_cur']: return 'non-dereferenceable iterator for std::deque' return str(self._val['_M_cur'].dereference()) class StdStringPrinter(printer_base): """Print a std::basic_string of some kind.""" def __init__(self, typename, val): self._val = val self._new_string = typename.find("::__cxx11::basic_string") != -1 def to_string(self): # Make sure &string works, too. type = self._val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() # Calculate the length of the string so that to_string returns # the string according to length, not according to first null # encountered. ptr = self._val['_M_dataplus']['_M_p'] if self._new_string: length = self._val['_M_string_length'] # https://sourceware.org/bugzilla/show_bug.cgi?id=17728 ptr = ptr.cast(ptr.type.strip_typedefs()) else: realtype = type.unqualified().strip_typedefs() reptype = gdb.lookup_type(str(realtype) + '::_Rep').pointer() header = ptr.cast(reptype) - 1 length = header.dereference()['_M_length'] if hasattr(ptr, "lazy_string"): return ptr.lazy_string(length=length) return ptr.string(length=length) def display_hint(self): return 'string' def access_streambuf_ptrs(streambuf): """Access the streambuf put area pointers.""" pbase = streambuf['_M_out_beg'] pptr = streambuf['_M_out_cur'] egptr = streambuf['_M_in_end'] return pbase, pptr, egptr class StdStringBufPrinter(printer_base): """Print a std::basic_stringbuf.""" def __init__(self, _, val): self._val = val def to_string(self): (pbase, pptr, egptr) = access_streambuf_ptrs(self._val) # Logic from basic_stringbuf::_M_high_mark() if pptr: if not egptr or pptr > egptr: return pbase.string(length=pptr - pbase) else: return pbase.string(length=egptr - pbase) return self._val['_M_string'] def display_hint(self): return 'string' class StdStringStreamPrinter(printer_base): """Print a std::basic_stringstream.""" def __init__(self, typename, val): self._val = val self._typename = typename # Check if the stream was redirected. This is essentially: # val['_M_streambuf'] != val['_M_stringbuf'].address # However, GDB can't resolve the virtual inheritance, so we do that # manually. basetype = [f.type for f in val.type.fields() if f.is_base_class][0] gdb.set_convenience_variable('__stream', val.cast(basetype).address) self._streambuf = gdb.parse_and_eval('$__stream->rdbuf()') self._was_redirected = self._streambuf != val['_M_stringbuf'].address def to_string(self): if self._was_redirected: return "%s redirected to %s" % ( self._typename, self._streambuf.dereference()) return self._val['_M_stringbuf'] def display_hint(self): if self._was_redirected: return None return 'string' class Tr1HashtableIterator(Iterator): def __init__(self, hashtable): self._buckets = hashtable['_M_buckets'] self._bucket = 0 self._bucket_count = hashtable['_M_bucket_count'] self._node_type = find_type(hashtable.type, '_Node').pointer() self._node = 0 while self._bucket != self._bucket_count: self._node = self._buckets[self._bucket] if self._node: break self._bucket = self._bucket + 1 def __iter__(self): return self def __next__(self): if self._node == 0: raise StopIteration node = self._node.cast(self._node_type) result = node.dereference()['_M_v'] self._node = node.dereference()['_M_next'] if self._node == 0: self._bucket = self._bucket + 1 while self._bucket != self._bucket_count: self._node = self._buckets[self._bucket] if self._node: break self._bucket = self._bucket + 1 return result class StdHashtableIterator(Iterator): def __init__(self, hashtable): self._node = hashtable['_M_before_begin']['_M_nxt'] valtype = hashtable.type.template_argument(1) cached = hashtable.type.template_argument(9).template_argument(0) node_type = lookup_templ_spec('std::__detail::_Hash_node', str(valtype), 'true' if cached else 'false') self._node_type = node_type.pointer() def __iter__(self): return self def __next__(self): if self._node == 0: raise StopIteration elt = self._node.cast(self._node_type).dereference() self._node = elt['_M_nxt'] valptr = elt['_M_storage'].address valptr = valptr.cast(elt.type.template_argument(0).pointer()) return valptr.dereference() class Tr1UnorderedSetPrinter(printer_base): """Print a std::unordered_set or tr1::unordered_set.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def _hashtable(self): if self._typename.startswith('std::tr1'): return self._val return self._val['_M_h'] def to_string(self): count = self._hashtable()['_M_element_count'] return '%s with %s' % (self._typename, num_elements(count)) @staticmethod def _format_count(i): return '[%d]' % i def children(self): counter = imap(self._format_count, itertools.count()) if self._typename.startswith('std::tr1'): return izip(counter, Tr1HashtableIterator(self._hashtable())) return izip(counter, StdHashtableIterator(self._hashtable())) class Tr1UnorderedMapPrinter(printer_base): """Print a std::unordered_map or tr1::unordered_map.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def _hashtable(self): if self._typename.startswith('std::tr1'): return self._val return self._val['_M_h'] def to_string(self): count = self._hashtable()['_M_element_count'] return '%s with %s' % (self._typename, num_elements(count)) @staticmethod def _flatten(list): for elt in list: for i in elt: yield i @staticmethod def _format_one(elt): return (elt['first'], elt['second']) @staticmethod def _format_count(i): return '[%d]' % i def children(self): counter = imap(self._format_count, itertools.count()) # Map over the hash table and flatten the result. if self._typename.startswith('std::tr1'): data = self._flatten( imap(self._format_one, Tr1HashtableIterator(self._hashtable()))) # Zip the two iterators together. return izip(counter, data) data = self._flatten( imap(self._format_one, StdHashtableIterator(self._hashtable()))) # Zip the two iterators together. return izip(counter, data) def display_hint(self): return 'map' class StdForwardListPrinter(printer_base): """Print a std::forward_list.""" class _iterator(Iterator): def __init__(self, nodetype, head): self._nodetype = nodetype self._base = head['_M_next'] self._count = 0 def __iter__(self): return self def __next__(self): if self._base == 0: raise StopIteration elt = self._base.cast(self._nodetype).dereference() self._base = elt['_M_next'] count = self._count self._count = self._count + 1 valptr = elt['_M_storage'].address valptr = valptr.cast(elt.type.template_argument(0).pointer()) return ('[%d]' % count, valptr.dereference()) def __init__(self, typename, val): self._val = val self._typename = strip_versioned_namespace(typename) def children(self): nodetype = lookup_node_type('_Fwd_list_node', self._val.type).pointer() return self._iterator(nodetype, self._val['_M_impl']['_M_head']) def to_string(self): if self._val['_M_impl']['_M_head']['_M_next'] == 0: return 'empty %s' % self._typename return '%s' % self._typename class SingleObjContainerPrinter(printer_base): """Base class for printers of containers of single objects.""" def __init__(self, val, viz, hint=None): self._contained_value = val self._visualizer = viz self._hint = hint def _recognize(self, type): """Return type as a string after applying type printers.""" global _use_type_printing if not _use_type_printing: return str(type) return gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(), type) or str(type) class _contained(Iterator): def __init__(self, val): self._val = val def __iter__(self): return self def __next__(self): if self._val is None: raise StopIteration retval = self._val self._val = None return ('[contained value]', retval) def children(self): if self._contained_value is None: return self._contained(None) if hasattr(self._visualizer, 'children'): return self._visualizer.children() return self._contained(self._contained_value) def display_hint(self): if (hasattr(self._visualizer, 'children') and hasattr(self._visualizer, 'display_hint')): # If contained value is a map we want to display in the same way. return self._visualizer.display_hint() return self._hint def function_pointer_to_name(f): """Find the name of the function referred to by the gdb.Value f, which should contain a function pointer from the program.""" # Turn the function pointer into an actual address. # This is needed to unpack ppc64 function descriptors. f = f.dereference().address if sys.version_info[0] == 2: # Older versions of GDB need to use long for Python 2, # because int(f) on 64-bit big-endian values raises a # gdb.error saying "Cannot convert value to int." f = long(f) else: f = int(f) try: # If the function can't be found older versions of GDB raise a # RuntimeError saying "Cannot locate object file for block." return gdb.block_for_pc(f).function.name except: return None class StdExpAnyPrinter(SingleObjContainerPrinter): """Print a std::any or std::experimental::any.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._typename = strip_fundts_namespace(self._typename) self._val = val self._contained_type = None contained_value = None visualizer = None mgr = self._val['_M_manager'] if mgr != 0: func = function_pointer_to_name(mgr) if not func: raise ValueError( "Invalid function pointer in %s" % (self._typename)) # We want to use this regular expression: # T::_Manager_xxx<.*>::_S_manage\(T::_Op, const T\*, T::_Arg\*\) # where T is std::any or std::experimental::any. # But we need to account for variances in demangled names # between GDB versions, e.g. 'enum T::_Op' instead of 'T::_Op'. rx = ( r"({0}::_Manager_\w+<.*>)::_S_manage\(" r"(enum )?{0}::_Op, (const {0}|{0} const) ?\*, " r"(union )?{0}::_Arg ?\*\)" ).format(typename) m = re.match(rx, func) if not m: raise ValueError( "Unknown manager function in %s" % self._typename) mgrname = m.group(1) # FIXME need to expand 'std::string' so that gdb.lookup_type works if 'std::string' in mgrname: mgrtypes = [] for s in StdExpAnyPrinter._string_types(): try: x = re.sub(r"std::string(?!\w)", s, m.group(1)) # The following lookup might raise gdb.error if the # manager function was never instantiated for 's' in # the program, because there will be no such type. mgrtypes.append(gdb.lookup_type(x)) except gdb.error: pass if len(mgrtypes) != 1: # FIXME: this is unlikely in practice, but possible for # programs that use both old and new string types with # std::any in a single program. Can we do better? # Maybe find the address of each type's _S_manage and # compare to the address stored in _M_manager? raise ValueError( 'Cannot uniquely determine std::string type ' 'used in std::any' ) mgrtype = mgrtypes[0] else: mgrtype = gdb.lookup_type(mgrname) self._contained_type = mgrtype.template_argument(0) valptr = None if '::_Manager_internal' in mgrname: valptr = self._val['_M_storage']['_M_buffer'].address elif '::_Manager_external' in mgrname: valptr = self._val['_M_storage']['_M_ptr'] else: raise ValueError( "Unknown manager function in %s" % self._typename) contained_value = valptr.cast( self._contained_type.pointer()).dereference() visualizer = gdb.default_visualizer(contained_value) super(StdExpAnyPrinter, self).__init__(contained_value, visualizer) def to_string(self): if self._contained_type is None: return '%s [no contained value]' % self._typename desc = "%s containing " % self._typename if hasattr(self._visualizer, 'children'): return desc + self._visualizer.to_string() valtype = self._recognize(self._contained_type) return desc + strip_versioned_namespace(str(valtype)) @staticmethod def _string_types(): # This lookup for std::string might return the __cxx11 version, # but that's not necessarily the one used by the std::any # manager function we're trying to find. strings = {str(gdb.lookup_type('std::string').strip_typedefs())} # So also consider all the other possible std::string types! s = 'basic_string, std::allocator >' quals = ['std::', 'std::__cxx11::', 'std::' + _versioned_namespace] strings |= {q + s for q in quals} # set of unique strings return strings class StdExpOptionalPrinter(SingleObjContainerPrinter): """Print a std::optional or std::experimental::optional.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._typename = strip_fundts_namespace(self._typename) payload = val['_M_payload'] if self._typename.startswith('std::experimental'): engaged = val['_M_engaged'] contained_value = payload else: engaged = payload['_M_engaged'] contained_value = payload['_M_payload'] try: # Since GCC 9 contained_value = contained_value['_M_value'] except: pass visualizer = gdb.default_visualizer(contained_value) if not engaged: contained_value = None super(StdExpOptionalPrinter, self).__init__( contained_value, visualizer) def to_string(self): if self._contained_value is None: return "%s [no contained value]" % self._typename if hasattr(self._visualizer, 'children'): return "%s containing %s" % (self._typename, self._visualizer.to_string()) return self._typename class StdVariantPrinter(SingleObjContainerPrinter): """Print a std::variant.""" def __init__(self, typename, val): alternatives = get_template_arg_list(val.type) self._typename = strip_versioned_namespace(typename) self._index = val['_M_index'] if self._index >= len(alternatives): self._contained_type = None contained_value = None visualizer = None else: self._contained_type = alternatives[int(self._index)] addr = val['_M_u']['_M_first']['_M_storage'].address contained_value = addr.cast( self._contained_type.pointer()).dereference() visualizer = gdb.default_visualizer(contained_value) super(StdVariantPrinter, self).__init__( contained_value, visualizer, 'array') def to_string(self): if self._contained_value is None: return "%s [no contained value]" % self._typename if hasattr(self._visualizer, 'children'): return "%s [index %d] containing %s" % (self._typename, self._index, self._visualizer.to_string()) return "%s [index %d]" % (self._typename, self._index) class StdNodeHandlePrinter(SingleObjContainerPrinter): """Print a container node handle.""" def __init__(self, typename, val): self._value_type = val.type.template_argument(1) nodetype = val.type.template_argument(2).template_argument(0) self._is_rb_tree_node = is_specialization_of( nodetype.name, '_Rb_tree_node') self._is_map_node = val.type.template_argument(0) != self._value_type nodeptr = val['_M_ptr'] if nodeptr: if self._is_rb_tree_node: contained_value = get_value_from_Rb_tree_node( nodeptr.dereference()) else: contained_value = get_value_from_aligned_membuf(nodeptr['_M_storage'], self._value_type) visualizer = gdb.default_visualizer(contained_value) else: contained_value = None visualizer = None optalloc = val['_M_alloc'] self._alloc = optalloc['_M_payload'] if optalloc['_M_engaged'] else None super(StdNodeHandlePrinter, self).__init__(contained_value, visualizer, 'array') def to_string(self): desc = 'node handle for ' if not self._is_rb_tree_node: desc += 'unordered ' if self._is_map_node: desc += 'map' else: desc += 'set' if self._contained_value: desc += ' with element' if hasattr(self._visualizer, 'children'): return "%s = %s" % (desc, self._visualizer.to_string()) return desc else: return 'empty %s' % desc class StdExpStringViewPrinter(printer_base): """ Print a std::basic_string_view or std::experimental::basic_string_view """ def __init__(self, typename, val): self._val = val def to_string(self): ptr = self._val['_M_str'] len = self._val['_M_len'] if hasattr(ptr, "lazy_string"): return ptr.lazy_string(length=len) return ptr.string(length=len) def display_hint(self): return 'string' class StdExpPathPrinter(printer_base): """Print a std::experimental::filesystem::path.""" def __init__(self, typename, val): self._val = val self._typename = typename start = self._val['_M_cmpts']['_M_impl']['_M_start'] finish = self._val['_M_cmpts']['_M_impl']['_M_finish'] self._num_cmpts = int(finish - start) def _path_type(self): t = str(self._val['_M_type']) if t[-9:] == '_Root_dir': return "root-directory" if t[-10:] == '_Root_name': return "root-name" return None def to_string(self): path = "%s" % self._val['_M_pathname'] if self._num_cmpts == 0: t = self._path_type() if t: path = '%s [%s]' % (path, t) return "experimental::filesystem::path %s" % path class _iterator(Iterator): def __init__(self, cmpts, pathtype): self._pathtype = pathtype self._item = cmpts['_M_impl']['_M_start'] self._finish = cmpts['_M_impl']['_M_finish'] self._count = 0 def __iter__(self): return self def __next__(self): if self._item == self._finish: raise StopIteration item = self._item.dereference() count = self._count self._count = self._count + 1 self._item = self._item + 1 path = item['_M_pathname'] t = StdExpPathPrinter(self._pathtype, item)._path_type() if not t: t = count return ('[%s]' % t, path) def children(self): return self._iterator(self._val['_M_cmpts'], self._typename) class StdPathPrinter(printer_base): """Print a std::filesystem::path.""" def __init__(self, typename, val): self._val = val self._typename = typename impl = unique_ptr_get(self._val['_M_cmpts']['_M_impl']) self._type = impl.cast(gdb.lookup_type('uintptr_t')) & 3 if self._type == 0: self._impl = impl else: self._impl = None def _path_type(self): t = str(self._type.cast(gdb.lookup_type(self._typename + '::_Type'))) if t[-9:] == '_Root_dir': return "root-directory" if t[-10:] == '_Root_name': return "root-name" return None def to_string(self): path = "%s" % self._val['_M_pathname'] if self._type != 0: t = self._path_type() if t: path = '%s [%s]' % (path, t) return "filesystem::path %s" % path class _iterator(Iterator): def __init__(self, impl, pathtype): self._pathtype = pathtype if impl: # We can't access _Impl::_M_size because _Impl is incomplete # so cast to int* to access the _M_size member at offset zero, int_type = gdb.lookup_type('int') cmpt_type = gdb.lookup_type(pathtype + '::_Cmpt') char_type = gdb.lookup_type('char') impl = impl.cast(int_type.pointer()) size = impl.dereference() #self._capacity = (impl + 1).dereference() if hasattr(gdb.Type, 'alignof'): sizeof_Impl = max(2 * int_type.sizeof, cmpt_type.alignof) else: sizeof_Impl = 2 * int_type.sizeof begin = impl.cast(char_type.pointer()) + sizeof_Impl self._item = begin.cast(cmpt_type.pointer()) self._finish = self._item + size self._count = 0 else: self._item = None self._finish = None def __iter__(self): return self def __next__(self): if self._item == self._finish: raise StopIteration item = self._item.dereference() count = self._count self._count = self._count + 1 self._item = self._item + 1 path = item['_M_pathname'] t = StdPathPrinter(self._pathtype, item)._path_type() if not t: t = count return ('[%s]' % t, path) def children(self): return self._iterator(self._impl, self._typename) class StdPairPrinter(printer_base): """Print a std::pair object, with 'first' and 'second' as children.""" def __init__(self, typename, val): self._val = val class _iter(Iterator): """An iterator for std::pair types. Returns 'first' then 'second'.""" def __init__(self, val): self._val = val self._which = 'first' def __iter__(self): return self def __next__(self): if self._which is None: raise StopIteration which = self._which if which == 'first': self._which = 'second' else: self._which = None return (which, self._val[which]) def children(self): return self._iter(self._val) def to_string(self): return None class StdCmpCatPrinter(printer_base): """Print a comparison category object.""" def __init__(self, typename, val): self._typename = typename[typename.rfind(':') + 1:] self._val = val['_M_value'] def to_string(self): if self._typename == 'strong_ordering' and self._val == 0: name = 'equal' else: names = {2: 'unordered', -1: 'less', 0: 'equivalent', 1: 'greater'} name = names[int(self._val)] return 'std::{}::{}'.format(self._typename, name) class StdErrorCodePrinter(printer_base): """Print a std::error_code or std::error_condition.""" _system_is_posix = None # Whether std::system_category() use errno values. def __init__(self, typename, val): self._val = val self._typename = strip_versioned_namespace(typename) # Do this only once ... if StdErrorCodePrinter._system_is_posix is None: try: import posix StdErrorCodePrinter._system_is_posix = True except ImportError: StdErrorCodePrinter._system_is_posix = False @staticmethod def _find_errc_enum(name): typ = gdb.lookup_type(name) if typ is not None and typ.code == gdb.TYPE_CODE_ENUM: return typ return None @classmethod def _find_standard_errc_enum(cls, name): for ns in ['', _versioned_namespace]: try: qname = 'std::{}{}'.format(ns, name) return cls._find_errc_enum(qname) except RuntimeError: pass @classmethod def _match_net_ts_category(cls, cat): net_cats = ['stream', 'socket', 'ip::resolver'] for c in net_cats: func = c + '_category()' for ns in ['', _versioned_namespace]: ns = 'std::{}experimental::net::v1'.format(ns) sym = gdb.lookup_symbol('{}::{}::__c'.format(ns, func))[0] if sym is not None: if cat == sym.value().address: name = 'net::' + func enum = cls._find_errc_enum('{}::{}_errc'.format(ns, c)) return (name, enum) return (None, None) @classmethod def _category_info(cls, cat): """Return details of a std::error_category.""" name = None enum = None is_errno = False # Try these first, or we get "warning: RTTI symbol not found" when # using cat.dynamic_type on the local class types for Net TS # categories. func, enum = cls._match_net_ts_category(cat) if func is not None: return (None, func, enum, is_errno) # This might give a warning for a program-defined category defined as # a local class, but there doesn't seem to be any way to avoid that. typ = cat.dynamic_type.target() # Shortcuts for the known categories defined by libstdc++. if typ.tag.endswith('::generic_error_category'): name = 'generic' is_errno = True if typ.tag.endswith('::system_error_category'): name = 'system' is_errno = cls._system_is_posix if typ.tag.endswith('::future_error_category'): name = 'future' enum = cls._find_standard_errc_enum('future_errc') if typ.tag.endswith('::io_error_category'): name = 'io' enum = cls._find_standard_errc_enum('io_errc') if name is None: try: # Want to call std::error_category::name() override, but it's # unsafe: https://sourceware.org/bugzilla/show_bug.cgi?id=28856 # gdb.set_convenience_variable('__cat', cat) # return '"%s"' % gdb.parse_and_eval('$__cat->name()').string() pass except: pass return (name, typ.tag, enum, is_errno) @staticmethod def _unqualified_name(name): """ Strip any nested-name-specifier from name to give an unqualified name. """ return name.split('::')[-1] def to_string(self): value = self._val['_M_value'] cat = self._val['_M_cat'] name, alt_name, enum, is_errno = self._category_info(cat) if value == 0: default_cats = {'error_code': 'system', 'error_condition': 'generic'} if name == default_cats[self._unqualified_name(self._typename)]: return self._typename + ' = { }' # default-constructed value strval = str(value) if is_errno and value != 0: try: strval = errno.errorcode[int(value)] except: pass elif enum is not None: strval = self._unqualified_name(str(value.cast(enum))) if name is not None: name = '"%s"' % name else: name = alt_name return '%s = {%s: %s}' % (self._typename, name, strval) class StdRegexStatePrinter(printer_base): """Print a state node in the NFA for a std::regex.""" def __init__(self, typename, val): self._val = val self._typename = typename def to_string(self): opcode = str(self._val['_M_opcode']) if opcode: opcode = opcode[25:] next_id = self._val['_M_next'] variants = {'repeat': 'alt', 'alternative': 'alt', 'subexpr_begin': 'subexpr', 'subexpr_end': 'subexpr', 'line_begin_assertion': None, 'line_end_assertion': None, 'word_boundary': 'neg', 'subexpr_lookahead': 'neg', 'backref': 'backref_index', 'match': None, 'accept': None, 'dummy': None, 'unknown': None } v = variants[opcode] s = "opcode={}, next={}".format(opcode, next_id) if v is not None and self._val['_M_' + v] is not None: s = "{}, {}={}".format(s, v, self._val['_M_' + v]) return "{%s}" % (s) class StdSpanPrinter(printer_base): """Print a std::span.""" class _iterator(Iterator): def __init__(self, begin, size): self._count = 0 self._begin = begin self._size = size def __iter__(self): return self def __next__(self): if self._count == self._size: raise StopIteration count = self._count self._count = self._count + 1 return '[%d]' % count, (self._begin + count).dereference() def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val size_max = gdb.parse_and_eval('static_cast(-1)') if val.type.template_argument(1) == size_max: self._size = val['_M_extent']['_M_extent_value'] else: self._size = val.type.template_argument(1) def to_string(self): return '%s of length %d' % (self._typename, self._size) def children(self): return self._iterator(self._val['_M_ptr'], self._size) def display_hint(self): return 'array' class StdInitializerListPrinter(printer_base): """Print a std::initializer_list.""" def __init__(self, typename, val): self._typename = typename self._val = val self._size = val['_M_len'] def to_string(self): return '%s of length %d' % (self._typename, self._size) def children(self): return StdSpanPrinter._iterator(self._val['_M_array'], self._size) def display_hint(self): return 'array' class StdAtomicPrinter(printer_base): """Print a std:atomic.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val self._shptr_printer = None self._value_type = self._val.type.template_argument(0) if self._value_type.tag is not None: typ = strip_versioned_namespace(self._value_type.tag) if (typ.startswith('std::shared_ptr<') or typ.startswith('std::weak_ptr<')): impl = val['_M_impl'] self._shptr_printer = SharedPointerPrinter(typename, impl) self.children = self._shptr_children def _shptr_children(self): return SmartPtrIterator(self._shptr_printer._pointer) def to_string(self): if self._shptr_printer is not None: return self._shptr_printer.to_string() if self._value_type.code == gdb.TYPE_CODE_INT: val = self._val['_M_i'] elif self._value_type.code == gdb.TYPE_CODE_FLT: val = self._val['_M_fp'] elif self._value_type.code == gdb.TYPE_CODE_PTR: val = self._val['_M_b']['_M_p'] elif self._value_type.code == gdb.TYPE_CODE_BOOL: val = self._val['_M_base']['_M_i'] else: val = self._val['_M_i'] return '%s<%s> = { %s }' % (self._typename, str(self._value_type), val) class StdFormatArgsPrinter(printer_base): """Print a std::basic_format_args.""" # TODO: add printer for basic_format_arg and print out children. # TODO: add printer for __format::_ArgStore. def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): targs = get_template_arg_list(self._val.type) char_type = get_template_arg_list(targs[0])[1] if char_type == gdb.lookup_type('char'): typ = 'std::format_args' elif char_type == gdb.lookup_type('wchar_t'): typ = 'std::wformat_args' else: typ = 'std::basic_format_args' size = self._val['_M_packed_size'] if size == 1: return "%s with 1 argument" % (typ) if size == 0: size = self._val['_M_unpacked_size'] return "%s with %d arguments" % (typ, size) class StdChronoDurationPrinter(printer_base): """Print a std::chrono::duration.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def _ratio(self): # TODO use reduced period i.e. duration::period period = self._val.type.template_argument(1) num = period.template_argument(0) den = period.template_argument(1) return (num, den) def _suffix(self): num, den = self._ratio() if num == 1: if den == 1: return 's' if den == 1000: return 'ms' if den == 1000000: return 'us' if den == 1000000000: return 'ns' elif den == 1: if num == 60: return 'min' if num == 3600: return 'h' if num == 86400: return 'd' return '[{}]s'.format(num) return "[{}/{}]s".format(num, den) def to_string(self): r = self._val['__r'] if r.type.strip_typedefs().code == gdb.TYPE_CODE_FLT: r = "%g" % r return "std::chrono::duration = {{ {}{} }}".format(r, self._suffix()) class StdChronoTimePointPrinter(printer_base): """Print a std::chrono::time_point.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def _clock(self): clock = self._val.type.template_argument(0) name = strip_versioned_namespace(clock.name) if name == 'std::chrono::_V2::system_clock' \ or name == 'std::chrono::system_clock': return ('std::chrono::sys_time', 0) # XXX need to remove leap seconds from utc, gps, and tai if name == 'std::chrono::utc_clock': return ('std::chrono::utc_time', None) # XXX if name == 'std::chrono::gps_clock': return ('std::chrono::gps_time', None) # XXX 315964809 if name == 'std::chrono::tai_clock': return ('std::chrono::tai_time', None) # XXX -378691210 if name == 'std::filesystem::__file_clock': return ('std::chrono::file_time', 6437664000) if name == 'std::chrono::local_t': return ('std::chrono::local_time', 0) return ('{} time_point'.format(name), None) def to_string(self, abbrev=False): clock, offset = self._clock() d = self._val['__d'] r = d['__r'] printer = StdChronoDurationPrinter(d.type.name, d) suffix = printer._suffix() time = '' if offset is not None: num, den = printer._ratio() secs = (r * num / den) + offset try: dt = datetime.datetime.fromtimestamp(secs, _utc_timezone) time = ' [{:%Y-%m-%d %H:%M:%S}]'.format(dt) except: pass s = '%d%s%s' % (r, suffix, time) if abbrev: return s return '%s = { %s }' % (clock, s) class StdChronoZonedTimePrinter(printer_base): """Print a std::chrono::zoned_time.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): zone = self._val['_M_zone'].dereference()['_M_name'] time = self._val['_M_tp'] printer = StdChronoTimePointPrinter(time.type.name, time) time = printer.to_string(True) return 'std::chrono::zoned_time = {{ {} {} }}'.format(zone, time) months = [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] class StdChronoCalendarPrinter(printer_base): """Print a std::chrono::day, std::chrono::month, std::chrono::year etc.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): val = self._val typ = self._typename if 'month' in typ and typ != 'std::chrono::year_month_day_last': m = val['_M_m'] if typ.startswith('std::chrono::year'): y = val['_M_y'] if typ == 'std::chrono::day': return '{}'.format(int(val['_M_d'])) if typ == 'std::chrono::month': if m < 1 or m >= len(months): return "%d is not a valid month" % m return months[m] if typ == 'std::chrono::year': return '{}y'.format(y) if typ == 'std::chrono::weekday': wd = val['_M_wd'] if wd < 0 or wd >= len(weekdays): return "%d is not a valid weekday" % wd return '{}'.format(weekdays[wd]) if typ == 'std::chrono::weekday_indexed': return '{}[{}]'.format(val['_M_wd'], int(val['_M_index'])) if typ == 'std::chrono::weekday_last': return '{}[last]'.format(val['_M_wd']) if typ == 'std::chrono::month_day': return '{}/{}'.format(m, val['_M_d']) if typ == 'std::chrono::month_day_last': return '{}/last'.format(m) if typ == 'std::chrono::month_weekday': return '{}/{}'.format(m, val['_M_wdi']) if typ == 'std::chrono::month_weekday_last': return '{}/{}'.format(m, val['_M_wdl']) if typ == 'std::chrono::year_month': return '{}/{}'.format(y, m) if typ == 'std::chrono::year_month_day': return '{}/{}/{}'.format(y, m, val['_M_d']) if typ == 'std::chrono::year_month_day_last': return '{}/{}'.format(y, val['_M_mdl']) if typ == 'std::chrono::year_month_weekday': return '{}/{}/{}'.format(y, m, val['_M_wdi']) if typ == 'std::chrono::year_month_weekday_last': return '{}/{}/{}'.format(y, m, val['_M_wdl']) if typ.startswith('std::chrono::hh_mm_ss'): fract = '' if val['fractional_width'] != 0: fract = '.{:0{}d}'.format(int(val['_M_ss']['_M_r']), int(val['fractional_width'])) h = int(val['_M_h']['__r']) m = int(val['_M_m']['__r']) s = int(val['_M_s']['__r']) if val['_M_is_neg']: h = -h return '{:02}:{:02}:{:02}{}'.format(h, m, s, fract) class StdChronoTimeZonePrinter(printer_base): """Print a chrono::time_zone or chrono::time_zone_link.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): str = '%s = %s' % (self._typename, self._val['_M_name']) if self._typename.endswith("_link"): str += ' -> %s' % (self._val['_M_target']) return str class StdChronoLeapSecondPrinter(printer_base): """Print a chrono::leap_second.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): date = self._val['_M_s']['__r'] neg = '+-'[date < 0] return '%s %d (%c)' % (self._typename, abs(date), neg) class StdChronoTzdbPrinter(printer_base): """Print a chrono::tzdb.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): return '%s %s' % (self._typename, self._val['version']) class StdChronoTimeZoneRulePrinter(printer_base): """Print a chrono::time_zone rule.""" def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._val = val def to_string(self): on = self._val['on'] kind = on['kind'] month = months[on['month']] suffixes = {1: 'st', 2: 'nd', 3: 'rd', 21: 'st', 22: 'nd', 23: 'rd', 31: 'st'} day = on['day_of_month'] ordinal_day = '{}{}'.format(day, suffixes.get(day, 'th')) if kind == 0: # DayOfMonth start = '{} {}'.format(month, ordinal_day) else: weekday = weekdays[on['day_of_week']] if kind == 1: # LastWeekDay start = 'last {} in {}'.format(weekday, month) else: if kind == 2: # LessEq direction = ('last', '<=') else: direction = ('first', '>=') day = on['day_of_month'] start = '{} {} {} {} {}'.format(direction[0], weekday, direction[1], month, ordinal_day) return 'time_zone rule {} from {} to {} starting on {}'.format( self._val['name'], self._val['from'], self._val['to'], start) class StdLocalePrinter(printer_base): """Print a std::locale.""" def __init__(self, typename, val): self._val = val self._typename = typename def to_string(self): names = self._val['_M_impl']['_M_names'] mod = '' if names[0] == 0: name = '*' else: cats = gdb.parse_and_eval(self._typename + '::_S_categories') ncat = gdb.parse_and_eval(self._typename + '::_S_categories_size') n = names[0].string() cat = cats[0].string() name = '{}={}'.format(cat, n) cat_names = {cat: n} i = 1 while i < ncat and names[i] != 0: n = names[i].string() cat = cats[i].string() name = '{};{}={}'.format(name, cat, n) cat_names[cat] = n i = i + 1 uniq_names = set(cat_names.values()) if len(uniq_names) == 1: name = n elif len(uniq_names) == 2: n1, n2 = (uniq_names) name_list = list(cat_names.values()) other = None if name_list.count(n1) == 1: name = n2 other = n1 elif name_list.count(n2) == 1: name = n1 other = n2 if other is not None: cat = next(c for c, n in cat_names.items() if n == other) mod = ' with "{}={}"'.format(cat, other) return 'std::locale = "{}"{}'.format(name, mod) class StdIntegralConstantPrinter(printer_base): """Print a std::true_type or std::false_type.""" def __init__(self, typename, val): self._val = val self._typename = typename def to_string(self): value_type = self._val.type.template_argument(0) value = self._val.type.template_argument(1) if value_type.code == gdb.TYPE_CODE_BOOL: if value: return "std::true_type" else: return "std::false_type" typename = strip_versioned_namespace(self._typename) return "{}<{}, {}>".format(typename, value_type, value) class StdTextEncodingPrinter(printer_base): """Print a std::text_encoding.""" def __init__(self, typename, val): self._val = val self._typename = typename def to_string(self): rep = self._val['_M_rep'].dereference() if rep['_M_id'] == 1: return self._val['_M_name'] if rep['_M_id'] == 2: return 'unknown' return rep['_M_name'] # A "regular expression" printer which conforms to the # "SubPrettyPrinter" protocol from gdb.printing. class RxPrinter(object): def __init__(self, name, function): super(RxPrinter, self).__init__() self.name = name self._function = function self.enabled = True def invoke(self, value): if not self.enabled: return None if value.type.code == gdb.TYPE_CODE_REF: if hasattr(gdb.Value, "referenced_value"): value = value.referenced_value() return self._function(self.name, value) # A pretty-printer that conforms to the "PrettyPrinter" protocol from # gdb.printing. It can also be used directly as an old-style printer. class Printer(object): def __init__(self, name): super(Printer, self).__init__() self.name = name self._subprinters = [] self._lookup = {} self.enabled = True self._compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$') def add(self, name, function): # A small sanity check. # FIXME if not self._compiled_rx.match(name): raise ValueError( 'libstdc++ programming error: "%s" does not match' % name) printer = RxPrinter(name, function) self._subprinters.append(printer) self._lookup[name] = printer # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): self.add(base + name, function) if '__cxx11' not in base: vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base) self.add(vbase + name, function) # Add a name using _GLIBCXX_BEGIN_NAMESPACE_CONTAINER. def add_container(self, base, name, function): self.add_version(base, name, function) self.add_version(base + '__cxx1998::', name, function) @staticmethod def get_basic_type(type): # If it points to a reference, get the reference. if type.code == gdb.TYPE_CODE_REF: type = type.target() # Get the unqualified type, stripped of typedefs. type = type.unqualified().strip_typedefs() return type.tag def __call__(self, val): typename = self.get_basic_type(val.type) if not typename: return None # All the types we match are template types, so we can use a # dictionary. match = self._compiled_rx.match(typename) if not match: return None basename = match.group(1) if val.type.code == gdb.TYPE_CODE_REF: if hasattr(gdb.Value, "referenced_value"): val = val.referenced_value() if basename in self._lookup: return self._lookup[basename].invoke(val) # Cannot find a pretty printer. Return None. return None libstdcxx_printer = None class TemplateTypePrinter(object): """ A type printer for class templates with default template arguments. Recognizes specializations of class templates and prints them without any template arguments that use a default template argument. Type printers are recursively applied to the template arguments. e.g. replace 'std::vector >' with 'std::vector'. """ def __init__(self, name, defargs): self.name = name self._defargs = defargs self.enabled = True class _recognizer(object): """The recognizer class for TemplateTypePrinter.""" def __init__(self, name, defargs): self.name = name self._defargs = defargs # self._type_obj = None def recognize(self, type_obj): """ If type_obj is a specialization of self.name that uses all the default template arguments for the class template, then return a string representation of the type without default arguments. Otherwise, return None. """ if type_obj.tag is None: return None if not type_obj.tag.startswith(self.name): return None template_args = get_template_arg_list(type_obj) displayed_args = [] require_defaulted = False for n in range(len(template_args)): # The actual template argument in the type: targ = template_args[n] # The default template argument for the class template: defarg = self._defargs.get(n) if defarg is not None: # Substitute other template arguments into the default: defarg = defarg.format(*template_args) # Fail to recognize the type (by returning None) # unless the actual argument is the same as the default. try: if targ != gdb.lookup_type(defarg): return None except gdb.error: # Type lookup failed, just use string comparison: if targ.tag != defarg: return None # All subsequent args must have defaults: require_defaulted = True elif require_defaulted: return None else: # Recursively apply recognizers to the template argument # and add it to the arguments that will be displayed: displayed_args.append(self._recognize_subtype(targ)) # This assumes no class templates in the nested-name-specifier: template_name = type_obj.tag[0:type_obj.tag.find('<')] template_name = strip_inline_namespaces(template_name) return template_name + '<' + ', '.join(displayed_args) + '>' def _recognize_subtype(self, type_obj): """Convert a gdb.Type to a string by applying recognizers, or if that fails then simply converting to a string.""" if type_obj.code == gdb.TYPE_CODE_PTR: return self._recognize_subtype(type_obj.target()) + '*' if type_obj.code == gdb.TYPE_CODE_ARRAY: type_str = self._recognize_subtype(type_obj.target()) if str(type_obj.strip_typedefs()).endswith('[]'): return type_str + '[]' # array of unknown bound return "%s[%d]" % (type_str, type_obj.range()[1] + 1) if type_obj.code == gdb.TYPE_CODE_REF: return self._recognize_subtype(type_obj.target()) + '&' if hasattr(gdb, 'TYPE_CODE_RVALUE_REF'): if type_obj.code == gdb.TYPE_CODE_RVALUE_REF: return self._recognize_subtype(type_obj.target()) + '&&' type_str = gdb.types.apply_type_recognizers( gdb.types.get_type_recognizers(), type_obj) if type_str: return type_str return str(type_obj) def instantiate(self): """Return a recognizer object for this type printer.""" return self._recognizer(self.name, self._defargs) def add_one_template_type_printer(obj, name, defargs): """ Add a type printer for a class template with default template arguments. Args: name (str): The template-name of the class template. defargs (dict int:string) The default template arguments. Types in defargs can refer to the Nth template-argument using {N} (with zero-based indices). e.g. 'unordered_map' has these defargs: { 2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator >' } """ printer = TemplateTypePrinter('std::' + name, defargs) gdb.types.register_type_printer(obj, printer) # Add type printer for same type in debug namespace: printer = TemplateTypePrinter('std::__debug::' + name, defargs) gdb.types.register_type_printer(obj, printer) if '__cxx11' not in name: # Add second type printer for same type in versioned namespace: ns = 'std::' + _versioned_namespace # PR 86112 Cannot use dict comprehension here: defargs = dict((n, d.replace('std::', ns)) for (n, d) in defargs.items()) printer = TemplateTypePrinter(ns + name, defargs) gdb.types.register_type_printer(obj, printer) # Add type printer for same type in debug namespace: printer = TemplateTypePrinter('std::__debug::' + name, defargs) gdb.types.register_type_printer(obj, printer) class FilteringTypePrinter(object): """ A type printer that uses typedef names for common template specializations. Args: template (str): The class template to recognize. name (str): The typedef-name that will be used instead. targ1 (str, optional): The first template argument. Defaults to None. Checks if a specialization of the class template 'template' is the same type as the typedef 'name', and prints it as 'name' instead. e.g. if an instantiation of std::basic_istream is the same type as std::istream then print it as std::istream. If targ1 is provided (not None), match only template specializations with this type as the first template argument, e.g. if template='basic_string' and targ1='char' then only match 'basic_string' and not 'basic_string'. This rejects non-matching specializations more quickly, without needing to do GDB type lookups. """ def __init__(self, template, name, targ1=None): self._template = template self.name = name self._targ1 = targ1 self.enabled = True class _recognizer(object): """The recognizer class for FilteringTypePrinter.""" def __init__(self, template, name, targ1): self._template = template self.name = name self._targ1 = targ1 self._type_obj = None def recognize(self, type_obj): """ If type_obj starts with self._template and is the same type as self.name then return self.name, otherwise None. """ if type_obj.tag is None: return None if self._type_obj is None: if self._targ1 is not None: s = '{}<{}'.format(self._template, self._targ1) if not type_obj.tag.startswith(s): # Filter didn't match. return None elif not type_obj.tag.startswith(self._template): # Filter didn't match. return None try: self._type_obj = gdb.lookup_type( self.name).strip_typedefs() except: pass if self._type_obj is None: return None t1 = gdb.types.get_basic_type(self._type_obj) t2 = gdb.types.get_basic_type(type_obj) if t1 == t2: return strip_inline_namespaces(self.name) # Workaround ambiguous typedefs matching both std:: and # std::__cxx11:: symbols. if self._template.split('::')[-1] == 'basic_string': s1 = self._type_obj.tag.replace('__cxx11::', '') s2 = type_obj.tag.replace('__cxx11::', '') if s1 == s2: return strip_inline_namespaces(self.name) return None def instantiate(self): """Return a recognizer object for this type printer.""" return self._recognizer(self._template, self.name, self._targ1) def add_one_type_printer(obj, template, name, targ1=None): printer = FilteringTypePrinter('std::' + template, 'std::' + name, targ1) gdb.types.register_type_printer(obj, printer) if '__cxx11' not in template: ns = 'std::' + _versioned_namespace printer = FilteringTypePrinter(ns + template, ns + name, targ1) gdb.types.register_type_printer(obj, printer) def register_type_printers(obj): global _use_type_printing if not _use_type_printing: return # Add type printers for typedefs std::string, std::wstring etc. for ch in (('', 'char'), ('w', 'wchar_t'), ('u8', 'char8_t'), ('u16', 'char16_t'), ('u32', 'char32_t')): add_one_type_printer(obj, 'basic_string', ch[0] + 'string', ch[1]) add_one_type_printer(obj, '__cxx11::basic_string', ch[0] + 'string', ch[1]) # Typedefs for __cxx11::basic_string used to be in namespace __cxx11: add_one_type_printer(obj, '__cxx11::basic_string', '__cxx11::' + ch[0] + 'string', ch[1]) add_one_type_printer(obj, 'basic_string_view', ch[0] + 'string_view', ch[1]) # Add type printers for typedefs std::istream, std::wistream etc. for ch in (('', 'char'), ('w', 'wchar_t')): for x in ('ios', 'streambuf', 'istream', 'ostream', 'iostream', 'filebuf', 'ifstream', 'ofstream', 'fstream'): add_one_type_printer(obj, 'basic_' + x, ch[0] + x, ch[1]) for x in ('stringbuf', 'istringstream', 'ostringstream', 'stringstream'): add_one_type_printer(obj, 'basic_' + x, ch[0] + x, ch[1]) # types are in __cxx11 namespace, but typedefs aren't: add_one_type_printer(obj, '__cxx11::basic_' + x, ch[0] + x, ch[1]) # Add type printers for typedefs regex, wregex, cmatch, wcmatch etc. for abi in ('', '__cxx11::'): for ch in (('', 'char'), ('w', 'wchar_t')): add_one_type_printer(obj, abi + 'basic_regex', abi + ch[0] + 'regex', ch[1]) for ch in ('c', 's', 'wc', 'ws'): add_one_type_printer( obj, abi + 'match_results', abi + ch + 'match') for x in ('sub_match', 'regex_iterator', 'regex_token_iterator'): add_one_type_printer(obj, abi + x, abi + ch + x) # Note that we can't have a printer for std::wstreampos, because # it is the same type as std::streampos. add_one_type_printer(obj, 'fpos', 'streampos') # Add type printers for typedefs. for dur in ('nanoseconds', 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'days', 'weeks', 'years', 'months'): add_one_type_printer(obj, 'chrono::duration', 'chrono::' + dur) # Add type printers for typedefs. add_one_type_printer(obj, 'linear_congruential_engine', 'minstd_rand0') add_one_type_printer(obj, 'linear_congruential_engine', 'minstd_rand') add_one_type_printer(obj, 'mersenne_twister_engine', 'mt19937') add_one_type_printer(obj, 'mersenne_twister_engine', 'mt19937_64') add_one_type_printer(obj, 'subtract_with_carry_engine', 'ranlux24_base') add_one_type_printer(obj, 'subtract_with_carry_engine', 'ranlux48_base') add_one_type_printer(obj, 'discard_block_engine', 'ranlux24') add_one_type_printer(obj, 'discard_block_engine', 'ranlux48') add_one_type_printer(obj, 'shuffle_order_engine', 'knuth_b') # Add type printers for experimental::basic_string_view typedefs. ns = 'experimental::fundamentals_v1::' for ch in (('', 'char'), ('w', 'wchar_t'), ('u8', 'char8_t'), ('u16', 'char16_t'), ('u32', 'char32_t')): add_one_type_printer(obj, ns + 'basic_string_view', ns + ch[0] + 'string_view', ch[1]) # Do not show defaulted template arguments in class templates. add_one_template_type_printer(obj, 'unique_ptr', {1: 'std::default_delete<{0}>'}) add_one_template_type_printer(obj, 'deque', {1: 'std::allocator<{0}>'}) add_one_template_type_printer( obj, 'forward_list', {1: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'list', {1: 'std::allocator<{0}>'}) add_one_template_type_printer( obj, '__cxx11::list', {1: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'vector', {1: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'map', {2: 'std::less<{0}>', 3: 'std::allocator>'}) add_one_template_type_printer(obj, 'multimap', {2: 'std::less<{0}>', 3: 'std::allocator>'}) add_one_template_type_printer(obj, 'set', {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'multiset', {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'unordered_map', {2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator>'}) add_one_template_type_printer(obj, 'unordered_multimap', {2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator>'}) add_one_template_type_printer(obj, 'unordered_set', {1: 'std::hash<{0}>', 2: 'std::equal_to<{0}>', 3: 'std::allocator<{0}>'}) add_one_template_type_printer(obj, 'unordered_multiset', {1: 'std::hash<{0}>', 2: 'std::equal_to<{0}>', 3: 'std::allocator<{0}>'}) def register_libstdcxx_printers(obj): """Register libstdc++ pretty-printers with objfile Obj.""" global _use_gdb_pp global libstdcxx_printer if _use_gdb_pp: gdb.printing.register_pretty_printer(obj, libstdcxx_printer) else: if obj is None: obj = gdb obj.pretty_printers.append(libstdcxx_printer) register_type_printers(obj) def build_libstdcxx_dictionary(): global libstdcxx_printer libstdcxx_printer = Printer("libstdc++-v6") # libstdc++ objects requiring pretty-printing. # In order from: # http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html libstdcxx_printer.add_version('std::', 'basic_string', StdStringPrinter) libstdcxx_printer.add_version( 'std::__cxx11::', 'basic_string', StdStringPrinter) libstdcxx_printer.add_container('std::', 'bitset', StdBitsetPrinter) libstdcxx_printer.add_container('std::', 'deque', StdDequePrinter) libstdcxx_printer.add_container('std::', 'list', StdListPrinter) libstdcxx_printer.add_container('std::__cxx11::', 'list', StdListPrinter) libstdcxx_printer.add_container('std::', 'map', StdMapPrinter) libstdcxx_printer.add_container('std::', 'multimap', StdMapPrinter) libstdcxx_printer.add_container('std::', 'multiset', StdSetPrinter) libstdcxx_printer.add_version('std::', 'pair', StdPairPrinter) libstdcxx_printer.add_version('std::', 'priority_queue', StdStackOrQueuePrinter) libstdcxx_printer.add_version('std::', 'queue', StdStackOrQueuePrinter) libstdcxx_printer.add_version('std::', 'tuple', StdTuplePrinter) libstdcxx_printer.add_container('std::', 'set', StdSetPrinter) libstdcxx_printer.add_version('std::', 'stack', StdStackOrQueuePrinter) libstdcxx_printer.add_version('std::', 'unique_ptr', UniquePointerPrinter) libstdcxx_printer.add_container('std::', 'vector', StdVectorPrinter) # vector libstdcxx_printer.add_version('std::', 'locale', StdLocalePrinter) if hasattr(gdb.Value, 'dynamic_type'): libstdcxx_printer.add_version('std::', 'error_code', StdErrorCodePrinter) libstdcxx_printer.add_version('std::', 'error_condition', StdErrorCodePrinter) # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG. libstdcxx_printer.add('std::__debug::bitset', StdBitsetPrinter) libstdcxx_printer.add('std::__debug::deque', StdDequePrinter) libstdcxx_printer.add('std::__debug::list', StdListPrinter) libstdcxx_printer.add('std::__debug::map', StdMapPrinter) libstdcxx_printer.add('std::__debug::multimap', StdMapPrinter) libstdcxx_printer.add('std::__debug::multiset', StdSetPrinter) libstdcxx_printer.add('std::__debug::set', StdSetPrinter) libstdcxx_printer.add('std::__debug::vector', StdVectorPrinter) # These are the TR1 and C++11 printers. # For array - the default GDB pretty-printer seems reasonable. libstdcxx_printer.add_version('std::', 'shared_ptr', SharedPointerPrinter) libstdcxx_printer.add_version('std::', 'weak_ptr', SharedPointerPrinter) libstdcxx_printer.add_container('std::', 'unordered_map', Tr1UnorderedMapPrinter) libstdcxx_printer.add_container('std::', 'unordered_set', Tr1UnorderedSetPrinter) libstdcxx_printer.add_container('std::', 'unordered_multimap', Tr1UnorderedMapPrinter) libstdcxx_printer.add_container('std::', 'unordered_multiset', Tr1UnorderedSetPrinter) libstdcxx_printer.add_container('std::', 'forward_list', StdForwardListPrinter) libstdcxx_printer.add_version( 'std::tr1::', 'shared_ptr', SharedPointerPrinter) libstdcxx_printer.add_version( 'std::tr1::', 'weak_ptr', SharedPointerPrinter) libstdcxx_printer.add_version('std::tr1::', 'unordered_map', Tr1UnorderedMapPrinter) libstdcxx_printer.add_version('std::tr1::', 'unordered_set', Tr1UnorderedSetPrinter) libstdcxx_printer.add_version('std::tr1::', 'unordered_multimap', Tr1UnorderedMapPrinter) libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset', Tr1UnorderedSetPrinter) libstdcxx_printer.add_version('std::', 'initializer_list', StdInitializerListPrinter) libstdcxx_printer.add_version('std::', 'atomic', StdAtomicPrinter) libstdcxx_printer.add_version( 'std::', 'basic_stringbuf', StdStringBufPrinter) libstdcxx_printer.add_version( 'std::__cxx11::', 'basic_stringbuf', StdStringBufPrinter) for sstream in ('istringstream', 'ostringstream', 'stringstream'): libstdcxx_printer.add_version( 'std::', 'basic_' + sstream, StdStringStreamPrinter) libstdcxx_printer.add_version( 'std::__cxx11::', 'basic_' + sstream, StdStringStreamPrinter) libstdcxx_printer.add_version('std::chrono::', 'duration', StdChronoDurationPrinter) libstdcxx_printer.add_version('std::chrono::', 'time_point', StdChronoTimePointPrinter) libstdcxx_printer.add_version('std::', 'integral_constant', StdIntegralConstantPrinter) # std::regex components libstdcxx_printer.add_version('std::__detail::', '_State', StdRegexStatePrinter) # These are the C++11 printer registrations for -D_GLIBCXX_DEBUG cases. # The tr1 namespace containers do not have any debug equivalents, # so do not register printers for them. libstdcxx_printer.add('std::__debug::unordered_map', Tr1UnorderedMapPrinter) libstdcxx_printer.add('std::__debug::unordered_set', Tr1UnorderedSetPrinter) libstdcxx_printer.add('std::__debug::unordered_multimap', Tr1UnorderedMapPrinter) libstdcxx_printer.add('std::__debug::unordered_multiset', Tr1UnorderedSetPrinter) libstdcxx_printer.add('std::__debug::forward_list', StdForwardListPrinter) # Library Fundamentals TS components libstdcxx_printer.add_version('std::experimental::fundamentals_v1::', 'any', StdExpAnyPrinter) libstdcxx_printer.add_version('std::experimental::fundamentals_v1::', 'optional', StdExpOptionalPrinter) libstdcxx_printer.add_version('std::experimental::fundamentals_v1::', 'basic_string_view', StdExpStringViewPrinter) # Filesystem TS components libstdcxx_printer.add_version('std::experimental::filesystem::v1::', 'path', StdExpPathPrinter) libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11::', 'path', StdExpPathPrinter) libstdcxx_printer.add_version('std::filesystem::', 'path', StdPathPrinter) libstdcxx_printer.add_version('std::filesystem::__cxx11::', 'path', StdPathPrinter) # C++17 components libstdcxx_printer.add_version('std::', 'any', StdExpAnyPrinter) libstdcxx_printer.add_version('std::', 'optional', StdExpOptionalPrinter) libstdcxx_printer.add_version('std::', 'basic_string_view', StdExpStringViewPrinter) libstdcxx_printer.add_version('std::', 'variant', StdVariantPrinter) libstdcxx_printer.add_version('std::', '_Node_handle', StdNodeHandlePrinter) # C++20 components libstdcxx_printer.add_version( 'std::', 'partial_ordering', StdCmpCatPrinter) libstdcxx_printer.add_version('std::', 'weak_ordering', StdCmpCatPrinter) libstdcxx_printer.add_version('std::', 'strong_ordering', StdCmpCatPrinter) libstdcxx_printer.add_version('std::', 'span', StdSpanPrinter) libstdcxx_printer.add_version('std::', 'basic_format_args', StdFormatArgsPrinter) for c in ['day', 'month', 'year', 'weekday', 'weekday_indexed', 'weekday_last', 'month_day', 'month_day_last', 'month_weekday', 'month_weekday_last', 'year_month', 'year_month_day', 'year_month_day_last', 'year_month_weekday', 'year_month_weekday_last', 'hh_mm_ss']: libstdcxx_printer.add_version('std::chrono::', c, StdChronoCalendarPrinter) libstdcxx_printer.add_version('std::chrono::', 'time_zone', StdChronoTimeZonePrinter) libstdcxx_printer.add_version('std::chrono::', 'time_zone_link', StdChronoTimeZonePrinter) libstdcxx_printer.add_version('std::chrono::', 'zoned_time', StdChronoZonedTimePrinter) libstdcxx_printer.add_version('std::chrono::', 'leap_second', StdChronoLeapSecondPrinter) libstdcxx_printer.add_version( 'std::chrono::', 'tzdb', StdChronoTzdbPrinter) # libstdcxx_printer.add_version('std::chrono::(anonymous namespace)', 'Rule', # StdChronoTimeZoneRulePrinter) # C++26 components libstdcxx_printer.add_version('std::', 'text_encoding', StdTextEncodingPrinter) # Extensions. libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter) if True: # These shouldn't be necessary, if GDB "print *i" worked. # But it often doesn't, so here they are. libstdcxx_printer.add_container('std::', '_List_iterator', StdListIteratorPrinter) libstdcxx_printer.add_container('std::', '_List_const_iterator', StdListIteratorPrinter) libstdcxx_printer.add_version('std::', '_Rb_tree_iterator', StdRbtreeIteratorPrinter) libstdcxx_printer.add_version('std::', '_Rb_tree_const_iterator', StdRbtreeIteratorPrinter) libstdcxx_printer.add_container('std::', '_Deque_iterator', StdDequeIteratorPrinter) libstdcxx_printer.add_container('std::', '_Deque_const_iterator', StdDequeIteratorPrinter) libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator', StdVectorIteratorPrinter) libstdcxx_printer.add_container('std::', '_Bit_iterator', StdBitIteratorPrinter) libstdcxx_printer.add_container('std::', '_Bit_const_iterator', StdBitIteratorPrinter) libstdcxx_printer.add_container('std::', '_Bit_reference', StdBitReferencePrinter) libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator', StdSlistIteratorPrinter) libstdcxx_printer.add_container('std::', '_Fwd_list_iterator', StdFwdListIteratorPrinter) libstdcxx_printer.add_container('std::', '_Fwd_list_const_iterator', StdFwdListIteratorPrinter) # Debug (compiled with -D_GLIBCXX_DEBUG) printer # registrations. libstdcxx_printer.add('__gnu_debug::_Safe_iterator', StdDebugIteratorPrinter) build_libstdcxx_dictionary() PKr1]@JY:python/libstdcxx/__pycache__/__init__.cpython-36.opt-1.pycnu[3 h@sdS)Nrrr-/usr/share/gcc-8/python/libstdcxx/__init__.pysPKr1]@JY4python/libstdcxx/__pycache__/__init__.cpython-36.pycnu[3 h@sdS)Nrrr-/usr/share/gcc-8/python/libstdcxx/__init__.pysPKr1]2python/libstdcxx/__init__.pynu[ PKr1]3,xexe=python/libstdcxx/v6/__pycache__/printers.cpython-36.opt-1.pycnu[PKr1]e7epython/libstdcxx/v6/__pycache__/xmethods.cpython-36.pycnu[PKr1] B66=2python/libstdcxx/v6/__pycache__/__init__.cpython-36.opt-1.pycnu[PKr1]3,xexe7python/libstdcxx/v6/__pycache__/printers.cpython-36.pycnu[PKr1]e=]python/libstdcxx/v6/__pycache__/xmethods.cpython-36.opt-1.pycnu[PKr1] B667python/libstdcxx/v6/__pycache__/__init__.cpython-36.pycnu[PKr1]qqpython/libstdcxx/v6/xmethods.pynu[PKr1]ܯ}}apython/libstdcxx/v6/__init__.pynu[PKr1]CBepython/libstdcxx/v6/printers.pynu[PKr1]@JY:python/libstdcxx/__pycache__/__init__.cpython-36.opt-1.pycnu[PKr1]@JY4python/libstdcxx/__pycache__/__init__.cpython-36.pycnu[PKr1]2python/libstdcxx/__init__.pynu[PK C-