@@ -0,0 +1,2380 @@
+ #%0A # Copyright 2015-2017 Michele %22King_DuckZ%22 Santullo%0A #%0A # Licensed under the Apache License, Version 2.0 (the %22License%22);%0A # you may not use this file except in compliance with the License.%0A # You may obtain a copy of the License at%0A #%0A #     http://www.apache.org/licenses/LICENSE-2.0%0A #%0A # Unless required by applicable law or agreed to in writing, software%0A # distributed under the License is distributed on an %22AS IS%22 BASIS,%0A # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A # See the License for the specific language governing permissions and%0A # limitations under the License.%0A%0Aimport gdb.printing%0A%0A#NOTE:%0A#This pretty-printer has been written for vectorwrapper + std::array.%0A#You will have to customize it if your wrapped type is different.%0A%0Aclass VectorWrapperPrinter(object):%0A    %22Print values in a VectorWrapper%22%0A%0A    class _iterator(object):%0A        def __init__(self, start, size):%0A            self.item = start%0A            self.pos = 0%0A            self.size = size%0A%0A        def __iter__(self):%0A            return self%0A%0A        def __next__(self):%0A            if self.pos == self.size:%0A                raise StopIteration%0A            elt = self.item.dereference()%0A            self.item = self.item + 1%0A            self.pos = self.pos + 1%0A            return str(elt)%0A%0A    def __init__(self, val):%0A        self.val = val%0A        self.dimensions = int(val.type.template_argument(1))%0A%0A    def to_string(self):%0A        #get the scalar%5Bn%5D value%0A        stdarray_elems = self.val%5B'm_wrapped'%5D%5B'_M_elems'%5D%0A        #get the actual scalar type%0A        elem_type = self.val%5B'm_wrapped'%5D.type.template_argument(0)%0A        #cast scalar%5Bn%5D to scalar*%0A        ptr = stdarray_elems.address.cast(elem_type.pointer())%0A        #iterate over the values in scalar* and str() them%0A        retval = %22vec%22 + str(self.dimensions) + %22%3C%22 + %5C%0A            %22, %22.join(%0A                str(itm) for itm in self._iterator(ptr, self.dimensions)%0A            ) + %22%3E%22%0A        return retval%0A%0A    def display_hint(self):%0A        return 'string'%0A%0Adef build_pretty_printer():%0A    pp = gdb.printing.RegexpCollectionPrettyPrinter(__name__)%0A    #add your namespace before 'vwr' if you're using a custom one%0A    pp.add_printer('vwr', '%5Evwr::Vec%3C.+$', VectorWrapperPrinter)%0A    return pp%0A%0Agdb.printing.register_pretty_printer(%0A    gdb.current_objfile(),%0A    build_pretty_printer()%0A)%0A

Add a sample gdb pretty printer for Vec<std::array> types