summaryrefslogtreecommitdiff
path: root/lldb/bindings/interface/SBFrameListExtensions.i
blob: 1c6ac8d50a54c978ca74cc2d375ade19b1406ced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%extend lldb::SBFrameList {

#ifdef SWIGPYTHON
       %nothreadallow;
#endif
       std::string lldb::SBFrameList::__str__ (){
           lldb::SBStream description;
           if (!$self->GetDescription(description))
               return std::string("<empty> lldb.SBFrameList()");
           const char *desc = description.GetData();
           size_t desc_len = description.GetSize();
           if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
               --desc_len;
           return std::string(desc, desc_len);
       }
#ifdef SWIGPYTHON
       %clearnothreadallow;
#endif

#ifdef SWIGPYTHON
    %pythoncode %{
        def __iter__(self):
            '''Iterate over all frames in a lldb.SBFrameList object.'''
            return lldb_iter(self, 'GetSize', 'GetFrameAtIndex')

        def __len__(self):
            return int(self.GetSize())

        def __getitem__(self, key):
            if type(key) is not int:
                return None
            if key < 0:
                count = len(self)
                if -count <= key < count:
                    key %= count

            frame = self.GetFrameAtIndex(key)
            return frame if frame.IsValid() else None
    %}
#endif
}