Skip to content

Commit 662548c

Browse files
committed
[lldb] Replace SB swig interfaces with API headers
Instead of maintaining separate swig interface files, we can use the API headers directly. They implement the exact same C++ APIs and we can conditionally include the python extensions as needed. To remove the swig extensions from the API headers when building the LLDB framework, we can use the unifdef tool when it is available. Otherwise we just copy them as-is. Differential Revision: https://reviews.llvm.org/D142926
1 parent 23d43e6 commit 662548c

File tree

205 files changed

+4606
-10646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+4606
-10646
lines changed

lldb/bindings/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ endif()
2323

2424
set(SWIG_COMMON_FLAGS
2525
-c++
26+
-w361,362 # Ignore warnings about ignored operator overloads
2627
-features autodoc
2728
-I${LLDB_SOURCE_DIR}/include
2829
-I${CMAKE_CURRENT_SOURCE_DIR}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
%feature("docstring",
2+
"A section + offset based address class.
3+
4+
The SBAddress class allows addresses to be relative to a section
5+
that can move during runtime due to images (executables, shared
6+
libraries, bundles, frameworks) being loaded at different
7+
addresses than the addresses found in the object file that
8+
represents them on disk. There are currently two types of addresses
9+
for a section:
10+
11+
* file addresses
12+
* load addresses
13+
14+
File addresses represents the virtual addresses that are in the 'on
15+
disk' object files. These virtual addresses are converted to be
16+
relative to unique sections scoped to the object file so that
17+
when/if the addresses slide when the images are loaded/unloaded
18+
in memory, we can easily track these changes without having to
19+
update every object (compile unit ranges, line tables, function
20+
address ranges, lexical block and inlined subroutine address
21+
ranges, global and static variables) each time an image is loaded or
22+
unloaded.
23+
24+
Load addresses represents the virtual addresses where each section
25+
ends up getting loaded at runtime. Before executing a program, it
26+
is common for all of the load addresses to be unresolved. When a
27+
DynamicLoader plug-in receives notification that shared libraries
28+
have been loaded/unloaded, the load addresses of the main executable
29+
and any images (shared libraries) will be resolved/unresolved. When
30+
this happens, breakpoints that are in one of these sections can be
31+
set/cleared.
32+
33+
See docstring of SBFunction for example usage of SBAddress."
34+
) lldb::SBAddress;
35+
36+
%feature("docstring", "
37+
Create an address by resolving a load address using the supplied target.")
38+
lldb::SBAddress::SBAddress;
39+
40+
%feature("docstring", "
41+
GetSymbolContext() and the following can lookup symbol information for a given address.
42+
An address might refer to code or data from an existing module, or it
43+
might refer to something on the stack or heap. The following functions
44+
will only return valid values if the address has been resolved to a code
45+
or data address using :py:class:`SBAddress.SetLoadAddress' or
46+
:py:class:`SBTarget.ResolveLoadAddress`.") lldb::SBAddress::GetSymbolContext;
47+
48+
%feature("docstring", "
49+
GetModule() and the following grab individual objects for a given address and
50+
are less efficient if you want more than one symbol related objects.
51+
Use :py:class:`SBAddress.GetSymbolContext` or
52+
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
53+
debug symbol related objects for an address.
54+
One or more bits from the SymbolContextItem enumerations can be logically
55+
OR'ed together to more efficiently retrieve multiple symbol objects.")
56+
lldb::SBAddress::GetModule;
Lines changed: 3 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,14 @@
1-
//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
2-
//
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
6-
//
7-
//===----------------------------------------------------------------------===//
8-
9-
namespace lldb {
10-
11-
%feature("docstring",
12-
"A section + offset based address class.
13-
14-
The SBAddress class allows addresses to be relative to a section
15-
that can move during runtime due to images (executables, shared
16-
libraries, bundles, frameworks) being loaded at different
17-
addresses than the addresses found in the object file that
18-
represents them on disk. There are currently two types of addresses
19-
for a section:
20-
21-
* file addresses
22-
* load addresses
23-
24-
File addresses represents the virtual addresses that are in the 'on
25-
disk' object files. These virtual addresses are converted to be
26-
relative to unique sections scoped to the object file so that
27-
when/if the addresses slide when the images are loaded/unloaded
28-
in memory, we can easily track these changes without having to
29-
update every object (compile unit ranges, line tables, function
30-
address ranges, lexical block and inlined subroutine address
31-
ranges, global and static variables) each time an image is loaded or
32-
unloaded.
33-
34-
Load addresses represents the virtual addresses where each section
35-
ends up getting loaded at runtime. Before executing a program, it
36-
is common for all of the load addresses to be unresolved. When a
37-
DynamicLoader plug-in receives notification that shared libraries
38-
have been loaded/unloaded, the load addresses of the main executable
39-
and any images (shared libraries) will be resolved/unresolved. When
40-
this happens, breakpoints that are in one of these sections can be
41-
set/cleared.
42-
43-
See docstring of SBFunction for example usage of SBAddress."
44-
) SBAddress;
45-
class SBAddress
46-
{
47-
public:
48-
49-
SBAddress ();
50-
51-
SBAddress (const lldb::SBAddress &rhs);
52-
53-
SBAddress (lldb::SBSection section,
54-
lldb::addr_t offset);
55-
56-
%feature("docstring", "
57-
Create an address by resolving a load address using the supplied target.") SBAddress;
58-
SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
59-
60-
~SBAddress ();
61-
62-
bool
63-
IsValid () const;
64-
65-
explicit operator bool() const;
1+
STRING_EXTENSION_OUTSIDE(SBAddress)
662

3+
%extend lldb::SBAddress {
674
#ifdef SWIGPYTHON
685
// operator== is a free function, which swig does not handle, so we inject
696
// our own equality operator here
707
%pythoncode%{
718
def __eq__(self, other):
729
return not self.__ne__(other)
7310
%}
74-
#endif
75-
76-
bool operator!=(const SBAddress &rhs) const;
77-
78-
void
79-
Clear ();
80-
81-
addr_t
82-
GetFileAddress () const;
8311

84-
addr_t
85-
GetLoadAddress (const lldb::SBTarget &target) const;
86-
87-
void
88-
SetLoadAddress (lldb::addr_t load_addr,
89-
lldb::SBTarget &target);
90-
91-
bool
92-
OffsetAddress (addr_t offset);
93-
94-
bool
95-
GetDescription (lldb::SBStream &description);
96-
97-
lldb::SBSection
98-
GetSection ();
99-
100-
lldb::addr_t
101-
SBAddress::GetOffset ();
102-
103-
void
104-
SetAddress (lldb::SBSection section,
105-
lldb::addr_t offset);
106-
107-
%feature("docstring", "
108-
GetSymbolContext() and the following can lookup symbol information for a given address.
109-
An address might refer to code or data from an existing module, or it
110-
might refer to something on the stack or heap. The following functions
111-
will only return valid values if the address has been resolved to a code
112-
or data address using :py:class:`SBAddress.SetLoadAddress' or
113-
:py:class:`SBTarget.ResolveLoadAddress`.") GetSymbolContext;
114-
lldb::SBSymbolContext
115-
GetSymbolContext (uint32_t resolve_scope);
116-
117-
%feature("docstring", "
118-
GetModule() and the following grab individual objects for a given address and
119-
are less efficient if you want more than one symbol related objects.
120-
Use :py:class:`SBAddress.GetSymbolContext` or
121-
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
122-
debug symbol related objects for an address.
123-
One or more bits from the SymbolContextItem enumerations can be logically
124-
OR'ed together to more efficiently retrieve multiple symbol objects.") GetModule;
125-
lldb::SBModule
126-
GetModule ();
127-
128-
lldb::SBCompileUnit
129-
GetCompileUnit ();
130-
131-
lldb::SBFunction
132-
GetFunction ();
133-
134-
lldb::SBBlock
135-
GetBlock ();
136-
137-
lldb::SBSymbol
138-
GetSymbol ();
139-
140-
lldb::SBLineEntry
141-
GetLineEntry ();
142-
143-
STRING_EXTENSION(SBAddress)
144-
145-
#ifdef SWIGPYTHON
14612
%pythoncode %{
14713
__runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'
14814

@@ -186,7 +52,4 @@ public:
18652
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''')
18753
%}
18854
#endif
189-
190-
};
191-
192-
} // namespace lldb
55+
}

lldb/bindings/interface/SBAttachInfo.i

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%feature("docstring",
2+
"Describes how to attach when calling :py:class:`SBTarget.Attach`."
3+
) lldb::SBAttachInfo;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
%feature("docstring",
2+
"Represents a lexical block. SBFunction contains SBBlock(s)."
3+
) lldb::SBBlock;
4+
5+
%feature("docstring",
6+
"Is this block contained within an inlined function?"
7+
) lldb::SBBlock::IsInlined;
8+
9+
%feature("docstring", "
10+
Get the function name if this block represents an inlined function;
11+
otherwise, return None.") lldb::SBBlock::GetInlinedName;
12+
13+
%feature("docstring", "
14+
Get the call site file if this block represents an inlined function;
15+
otherwise, return an invalid file spec.") lldb::SBBlock::GetInlinedCallSiteFile;
16+
17+
%feature("docstring", "
18+
Get the call site line if this block represents an inlined function;
19+
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteLine;
20+
21+
%feature("docstring", "
22+
Get the call site column if this block represents an inlined function;
23+
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteColumn;
24+
25+
%feature("docstring", "Get the parent block.") lldb::SBBlock::GetParent;
26+
27+
%feature("docstring", "Get the inlined block that is or contains this block."
28+
) lldb::SBBlock::GetContainingInlinedBlock;
29+
30+
%feature("docstring", "Get the sibling block for this block.") lldb::SBBlock::GetSibling;
31+
32+
%feature("docstring", "Get the first child block.") lldb::SBBlock::GetFirstChild;

0 commit comments

Comments
 (0)