Johnny Chen | 3cfd5e8 | 2011-07-18 21:30:21 +0000 | [diff] [blame] | 1 | //===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | namespace lldb { |
| 11 | |
| 12 | %feature("docstring", |
| 13 | "Represents a lexical block. SBFunction contains SBBlock(s)." |
| 14 | ) SBBlock; |
| 15 | class SBBlock |
| 16 | { |
| 17 | public: |
| 18 | |
| 19 | SBBlock (); |
| 20 | |
| 21 | SBBlock (const lldb::SBBlock &rhs); |
| 22 | |
| 23 | ~SBBlock (); |
| 24 | |
| 25 | %feature("docstring", |
| 26 | "Does this block represent an inlined function?" |
| 27 | ) IsInlined; |
| 28 | bool |
| 29 | IsInlined () const; |
| 30 | |
| 31 | bool |
| 32 | IsValid () const; |
| 33 | |
| 34 | %feature("docstring", " |
| 35 | Get the function name if this block represents an inlined function; |
| 36 | otherwise, return None. |
| 37 | ") GetInlinedName; |
| 38 | const char * |
| 39 | GetInlinedName () const; |
| 40 | |
| 41 | %feature("docstring", " |
| 42 | Get the call site file if this block represents an inlined function; |
| 43 | otherwise, return an invalid file spec. |
| 44 | ") GetInlinedCallSiteFile; |
| 45 | lldb::SBFileSpec |
| 46 | GetInlinedCallSiteFile () const; |
| 47 | |
| 48 | %feature("docstring", " |
| 49 | Get the call site line if this block represents an inlined function; |
| 50 | otherwise, return 0. |
| 51 | ") GetInlinedCallSiteLine; |
| 52 | uint32_t |
| 53 | GetInlinedCallSiteLine () const; |
| 54 | |
| 55 | %feature("docstring", " |
| 56 | Get the call site column if this block represents an inlined function; |
| 57 | otherwise, return 0. |
| 58 | ") GetInlinedCallSiteColumn; |
| 59 | uint32_t |
| 60 | GetInlinedCallSiteColumn () const; |
| 61 | |
| 62 | %feature("docstring", "Get the parent block.") GetParent; |
| 63 | lldb::SBBlock |
| 64 | GetParent (); |
| 65 | |
Greg Clayton | 23b8abb | 2011-09-26 07:11:27 +0000 | [diff] [blame] | 66 | %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; |
| 67 | lldb::SBBlock |
| 68 | GetContainingInlinedBlock (); |
| 69 | |
Johnny Chen | 3cfd5e8 | 2011-07-18 21:30:21 +0000 | [diff] [blame] | 70 | %feature("docstring", "Get the sibling block for this block.") GetSibling; |
| 71 | lldb::SBBlock |
| 72 | GetSibling (); |
| 73 | |
| 74 | %feature("docstring", "Get the first child block.") GetFirstChild; |
| 75 | lldb::SBBlock |
| 76 | GetFirstChild (); |
Greg Clayton | 23b8abb | 2011-09-26 07:11:27 +0000 | [diff] [blame] | 77 | |
| 78 | uint32_t |
| 79 | GetNumRanges (); |
| 80 | |
| 81 | lldb::SBAddress |
| 82 | GetRangeStartAddress (uint32_t idx); |
| 83 | |
| 84 | lldb::SBAddress |
| 85 | GetRangeEndAddress (uint32_t idx); |
| 86 | |
| 87 | uint32_t |
| 88 | GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); |
Johnny Chen | 3cfd5e8 | 2011-07-18 21:30:21 +0000 | [diff] [blame] | 89 | |
| 90 | bool |
| 91 | GetDescription (lldb::SBStream &description); |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 92 | |
| 93 | lldb::SBValueList |
| 94 | GetVariables (lldb::SBFrame& frame, |
| 95 | bool arguments, |
| 96 | bool locals, |
| 97 | bool statics, |
| 98 | lldb::DynamicValueType use_dynamic); |
| 99 | |
| 100 | lldb::SBValueList |
| 101 | GetVariables (lldb::SBTarget& target, |
| 102 | bool arguments, |
| 103 | bool locals, |
| 104 | bool statics); |
| 105 | |
| 106 | %pythoncode %{ |
| 107 | def get_range_at_index(self, idx): |
| 108 | if idx < self.GetNumRanges(): |
| 109 | return [self.sbblock.GetRangeStartAddress(key), self.sbblock.GetRangeEndAddress(key)] |
| 110 | return [] |
| 111 | |
| 112 | class ranges_access(object): |
| 113 | '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.''' |
| 114 | def __init__(self, sbblock): |
| 115 | self.sbblock = sbblock |
| 116 | |
| 117 | def __len__(self): |
| 118 | if self.sbblock: |
Filipe Cabecinhas | 3cae38b | 2012-05-11 20:39:42 +0000 | [diff] [blame] | 119 | return int(self.sbblock.GetNumRanges()) |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 120 | return 0 |
| 121 | |
| 122 | def __getitem__(self, key): |
| 123 | count = len(self) |
| 124 | if type(key) is int: |
| 125 | return self.sbblock.get_range_at_index (key); |
Greg Clayton | 698e94a | 2012-06-27 20:23:09 +0000 | [diff] [blame] | 126 | if isinstance(key, SBAddress): |
| 127 | range_idx = self.sbblock.GetRangeIndexForBlockAddress(key); |
| 128 | if range_idx < len(self): |
| 129 | return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)] |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 130 | else: |
| 131 | print "error: unsupported item type: %s" % type(key) |
| 132 | return None |
| 133 | |
| 134 | def get_ranges_access_object(self): |
| 135 | '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.''' |
| 136 | return self.ranges_access (self) |
| 137 | |
| 138 | def get_ranges_array(self): |
| 139 | '''An accessor function that returns an array object that contains all ranges in this block object.''' |
| 140 | if not hasattr(self, 'ranges'): |
| 141 | self.ranges = [] |
| 142 | for idx in range(self.num_ranges): |
| 143 | self.ranges.append (self.get_range_at_index (idx)) |
| 144 | return self.ranges |
| 145 | |
| 146 | def get_call_site(self): |
| 147 | return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) |
| 148 | |
| 149 | __swig_getmethods__["parent"] = GetParent |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 150 | if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 151 | |
| 152 | __swig_getmethods__["first_child"] = GetFirstChild |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 153 | if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 154 | |
| 155 | __swig_getmethods__["call_site"] = get_call_site |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 156 | if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 157 | |
| 158 | __swig_getmethods__["sibling"] = GetSibling |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 159 | if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 160 | |
| 161 | __swig_getmethods__["name"] = GetInlinedName |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 162 | if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 163 | |
| 164 | __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 165 | if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 166 | |
| 167 | __swig_getmethods__["range"] = get_ranges_access_object |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 168 | if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 169 | |
| 170 | __swig_getmethods__["ranges"] = get_ranges_array |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 171 | if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 172 | |
| 173 | __swig_getmethods__["num_ranges"] = GetNumRanges |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 174 | if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 175 | %} |
| 176 | |
Johnny Chen | 3cfd5e8 | 2011-07-18 21:30:21 +0000 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | } // namespace lldb |