> On Oct 2, 2017, at 9:25 AM, Francois Fayard via lldb-dev > <lldb-dev@lists.llvm.org> wrote: > > Hi, > > I would like to write a data formatter for LLDB, for a class which is very > close to std::array. Here it is: > > template <typename T, int n> > class StaticArray { > private: > T data_[n]; > } > > I wrote the following data formatter adapted from my own “std::vector” data > formatter but I still have blanks to fill : > > class StaticArrayProvider: > def __init__(self, valobj, internal_dict): > self.valobj = valobj > self.data = > self.valobj.GetChildMemberWithName('data_').GetChildAtIndex(0)
This is wrong, just remove the ".GetChildAtIndex(0)" from the above line otherwise "self.data" has a reference to the first value in the data_ array. > self.data_type = self.data.GetType() > self.type_size = self.data_type.GetByteSize() Don't need the above two lines. > self.size = #??? Since "data_" is an array, it can already be displayed as is. With this data formatter you are just trying to avoid showing "data_" as an extra level in the variable, so you can just forward all queries to "self.data". > > def num_children(self): > return self.size Just forward all queries to 'data_': def num_children(self): return self.data.GetNumChildren() > > def get_child_index(self, name): > try: > return int(name.lstrip('[').rstrip(']')) > except: > return -1 > def get_child_index(self, name): return self.data.etChildMemberWithName(name) > def get_child_at_index(self, index): > if index < 0: > return None > if index >= self.num_children(): > return None > try: > return #??? > except: > return None > def get_child_at_index(self, index): return self.data.etChildMemberAtIndex(index) > Could you please give me a hand to fill those blanks? > > François Fayard > Founder & Consultant - +33 (0)6 01 44 06 93 > Inside Loop - Scaling up Computational Science > Paris - 38 rue Desbordes-Valmore, 75116 Paris > Lyon/Grenoble - 34 route de Four, 38090 Vaulx-Milieu > > _______________________________________________ > lldb-dev mailing list > lldb-dev@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
_______________________________________________ lldb-dev mailing list lldb-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev