blob: d3660aff08c7f203658750c653504f9d7c3e29c0 [file] [log] [blame]
Johnny Chend84a9a12011-07-18 22:15:37 +00001//===-- SWIG Interface for SBFunction ---------------------------*- 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
10namespace lldb {
11
12%feature("docstring",
13"Represents a generic function, which can be inlined or not.
14
15For example (from test/lldbutil.py, but slightly modified for doc purpose),
16
17 ...
18
19 frame = thread.GetFrameAtIndex(i)
20 addr = frame.GetPCAddress()
21 load_addr = addr.GetLoadAddress(target)
22 function = frame.GetFunction()
23 mod_name = frame.GetModule().GetFileSpec().GetFilename()
24
25 if not function:
26 # No debug info for 'function'.
27 symbol = frame.GetSymbol()
28 file_addr = addr.GetFileAddress()
29 start_addr = symbol.GetStartAddress().GetFileAddress()
30 symbol_name = symbol.GetName()
31 symbol_offset = file_addr - start_addr
32 print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
33 num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset)
34 else:
35 # Debug info is available for 'function'.
36 func_name = frame.GetFunctionName()
37 file_name = frame.GetLineEntry().GetFileSpec().GetFilename()
38 line_num = frame.GetLineEntry().GetLine()
39 print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
40 num=i, addr=load_addr, mod=mod_name,
41 func='%s [inlined]' % func_name] if frame.IsInlined() else func_name,
42 file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False))
43
44 ...
45") SBFunction;
46class SBFunction
47{
48public:
49
50 SBFunction ();
51
52 SBFunction (const lldb::SBFunction &rhs);
53
54 ~SBFunction ();
55
56 bool
57 IsValid () const;
58
59 const char *
60 GetName() const;
61
62 const char *
63 GetMangledName () const;
64
65 lldb::SBInstructionList
66 GetInstructions (lldb::SBTarget target);
67
Jim Ingham0f063ba2013-03-02 00:26:47 +000068 lldb::SBInstructionList
69 GetInstructions (lldb::SBTarget target, const char *flavor);
70
Greg Clayton5569e642012-02-06 01:44:54 +000071 lldb::SBAddress
Johnny Chend84a9a12011-07-18 22:15:37 +000072 GetStartAddress ();
73
Greg Clayton5569e642012-02-06 01:44:54 +000074 lldb::SBAddress
Johnny Chend84a9a12011-07-18 22:15:37 +000075 GetEndAddress ();
76
77 uint32_t
78 GetPrologueByteSize ();
79
Greg Clayton5569e642012-02-06 01:44:54 +000080 lldb::SBType
81 GetType ();
82
83 lldb::SBBlock
84 GetBlock ();
Enrico Granata6cd8e0c2014-11-17 23:06:20 +000085
86 lldb::LanguageType
87 GetLanguage ();
Greg Clayton5569e642012-02-06 01:44:54 +000088
Johnny Chend84a9a12011-07-18 22:15:37 +000089 bool
90 GetDescription (lldb::SBStream &description);
Greg Clayton13d19502012-01-29 06:07:39 +000091
Enrico Granatac3387332013-05-03 01:29:27 +000092 bool
93 operator == (const lldb::SBFunction &rhs) const;
94
95 bool
96 operator != (const lldb::SBFunction &rhs) const;
97
Greg Clayton13d19502012-01-29 06:07:39 +000098 %pythoncode %{
Greg Clayton6b2bd932012-02-01 08:09:32 +000099 def get_instructions_from_current_target (self):
100 return self.GetInstructions (target)
101
Greg Clayton6b2bd932012-02-01 08:09:32 +0000102 __swig_getmethods__["addr"] = GetStartAddress
Greg Clayton5ef31a92012-06-29 22:00:42 +0000103 if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''')
Greg Clayton5569e642012-02-06 01:44:54 +0000104
Greg Clayton13d19502012-01-29 06:07:39 +0000105 __swig_getmethods__["end_addr"] = GetEndAddress
Greg Clayton5ef31a92012-06-29 22:00:42 +0000106 if _newclass: 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.''')
107
108 __swig_getmethods__["block"] = GetBlock
109 if _newclass: 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.''')
110
Greg Clayton6b2bd932012-02-01 08:09:32 +0000111 __swig_getmethods__["instructions"] = get_instructions_from_current_target
Greg Clayton5ef31a92012-06-29 22:00:42 +0000112 if _newclass: 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.''')
Greg Clayton6b2bd932012-02-01 08:09:32 +0000113
Greg Clayton5569e642012-02-06 01:44:54 +0000114 __swig_getmethods__["mangled"] = GetMangledName
Greg Clayton5ef31a92012-06-29 22:00:42 +0000115 if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''')
Greg Clayton5569e642012-02-06 01:44:54 +0000116
117 __swig_getmethods__["name"] = GetName
Greg Clayton5ef31a92012-06-29 22:00:42 +0000118 if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''')
Greg Clayton5569e642012-02-06 01:44:54 +0000119
120 __swig_getmethods__["prologue_size"] = GetPrologueByteSize
Greg Clayton5ef31a92012-06-29 22:00:42 +0000121 if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
Greg Clayton5569e642012-02-06 01:44:54 +0000122
123 __swig_getmethods__["type"] = GetType
Greg Clayton5ef31a92012-06-29 22:00:42 +0000124 if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')
Greg Clayton13d19502012-01-29 06:07:39 +0000125 %}
126
Johnny Chend84a9a12011-07-18 22:15:37 +0000127};
128
129} // namespace lldb