Skip to content

[lldb] Cherry-pick changes to generate swig bindings from API headers instead of interface files #6731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ endif()

set(SWIG_COMMON_FLAGS
-c++
-w361,362 # Ignore warnings about ignored operator overloads
-features autodoc
-I${LLDB_SOURCE_DIR}/include
-I${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
56 changes: 56 additions & 0 deletions lldb/bindings/interface/SBAddressDocstrings.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
%feature("docstring",
"A section + offset based address class.

The SBAddress class allows addresses to be relative to a section
that can move during runtime due to images (executables, shared
libraries, bundles, frameworks) being loaded at different
addresses than the addresses found in the object file that
represents them on disk. There are currently two types of addresses
for a section:

* file addresses
* load addresses

File addresses represents the virtual addresses that are in the 'on
disk' object files. These virtual addresses are converted to be
relative to unique sections scoped to the object file so that
when/if the addresses slide when the images are loaded/unloaded
in memory, we can easily track these changes without having to
update every object (compile unit ranges, line tables, function
address ranges, lexical block and inlined subroutine address
ranges, global and static variables) each time an image is loaded or
unloaded.

Load addresses represents the virtual addresses where each section
ends up getting loaded at runtime. Before executing a program, it
is common for all of the load addresses to be unresolved. When a
DynamicLoader plug-in receives notification that shared libraries
have been loaded/unloaded, the load addresses of the main executable
and any images (shared libraries) will be resolved/unresolved. When
this happens, breakpoints that are in one of these sections can be
set/cleared.

See docstring of SBFunction for example usage of SBAddress."
) lldb::SBAddress;

%feature("docstring", "
Create an address by resolving a load address using the supplied target.")
lldb::SBAddress::SBAddress;

%feature("docstring", "
GetSymbolContext() and the following can lookup symbol information for a given address.
An address might refer to code or data from an existing module, or it
might refer to something on the stack or heap. The following functions
will only return valid values if the address has been resolved to a code
or data address using :py:class:`SBAddress.SetLoadAddress' or
:py:class:`SBTarget.ResolveLoadAddress`.") lldb::SBAddress::GetSymbolContext;

%feature("docstring", "
GetModule() and the following grab individual objects for a given address and
are less efficient if you want more than one symbol related objects.
Use :py:class:`SBAddress.GetSymbolContext` or
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
debug symbol related objects for an address.
One or more bits from the SymbolContextItem enumerations can be logically
OR'ed together to more efficiently retrieve multiple symbol objects.")
lldb::SBAddress::GetModule;
Original file line number Diff line number Diff line change
@@ -1,148 +1,14 @@
//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

namespace lldb {

%feature("docstring",
"A section + offset based address class.

The SBAddress class allows addresses to be relative to a section
that can move during runtime due to images (executables, shared
libraries, bundles, frameworks) being loaded at different
addresses than the addresses found in the object file that
represents them on disk. There are currently two types of addresses
for a section:

* file addresses
* load addresses

File addresses represents the virtual addresses that are in the 'on
disk' object files. These virtual addresses are converted to be
relative to unique sections scoped to the object file so that
when/if the addresses slide when the images are loaded/unloaded
in memory, we can easily track these changes without having to
update every object (compile unit ranges, line tables, function
address ranges, lexical block and inlined subroutine address
ranges, global and static variables) each time an image is loaded or
unloaded.

Load addresses represents the virtual addresses where each section
ends up getting loaded at runtime. Before executing a program, it
is common for all of the load addresses to be unresolved. When a
DynamicLoader plug-in receives notification that shared libraries
have been loaded/unloaded, the load addresses of the main executable
and any images (shared libraries) will be resolved/unresolved. When
this happens, breakpoints that are in one of these sections can be
set/cleared.

See docstring of SBFunction for example usage of SBAddress."
) SBAddress;
class SBAddress
{
public:

SBAddress ();

SBAddress (const lldb::SBAddress &rhs);

SBAddress (lldb::SBSection section,
lldb::addr_t offset);

%feature("docstring", "
Create an address by resolving a load address using the supplied target.") SBAddress;
SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);

~SBAddress ();

bool
IsValid () const;

explicit operator bool() const;
STRING_EXTENSION_OUTSIDE(SBAddress)

%extend lldb::SBAddress {
#ifdef SWIGPYTHON
// operator== is a free function, which swig does not handle, so we inject
// our own equality operator here
%pythoncode%{
def __eq__(self, other):
return not self.__ne__(other)
%}
#endif

bool operator!=(const SBAddress &rhs) const;

void
Clear ();

addr_t
GetFileAddress () const;

addr_t
GetLoadAddress (const lldb::SBTarget &target) const;

void
SetLoadAddress (lldb::addr_t load_addr,
lldb::SBTarget &target);

bool
OffsetAddress (addr_t offset);

bool
GetDescription (lldb::SBStream &description);

lldb::SBSection
GetSection ();

lldb::addr_t
SBAddress::GetOffset ();

void
SetAddress (lldb::SBSection section,
lldb::addr_t offset);

%feature("docstring", "
GetSymbolContext() and the following can lookup symbol information for a given address.
An address might refer to code or data from an existing module, or it
might refer to something on the stack or heap. The following functions
will only return valid values if the address has been resolved to a code
or data address using :py:class:`SBAddress.SetLoadAddress' or
:py:class:`SBTarget.ResolveLoadAddress`.") GetSymbolContext;
lldb::SBSymbolContext
GetSymbolContext (uint32_t resolve_scope);

%feature("docstring", "
GetModule() and the following grab individual objects for a given address and
are less efficient if you want more than one symbol related objects.
Use :py:class:`SBAddress.GetSymbolContext` or
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
debug symbol related objects for an address.
One or more bits from the SymbolContextItem enumerations can be logically
OR'ed together to more efficiently retrieve multiple symbol objects.") GetModule;
lldb::SBModule
GetModule ();

lldb::SBCompileUnit
GetCompileUnit ();

lldb::SBFunction
GetFunction ();

lldb::SBBlock
GetBlock ();

lldb::SBSymbol
GetSymbol ();

lldb::SBLineEntry
GetLineEntry ();

STRING_EXTENSION(SBAddress)

#ifdef SWIGPYTHON
%pythoncode %{
__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.'

Expand Down Expand Up @@ -186,7 +52,4 @@ public:
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.''')
%}
#endif

};

} // namespace lldb
}
133 changes: 0 additions & 133 deletions lldb/bindings/interface/SBAttachInfo.i

This file was deleted.

3 changes: 3 additions & 0 deletions lldb/bindings/interface/SBAttachInfoDocstrings.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%feature("docstring",
"Describes how to attach when calling :py:class:`SBTarget.Attach`."
) lldb::SBAttachInfo;
32 changes: 32 additions & 0 deletions lldb/bindings/interface/SBBlockDocstrings.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
%feature("docstring",
"Represents a lexical block. SBFunction contains SBBlock(s)."
) lldb::SBBlock;

%feature("docstring",
"Is this block contained within an inlined function?"
) lldb::SBBlock::IsInlined;

%feature("docstring", "
Get the function name if this block represents an inlined function;
otherwise, return None.") lldb::SBBlock::GetInlinedName;

%feature("docstring", "
Get the call site file if this block represents an inlined function;
otherwise, return an invalid file spec.") lldb::SBBlock::GetInlinedCallSiteFile;

%feature("docstring", "
Get the call site line if this block represents an inlined function;
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteLine;

%feature("docstring", "
Get the call site column if this block represents an inlined function;
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteColumn;

%feature("docstring", "Get the parent block.") lldb::SBBlock::GetParent;

%feature("docstring", "Get the inlined block that is or contains this block."
) lldb::SBBlock::GetContainingInlinedBlock;

%feature("docstring", "Get the sibling block for this block.") lldb::SBBlock::GetSibling;

%feature("docstring", "Get the first child block.") lldb::SBBlock::GetFirstChild;
Loading