diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/CMakeLists.txt | 4 | ||||
-rw-r--r-- | scripts/Python/python-extensions.swig | 15 | ||||
-rw-r--r-- | scripts/Python/python-swigsafecast.swig | 7 | ||||
-rwxr-xr-x | scripts/Xcode/build-llvm.py | 33 | ||||
-rw-r--r-- | scripts/Xcode/lldbbuild.py | 9 | ||||
-rwxr-xr-x | scripts/build-lldb-llvm-clang | 4 | ||||
-rwxr-xr-x | scripts/framework-header-fix.sh | 13 | ||||
-rw-r--r-- | scripts/interface/SBBreakpoint.i | 43 | ||||
-rw-r--r-- | scripts/interface/SBBreakpointLocation.i | 11 | ||||
-rw-r--r-- | scripts/interface/SBBreakpointName.i | 111 | ||||
-rw-r--r-- | scripts/interface/SBCommandInterpreter.i | 14 | ||||
-rw-r--r-- | scripts/interface/SBDebugger.i | 33 | ||||
-rw-r--r-- | scripts/interface/SBProcess.i | 12 | ||||
-rw-r--r-- | scripts/interface/SBProcessInfo.i | 66 | ||||
-rw-r--r-- | scripts/interface/SBTarget.i | 4 | ||||
-rw-r--r-- | scripts/interface/SBValue.i | 8 | ||||
-rw-r--r-- | scripts/lldb.swig | 4 |
17 files changed, 362 insertions, 29 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index fad841b37c09d..1fe34115244b7 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -48,10 +48,10 @@ add_custom_command( --swigExecutable=${SWIG_EXECUTABLE} VERBATIM COMMENT "Python script building LLDB Python wrapper") -set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) +add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON}) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1) -add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON}) # Install the LLDB python module install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR}) diff --git a/scripts/Python/python-extensions.swig b/scripts/Python/python-extensions.swig index 693b06b9aab39..d79917b921589 100644 --- a/scripts/Python/python-extensions.swig +++ b/scripts/Python/python-extensions.swig @@ -71,6 +71,21 @@ } } +%extend lldb::SBBreakpointName { + PyObject *lldb::SBBreakpointName::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release(); + else + return lldb_private::PythonString("").release(); + } +} + %extend lldb::SBBroadcaster { %pythoncode %{ def __eq__(self, rhs): diff --git a/scripts/Python/python-swigsafecast.swig b/scripts/Python/python-swigsafecast.swig index ea3f21f859ad2..ffd7546323a00 100644 --- a/scripts/Python/python-swigsafecast.swig +++ b/scripts/Python/python-swigsafecast.swig @@ -115,6 +115,13 @@ SBTypeToSWIGWrapper (lldb::SBBreakpointLocation* breakpoint_location_sb) template <> PyObject* +SBTypeToSWIGWrapper (lldb::SBBreakpointName* breakpoint_name_sb) +{ + return SWIG_NewPointerObj((void *) breakpoint_name_sb, SWIGTYPE_p_lldb__SBBreakpointName, 0); +} + +template <> +PyObject* SBTypeToSWIGWrapper (lldb::SBValue* value_sb) { return SWIG_NewPointerObj((void *) value_sb, SWIGTYPE_p_lldb__SBValue, 0); diff --git a/scripts/Xcode/build-llvm.py b/scripts/Xcode/build-llvm.py index e2a46de1a16ce..4d868de6b1099 100755 --- a/scripts/Xcode/build-llvm.py +++ b/scripts/Xcode/build-llvm.py @@ -14,7 +14,6 @@ from lldbbuild import * #### SETTINGS #### - def LLVM_HASH_INCLUDES_DIFFS(): return False @@ -42,7 +41,25 @@ def process_repo(r): 'ref': r["ref"] } +def fallback_repo(name): + return { + 'name': name, + 'vcs': None, + 'root': process_root(name), + 'url': None, + 'ref': None + } + +def dirs_exist(names): + for name in names: + if not os.path.isdir(process_root(name)): + return False + return True + def XCODE_REPOSITORIES(): + names = ["llvm", "clang", "ninja"] + if dirs_exist(names): + return [fallback_repo(n) for n in names] override = repo.get_override() if override: return [process_repo(r) for r in override] @@ -207,7 +224,7 @@ def apply_patches(spec): f, spec['name'] + '.*.diff')] for p in patches: run_in_directory(["patch", - "-p0", + "-p1", "-i", os.path.join(lldb_source_path(), 'scripts', @@ -233,6 +250,8 @@ def should_build_llvm(): def do_symlink(source_path, link_path): print "Symlinking " + source_path + " to " + link_path + if os.path.islink(link_path): + os.remove(link_path) if not os.path.exists(link_path): os.symlink(source_path, link_path) @@ -433,8 +452,8 @@ def build_llvm_if_needed(): #### MAIN LOGIC #### -all_check_out_if_needed() -build_llvm_if_needed() -write_archives_txt() - -sys.exit(0) +if __name__ == "__main__": + all_check_out_if_needed() + build_llvm_if_needed() + write_archives_txt() + sys.exit(0) diff --git a/scripts/Xcode/lldbbuild.py b/scripts/Xcode/lldbbuild.py index 8496cfabf3daf..e70fe1bf803ff 100644 --- a/scripts/Xcode/lldbbuild.py +++ b/scripts/Xcode/lldbbuild.py @@ -1,5 +1,6 @@ import os import subprocess +import sys #### UTILITIES #### @@ -14,7 +15,11 @@ def enum(*sequential, **named): def lldb_source_path(): - return os.environ.get('SRCROOT') + path = os.environ.get('SRCROOT') + if path: + return path + else: + return "./" def expected_llvm_build_path(): @@ -80,7 +85,7 @@ VCS = enum('git', def run_in_directory(args, path): - return subprocess.check_output(args, cwd=path) + return subprocess.check_output([str(arg) for arg in args], cwd=path) class Git: diff --git a/scripts/build-lldb-llvm-clang b/scripts/build-lldb-llvm-clang index 822e9944bf6a5..c71188ddd0066 100755 --- a/scripts/build-lldb-llvm-clang +++ b/scripts/build-lldb-llvm-clang @@ -33,7 +33,7 @@ cd .. for patch_file in ../scripts/llvm.*.diff do echo "Applying patch from '$patch_file'" - patch -p0 < "$patch_file" + patch -p1 < "$patch_file" done # change directory to "./llvm/tools/clang" @@ -41,7 +41,7 @@ cd tools/clang for patch_file in ../../../scripts/clang.*.diff do echo "Applying patch from '$patch_file'" - patch -p0 < "$patch_file" + patch -p1 < "$patch_file" done # change directory to "./" diff --git a/scripts/framework-header-fix.sh b/scripts/framework-header-fix.sh new file mode 100755 index 0000000000000..c09d1458ff827 --- /dev/null +++ b/scripts/framework-header-fix.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Usage: framework-header-fix.sh <source header dir> <LLDB Version> +for file in `find $1 -name "*.h"` +do + sed -i '' 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 <LLDB\/\3>/1' "$file" + sed -i '' 's|<LLDB/Utility|<LLDB|' "$file" + LLDB_VERSION=`echo $2 | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$/\\1/g'` + LLDB_REVISION=`echo $2 | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$/\\3/g'` + LLDB_VERSION_STRING=`echo $2` + sed -i '' "s|//#define LLDB_VERSION$|#define LLDB_VERSION $LLDB_VERSION |" "$file" + sed -i '' "s|//#define LLDB_REVISION|#define LLDB_REVISION $LLDB_REVISION |" "$file" + sed -i '' "s|//#define LLDB_VERSION_STRING|#define LLDB_VERSION_STRING \"$LLDB_VERSION_STRING\" |" "$file" +done diff --git a/scripts/interface/SBBreakpoint.i b/scripts/interface/SBBreakpoint.i index 95bc0cda00517..525797ad91f10 100644 --- a/scripts/interface/SBBreakpoint.i +++ b/scripts/interface/SBBreakpoint.i @@ -6,7 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - namespace lldb { %feature("docstring", @@ -81,11 +80,6 @@ class SBBreakpoint { public: - typedef bool (*BreakpointHitCallback) (void *baton, - SBProcess &process, - SBThread &thread, - lldb::SBBreakpointLocation &location); - SBBreakpoint (); SBBreakpoint (const lldb::SBBreakpoint& rhs); @@ -153,6 +147,10 @@ public: const char * GetCondition (); + void SetAutoContinue(bool auto_continue); + + bool GetAutoContinue(); + void SetThreadID (lldb::tid_t sb_thread_id); @@ -251,6 +249,39 @@ public: %pythoncode %{ + class locations_access(object): + '''A helper object that will lazily hand out locations for a breakpoint when supplied an index.''' + def __init__(self, sbbreakpoint): + self.sbbreakpoint = sbbreakpoint + + def __len__(self): + if self.sbbreakpoint: + return int(self.sbbreakpoint.GetNumLocations()) + return 0 + + def __getitem__(self, key): + if type(key) is int and key < len(self): + return self.sbbreakpoint.GetLocationAtIndex(key) + return None + + def get_locations_access_object(self): + '''An accessor function that returns a locations_access() object which allows lazy location access from a lldb.SBBreakpoint object.''' + return self.locations_access (self) + + def get_breakpoint_location_list(self): + '''An accessor function that returns a list() that contains all locations in a lldb.SBBreakpoint object.''' + locations = [] + accessor = self.get_locations_access_object() + for idx in range(len(accessor)): + locations.append(accessor[idx]) + return locations + + __swig_getmethods__["locations"] = get_breakpoint_location_list + if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') + + __swig_getmethods__["location"] = get_locations_access_object + if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') + __swig_getmethods__["id"] = GetID if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') diff --git a/scripts/interface/SBBreakpointLocation.i b/scripts/interface/SBBreakpointLocation.i index a3073538e6766..7a9a15db8ffaa 100644 --- a/scripts/interface/SBBreakpointLocation.i +++ b/scripts/interface/SBBreakpointLocation.i @@ -48,6 +48,9 @@ public: IsEnabled (); uint32_t + GetHitCount (); + + uint32_t GetIgnoreCount (); void @@ -70,6 +73,10 @@ public: const char * GetCondition (); + bool GetAutoContinue(); + + void SetAutoContinue(bool auto_continue); + %feature("docstring", " //------------------------------------------------------------------ /// Set the callback to the given Python function name. @@ -93,6 +100,10 @@ public: SBError SetScriptCallbackBody (const char *script_body_text); + void SetCommandLineCommands(SBStringList &commands); + + bool GetCommandLineCommands(SBStringList &commands); + void SetThreadID (lldb::tid_t sb_thread_id); diff --git a/scripts/interface/SBBreakpointName.i b/scripts/interface/SBBreakpointName.i new file mode 100644 index 0000000000000..dbc078b94adf8 --- /dev/null +++ b/scripts/interface/SBBreakpointName.i @@ -0,0 +1,111 @@ +//===-- SWIG interface for SBBreakpointName.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 { +%feature("docstring", +"Represents a breakpoint name registered in a given SBTarget. + +Breakpoint names provide a way to act on groups of breakpoints. When you add a +name to a group of breakpoints, you can then use the name in all the command +line lldb commands for that name. You can also configure the SBBreakpointName +options and those options will be propagated to any SBBreakpoints currently +using that name. Adding a name to a breakpoint will also apply any of the +set options to that breakpoint. + +You can also set permissions on a breakpoint name to disable listing, deleting +and disabling breakpoints. That will disallow the given operation for breakpoints +except when the breakpoint is mentioned by ID. So for instance deleting all the +breakpoints won't delete breakpoints so marked." +) SBBreakpointName; +class LLDB_API SBBreakpointName { +public: + SBBreakpointName(); + + SBBreakpointName(SBTarget &target, const char *name); + + SBBreakpointName(SBBreakpoint &bkpt, const char *name); + + SBBreakpointName(const lldb::SBBreakpointName &rhs); + + ~SBBreakpointName(); + + const lldb::SBBreakpointName &operator=(const lldb::SBBreakpointName &rhs); + + // Tests to see if the opaque breakpoint object in this object matches the + // opaque breakpoint object in "rhs". + bool operator==(const lldb::SBBreakpointName &rhs); + + bool operator!=(const lldb::SBBreakpointName &rhs); + + bool IsValid() const; + + const char *GetName() const; + + void SetEnabled(bool enable); + + bool IsEnabled(); + + void SetOneShot(bool one_shot); + + bool IsOneShot() const; + + void SetIgnoreCount(uint32_t count); + + uint32_t GetIgnoreCount() const; + + void SetCondition(const char *condition); + + const char *GetCondition(); + + void SetAutoContinue(bool auto_continue); + + bool GetAutoContinue(); + + void SetThreadID(lldb::tid_t sb_thread_id); + + lldb::tid_t GetThreadID(); + + void SetThreadIndex(uint32_t index); + + uint32_t GetThreadIndex() const; + + void SetThreadName(const char *thread_name); + + const char *GetThreadName() const; + + void SetQueueName(const char *queue_name); + + const char *GetQueueName() const; + + void SetScriptCallbackFunction(const char *callback_function_name); + + void SetCommandLineCommands(SBStringList &commands); + + bool GetCommandLineCommands(SBStringList &commands); + + SBError SetScriptCallbackBody(const char *script_body_text); + + const char *GetHelpString() const; + void SetHelpString(const char *help_string); + + bool GetAllowList() const; + void SetAllowList(bool value); + + bool GetAllowDelete(); + void SetAllowDelete(bool value); + + bool GetAllowDisable(); + void SetAllowDisable(bool value); + + bool GetDescription(lldb::SBStream &description); + +}; + +} // namespace lldb + diff --git a/scripts/interface/SBCommandInterpreter.i b/scripts/interface/SBCommandInterpreter.i index c427d38b14d82..255e8ba4496ac 100644 --- a/scripts/interface/SBCommandInterpreter.i +++ b/scripts/interface/SBCommandInterpreter.i @@ -125,18 +125,18 @@ public: { eBroadcastBitThreadShouldExit = (1 << 0), eBroadcastBitResetPrompt = (1 << 1), - eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit + eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit eBroadcastBitAsynchronousOutputData = (1 << 3), eBroadcastBitAsynchronousErrorData = (1 << 4) }; SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); - + ~SBCommandInterpreter (); - static const char * + static const char * GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); - + static const char * GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); @@ -181,7 +181,7 @@ public: lldb::SBProcess GetProcess (); - + lldb::SBDebugger GetDebugger (); @@ -209,10 +209,12 @@ public: int match_start_point, int max_return_elements, lldb::SBStringList &matches); - + bool IsActive (); + bool + WasInterrupted () const; }; } // namespace lldb diff --git a/scripts/interface/SBDebugger.i b/scripts/interface/SBDebugger.i index db774d350e9c5..9f746d36348cb 100644 --- a/scripts/interface/SBDebugger.i +++ b/scripts/interface/SBDebugger.i @@ -214,6 +214,11 @@ public: CreateTarget (const char *filename); %feature("docstring", + "The dummy target holds breakpoints and breakpoint names that will prime newly created targets." + ) GetDummyTarget; + lldb::SBTarget GetDummyTarget(); + + %feature("docstring", "Return true if target is deleted from the target list of the debugger." ) DeleteTarget; bool @@ -247,6 +252,34 @@ public: void SetSelectedPlatform(lldb::SBPlatform &platform); + %feature("docstring", + "Get the number of currently active platforms." + ) GetNumPlatforms; + uint32_t + GetNumPlatforms (); + + %feature("docstring", + "Get one of the currently active platforms." + ) GetPlatformAtIndex; + lldb::SBPlatform + GetPlatformAtIndex (uint32_t idx); + + %feature("docstring", + "Get the number of available platforms." + ) GetNumAvailablePlatforms; + uint32_t + GetNumAvailablePlatforms (); + + %feature("docstring", " + Get the name and description of one of the available platforms. + + @param idx Zero-based index of the platform for which info should be + retrieved, must be less than the value returned by + GetNumAvailablePlatforms(). + ") GetAvailablePlatformInfoAtIndex; + lldb::SBStructuredData + GetAvailablePlatformInfoAtIndex (uint32_t idx); + lldb::SBSourceManager GetSourceManager (); diff --git a/scripts/interface/SBProcess.i b/scripts/interface/SBProcess.i index 527442e274ece..55d39f826b7d6 100644 --- a/scripts/interface/SBProcess.i +++ b/scripts/interface/SBProcess.i @@ -417,6 +417,18 @@ public: lldb::SBMemoryRegionInfoList GetMemoryRegions(); + %feature("autodoc", " + Get information about the process. + Valid process info will only be returned when the process is alive, + use IsValid() to check if the info returned is valid. + + process_info = process.GetProcessInfo() + if process_info.IsValid(): + process_info.GetProcessID() + ") GetProcessInfo; + lldb::SBProcessInfo + GetProcessInfo(); + %pythoncode %{ def __get_is_alive__(self): '''Returns "True" if the process is currently alive, "False" otherwise''' diff --git a/scripts/interface/SBProcessInfo.i b/scripts/interface/SBProcessInfo.i new file mode 100644 index 0000000000000..7332e67a966ad --- /dev/null +++ b/scripts/interface/SBProcessInfo.i @@ -0,0 +1,66 @@ +//===-- SWIG Interface for SBProcessInfo-------------------------*- 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", +"Describes an existing process and any discoverable information that pertains to +that process." +) SBProcessInfo; + +class SBProcessInfo +{ +public: + SBProcessInfo(); + + SBProcessInfo (const SBProcessInfo &rhs); + + ~SBProcessInfo (); + + bool + IsValid (); + + const char * + GetName (); + + SBFileSpec + GetExecutableFile (); + + lldb::pid_t + GetProcessID (); + + uint32_t + GetUserID (); + + uint32_t + GetGroupID (); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + uint32_t + GetEffectiveUserID (); + + uint32_t + GetEffectiveGroupID (); + + bool + EffectiveUserIDIsValid (); + + bool + EffectiveGroupIDIsValid (); + + lldb::pid_t + GetParentProcessID (); +}; + +} // namespace lldb diff --git a/scripts/interface/SBTarget.i b/scripts/interface/SBTarget.i index c1d749c7ce75d..bcec606005f4d 100644 --- a/scripts/interface/SBTarget.i +++ b/scripts/interface/SBTarget.i @@ -711,6 +711,10 @@ public: bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); + void DeleteBreakpointName(const char *name); + + void GetBreakpointNames(SBStringList &names); + bool EnableAllBreakpoints (); diff --git a/scripts/interface/SBValue.i b/scripts/interface/SBValue.i index ef9fe3c748516..2063626fc2400 100644 --- a/scripts/interface/SBValue.i +++ b/scripts/interface/SBValue.i @@ -16,15 +16,15 @@ SBValue supports iteration through its child, which in turn is represented as an SBValue. For example, we can get the general purpose registers of a frame as an SBValue, and iterate through all the registers, - registerSet = frame.GetRegisters() # Returns an SBValueList. + registerSet = frame.registers # Returns an SBValueList. for regs in registerSet: - if 'general purpose registers' in regs.getName().lower(): + if 'general purpose registers' in regs.name.lower(): GPRs = regs break - print('%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren())) + print('%s (number of children = %d):' % (GPRs.name, GPRs.num_children)) for reg in GPRs: - print('Name: ', reg.GetName(), ' Value: ', reg.GetValue()) + print('Name: ', reg.name, ' Value: ', reg.value) produces the output: diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 8345a4b95038a..dc987040e768a 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -82,6 +82,7 @@ import six #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBBreakpointName.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandReturnObject.h" @@ -111,6 +112,7 @@ import six #include "lldb/API/SBModuleSpec.h" #include "lldb/API/SBPlatform.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBProcessInfo.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBSection.h" @@ -167,6 +169,7 @@ import six %include "./interface/SBBlock.i" %include "./interface/SBBreakpoint.i" %include "./interface/SBBreakpointLocation.i" +%include "./interface/SBBreakpointName.i" %include "./interface/SBBroadcaster.i" %include "./interface/SBCommandInterpreter.i" %include "./interface/SBCommandReturnObject.i" @@ -196,6 +199,7 @@ import six %include "./interface/SBModuleSpec.i" %include "./interface/SBPlatform.i" %include "./interface/SBProcess.i" +%include "./interface/SBProcessInfo.i" %include "./interface/SBQueue.i" %include "./interface/SBQueueItem.i" %include "./interface/SBSection.i" |