1 //===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 "Represents a generic function, which can be inlined or not.
14 For example (from test/lldbutil.py, but slightly modified for doc purpose),
18 frame = thread.GetFrameAtIndex(i)
19 addr = frame.GetPCAddress()
20 load_addr = addr.GetLoadAddress(target)
21 function = frame.GetFunction()
22 mod_name = frame.GetModule().GetFileSpec().GetFilename()
25 # No debug info for 'function'.
26 symbol = frame.GetSymbol()
27 file_addr = addr.GetFileAddress()
28 start_addr = symbol.GetStartAddress().GetFileAddress()
29 symbol_name = symbol.GetName()
30 symbol_offset = file_addr - start_addr
31 print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
32 num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset)
34 # Debug info is available for 'function'.
35 func_name = frame.GetFunctionName()
36 file_name = frame.GetLineEntry().GetFileSpec().GetFilename()
37 line_num = frame.GetLineEntry().GetLine()
38 print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
39 num=i, addr=load_addr, mod=mod_name,
40 func='%s [inlined]' % func_name] if frame.IsInlined() else func_name,
41 file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False))
50 SBFunction (const lldb::SBFunction &rhs);
57 explicit operator bool() const;
63 GetDisplayName() const;
66 GetMangledName () const;
68 lldb::SBInstructionList
69 GetInstructions (lldb::SBTarget target);
71 lldb::SBInstructionList
72 GetInstructions (lldb::SBTarget target, const char *flavor);
81 GetArgumentName (uint32_t arg_idx);
84 GetPrologueByteSize ();
95 %feature("docstring", "
96 Returns true if the function was compiled with optimization.
97 Optimization, in this case, is meant to indicate that the debugger
98 experience may be confusing for the user -- variables optimized away,
99 stepping jumping between source lines -- and the driver may want to
100 provide some guidance to the user about this.
101 Returns false if unoptimized, or unknown.") GetIsOptimized;
106 GetDescription (lldb::SBStream &description);
109 operator == (const lldb::SBFunction &rhs) const;
112 operator != (const lldb::SBFunction &rhs) const;
114 STRING_EXTENSION(SBFunction)
118 def get_instructions_from_current_target (self):
119 return self.GetInstructions (target)
121 addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''')
122 end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''')
123 block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''')
124 instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''')
125 mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''')
126 name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''')
127 prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
128 type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')