diff options
Diffstat (limited to 'contrib/llvm-project/lldb/bindings')
19 files changed, 807 insertions, 68 deletions
diff --git a/contrib/llvm-project/lldb/bindings/headers.swig b/contrib/llvm-project/lldb/bindings/headers.swig index 6e1668ea4c42..3c2cd85f504d 100644 --- a/contrib/llvm-project/lldb/bindings/headers.swig +++ b/contrib/llvm-project/lldb/bindings/headers.swig @@ -62,7 +62,6 @@ #include "lldb/API/SBThreadCollection.h" #include "lldb/API/SBThreadPlan.h" #include "lldb/API/SBTrace.h" -#include "lldb/API/SBTraceOptions.h" #include "lldb/API/SBType.h" #include "lldb/API/SBTypeCategory.h" #include "lldb/API/SBTypeEnumMember.h" diff --git a/contrib/llvm-project/lldb/bindings/interface/SBBreakpoint.i b/contrib/llvm-project/lldb/bindings/interface/SBBreakpoint.i index 37fcc7fbab48..a7048309edd9 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBBreakpoint.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBBreakpoint.i @@ -184,7 +184,7 @@ public: %feature("docstring", " Set the name of the script function to be called when the breakpoint is hit. - To use this variant, the function should take (frame, bp_loc, extra_args, dict) and + To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction; SBError SetScriptCallbackFunction (const char *callback_function_name, diff --git a/contrib/llvm-project/lldb/bindings/interface/SBBreakpointLocation.i b/contrib/llvm-project/lldb/bindings/interface/SBBreakpointLocation.i index fc37475ba745..354737b98c6a 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBBreakpointLocation.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBBreakpointLocation.i @@ -74,13 +74,13 @@ public: %feature("docstring", " Set the callback to the given Python function name. - The function takes three arguments (frame, bp_loc, dict).") SetScriptCallbackFunction; + The function takes three arguments (frame, bp_loc, internal_dict).") SetScriptCallbackFunction; void SetScriptCallbackFunction (const char *callback_function_name); %feature("docstring", " Set the name of the script function to be called when the breakpoint is hit. - To use this variant, the function should take (frame, bp_loc, extra_args, dict) and + To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction; SBError SetScriptCallbackFunction (const char *callback_function_name, diff --git a/contrib/llvm-project/lldb/bindings/interface/SBCommandInterpreterRunOptions.i b/contrib/llvm-project/lldb/bindings/interface/SBCommandInterpreterRunOptions.i index 1a618a228bbe..28437abb60c6 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBCommandInterpreterRunOptions.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBCommandInterpreterRunOptions.i @@ -18,6 +18,7 @@ A default SBCommandInterpreterRunOptions object has: * StopOnCrash: false * EchoCommands: true * PrintResults: true +* PrintErrors: true * AddToHistory: true ") SBCommandInterpreterRunOptions; @@ -59,6 +60,12 @@ public: SetPrintResults (bool); bool + GetPrintErrors () const; + + void + SetPrintErrors (bool); + + bool GetAddToHistory () const; void diff --git a/contrib/llvm-project/lldb/bindings/interface/SBLaunchInfo.i b/contrib/llvm-project/lldb/bindings/interface/SBLaunchInfo.i index d76656ddd493..535ed3b79060 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBLaunchInfo.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBLaunchInfo.i @@ -135,6 +135,16 @@ public: void SetDetachOnError(bool enable); + + const char * + GetScriptedProcessClassName() const; + + void SetScriptedProcessClassName(const char *class_name); + + lldb::SBStructuredData + GetScriptedProcessDictionary() const; + + void SetScriptedProcessDictionary(lldb::SBStructuredData dict); }; } // namespace lldb diff --git a/contrib/llvm-project/lldb/bindings/interface/SBMemoryRegionInfo.i b/contrib/llvm-project/lldb/bindings/interface/SBMemoryRegionInfo.i index 6a2ad6a3e364..3460dc0d06e2 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBMemoryRegionInfo.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBMemoryRegionInfo.i @@ -46,6 +46,42 @@ public: const char * GetName (); + %feature("autodoc", " + GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t + Returns whether this memory region has a list of modified (dirty) + pages available or not. When calling GetNumDirtyPages(), you will + have 0 returned for both \"dirty page list is not known\" and + \"empty dirty page list\" (that is, no modified pages in this + memory region). You must use this method to disambiguate.") HasDirtyMemoryPageList; + bool + HasDirtyMemoryPageList(); + + %feature("autodoc", " + GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t + Return the number of dirty (modified) memory pages in this + memory region, if available. You must use the + SBMemoryRegionInfo::HasDirtyMemoryPageList() method to + determine if a dirty memory list is available; it will depend + on the target system can provide this information.") GetNumDirtyPages; + uint32_t + GetNumDirtyPages(); + + %feature("autodoc", " + GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> lldb::addr_t + Return the address of a modified, or dirty, page of memory. + If the provided index is out of range, or this memory region + does not have dirty page information, LLDB_INVALID_ADDRESS + is returned.") GetDirtyPageAddressAtIndex; + addr_t + GetDirtyPageAddressAtIndex(uint32_t idx); + + %feature("autodoc", " + GetPageSize(SBMemoryRegionInfo self) -> int + Return the size of pages in this memory region. 0 will be returned + if this information was unavailable.") GetPageSize(); + int + GetPageSize(); + bool operator == (const lldb::SBMemoryRegionInfo &rhs) const; diff --git a/contrib/llvm-project/lldb/bindings/interface/SBProcess.i b/contrib/llvm-project/lldb/bindings/interface/SBProcess.i index e30b89d1ed39..14566a2942d0 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBProcess.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBProcess.i @@ -400,9 +400,6 @@ public: lldb::SBError SaveCore(const char *file_name); - lldb::SBTrace - StartTrace(SBTraceOptions &options, lldb::SBError &error); - lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info); @@ -420,6 +417,25 @@ public: lldb::SBProcessInfo GetProcessInfo(); + %feature("autodoc", " + Allocates a block of memory within the process, with size and + access permissions specified in the arguments. The permisssions + argument is an or-combination of zero or more of + lldb.ePermissionsWritable, lldb.ePermissionsReadable, and + lldb.ePermissionsExecutable. Returns the address + of the allocated buffer in the process, or + lldb.LLDB_INVALID_ADDRESS if the allocation failed.") AllocateMemory; + + lldb::addr_t + AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &error); + + %feature("autodoc", " + Deallocates the block of memory (previously allocated using + AllocateMemory) given in the argument.") DeallocateMemory; + + lldb::SBError + DeallocateMemory(lldb::addr_t ptr); + STRING_EXTENSION(SBProcess) #ifdef SWIGPYTHON diff --git a/contrib/llvm-project/lldb/bindings/interface/SBProcessInfo.i b/contrib/llvm-project/lldb/bindings/interface/SBProcessInfo.i index 009842599bf8..17b2761a344e 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBProcessInfo.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBProcessInfo.i @@ -62,6 +62,12 @@ public: lldb::pid_t GetParentProcessID (); + + %feature("docstring", + "Return the target triple (arch-vendor-os) for the described process." + ) GetTriple; + const char * + GetTriple (); }; } // namespace lldb diff --git a/contrib/llvm-project/lldb/bindings/interface/SBStructuredData.i b/contrib/llvm-project/lldb/bindings/interface/SBStructuredData.i index 5aba35229855..ba5b7e075065 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBStructuredData.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBStructuredData.i @@ -58,5 +58,8 @@ This class wraps the event type generated by StructuredData features." lldb::SBError SetFromJSON(lldb::SBStream &stream); + + lldb::SBError + SetFromJSON(const char *json); }; } diff --git a/contrib/llvm-project/lldb/bindings/interface/SBTarget.i b/contrib/llvm-project/lldb/bindings/interface/SBTarget.i index f874726b42d8..3f9e4cdc6d67 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBTarget.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBTarget.i @@ -938,6 +938,16 @@ public: lldb::addr_t GetStackRedZoneSize(); + %feature("docstring", " + Returns true if the module has been loaded in this `SBTarget`. + A module can be loaded either by the dynamic loader or by being manually + added to the target (see `SBTarget.AddModule` and the `target module add` command). + + :rtype: bool + ") IsLoaded; + bool + IsLoaded (const lldb::SBModule &module) const; + lldb::SBLaunchInfo GetLaunchInfo () const; @@ -964,6 +974,12 @@ public: STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief) + lldb::SBTrace + GetTrace (); + + lldb::SBTrace + CreateTrace (lldb::SBError &error); + #ifdef SWIGPYTHON %pythoncode %{ class modules_access(object): diff --git a/contrib/llvm-project/lldb/bindings/interface/SBThread.i b/contrib/llvm-project/lldb/bindings/interface/SBThread.i index 463584d2cab1..d847d38f0d66 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBThread.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBThread.i @@ -104,6 +104,9 @@ public: eStopReasonSignal 1 unix signal number eStopReasonException N exception data eStopReasonExec 0 + eStopReasonFork 1 pid of the child process + eStopReasonVFork 1 pid of the child process + eStopReasonVForkDone 0 eStopReasonPlanComplete 0") GetStopReasonDataAtIndex; uint64_t GetStopReasonDataAtIndex(uint32_t idx); diff --git a/contrib/llvm-project/lldb/bindings/interface/SBThreadPlan.i b/contrib/llvm-project/lldb/bindings/interface/SBThreadPlan.i index 94ae1a42dd3b..9e1053525354 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBThreadPlan.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBThreadPlan.i @@ -73,6 +73,9 @@ public: eStopReasonSignal 1 unix signal number eStopReasonException N exception data eStopReasonExec 0 + eStopReasonFork 1 pid of the child process + eStopReasonVFork 1 pid of the child process + eStopReasonVForkDone 0 eStopReasonPlanComplete 0") GetStopReasonDataAtIndex; uint64_t GetStopReasonDataAtIndex(uint32_t idx); diff --git a/contrib/llvm-project/lldb/bindings/interface/SBTrace.i b/contrib/llvm-project/lldb/bindings/interface/SBTrace.i index 6d4b7e6be27d..0f5bf0ecc8d9 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBTrace.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBTrace.i @@ -14,25 +14,19 @@ namespace lldb { class LLDB_API SBTrace { public: SBTrace(); - size_t GetTraceData(SBError &error, void *buf, - size_t size, size_t offset, - lldb::tid_t thread_id); - size_t GetMetaData(SBError &error, void *buf, - size_t size, size_t offset, - lldb::tid_t thread_id); + const char *GetStartConfigurationHelp(); - void StopTrace(SBError &error, - lldb::tid_t thread_id); + SBError Start(const SBStructuredData &configuration); - void GetTraceConfig(SBTraceOptions &options, - SBError &error); + SBError Start(const SBThread &thread, const SBStructuredData &configuration); - lldb::user_id_t GetTraceUID(); + SBError Stop(); + + SBError Stop(const SBThread &thread); explicit operator bool() const; bool IsValid(); - }; -} // namespace lldb
\ No newline at end of file +} // namespace lldb diff --git a/contrib/llvm-project/lldb/bindings/interface/SBTraceOptions.i b/contrib/llvm-project/lldb/bindings/interface/SBTraceOptions.i deleted file mode 100644 index 4a1878b5b76f..000000000000 --- a/contrib/llvm-project/lldb/bindings/interface/SBTraceOptions.i +++ /dev/null @@ -1,44 +0,0 @@ -//===-- SWIG Interface for SBTraceOptions -----------------------*- 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 possible options when doing processor tracing. - -See :py:class:`SBProcess.StartTrace`." -) SBTraceOptions; -class LLDB_API SBTraceOptions { -public: - SBTraceOptions(); - - lldb::TraceType getType() const; - - uint64_t getTraceBufferSize() const; - - lldb::SBStructuredData getTraceParams(lldb::SBError &error); - - uint64_t getMetaDataBufferSize() const; - - void setTraceParams(lldb::SBStructuredData ¶ms); - - void setType(lldb::TraceType type); - - void setTraceBufferSize(uint64_t size); - - void setMetaDataBufferSize(uint64_t size); - - void setThreadID(lldb::tid_t thread_id); - - lldb::tid_t getThreadID(); - - explicit operator bool() const; - - bool IsValid(); -}; -} diff --git a/contrib/llvm-project/lldb/bindings/interface/SBType.i b/contrib/llvm-project/lldb/bindings/interface/SBType.i index e7b3fd11e338..500bc99ca8cd 100644 --- a/contrib/llvm-project/lldb/bindings/interface/SBType.i +++ b/contrib/llvm-project/lldb/bindings/interface/SBType.i @@ -111,8 +111,24 @@ protected: }; %feature("docstring", -"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule -returns a SBType. +"Represents a data type in lldb. + +The actual characteristics of each type are defined by the semantics of the +programming language and the specific language implementation that was used +to compile the target program. See the language-specific notes in the +documentation of each method. + +SBType instances can be obtained by a variety of methods. +`SBTarget.FindFirstType` and `SBModule.FindFirstType` can be used to create +`SBType` representations of types in executables/libraries with debug +information. For some languages such as C, C++ and Objective-C it is possible +to create new types by evaluating expressions that define a new type. + +Note that most `SBType` properties are computed independently of any runtime +information so for dynamic languages the functionality can be very limited. +`SBValue` can be used to represent runtime values which then can be more +accurately queried for certain information such as byte size. + SBType supports the eq/ne operator. For example,:: @@ -181,7 +197,7 @@ SBType supports the eq/ne operator. For example,:: # id_type and int_type should be the same type! self.assertTrue(id_type == int_type) -...") SBType; +") SBType; class SBType { public: @@ -196,132 +212,649 @@ public: explicit operator bool() const; + + %feature("docstring", + "Returns the number of bytes a variable with the given types occupies in memory. + + Returns ``0`` if the size can't be determined. + + If a type occupies ``N`` bytes + ``M`` bits in memory, this function returns + the rounded up amount of bytes (i.e., if ``M`` is ``0``, + this function returns ``N`` and otherwise ``N + 1``). + + Language-specific behaviour: + + * C: The output is expected to match the value of ``sizeof(Type)``. If + ``sizeof(Type)`` is not a valid expression for the given type, the + function returns ``0``. + * C++: Same as in C. + * Objective-C: Same as in C. For Objective-C classes this always returns + `0`` as the actual size depends on runtime information. + ") GetByteSize; uint64_t GetByteSize(); + + %feature("docstring", + "Returns true if this type is a pointer type. + + Language-specific behaviour: + + * C: Returns true for C pointer types (or typedefs of these types). + * C++: Pointer types include the C pointer types as well as pointers to data + mebers or member functions. + * Objective-C: Pointer types include the C pointer types. ``id``, ``Class`` + and pointers to blocks are also considered pointer types. + ") IsPointerType; bool IsPointerType(); + %feature("docstring", + "Returns true if this type is a reference type. + + Language-specific behaviour: + + * C: Returns false for all types. + * C++: Both l-value and r-value references are considered reference types. + * Objective-C: Returns false for all types. + ") IsReferenceType; bool IsReferenceType(); + %feature("docstring", + "Returns true if this type is a function type. + + Language-specific behaviour: + + * C: Returns true for types that represent functions. Note that function + pointers are not function types (but their `GetPointeeType()` are function + types). + * C++: Same as in C. + * Objective-C: Returns false for all types. + ") IsPolymorphicClass; bool IsFunctionType (); + %feature("docstring", + "Returns true if this type is a polymorphic type. + + Language-specific behaviour: + + * C: Returns false for all types. + * C++: Returns true if the type is a class type that contains at least one + virtual member function or if at least one of its base classes is + considered a polymorphic type. + * Objective-C: Returns false for all types. + ") IsPolymorphicClass; bool IsPolymorphicClass (); + %feature("docstring", + "Returns true if this type is an array type. + + Language-specific behaviour: + + * C: Returns true if the types is an array type. This includes incomplete + array types ``T[]`` and array types with integer (``T[1]``) or variable + length (``T[some_variable]``). Pointer types are not considered arrays. + * C++: Includes C's array types and dependent array types (i.e., array types + in templates which size depends on template arguments). + * Objective-C: Same as in C. + ") IsArrayType; bool IsArrayType (); + %feature("docstring", + "Returns true if this type is a vector type. + + Language-specific behaviour: + + * C: Returns true if the types is a vector type created with + GCC's ``vector_size`` or Clang's ``ext_vector_type`` feature. + * C++: Same as in C. + * Objective-C: Same as in C. + ") IsVectorType; bool IsVectorType (); + %feature("docstring", + "Returns true if this type is a typedef. + + Language-specific behaviour: + + * C: Returns true if the type is a C typedef. + * C++: Same as in C. Also treats type aliases as typedefs. + * Objective-C: Same as in C. + ") IsTypedefType; bool IsTypedefType (); + %feature("docstring", + "Returns true if this type is an anonymous type. + + Language-specific behaviour: + + * C: Returns true for anonymous unions. Also returns true for + anonymous structs (which are a GNU language extension). + * C++: Same as in C. + * Objective-C: Same as in C. + ") IsAnonymousType; bool IsAnonymousType (); + %feature("docstring", + "Returns true if this type is a scoped enum. + + Language-specific behaviour: + + * C: Returns false for all types. + * C++: Return true only for C++11 scoped enums. + * Objective-C: Returns false for all types. + ") IsScopedEnumerationType; bool IsScopedEnumerationType (); + %feature("docstring", + "Returns a type that represents a pointer to this type. + + If the type system of the current language can't represent a pointer to this + type or this type is invalid, an invalid `SBType` is returned. + + Language-specific behaviour: + + * C: Returns the pointer type of this type. + * C++: Same as in C. + * Objective-C: Same as in C. + ") GetPointerType; lldb::SBType GetPointerType(); + %feature("docstring", + "Returns the underlying pointee type. + + If this type is a pointer type as specified by `IsPointerType` then this + returns the underlying type. If this is not a pointer type or an invalid + `SBType` then this returns an invalid `SBType`. + + Language-specific behaviour: + + * C: Returns the underlying type for for C pointer types or typedefs of + these types). For example, ``int *`` will return ``int``. + * C++: Same as in C. Returns an `SBType` representation for data members/ + member functions in case the `SBType` is a pointer to data member or + pointer to member function. + * Objective-C: Same as in C. The pointee type of ``id`` and ``Class`` is + an invalid `SBType`. The pointee type of pointers Objective-C types is an + `SBType` for the non-pointer type of the respective type. For example, + ``NSString *`` will return ``NSString`` as a pointee type. + ") GetPointeeType; lldb::SBType GetPointeeType(); + %feature("docstring", + "Returns a type that represents a reference to this type. + + If the type system of the current language can't represent a reference to + this type, an invalid `SBType` is returned. + + Language-specific behaviour: + + * C: Currently assumes the type system is C++ and returns an l-value + reference type. For example, ``int`` will return ``int&``. This behavior + is likely to change in the future and shouldn't be relied on. + * C++: Same as in C. + * Objective-C: Same as in C. + ") GetReferenceType; lldb::SBType GetReferenceType(); + %feature("docstring", + "Returns the underlying type of a typedef. + + If this type is a typedef as designated by `IsTypedefType`, then the + underlying type is being returned. Otherwise an invalid `SBType` is + returned. + + Language-specific behaviour: + + * C: Returns the underlying type of a typedef type. + * C++: Same as in C. For type aliases, the underlying type is returned. + * Objective-C: Same as in C. + ") GetTypedefedType; lldb::SBType SBType::GetTypedefedType(); + %feature("docstring", + "Returns the underlying type of a reference type. + + If this type is a reference as designated by `IsReferenceType`, then the + underlying type is being returned. Otherwise an invalid `SBType` is + returned. + + Language-specific behaviour: + + * C: Always returns an invalid type. + * C++: For l-value and r-value references the underlying type is returned. + For example, ``int &`` will return ``int``. + * Objective-C: Same as in C. + ") GetDereferencedType; lldb::SBType GetDereferencedType(); + %feature("docstring", + "Returns the unqualified version of this type. + + Language-specific behaviour: + + * C: If this type with any const or volatile specifier removed. + * C++: Same as in C. + * Objective-C: Same as in C. + ") GetUnqualifiedType; lldb::SBType GetUnqualifiedType(); lldb::SBType GetCanonicalType(); + %feature("docstring", + "Returns the underlying integer type if this is an enumeration type. + + If this type is an invalid `SBType` or not an enumeration type an invalid + `SBType` is returned. + + Language-specific behaviour: + + * C: Returns the underlying type for enums. + * C++: Same as in C but also returns the underlying type for scoped enums. + * Objective-C: Same as in C. + ") GetEnumerationIntegerType; lldb::SBType GetEnumerationIntegerType(); + %feature("docstring", + "Returns the array element type if this type is an array type. + + Otherwise returns an invalid `SBType` if this type is invalid or not an + array type. + + Language-specific behaviour: + + * C: If this is an array type (see `IsArrayType`) such as ``T[]``, returns + the element type. + * C++: Same as in C. + * Objective-C: Same as in C. + + See also `IsArrayType`. + ") GetArrayElementType; lldb::SBType GetArrayElementType (); + %feature("docstring", + "Returns the array type with the given constant size. + + Language-specific behaviour: + + * C: Returns a constant-size array `T[size]` for any non-void type. + * C++: Same as in C. + * Objective-C: Same as in C. + + See also `IsArrayType` and `GetArrayElementType`. + ") GetArrayType; lldb::SBType GetArrayType (uint64_t size); + %feature("docstring", + "Returns the vector element type if this type is a vector type. + + Otherwise returns an invalid `SBType` if this type is invalid or not a + vector type. + + Language-specific behaviour: + + * C: If this is a vector type (see `IsVectorType`), returns the element + type. + * C++: Same as in C. + * Objective-C: Same as in C. + + See also `IsVectorType`. + ") GetVectorElementType; lldb::SBType GetVectorElementType (); + %feature("docstring", + "Returns the `BasicType` value that is most appropriate to this type. + + Returns `eBasicTypeInvalid` if no appropriate `BasicType` was found or this + type is invalid. See the `BasicType` documentation for the language-specific m + aning of each `BasicType` value. + + **Overload behaviour:** When called with a `BasicType` parameter, the + following behaviour applies: + + Returns the `SBType` that represents the passed `BasicType` value. Returns + an invalid `SBType` if no fitting `SBType` could be created. + + Language-specific behaviour: + + * C: Returns the respective builtin type. Note that some types + (e.g. ``__uint128_t``) might even be successfully created even if they are + not available on the target platform. C++ and Objective-C specific types + might also be created even if the target program is not written in C++ or + Objective-C. + * C++: Same as in C. + * Objective-C: Same as in C. + "); lldb::BasicType GetBasicType(); lldb::SBType GetBasicType (lldb::BasicType type); + %feature("docstring", + "Returns the number of fields of this type. + + Returns ``0`` if this type does not have fields. + + Language-specific behaviour: + + * C: Returns the number of fields if the type is a struct. If the type + contains an anonymous struct/union it only counts as a single field (even + if the struct/union contains several fields). + * C++: Returns the number of non-static fields if the type is a + struct/class. If the type contains an anonymous struct/union it only + counts as a single field (even if the struct/union contains several + fields). The fields of any base classes are not included in the count. + * Objective-C: Same as in C for structs. For Objective-C classes the number + of ivars is returned. + + See also `GetFieldAtIndex`. + ") GetNumberOfFields; uint32_t GetNumberOfFields (); + %feature("docstring", + "Returns the number of base/parent classes of this type. + + Returns ``0`` if this type doesn't have any base classes. + + Language-specific behaviour: + + * C: Returns always ``0``. + * C++: The number of direct non-virtual base classes if this type is + a class. + * Objective-C: The number of super classes for Objective-C classes. + As Objective-C doesn't have multiple inheritance this is usually returns 1 + except for NSObject. + ") GetNumberOfDirectBaseClasses; uint32_t GetNumberOfDirectBaseClasses (); + %feature("docstring", + "Returns the number of virtual base/parent classes of this type + + Returns ``0`` if this type doesn't have any base classes. + + Language-specific behaviour: + + * C: Returns always ``0``. + * C++: The number of direct virtual base classes if this type is a + class. + * Objective-C: Returns always ``0``. + ") GetNumberOfVirtualBaseClasses; uint32_t GetNumberOfVirtualBaseClasses (); + %feature("docstring", + "Returns the field at the given index. + + Returns an invalid `SBType` if the index is out of range or the current + type doesn't have any fields. + + Language-specific behaviour: + + * C: Returns the field with the given index for struct types. Fields are + ordered/indexed starting from ``0`` for the first field in a struct (as + declared in the definition). + * C++: Returns the non-static field with the given index for struct types. + Fields are ordered/indexed starting from ``0`` for the first field in a + struct (as declared in the definition). + * Objective-C: Same as in C for structs. For Objective-C classes the ivar + with the given index is returned. ivars are indexed starting from ``0``. + ") GetFieldAtIndex; lldb::SBTypeMember GetFieldAtIndex (uint32_t idx); + %feature("docstring", + "Returns the direct base class as indexed by `GetNumberOfDirectBaseClasses`. + + Returns an invalid SBTypeMember if the index is invalid or this SBType is + invalid. + ") GetDirectBaseClassAtIndex; lldb::SBTypeMember GetDirectBaseClassAtIndex (uint32_t idx); + %feature("docstring", + "Returns the virtual base class as indexed by + `GetNumberOfVirtualBaseClasses`. + + Returns an invalid SBTypeMember if the index is invalid or this SBType is + invalid. + ") GetVirtualBaseClassAtIndex; lldb::SBTypeMember GetVirtualBaseClassAtIndex (uint32_t idx); lldb::SBTypeEnumMemberList GetEnumMembers(); + %feature("docstring", + "Returns the `SBModule` this `SBType` belongs to. + Returns no `SBModule` if this type does not belong to any specific + `SBModule` or this `SBType` is invalid. An invalid `SBModule` might also + indicate that once came from an `SBModule` but LLDB could no longer + determine the original module. + ") GetModule; lldb::SBModule GetModule(); + %feature("autodoc", "GetName() -> string") GetName; + %feature("docstring", + "Returns the name of this type. + + Returns an empty string if an error occurred or this type is invalid. + + Use this function when trying to match a specific type by name in a script. + The names returned by this function try to uniquely identify a name but + conflicts can occur (for example, if a C++ program contains two different + classes with the same name in different translation units. `GetName` can + return the same name for both class types.) + + + Language-specific behaviour: + + * C: The name of the type. For structs the ``struct`` prefix is omitted. + * C++: Returns the qualified name of the type (including anonymous/inline + namespaces and all template arguments). + * Objective-C: Same as in C. + ") GetName; const char* GetName(); + %feature("autodoc", "GetDisplayTypeName() -> string") GetDisplayTypeName; + %feature("docstring", + "Returns the name of this type in a user-friendly format. + + Returns an empty string if an error occurred or this type is invalid. + + Use this function when displaying a type name to the user. + + Language-specific behaviour: + + * C: Returns the type name. For structs the ``struct`` prefix is omitted. + * C++: Returns the qualified name. Anonymous/inline namespaces are omitted. + Template arguments that match their default value might also be hidden + (this functionality depends on whether LLDB can determine the template's + default arguments). + * Objective-C: Same as in C. + ") GetDisplayTypeName; const char * GetDisplayTypeName (); + %feature("autodoc", "GetTypeClass() -> TypeClass") GetTypeClass; + %feature("docstring", + "Returns the `TypeClass` for this type. + + Returns an `eTypeClassInvalid` if this `SBType` is invalid. + + See `TypeClass` for the language-specific meaning of each `TypeClass` value. + ") GetTypeClass; lldb::TypeClass GetTypeClass (); + %feature("docstring", + "Returns the number of template arguments of this type. + + Returns ``0`` if this type is not a template. + + Language-specific behaviour: + + * C: Always returns ``0``. + * C++: If this type is a class template instantiation then this returns the + number of template parameters that were used in this instantiation. This i + cludes both explicit and implicit template parameters. + * Objective-C: Always returns ``0``. + ") GetNumberOfTemplateArguments; uint32_t GetNumberOfTemplateArguments (); + %feature("docstring", + "Returns the type of the template argument with the given index. + + Returns an invalid `SBType` if there is no template argument with the given + index or this type is not a template. The first template argument has the + index ``0``. + + Language-specific behaviour: + + * C: Always returns an invalid SBType. + * C++: If this type is a class template instantiation and the template + parameter with the given index is a type template parameter, then this + returns the type of that parameter. Otherwise returns an invalid `SBType`. + * Objective-C: Always returns an invalid SBType. + ") GetTemplateArgumentType; lldb::SBType GetTemplateArgumentType (uint32_t idx); + %feature("docstring", + "Returns the kind of the template argument with the given index. + + Returns `eTemplateArgumentKindNull` if there is no template argument + with the given index or this type is not a template. The first template + argument has the index ``0``. + + Language-specific behaviour: + + * C: Always returns `eTemplateArgumentKindNull`. + * C++: If this type is a class template instantiation then this returns + the appropriate `TemplateArgument` value for the parameter with the given + index. See the documentation of `TemplateArgument` for how certain C++ + template parameter kinds are mapped to `TemplateArgument` values. + * Objective-C: Always returns `eTemplateArgumentKindNull`. + ") GetTemplateArgumentKind; lldb::TemplateArgumentKind GetTemplateArgumentKind (uint32_t idx); + %feature("docstring", + "Returns the return type if this type represents a function. + + Returns an invalid `SBType` if this type is not a function type or invalid. + + Language-specific behaviour: + + * C: For functions return the return type. Returns an invalid `SBType` if + this type is a function pointer type. + * C++: Same as in C for functions and instantiated template functions. + Member functions are also considered functions. For functions that have + their return type specified by a placeholder type specifier (``auto``) + this returns the deduced return type. + * Objective-C: Same as in C for functions. For Objective-C methods this + returns the return type of the method. + ") GetFunctionReturnType; lldb::SBType GetFunctionReturnType (); + %feature("docstring", + "Returns the list of argument types if this type represents a function. + + Returns an invalid `SBType` if this type is not a function type or invalid. + + Language-specific behaviour: + + * C: For functions return the types of each parameter. Returns an invalid + `SBType` if this type is a function pointer. For variadic functions this + just returns the list of parameters before the variadic arguments. + * C++: Same as in C for functions and instantiated template functions. + Member functions are also considered functions. + * Objective-C: Always returns an invalid SBType for Objective-C methods. + ") GetFunctionArgumentTypes; lldb::SBTypeList GetFunctionArgumentTypes (); + %feature("docstring", + "Returns the number of member functions of this type. + + Returns ``0`` if an error occurred or this type is invalid. + + Language-specific behaviour: + + * C: Always returns ``0``. + * C++: If this type represents a struct/class, then the number of + member functions (static and non-static) is returned. The count includes + constructors and destructors (both explicit and implicit). Member + functions of base classes are not included in the count. + * Objective-C: If this type represents a struct/class, then the + number of methods is returned. Methods in categories or super classes + are not counted. + ") GetNumberOfMemberFunctions; uint32_t GetNumberOfMemberFunctions (); + %feature("docstring", + "Returns the member function of this type with the given index. + + Returns an invalid `SBTypeMemberFunction` if the index is invalid or this + type is invalid. + + Language-specific behaviour: + + * C: Always returns an invalid `SBTypeMemberFunction`. + * C++: Returns the member function or constructor/destructor with the given + index. + * Objective-C: Returns the method with the given index. + + See `GetNumberOfMemberFunctions` for what functions can be queried by this + function. + ") GetMemberFunctionAtIndex; lldb::SBTypeMemberFunction GetMemberFunctionAtIndex (uint32_t idx); bool IsTypeComplete (); + %feature("docstring", + "Returns the `TypeFlags` values for this type. + + See the respective `TypeFlags` values for what values can be set. Returns an + integer in which each `TypeFlags` value is represented by a bit. Specific + flags can be checked via Python's bitwise operators. For example, the + `eTypeIsInteger` flag can be checked like this: + + ``(an_sb_type.GetTypeFlags() & lldb.eTypeIsInteger) != 0`` + + If this type is invalid this returns ``0``. + + See the different values for `TypeFlags` for the language-specific meanings + of each `TypeFlags` value. + ") GetTypeFlags; uint32_t GetTypeFlags (); diff --git a/contrib/llvm-project/lldb/bindings/interfaces.swig b/contrib/llvm-project/lldb/bindings/interfaces.swig index 2df7a05b4f48..c9a6d0f06056 100644 --- a/contrib/llvm-project/lldb/bindings/interfaces.swig +++ b/contrib/llvm-project/lldb/bindings/interfaces.swig @@ -69,7 +69,6 @@ %include "./interface/SBThreadCollection.i" %include "./interface/SBThreadPlan.i" %include "./interface/SBTrace.i" -%include "./interface/SBTraceOptions.i" %include "./interface/SBType.i" %include "./interface/SBTypeCategory.i" %include "./interface/SBTypeEnumMember.i" diff --git a/contrib/llvm-project/lldb/bindings/lua/lua-swigsafecast.swig b/contrib/llvm-project/lldb/bindings/lua/lua-swigsafecast.swig index a3ed37279546..0b67c41434e9 100644 --- a/contrib/llvm-project/lldb/bindings/lua/lua-swigsafecast.swig +++ b/contrib/llvm-project/lldb/bindings/lua/lua-swigsafecast.swig @@ -15,6 +15,12 @@ PushSBClass (lua_State* L, lldb::SBBreakpointLocation* breakpoint_location_sb) } void +PushSBClass (lua_State* L, lldb::SBWatchpoint* watchpoint_sb) +{ + SWIG_NewPointerObj(L, watchpoint_sb, SWIGTYPE_p_lldb__SBWatchpoint, 0); +} + +void PushSBClass (lua_State* L, lldb::SBStructuredData* structured_data_sb) { SWIG_NewPointerObj(L, structured_data_sb, SWIGTYPE_p_lldb__SBStructuredData, 0); diff --git a/contrib/llvm-project/lldb/bindings/lua/lua-wrapper.swig b/contrib/llvm-project/lldb/bindings/lua/lua-wrapper.swig index 90c22920ddc1..e070bae23683 100644 --- a/contrib/llvm-project/lldb/bindings/lua/lua-wrapper.swig +++ b/contrib/llvm-project/lldb/bindings/lua/lua-wrapper.swig @@ -53,5 +53,40 @@ LLDBSwigLuaBreakpointCallbackFunction return stop; } +// This function is called from Lua::CallWatchpointCallback +SWIGEXPORT llvm::Expected<bool> +LLDBSwigLuaWatchpointCallbackFunction +( + lua_State *L, + lldb::StackFrameSP stop_frame_sp, + lldb::WatchpointSP wp_sp +) +{ + lldb::SBFrame sb_frame(stop_frame_sp); + lldb::SBWatchpoint sb_wp(wp_sp); + int nargs = 2; + + // Push the Lua wrappers + PushSBClass(L, &sb_frame); + PushSBClass(L, &sb_wp); + + // Call into the Lua callback passing 'sb_frame' and 'sb_wp'. + // Expects a boolean return. + if (lua_pcall(L, nargs, 1, 0) != LUA_OK) { + llvm::Error E = llvm::make_error<llvm::StringError>( + llvm::formatv("{0}\n", lua_tostring(L, -1)), + llvm::inconvertibleErrorCode()); + // Pop error message from the stack. + lua_pop(L, 1); + return std::move(E); + } + + // Boolean return from the callback + bool stop = lua_toboolean(L, -1); + lua_pop(L, 1); + + return stop; +} + %} diff --git a/contrib/llvm-project/lldb/bindings/python/python-wrapper.swig b/contrib/llvm-project/lldb/bindings/python/python-wrapper.swig index 443ddfb8dd20..4c39e9c2c776 100644 --- a/contrib/llvm-project/lldb/bindings/python/python-wrapper.swig +++ b/contrib/llvm-project/lldb/bindings/python/python-wrapper.swig @@ -39,6 +39,17 @@ private: // This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) // and is used when a script command is attached to a breakpoint for execution. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" + +// Disable warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has +// C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is +// incompatible with C +#if _MSC_VER +#pragma warning (push) +#pragma warning (disable : 4190) +#endif + SWIGEXPORT llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction ( @@ -85,6 +96,12 @@ LLDBSwigPythonBreakpointCallbackFunction return result.get().get() != Py_False; } +#if _MSC_VER +#pragma warning (pop) +#endif + +#pragma clang diagnostic pop + // This function is called by lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...) // and is used when a script command is attached to a watchpoint for execution. @@ -259,6 +276,72 @@ LLDBSwigPythonCreateCommandObject } SWIGEXPORT void* +LLDBSwigPythonCreateScriptedProcess +( + const char *python_class_name, + const char *session_dictionary_name, + const lldb::TargetSP& target_sp, + lldb_private::StructuredDataImpl *args_impl, + std::string &error_string +) +{ + if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) + Py_RETURN_NONE; + + + PyErr_Cleaner py_err_cleaner(true); + + auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name); + auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict); + + if (!pfunc.IsAllocated()) { + error_string.append("could not find script class: "); + error_string.append(python_class_name); + return nullptr; + } + + // I do not want the SBTarget to be deallocated when going out of scope + // because python has ownership of it and will manage memory for this + // object by itself + PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBTarget(target_sp))); + + if (!target_arg.IsAllocated()) + Py_RETURN_NONE; + + llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo(); + if (!arg_info) { + llvm::handleAllErrors( + arg_info.takeError(), + [&](PythonException &E) { + error_string.append(E.ReadBacktrace()); + }, + [&](const llvm::ErrorInfoBase &E) { + error_string.append(E.message()); + }); + Py_RETURN_NONE; + } + + PythonObject result = {}; + if (arg_info.get().max_positional_args == 2) { + if (args_impl != nullptr) { + error_string.assign("args passed, but __init__ does not take an args dictionary"); + Py_RETURN_NONE; + } + result = pfunc(target_arg, dict); + } else if (arg_info.get().max_positional_args >= 3) { + PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBStructuredData(args_impl))); + result = pfunc(target_arg, args_arg, dict); + } else { + error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)"); + Py_RETURN_NONE; + } + + if (result.IsAllocated()) + return result.release(); + Py_RETURN_NONE; +} + +SWIGEXPORT void* LLDBSwigPythonCreateScriptedThreadPlan ( const char *python_class_name, @@ -786,6 +869,40 @@ LLDBSwigPython_GetValueSynthProviderInstance } SWIGEXPORT void* +LLDBSWIGPython_CastPyObjectToSBData +( + PyObject* data +) +{ + lldb::SBData* sb_ptr = nullptr; + + int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBData, 0); + + if (valid_cast == -1) + return NULL; + + return sb_ptr; +} + + +SWIGEXPORT void* +LLDBSWIGPython_CastPyObjectToSBError +( + PyObject* data +) +{ + lldb::SBError* sb_ptr = nullptr; + + int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBError, 0); + + if (valid_cast == -1) + return NULL; + + return sb_ptr; +} + + +SWIGEXPORT void* LLDBSWIGPython_CastPyObjectToSBValue ( PyObject* data |