LLDB Python API GetArrayType() Equivalent in Version 3.9


In LLDB 4.0+ x.GetArrayType(n) can be called to generate the a fixed size array type for some given element type x. How can this be achieved in LLDB 3.9? Reason is that I am using CLion and the current version 2017.2 only supports LLDB 3.9.


I am writing a synthetic provider for a class that looks like

struct X
    int n_a;
    int n_b;
    double * a;
    double * b;

I.e. it has a bunch of pointers and corresponding sizes. I know this could/should be refactored – but this is not my question.

I want to write a synthetic provider in for LLDB to visualize the arrays properly. My idea was to do sth. along the lines of

def get_child_at_index(self, index):
    if is_pointer(index):
        size = get_array_size(index)
        name = get_name(index)
        child = self.value.GetChildMemberWithName(name)
        data = child.GetPointeeData(0, size)
        array_type = ???
        return self.value.CreateValueFromData(name, data, array_type)

So given the index, I can determine if it’s a pointer, get the size and name. My problem is that I need to then construct an SBType instance that corresponds to double [size]. This is exactly what GetArrayType(size) seems to do but it is unavailable to me.

Alternatively, is there a better way to get X formatted in LLDB?

لینک منبع