diff options
Diffstat (limited to 'scripts/interface')
-rw-r--r-- | scripts/interface/SBCommandReturnObject.i | 16 | ||||
-rw-r--r-- | scripts/interface/SBDebugger.i | 10 | ||||
-rw-r--r-- | scripts/interface/SBExpressionOptions.i | 14 | ||||
-rw-r--r-- | scripts/interface/SBFileSpec.i | 5 | ||||
-rw-r--r-- | scripts/interface/SBHostOS.i | 3 | ||||
-rw-r--r-- | scripts/interface/SBMemoryRegionInfo.i | 58 | ||||
-rw-r--r-- | scripts/interface/SBMemoryRegionInfoList.i | 38 | ||||
-rw-r--r-- | scripts/interface/SBProcess.i | 14 | ||||
-rw-r--r-- | scripts/interface/SBTarget.i | 54 | ||||
-rw-r--r-- | scripts/interface/SBThread.i | 28 | ||||
-rw-r--r-- | scripts/interface/SBValue.i | 23 |
11 files changed, 251 insertions, 12 deletions
diff --git a/scripts/interface/SBCommandReturnObject.i b/scripts/interface/SBCommandReturnObject.i index 5ade97bebfec..ae32b79b5834 100644 --- a/scripts/interface/SBCommandReturnObject.i +++ b/scripts/interface/SBCommandReturnObject.i @@ -84,11 +84,17 @@ public: bool GetDescription (lldb::SBStream &description); - void - SetImmediateOutputFile (FILE *fh); - - void - SetImmediateErrorFile (FILE *fh); + + // wrapping here so that lldb takes ownership of the + // new FILE* created inside of the swig interface + %extend { + void SetImmediateOutputFile(FILE *fh) { + self->SetImmediateOutputFile(fh, true); + } + void SetImmediateErrorFile(FILE *fh) { + self->SetImmediateErrorFile(fh, true); + } + } void PutCString(const char* string, int len); diff --git a/scripts/interface/SBDebugger.i b/scripts/interface/SBDebugger.i index 89b2882aeb91..db774d350e9c 100644 --- a/scripts/interface/SBDebugger.i +++ b/scripts/interface/SBDebugger.i @@ -105,6 +105,16 @@ if target: else: print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state)) process.Kill() + +Sometimes you need to create an empty target that will get filled in later. The most common use for this +is to attach to a process by name or pid where you don't know the executable up front. The most convenient way +to do this is: + +target = debugger.CreateTarget('') +error = lldb.SBError() +process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error) + +or the equivalent arguments for AttachToProcessWithID. ") SBDebugger; class SBDebugger { diff --git a/scripts/interface/SBExpressionOptions.i b/scripts/interface/SBExpressionOptions.i index 1f423cf47e42..cb61dd9d9632 100644 --- a/scripts/interface/SBExpressionOptions.i +++ b/scripts/interface/SBExpressionOptions.i @@ -118,6 +118,20 @@ public: %feature("docstring", "Sets the prefix to use for this expression. This prefix gets inserted after the 'target.expr-prefix' prefix contents, but before the wrapped expression function body.") SetPrefix; void SetPrefix (const char *prefix); + + %feature("docstring", "Sets whether to auto-apply fix-it hints to the expression being evaluated.") SetAutoApplyFixIts; + void + SetAutoApplyFixIts(bool b = true); + + %feature("docstring", "Gets whether to auto-apply fix-it hints to an expression.") GetAutoApplyFixIts; + bool + GetAutoApplyFixIts(); + + bool + GetTopLevel(); + + void + SetTopLevel(bool b = true); protected: diff --git a/scripts/interface/SBFileSpec.i b/scripts/interface/SBFileSpec.i index c153f2bd86f6..a0e5da21187d 100644 --- a/scripts/interface/SBFileSpec.i +++ b/scripts/interface/SBFileSpec.i @@ -72,7 +72,10 @@ public: bool GetDescription (lldb::SBStream &description) const; - + + void + AppendPathComponent (const char *file_or_directory); + %pythoncode %{ def __get_fullpath__(self): spec_dir = self.GetDirectory() diff --git a/scripts/interface/SBHostOS.i b/scripts/interface/SBHostOS.i index d9f42160bf09..ed2e8b0477b1 100644 --- a/scripts/interface/SBHostOS.i +++ b/scripts/interface/SBHostOS.i @@ -22,6 +22,9 @@ public: static lldb::SBFileSpec GetLLDBPath (lldb::PathType path_type); + static lldb::SBFileSpec + GetUserHomeDirectory (); + static void ThreadCreated (const char *name); diff --git a/scripts/interface/SBMemoryRegionInfo.i b/scripts/interface/SBMemoryRegionInfo.i new file mode 100644 index 000000000000..d68770802618 --- /dev/null +++ b/scripts/interface/SBMemoryRegionInfo.i @@ -0,0 +1,58 @@ +//===-- SWIG Interface for SBMemoryRegionInfo -------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"API clients can get information about memory regions in processes." +) SBMemoryRegionInfo; + +class SBMemoryRegionInfo +{ +public: + + SBMemoryRegionInfo (); + + SBMemoryRegionInfo (const lldb::SBMemoryRegionInfo &rhs); + + ~SBMemoryRegionInfo (); + + void + Clear(); + + lldb::addr_t + GetRegionBase (); + + lldb::addr_t + GetRegionEnd (); + + bool + IsReadable (); + + bool + IsWritable (); + + bool + IsExecutable (); + + bool + IsMapped (); + + bool + operator == (const lldb::SBMemoryRegionInfo &rhs) const; + + bool + operator != (const lldb::SBMemoryRegionInfo &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + +}; + +} // namespace lldb diff --git a/scripts/interface/SBMemoryRegionInfoList.i b/scripts/interface/SBMemoryRegionInfoList.i new file mode 100644 index 000000000000..f46241145540 --- /dev/null +++ b/scripts/interface/SBMemoryRegionInfoList.i @@ -0,0 +1,38 @@ +//===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBMemoryRegionInfoList +{ +public: + + SBMemoryRegionInfoList (); + + SBMemoryRegionInfoList (const lldb::SBMemoryRegionInfoList &rhs); + + ~SBMemoryRegionInfoList (); + + uint32_t + GetSize () const; + + bool + GetMemoryRegionAtIndex (uint32_t idx, SBMemoryRegionInfo ®ion_info); + + void + Append (lldb::SBMemoryRegionInfo ®ion); + + void + Append (lldb::SBMemoryRegionInfoList ®ion_list); + + void + Clear (); +}; + +} // namespace lldb diff --git a/scripts/interface/SBProcess.i b/scripts/interface/SBProcess.i index 1571ebc4cb68..d9de9d087685 100644 --- a/scripts/interface/SBProcess.i +++ b/scripts/interface/SBProcess.i @@ -296,7 +296,7 @@ public: ") ReadCStringFromMemory; size_t - ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + ReadCStringFromMemory (addr_t addr, void *char_buf, size_t size, lldb::SBError &error); %feature("autodoc", " Reads an unsigned integer from memory given a byte size and an address. @@ -401,6 +401,12 @@ public: lldb::SBError SaveCore(const char *file_name); + lldb::SBError + GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info); + + lldb::SBMemoryRegionInfoList + GetMemoryRegions(); + %pythoncode %{ def __get_is_alive__(self): '''Returns "True" if the process is currently alive, "False" otherwise''' @@ -422,7 +428,7 @@ public: return True return False - def __get_is_running__(self): + def __get_is_stopped__(self): '''Returns "True" if the process is currently stopped, "False" otherwise''' state = self.GetState() if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: @@ -468,8 +474,8 @@ public: __swig_getmethods__["is_running"] = __get_is_running__ if _newclass: is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') - __swig_getmethods__["is_stopped"] = __get_is_running__ - if _newclass: is_stopped = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') + __swig_getmethods__["is_stopped"] = __get_is_stopped__ + if _newclass: is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') __swig_getmethods__["id"] = GetProcessID if _newclass: id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') diff --git a/scripts/interface/SBTarget.i b/scripts/interface/SBTarget.i index 74e470d4b3fa..6198c35fbd7b 100644 --- a/scripts/interface/SBTarget.i +++ b/scripts/interface/SBTarget.i @@ -586,6 +586,9 @@ public: BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); lldb::SBBreakpoint + BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset); + + lldb::SBBreakpoint BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); lldb::SBBreakpoint @@ -601,18 +604,59 @@ public: const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); +%typemap(in) (const char **symbol_name, uint32_t num_names) { + using namespace lldb_private; + /* Check if is a list */ + if (PythonList::Check($input)) { + PythonList list(PyRefType::Borrowed, $input); + $2 = list.GetSize(); + int i = 0; + $1 = (char**)malloc(($2+1)*sizeof(char*)); + for (i = 0; i < $2; i++) { + PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>(); + if (!py_str.IsAllocated()) { + PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby"); + free($1); + return nullptr; + } + + $1[i] = const_cast<char*>(py_str.GetString().data()); + } + $1[i] = 0; + } else if ($input == Py_None) { + $1 = NULL; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + +//%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (const char *symbol_name[], uint32_t num_names) { +// $1 = 1; +// $2 = 1; +//} + + lldb::SBBreakpoint + BreakpointCreateByNames (const char **symbol_name, + uint32_t num_names, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + lldb::SBBreakpoint - BreakpointCreateByNames (const char *symbol_name[], + BreakpointCreateByNames (const char **symbol_name, uint32_t num_names, uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + lldb::LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateByNames (const char *symbol_name[], + BreakpointCreateByNames (const char **symbol_name, uint32_t num_names, uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits lldb::LanguageType symbol_language, + lldb::addr_t offset, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); @@ -632,6 +676,12 @@ public: BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list); lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, + const SBFileSpecList &module_list, + const SBFileSpecList &source_file, + const SBStringList &func_names); + + lldb::SBBreakpoint BreakpointCreateForException (lldb::LanguageType language, bool catch_bp, bool throw_bp); diff --git a/scripts/interface/SBThread.i b/scripts/interface/SBThread.i index f2b27565d489..082805f42fd0 100644 --- a/scripts/interface/SBThread.i +++ b/scripts/interface/SBThread.i @@ -118,6 +118,15 @@ public: ") GetStopReasonExtendedInfoAsJSON; bool GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream); + + %feature("autodoc", " + Returns a collection of historical stack traces that are significant to the + current stop reason. Used by ThreadSanitizer, where we provide various stack + traces that were involved in a data race or other type of detected issue. + ") GetStopReasonExtendedBacktraces; + SBThreadCollection + GetStopReasonExtendedBacktraces (InstrumentationRuntimeType type); + %feature("autodoc", " Pass only an (int)length and expect to get a Python string describing the @@ -206,6 +215,17 @@ public: void StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + %feature("autodoc", " + Step the current thread from the current source line to the line given by end_line, stopping if + the thread steps into the function given by target_name. If target_name is None, then stepping will stop + in any of the places we would normally stop. + ") StepInto; + void + StepInto (const char *target_name, + uint32_t end_line, + SBError &error, + lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepOut (); @@ -239,6 +259,14 @@ public: SBError ReturnFromFrame (SBFrame &frame, SBValue &return_value); + %feature("autodoc", " + Unwind the stack frames from the innermost expression evaluation. + This API is equivalent to 'thread return -x'. + ") UnwindInnermostExpression; + + SBError + UnwindInnermostExpression(); + %feature("docstring", " //-------------------------------------------------------------------------- /// LLDB currently supports process centric debugging which means when any diff --git a/scripts/interface/SBValue.i b/scripts/interface/SBValue.i index 5049fd05794d..ef9fe3c74851 100644 --- a/scripts/interface/SBValue.i +++ b/scripts/interface/SBValue.i @@ -157,6 +157,12 @@ public: bool IsSynthetic (); + + bool + IsSyntheticChildrenGenerated (); + + void + SetSyntheticChildrenGenerated (bool); const char * GetLocation (); @@ -533,6 +539,23 @@ public: __swig_getmethods__["path"] = get_expr_path if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''') + + def synthetic_child_from_expression(self, name, expr, options=None): + if options is None: options = lldb.SBExpressionOptions() + child = self.CreateValueFromExpression(name, expr, options) + child.SetSyntheticChildrenGenerated(True) + return child + + def synthetic_child_from_data(self, name, data, type): + child = self.CreateValueFromData(name, data, type) + child.SetSyntheticChildrenGenerated(True) + return child + + def synthetic_child_from_address(self, name, addr, type): + child = self.CreateValueFromAddress(name, addr, type) + child.SetSyntheticChildrenGenerated(True) + return child + %} }; |