summaryrefslogtreecommitdiff
path: root/gnu/llvm/lldb/bindings
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2021-04-28 12:29:57 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2021-04-28 12:29:57 +0000
commita5b6d393184dd5775b95de77b942431bbae98146 (patch)
treebb35b33ae1f2890fecb2896052d06f7ad3f74bb6 /gnu/llvm/lldb/bindings
parent74c8725455b9e07524cc3c6cdb5639a587986353 (diff)
Import LLVM 11.1.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lldb/bindings')
-rw-r--r--gnu/llvm/lldb/bindings/CMakeLists.txt6
-rw-r--r--gnu/llvm/lldb/bindings/headers.swig7
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBAddress.i23
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBBlock.i2
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBBreakpoint.i3
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBCommandInterpreter.i64
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBCommandInterpreterRunOptions.i75
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBEnvironment.i48
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBExpressionOptions.i12
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBFile.i2
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBLaunchInfo.i6
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBModule.i9
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBPlatform.i5
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBProcess.i5
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBReproducer.i18
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBStream.i10
-rw-r--r--gnu/llvm/lldb/bindings/interface/SBTarget.i3
-rw-r--r--gnu/llvm/lldb/bindings/interfaces.swig3
-rw-r--r--gnu/llvm/lldb/bindings/python.swig9
-rw-r--r--gnu/llvm/lldb/bindings/python/python-typemaps.swig74
-rw-r--r--gnu/llvm/lldb/bindings/python/python-wrapper.swig41
21 files changed, 275 insertions, 150 deletions
diff --git a/gnu/llvm/lldb/bindings/CMakeLists.txt b/gnu/llvm/lldb/bindings/CMakeLists.txt
index 92ae402c478..a2e51c263f7 100644
--- a/gnu/llvm/lldb/bindings/CMakeLists.txt
+++ b/gnu/llvm/lldb/bindings/CMakeLists.txt
@@ -1,4 +1,4 @@
-file(GLOB SWIG_INTERFACES interfaces/*.i)
+file(GLOB SWIG_INTERFACES interface/*.i)
file(GLOB_RECURSE SWIG_SOURCES *.swig)
file(GLOB SWIG_HEADERS
${LLDB_SOURCE_DIR}/include/lldb/API/*.h
@@ -48,7 +48,7 @@ if (LLDB_ENABLE_PYTHON)
-o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
${LLDB_SOURCE_DIR}/bindings/python.swig
VERBATIM
- COMMENT "Builds LLDB Python wrapper")
+ COMMENT "Building LLDB Python wrapper")
add_custom_target(swig_wrapper ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
@@ -69,7 +69,7 @@ if (LLDB_ENABLE_LUA)
-o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
${LLDB_SOURCE_DIR}/bindings/lua.swig
VERBATIM
- COMMENT "Builds LLDB Lua wrapper")
+ COMMENT "Building LLDB Lua wrapper")
add_custom_target(swig_wrapper_lua ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
diff --git a/gnu/llvm/lldb/bindings/headers.swig b/gnu/llvm/lldb/bindings/headers.swig
index 69fd28e33c5..6e1668ea4c4 100644
--- a/gnu/llvm/lldb/bindings/headers.swig
+++ b/gnu/llvm/lldb/bindings/headers.swig
@@ -15,18 +15,20 @@
#include "lldb/API/SBBreakpointName.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBCommunication.h"
#include "lldb/API/SBCompileUnit.h"
#include "lldb/API/SBData.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBEnvironment.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
#include "lldb/API/SBExpressionOptions.h"
-#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFile.h"
+#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFileSpecList.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBFunction.h"
@@ -46,6 +48,7 @@
#include "lldb/API/SBProcessInfo.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBQueueItem.h"
+#include "lldb/API/SBReproducer.h"
#include "lldb/API/SBSection.h"
#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
@@ -68,9 +71,9 @@
#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"
+#include "lldb/API/SBUnixSignals.h"
#include "lldb/API/SBValue.h"
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
-#include "lldb/API/SBUnixSignals.h"
%}
diff --git a/gnu/llvm/lldb/bindings/interface/SBAddress.i b/gnu/llvm/lldb/bindings/interface/SBAddress.i
index 4658534d153..6fd06c83d29 100644
--- a/gnu/llvm/lldb/bindings/interface/SBAddress.i
+++ b/gnu/llvm/lldb/bindings/interface/SBAddress.i
@@ -144,27 +144,34 @@ public:
#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.'
+
def __get_load_addr_property__ (self):
- '''Get the load address for a lldb.SBAddress using the current target.'''
+ '''Get the load address for a lldb.SBAddress using the current target. 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.'''
+ if not target:
+ raise RuntimeError(self.__runtime_error_str)
return self.GetLoadAddress (target)
def __set_load_addr_property__ (self, load_addr):
- '''Set the load address for a lldb.SBAddress using the current target.'''
+ '''Set the load address for a lldb.SBAddress using the current target. 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.'''
+ if not target:
+ raise RuntimeError(self.__runtime_error_str)
return self.SetLoadAddress (load_addr, target)
def __int__(self):
- '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.'''
+ '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise. 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.'''
+ if not process or not target:
+ raise RuntimeError(self.__runtime_error_str)
if process.is_alive:
return self.GetLoadAddress (target)
- else:
- return self.GetFileAddress ()
+ return self.GetFileAddress ()
def __oct__(self):
- '''Convert the address to an octal string'''
+ '''Convert the address to an octal string. 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.'''
return '%o' % int(self)
def __hex__(self):
- '''Convert the address to an hex string'''
+ '''Convert the address to an hex string. 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.'''
return '0x%x' % int(self)
module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
@@ -176,7 +183,7 @@ public:
offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
- load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves 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) and not in Python based commands, or breakpoint commands.''')
+ 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
diff --git a/gnu/llvm/lldb/bindings/interface/SBBlock.i b/gnu/llvm/lldb/bindings/interface/SBBlock.i
index 8bd8e37953c..812b41fe5c3 100644
--- a/gnu/llvm/lldb/bindings/interface/SBBlock.i
+++ b/gnu/llvm/lldb/bindings/interface/SBBlock.i
@@ -152,7 +152,7 @@ public:
sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
- 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]").''')
+ 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.SBAddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
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.''')
num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
%}
diff --git a/gnu/llvm/lldb/bindings/interface/SBBreakpoint.i b/gnu/llvm/lldb/bindings/interface/SBBreakpoint.i
index 20354346be9..a2d747db0bf 100644
--- a/gnu/llvm/lldb/bindings/interface/SBBreakpoint.i
+++ b/gnu/llvm/lldb/bindings/interface/SBBreakpoint.i
@@ -206,6 +206,9 @@ public:
bool
AddName (const char *new_name);
+ SBError
+ AddNameWithErrorHandling (const char *new_name);
+
void
RemoveName (const char *name_to_remove);
diff --git a/gnu/llvm/lldb/bindings/interface/SBCommandInterpreter.i b/gnu/llvm/lldb/bindings/interface/SBCommandInterpreter.i
index ad2e8f1662c..498084ae3ab 100644
--- a/gnu/llvm/lldb/bindings/interface/SBCommandInterpreter.i
+++ b/gnu/llvm/lldb/bindings/interface/SBCommandInterpreter.i
@@ -9,70 +9,6 @@
namespace lldb {
%feature("docstring",
-"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
-A default SBCommandInterpreterRunOptions object has:
- StopOnContinue: false
- StopOnError: false
- StopOnCrash: false
- EchoCommands: true
- PrintResults: true
- AddToHistory: true
-
-") SBCommandInterpreterRunOptions;
-class SBCommandInterpreterRunOptions
-{
-friend class SBDebugger;
-public:
- SBCommandInterpreterRunOptions();
- ~SBCommandInterpreterRunOptions();
-
- bool
- GetStopOnContinue () const;
-
- void
- SetStopOnContinue (bool);
-
- bool
- GetStopOnError () const;
-
- void
- SetStopOnError (bool);
-
- bool
- GetStopOnCrash () const;
-
- void
- SetStopOnCrash (bool);
-
- bool
- GetEchoCommands () const;
-
- void
- SetEchoCommands (bool);
-
- bool
- GetPrintResults () const;
-
- void
- SetPrintResults (bool);
-
- bool
- GetAddToHistory () const;
-
- void
- SetAddToHistory (bool);
-private:
- lldb_private::CommandInterpreterRunOptions *
- get () const;
-
- lldb_private::CommandInterpreterRunOptions &
- ref () const;
-
- // This is set in the constructor and will always be valid.
- mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
-};
-
-%feature("docstring",
"SBCommandInterpreter handles/interprets commands for lldb. You get the
command interpreter from the SBDebugger instance. For example (from test/
python_api/interpreter/TestCommandInterpreterAPI.py),
diff --git a/gnu/llvm/lldb/bindings/interface/SBCommandInterpreterRunOptions.i b/gnu/llvm/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
new file mode 100644
index 00000000000..f9ccbbd24db
--- /dev/null
+++ b/gnu/llvm/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
@@ -0,0 +1,75 @@
+//===-- SWIG Interface for SBCommandInterpreter -----------------*- 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",
+"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
+A default SBCommandInterpreterRunOptions object has:
+ StopOnContinue: false
+ StopOnError: false
+ StopOnCrash: false
+ EchoCommands: true
+ PrintResults: true
+ AddToHistory: true
+
+") SBCommandInterpreterRunOptions;
+class SBCommandInterpreterRunOptions
+{
+friend class SBDebugger;
+public:
+ SBCommandInterpreterRunOptions();
+ ~SBCommandInterpreterRunOptions();
+
+ bool
+ GetStopOnContinue () const;
+
+ void
+ SetStopOnContinue (bool);
+
+ bool
+ GetStopOnError () const;
+
+ void
+ SetStopOnError (bool);
+
+ bool
+ GetStopOnCrash () const;
+
+ void
+ SetStopOnCrash (bool);
+
+ bool
+ GetEchoCommands () const;
+
+ void
+ SetEchoCommands (bool);
+
+ bool
+ GetPrintResults () const;
+
+ void
+ SetPrintResults (bool);
+
+ bool
+ GetAddToHistory () const;
+
+ void
+ SetAddToHistory (bool);
+private:
+ lldb_private::CommandInterpreterRunOptions *
+ get () const;
+
+ lldb_private::CommandInterpreterRunOptions &
+ ref () const;
+
+ // This is set in the constructor and will always be valid.
+ mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
+};
+
+} // namespace lldb
diff --git a/gnu/llvm/lldb/bindings/interface/SBEnvironment.i b/gnu/llvm/lldb/bindings/interface/SBEnvironment.i
new file mode 100644
index 00000000000..4ca22fc314d
--- /dev/null
+++ b/gnu/llvm/lldb/bindings/interface/SBEnvironment.i
@@ -0,0 +1,48 @@
+//===-- SWIG Interface for SBEnvironment-------------------------*- 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",
+"Represents the environment of a certain process.
+
+Example:
+ for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
+ print(entry)
+
+") SBEnvironment;
+class SBEnvironment {
+public:
+ SBEnvironment ();
+
+ SBEnvironment (const lldb::SBEnvironment &rhs);
+
+ ~SBEnvironment();
+
+ size_t GetNumValues();
+
+ const char *Get(const char *name);
+
+ const char *GetNameAtIndex(size_t index);
+
+ const char *GetValueAtIndex(size_t index);
+
+ SBStringList GetEntries();
+
+ void PutEntry(const char *name_and_value);
+
+ void SetEntries(const SBStringList &entries, bool append);
+
+ bool Set(const char *name, const char *value, bool overwrite);
+
+ bool Unset(const char *name);
+
+ void Clear();
+};
+
+} // namespace lldb
diff --git a/gnu/llvm/lldb/bindings/interface/SBExpressionOptions.i b/gnu/llvm/lldb/bindings/interface/SBExpressionOptions.i
index 5dbd7007c01..950641c320d 100644
--- a/gnu/llvm/lldb/bindings/interface/SBExpressionOptions.i
+++ b/gnu/llvm/lldb/bindings/interface/SBExpressionOptions.i
@@ -59,7 +59,7 @@ public:
uint32_t
GetTimeoutInMicroSeconds () const;
- %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expresson will finish.") SetTimeoutInMicroSeconds;
+ %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expression will finish.") SetTimeoutInMicroSeconds;
void
SetTimeoutInMicroSeconds (uint32_t timeout = 0);
@@ -80,7 +80,7 @@ public:
bool
GetStopOthers () const;
- %feature("docstring", "Sets whether to stop other threads at all while running expressins. If false, TryAllThreads does nothing.") SetTryAllThreads;
+ %feature("docstring", "Sets whether to stop other threads at all while running expressions. If false, TryAllThreads does nothing.") SetTryAllThreads;
void
SetStopOthers (bool stop_others = true);
@@ -126,6 +126,14 @@ public:
bool
GetAutoApplyFixIts();
+ %feature("docstring", "Sets how often LLDB should retry applying fix-its to an expression.") SetRetriesWithFixIts;
+ void
+ SetRetriesWithFixIts(uint64_t retries);
+
+ %feature("docstring", "Gets how often LLDB will retry applying fix-its to an expression.") GetRetriesWithFixIts;
+ uint64_t
+ GetRetriesWithFixIts();
+
bool
GetTopLevel();
diff --git a/gnu/llvm/lldb/bindings/interface/SBFile.i b/gnu/llvm/lldb/bindings/interface/SBFile.i
index a19666995cd..c86c5f26f14 100644
--- a/gnu/llvm/lldb/bindings/interface/SBFile.i
+++ b/gnu/llvm/lldb/bindings/interface/SBFile.i
@@ -92,7 +92,7 @@ public:
SBFile, call SBFile.Close().
If there is no underlying python file to unwrap, GetFile will
- use the file descriptor, if availble to create a new python
+ use the file descriptor, if available to create a new python
file object using `open(fd, mode=..., closefd=False)`
");
FileSP GetFile();
diff --git a/gnu/llvm/lldb/bindings/interface/SBLaunchInfo.i b/gnu/llvm/lldb/bindings/interface/SBLaunchInfo.i
index e76950c6fb4..1de89b58b27 100644
--- a/gnu/llvm/lldb/bindings/interface/SBLaunchInfo.i
+++ b/gnu/llvm/lldb/bindings/interface/SBLaunchInfo.i
@@ -65,6 +65,12 @@ public:
SetEnvironmentEntries (const char **envp, bool append);
void
+ SetEnvironment(const SBEnvironment &env, bool append);
+
+ SBEnvironment
+ GetEnvironment();
+
+ void
Clear ();
const char *
diff --git a/gnu/llvm/lldb/bindings/interface/SBModule.i b/gnu/llvm/lldb/bindings/interface/SBModule.i
index a9d9480cd7c..e902af0c49c 100644
--- a/gnu/llvm/lldb/bindings/interface/SBModule.i
+++ b/gnu/llvm/lldb/bindings/interface/SBModule.i
@@ -344,6 +344,15 @@ public:
lldb::SBAddress
GetObjectFileEntryPointAddress() const;
+ %feature("docstring", "
+ Returns the number of modules in the module cache. This is an
+ implementation detail exposed for testing and should not be relied upon.
+
+ @return
+ The number of modules in the module cache.") GetNumberAllocatedModules;
+ static uint32_t
+ GetNumberAllocatedModules();
+
STRING_EXTENSION(SBModule)
#ifdef SWIGPYTHON
diff --git a/gnu/llvm/lldb/bindings/interface/SBPlatform.i b/gnu/llvm/lldb/bindings/interface/SBPlatform.i
index 9baa2eb970c..81945222c05 100644
--- a/gnu/llvm/lldb/bindings/interface/SBPlatform.i
+++ b/gnu/llvm/lldb/bindings/interface/SBPlatform.i
@@ -115,6 +115,8 @@ public:
~SBPlatform();
+ static SBPlatform GetHostPlatform();
+
bool
IsValid () const;
@@ -192,6 +194,9 @@ public:
lldb::SBUnixSignals
GetUnixSignals();
+ lldb::SBEnvironment
+ GetEnvironment();
+
};
} // namespace lldb
diff --git a/gnu/llvm/lldb/bindings/interface/SBProcess.i b/gnu/llvm/lldb/bindings/interface/SBProcess.i
index ac6a265faec..b54c4629f9d 100644
--- a/gnu/llvm/lldb/bindings/interface/SBProcess.i
+++ b/gnu/llvm/lldb/bindings/interface/SBProcess.i
@@ -346,6 +346,11 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ %feature("autodoc", "
+ Returns the process' extended crash information.") GetExtendedCrashInformation;
+ lldb::SBStructuredData
+ GetExtendedCrashInformation ();
+
uint32_t
GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
diff --git a/gnu/llvm/lldb/bindings/interface/SBReproducer.i b/gnu/llvm/lldb/bindings/interface/SBReproducer.i
new file mode 100644
index 00000000000..7c9b007db3c
--- /dev/null
+++ b/gnu/llvm/lldb/bindings/interface/SBReproducer.i
@@ -0,0 +1,18 @@
+//===-- SWIG Interface for SBReproducer--------------------------*- 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 {
+class SBReproducer
+{
+ public:
+ static const char *Capture(const char *path);
+ static const char *PassiveReplay(const char *path);
+ static bool SetAutoGenerate(bool b);
+ static void SetWorkingDirectory(const char *path);
+};
+}
diff --git a/gnu/llvm/lldb/bindings/interface/SBStream.i b/gnu/llvm/lldb/bindings/interface/SBStream.i
index 31fb3802bf6..edd67f87c3f 100644
--- a/gnu/llvm/lldb/bindings/interface/SBStream.i
+++ b/gnu/llvm/lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@ public:
size_t
GetSize();
- // wrapping the variadic Printf() with a plain Print()
- // because it is hard to support varargs in SWIG bridgings
- %extend {
- void Print (const char* str)
- {
- self->Printf("%s", str);
- }
- }
+ void
+ Print (const char* str);
void
RedirectToFile (const char *path, bool append);
diff --git a/gnu/llvm/lldb/bindings/interface/SBTarget.i b/gnu/llvm/lldb/bindings/interface/SBTarget.i
index 371bf5c35eb..57b5ccea639 100644
--- a/gnu/llvm/lldb/bindings/interface/SBTarget.i
+++ b/gnu/llvm/lldb/bindings/interface/SBTarget.i
@@ -677,6 +677,9 @@ public:
lldb::SBBreakpoint
BreakpointCreateByAddress (addr_t address);
+ lldb::SBEnvironment
+ GetEnvironment();
+
lldb::SBBreakpoint
BreakpointCreateBySBAddress (SBAddress &sb_address);
diff --git a/gnu/llvm/lldb/bindings/interfaces.swig b/gnu/llvm/lldb/bindings/interfaces.swig
index 780fe34392f..2df7a05b4f4 100644
--- a/gnu/llvm/lldb/bindings/interfaces.swig
+++ b/gnu/llvm/lldb/bindings/interfaces.swig
@@ -22,6 +22,7 @@
%include "./interface/SBBreakpointName.i"
%include "./interface/SBBroadcaster.i"
%include "./interface/SBCommandInterpreter.i"
+%include "./interface/SBCommandInterpreterRunOptions.i"
%include "./interface/SBCommandReturnObject.i"
%include "./interface/SBCommunication.i"
%include "./interface/SBCompileUnit.i"
@@ -29,6 +30,7 @@
%include "./interface/SBDebugger.i"
%include "./interface/SBDeclaration.i"
%include "./interface/SBError.i"
+%include "./interface/SBEnvironment.i"
%include "./interface/SBEvent.i"
%include "./interface/SBExecutionContext.i"
%include "./interface/SBExpressionOptions.i"
@@ -53,6 +55,7 @@
%include "./interface/SBProcessInfo.i"
%include "./interface/SBQueue.i"
%include "./interface/SBQueueItem.i"
+%include "./interface/SBReproducer.i"
%include "./interface/SBSection.i"
%include "./interface/SBSourceManager.i"
%include "./interface/SBStream.i"
diff --git a/gnu/llvm/lldb/bindings/python.swig b/gnu/llvm/lldb/bindings/python.swig
index b086d436e57..5b1269878da 100644
--- a/gnu/llvm/lldb/bindings/python.swig
+++ b/gnu/llvm/lldb/bindings/python.swig
@@ -128,8 +128,15 @@ using namespace lldb;
%include "./python/python-wrapper.swig"
%pythoncode%{
+_initialize = True
+try:
+ import lldbconfig
+ _initialize = lldbconfig.INITIALIZE
+except ImportError:
+ pass
debugger_unique_id = 0
-SBDebugger.Initialize()
+if _initialize:
+ SBDebugger.Initialize()
debugger = None
target = None
process = None
diff --git a/gnu/llvm/lldb/bindings/python/python-typemaps.swig b/gnu/llvm/lldb/bindings/python/python-typemaps.swig
index bfd7ef9007d..c08aeab71f7 100644
--- a/gnu/llvm/lldb/bindings/python/python-typemaps.swig
+++ b/gnu/llvm/lldb/bindings/python/python-typemaps.swig
@@ -59,37 +59,25 @@
$result = list.release();
}
-
%typemap(in) lldb::tid_t {
- if (PythonInteger::Check($input))
- {
- PythonInteger py_int(PyRefType::Borrowed, $input);
- $1 = static_cast<lldb::tid_t>(py_int.GetInteger());
- }
- else
- {
- PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+ PythonObject obj = Retain<PythonObject>($input);
+ lldb::tid_t value = unwrapOrSetPythonException(As<unsigned long long>(obj));
+ if (PyErr_Occurred())
return nullptr;
- }
+ $1 = value;
}
%typemap(in) lldb::StateType {
- if (PythonInteger::Check($input))
- {
- PythonInteger py_int(PyRefType::Borrowed, $input);
- int64_t state_type_value = py_int.GetInteger() ;
-
- if (state_type_value > lldb::StateType::kLastStateType) {
- PyErr_SetString(PyExc_ValueError, "Not a valid StateType value");
- return nullptr;
- }
- $1 = static_cast<lldb::StateType>(state_type_value);
- }
- else
- {
- PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+ PythonObject obj = Retain<PythonObject>($input);
+ unsigned long long state_type_value =
+ unwrapOrSetPythonException(As<unsigned long long>(obj));
+ if (PyErr_Occurred())
+ return nullptr;
+ if (state_type_value > lldb::StateType::kLastStateType) {
+ PyErr_SetString(PyExc_ValueError, "Not a valid StateType value");
return nullptr;
}
+ $1 = static_cast<lldb::StateType>(state_type_value);
}
/* Typemap definitions to allow SWIG to properly handle char buffer. */
@@ -488,39 +476,53 @@ bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
}
}
+%inline %{
+
+struct Py_buffer_RAII {
+ Py_buffer buffer = {};
+ Py_buffer_RAII() {};
+ Py_buffer &operator=(const Py_buffer_RAII &) = delete;
+ Py_buffer_RAII(const Py_buffer_RAII &) = delete;
+ ~Py_buffer_RAII() {
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+ }
+};
+
+%}
+
// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
// and fixed so they will not crash if PyObject_GetBuffer fails.
// https://github.com/swig/swig/issues/1640
+//
+// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
+// doing it right away is not legal according to the python buffer protocol.
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
-%typemap(in) (TYPEMAP, SIZE) {
+%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
int res; Py_ssize_t size = 0; void *buf = 0;
- Py_buffer view;
- res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE);
+ res = PyObject_GetBuffer($input, &view.buffer, PyBUF_WRITABLE);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
- size = view.len;
- buf = view.buf;
- PyBuffer_Release(&view);
+ size = view.buffer.len;
+ buf = view.buffer.buf;
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size/sizeof($*1_type));
}
%enddef
%define %pybuffer_binary(TYPEMAP, SIZE)
-%typemap(in) (TYPEMAP, SIZE) {
+%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
int res; Py_ssize_t size = 0; const void *buf = 0;
- Py_buffer view;
- res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO);
+ res = PyObject_GetBuffer($input, &view.buffer, PyBUF_CONTIG_RO);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
- size = view.len;
- buf = view.buf;
- PyBuffer_Release(&view);
+ size = view.buffer.len;
+ buf = view.buffer.buf;
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size / sizeof($*1_type));
}
diff --git a/gnu/llvm/lldb/bindings/python/python-wrapper.swig b/gnu/llvm/lldb/bindings/python/python-wrapper.swig
index 3a63165cf58..f9e89373fe2 100644
--- a/gnu/llvm/lldb/bindings/python/python-wrapper.swig
+++ b/gnu/llvm/lldb/bindings/python/python-wrapper.swig
@@ -444,6 +444,7 @@ LLDBSwigPythonCallBreakpointResolver
if (PyErr_Occurred())
{
PyErr_Print();
+ PyErr_Clear();
return 0;
}
@@ -457,11 +458,13 @@ LLDBSwigPythonCallBreakpointResolver
return 1;
}
- PythonInteger int_result = result.AsType<PythonInteger>();
- if (!int_result.IsAllocated())
- return 0;
+ long long ret_val = unwrapOrSetPythonException(As<long long>(result));
- unsigned int ret_val = int_result.GetInteger();
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ PyErr_Clear();
+ return 0;
+ }
return ret_val;
}
@@ -515,26 +518,17 @@ LLDBSwigPython_CalculateNumChildren
return 0;
}
- PythonObject result;
-
+ size_t ret_val;
if (arg_info.get().max_positional_args < 1)
- result = pfunc();
+ ret_val = unwrapOrSetPythonException(As<long long>(pfunc.Call()));
else
- result = pfunc(PythonInteger(max));
-
- if (!result.IsAllocated())
- return 0;
-
- PythonInteger int_result = result.AsType<PythonInteger>();
- if (!int_result.IsAllocated())
- return 0;
-
- size_t ret_val = int_result.GetInteger();
+ ret_val = unwrapOrSetPythonException(As<long long>(pfunc.Call(PythonInteger(max))));
- if (PyErr_Occurred()) //FIXME use Expected to catch python exceptions
+ if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
+ return 0;
}
if (arg_info.get().max_positional_args < 1)
@@ -588,16 +582,15 @@ LLDBSwigPython_GetIndexOfChildWithName
if (!pfunc.IsAllocated())
return UINT32_MAX;
- PythonObject result = pfunc(PythonString(child_name));
+ llvm::Expected<PythonObject> result = pfunc.Call(PythonString(child_name));
- if (!result.IsAllocated())
- return UINT32_MAX;
+ long long retval = unwrapOrSetPythonException(As<long long>(std::move(result)));
- PythonInteger int_result = result.AsType<PythonInteger>();
- if (!int_result.IsAllocated())
+ if (PyErr_Occurred()) {
+ PyErr_Clear(); // FIXME print this? do something else
return UINT32_MAX;
+ }
- int64_t retval = int_result.GetInteger();
if (retval >= 0)
return (uint32_t)retval;