3 g@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_tuplezs   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 staticmethodrrXrYrrrrrrys  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_rgrrrrrvs 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_nodes rc@s eZdZdZddZddZdS)StdRbtreeIteratorPrinterz2Print std::map::iterator, std::set::iterator, etc.cCs"||_td|jj}|j|_dS)N _Rb_tree_node)rVr8rra _link_type)rrDrWrrrrrXsz!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)rrDrWrrrrX-sz 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)rrrrrgs 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 rXrgrrrrrr srcCs"|d}|d}|d}|||fS)z'Access the streambuf put area pointers.Z _M_out_begZ _M_out_curZ _M_in_endr) streambufpbasepptregptrrrraccess_streambuf_ptrs.src@s(eZdZdZddZddZddZdS) StdStringBufPrinterzPrint a std::basic_stringbuf.cCs ||_dS)N)rV)r_rWrrrrX9szStdStringBufPrinter.__init__cCsLt|j\}}}|rB| s"||kr2|j||dS|j||dS|jdS)N)rZ _M_string)rrVr)rrrrrrrrg<s zStdStringBufPrinter.to_stringcCsdS)Nrr)rrrrrFsz StdStringBufPrinter.display_hintN)r r r r rXrgrrrrrr6s rc@s(eZdZdZddZddZddZdS) StdStringStreamPrinterz Print a std::basic_stringstream.cCsZ||_||_dd|jjDd}tjd|j|jtjd|_ |j |djk|_ dS)NcSsg|]}|jr|jqSr)rr)r&frrrr(Usz3StdStringStreamPrinter.__init__..rZ__streamz$__stream->rdbuf() _M_stringbuf) rVr]rrrZset_convenience_variablerbrsparse_and_eval _streambuf_was_redirected)rrDrWZbasetyperrrrXMs  zStdStringStreamPrinter.__init__cCs$|jrd|j|jjfS|jdS)Nz%s redirected to %sr)rr]rrtrV)rrrrrgZsz StdStringStreamPrinter.to_stringcCs|jr dSdS)Nr)r)rrrrr`sz#StdStringStreamPrinter.display_hintN)r r r r rXrgrrrrrrJs 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 hashtablerrrrXgs  zTr1HashtableIterator.__init__cCs|S)Nr)rrrrrYsszTr1HashtableIterator.__iter__cCs|jdkrt|jj|j}|jd}|jd|_|jdkr|jd|_x2|j|jkr~|j|j|_|jrpP|jd|_qNW|S)NrZ_M_vrzr))rrZrbrrtrrr)rrlrrrrrvs    zTr1HashtableIterator.__next__N)r r r rXrYrrrrrrfs 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)rrrrrYsz-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)rrrrr0s   z&SingleObjContainerPrinter.display_hint)N) r r r r rXrrrr_rrrrrr s  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_name8s  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__rrrXSsX                 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$rrPs 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?r0rrrrOs    z$StdExpPathPrinter._iterator.__next__N)r r r rXrYrrrrrrEsrcCs|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)rrDrWrrrrrXcs zStdPathPrinter.__init__cCsHt|jjtj|jd}|dddkr0dS|d ddkrDdSdS) Nz::_Typerr:zroot-directoryr;r<z root-nameii)r!rrbrrr])rr0rrrr=ms zStdPathPrinter._path_typecCs8d|jd}|jdkr0|j}|r0d||f}d|S)Nz%sr>rz%s [%s]zfilesystem::path %s)rVrr=)rr?r0rrrrgus   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_ImplbeginrrrrX~s      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 rXrYrrrrrr}srcCs|j|j|jS)N)rrDr])rrrrr_szStdPathPrinter.childrenN) r r r r rXr=rgrrr_rrrrrB`s  (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 CsBx(-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_rrrrrrsrs  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)rrrrrrg s 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#rrrrg.s$   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)rrDrWrrrrXFs z"StdChronoZonedTimePrinter.__init__cCs@|jdjd}|jd}t|jj|}|jd}dj||S)NZ_M_zone_M_nameZ_M_tpTz%std::chrono::zoned_time = {{ {} {} }})rVrtrrr"rgr*)rZzonerrrrrrgJs   z#StdChronoZonedTimePrinter.to_stringN)r r r r rXrgrrrrrCsrZJanuaryZFebruaryZMarchZAprilZMayZJuneZJulyZAugustZ 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#rrrrg`sh               z"StdChronoCalendarPrinter.to_stringN)r r r r rXrgrrrrrYsrc@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$rrrX0 szRxPrinter.__init__cCs:|js dS|jjtjkr,ttjdr,|j}|j|j |S)Nreferenced_value) rrrrrrValuerrr")rrZrrrinvoke6 s  zRxPrinter.invoke)r r r rXrr(rr)r$rr/ 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$rrrXE s zPrinter.__init__cCs<|jj|std|t||}|jj|||j|<dS)Nz0libstdc++ programming error: "%s" does not match)rr?r rrrPr)rr"rrrrraddM s     z Printer.addcCs>|j|||d|kr:tjddt|}|j|||dS)N__cxx11z^(std|__gnu_cxx)::z\g<0>%s)rr>rHr-)rbaser"rZvbaserrr add_versionX s  zPrinter.add_versioncCs$|j||||j|d||dS)Nz __cxx1998::)r)rrr"rrrr add_container` szPrinter.add_containercCs&|jtjkr|j}|jj}|jS)N)rrrrrrr)rrrrget_basic_typed 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__o s     zPrinter.__call__) r r r rXrrrrrrr(rr)r$rrD 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"rrrrrX3 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#Zt1Zt2s1s2rrrr9 s4        z*FilteringTypePrinter._recognizer.recognizeN)r r r r rXrrrrrr0 srcCs|j|j|j|jS)z1Return a recognizer object for this type printer.)rrr"r)rrrrrc 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_printerh 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_printersq 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 tjddttjddttjddttjddtttjdrJtjddttjddttjdttjdttjdttjdttjdttjdt tjdt tjd ttjdd!ttjdd"ttjdd#ttjdd$ttjdd%ttjdd&ttjdd'ttjd(d!ttjd(d"ttjd(d#ttjd(d$ttjd(d%ttjd(d&ttjdd)ttjdd*ttjdd+ttjdd+tx2doD]*}tjdd/|ttjdd/|tqWtjd0d1ttjd0d2t tjd3d4t!tjd5ttjd6ttjd7ttjd8ttjd9ttjd:d;t"tjd:dd?t%tjd@d?t%tjdAd?t&tjdBd?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 oS