[lldb-dev] Writing a data formatter for LLDB

Francois Fayard via lldb-dev lldb-dev at lists.llvm.org
Mon Oct 2 09:25:45 PDT 2017


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 {
  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)
        self.data_type = self.data.GetType()
        self.type_size = self.data_type.GetByteSize()
        self.size = #???

    def num_children(self):
        return self.size

    def get_child_index(self, name):
            return int(name.lstrip('[').rstrip(']'))
            return -1

    def get_child_at_index(self, index):
        if index < 0:
            return None
        if index >= self.num_children():
            return None
            return #???
            return None

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20171002/384830a0/attachment.html>

More information about the lldb-dev mailing list