Skip to content
This repository was archived by the owner on Apr 2, 2020. It is now read-only.

Commit 0b2fe7a

Browse files
authored
Merge pull request #71 from tfiala/master-next-merge
Merge from master-next (i.e. upstream)
2 parents 3699cf5 + 1995b66 commit 0b2fe7a

File tree

572 files changed

+21924
-9578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

572 files changed

+21924
-9578
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# Byte compiled python modules.
1717
*.pyc
1818
*.pyproj
19+
# pyenv settings
20+
.python-version
1921
*.sln
2022
*.suo
2123
# vim swap files

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ endif()
2626
# add_subdirectory(include)
2727
add_subdirectory(docs)
2828
if (NOT LLDB_DISABLE_PYTHON)
29+
set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
30+
if(LLDB_BUILD_FRAMEWORK)
31+
set(LLDB_PYTHON_TARGET_DIR
32+
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
33+
else()
34+
# Don't set -m when building the framework.
35+
set(FINISH_EXTRA_ARGS "-m")
36+
endif()
37+
set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
38+
2939
add_subdirectory(scripts)
3040
endif ()
3141
add_subdirectory(source)
@@ -37,7 +47,13 @@ add_subdirectory(lit)
3747
if (NOT LLDB_DISABLE_PYTHON)
3848
# Add a Post-Build Event to copy over Python files and create the symlink to liblldb.so for the Python API(hardlink on Windows)
3949
add_custom_target( finish_swig ALL
40-
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--prefix=${CMAKE_BINARY_DIR}" "--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" "--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}" -m
50+
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
51+
"--srcRoot=${LLDB_SOURCE_DIR}"
52+
"--targetDir=${LLDB_PYTHON_TARGET_DIR}"
53+
"--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts"
54+
"--prefix=${CMAKE_BINARY_DIR}"
55+
"--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}"
56+
"--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}" ${FINISH_EXTRA_ARGS}
4157
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
4258
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
4359
COMMENT "Python script sym-linking LLDB Python API")

cmake/LLDBDependencies.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ set(LLVM_LINK_COMPONENTS
255255
)
256256

257257
if ( NOT LLDB_DISABLE_PYTHON )
258-
set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
259-
260258
set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
261259
if (CLANG_CL)
262260
set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES COMPILE_FLAGS -Wno-unused-function)

cmake/modules/AddLLDB.cmake

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function(lldb_link_common_libs name targetkind)
44
endif()
55

66
if(${targetkind} MATCHES "SHARED")
7-
set(LINK_KEYWORD PUBLIC)
7+
set(LINK_KEYWORD PRIVATE)
88
endif()
99

1010
if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
@@ -56,32 +56,32 @@ macro(add_lldb_library name)
5656
if (PARAM_OBJECT)
5757
add_library(${name} ${libkind} ${srcs})
5858
else()
59-
llvm_add_library(${name} ${libkind} DISABLE_LLVM_LINK_LLVM_DYLIB ${srcs})
60-
61-
lldb_link_common_libs(${name} "${libkind}")
62-
6359
if (PARAM_SHARED)
6460
if (LLDB_LINKER_SUPPORTS_GROUPS)
65-
target_link_libraries(${name} PUBLIC
66-
-Wl,--start-group ${SWIFT_ALL_LIBS} -Wl,--end-group)
67-
target_link_libraries(${name} PUBLIC
68-
-Wl,--start-group ${CLANG_ALL_LIBS} -Wl,--end-group)
69-
target_link_libraries(${name} PUBLIC
70-
-Wl,--start-group ${LLVM_ALL_LIBS} -Wl,--end-group)
61+
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
62+
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group
63+
-Wl,--start-group ${SWIFT_ALL_LIBS} -Wl,--end-group
64+
-Wl,--start-group ${CLANG_ALL_LIBS} -Wl,--end-group
65+
)
7166
else()
72-
target_link_libraries(${name} PUBLIC ${SWIFT_ALL_LIBS})
73-
target_link_libraries(${name} PUBLIC ${CLANG_ALL_LIBS})
74-
target_link_libraries(${name} PUBLIC ${LLVM_ALL_LIBS})
67+
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
68+
${LLDB_USED_LIBS} ${SWIFT_ALL_LIBS} ${CLANG_ALL_LIBS}
69+
)
7570
endif()
71+
else()
72+
llvm_add_library(${name} ${libkind} ${srcs})
7673
endif()
77-
llvm_config(${name} ${LLVM_LINK_COMPONENTS} ${LLVM_PRIVATE_LINK_COMPONENTS})
7874

7975
if (${name} STREQUAL "liblldb")
8076
if (PARAM_SHARED)
77+
set(out_dir lib${LLVM_LIBDIR_SUFFIX})
78+
if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
79+
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
80+
endif()
8181
install(TARGETS ${name}
8282
RUNTIME DESTINATION bin
83-
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
84-
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
83+
LIBRARY DESTINATION ${out_dir}
84+
ARCHIVE DESTINATION ${out_dir})
8585
else()
8686
install(TARGETS ${name}
8787
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
@@ -93,23 +93,39 @@ macro(add_lldb_library name)
9393
# Hack: only some LLDB libraries depend on the clang autogenerated headers,
9494
# but it is simple enough to make all of LLDB depend on some of those
9595
# headers without negatively impacting much of anything.
96-
add_dependencies(${name} libclang)
96+
get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
97+
if(CLANG_TABLEGEN_TARGETS)
98+
add_dependencies(${name} ${CLANG_TABLEGEN_TARGETS})
99+
endif()
97100

98101
set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
99102
endmacro(add_lldb_library)
100103

101104
macro(add_lldb_executable name)
102-
add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
103-
set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
104-
# ELF and Mach-O loaders have different ways of expressing that an rpath
105-
# should be relative to the binary being loaded. Mach-O uses @loader_path, and
106-
# ELF uses $ORIGIN.
107-
if(APPLE)
108-
set(rpath_prefix "@loader_path")
109-
else()
110-
set(rpath_prefix "$ORIGIN")
105+
cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK" "" "" ${ARGN})
106+
add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARG_UNPARSED_ARGUMENTS})
107+
set_target_properties(${name} PROPERTIES
108+
FOLDER "lldb executables")
109+
110+
if(LLDB_BUILD_FRAMEWORK)
111+
if(ARG_INCLUDE_IN_FRAMEWORK)
112+
string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
113+
set_target_properties(${name} PROPERTIES
114+
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:liblldb>/Resources
115+
BUILD_WITH_INSTALL_RPATH On
116+
INSTALL_RPATH "@loader_path/../../../../${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
117+
118+
add_llvm_tool_symlink(${name} $<TARGET_FILE:${name}> ARG_ALWAYS_GENERATE)
119+
else()
120+
set_target_properties(${name} PROPERTIES
121+
BUILD_WITH_INSTALL_RPATH On
122+
INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
123+
endif()
111124
endif()
112-
set_target_properties(${name} PROPERTIES INSTALL_RPATH "${rpath_prefix}/../lib")
125+
126+
# Might need the following in an else clause for above to cover non-Apple
127+
# set(rpath_prefix "$ORIGIN")
128+
# set_target_properties(${name} PROPERTIES INSTALL_RPATH "${rpath_prefix}/../lib")
113129
endmacro(add_lldb_executable)
114130

115131
# Support appending linker flags to an existing target.

cmake/modules/LLDBConfig.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
310310
find_library(SECURITY_LIBRARY Security)
311311
find_library(DEBUG_SYMBOLS_LIBRARY DebugSymbols PATHS "/System/Library/PrivateFrameworks")
312312

313+
set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Output directory for LLDB.framework")
314+
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
315+
set(LLDB_FRAMEWORK_RESOURCE_DIR
316+
LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources)
317+
313318
add_definitions( -DLIBXML2_DEFINED )
314319
list(APPEND system_libs xml2 ${CURSES_LIBRARIES})
315320
list(APPEND system_libs ${CARBON_LIBRARY} ${FOUNDATION_LIBRARY}

include/lldb/API/SBBreakpoint.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class LLDB_API SBBreakpoint {
8888

8989
void SetScriptCallbackFunction(const char *callback_function_name);
9090

91+
void SetCommandLineCommands(SBStringList &commands);
92+
93+
bool GetCommandLineCommands(SBStringList &commands);
94+
9195
SBError SetScriptCallbackBody(const char *script_body_text);
9296

9397
bool AddName(const char *new_name);
@@ -104,6 +108,8 @@ class LLDB_API SBBreakpoint {
104108

105109
bool GetDescription(lldb::SBStream &description);
106110

111+
bool GetDescription(lldb::SBStream &description, bool include_locations);
112+
107113
static bool EventIsBreakpointEvent(const lldb::SBEvent &event);
108114

109115
static lldb::BreakpointEventType
@@ -119,6 +125,7 @@ class LLDB_API SBBreakpoint {
119125
GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp);
120126

121127
private:
128+
friend class SBBreakpointList;
122129
friend class SBBreakpointLocation;
123130
friend class SBTarget;
124131

@@ -139,6 +146,37 @@ class LLDB_API SBBreakpoint {
139146
lldb::BreakpointSP m_opaque_sp;
140147
};
141148

149+
class SBBreakpointListImpl;
150+
151+
class LLDB_API SBBreakpointList {
152+
public:
153+
SBBreakpointList(SBTarget &target);
154+
155+
~SBBreakpointList();
156+
157+
size_t GetSize() const;
158+
159+
SBBreakpoint GetBreakpointAtIndex(size_t idx);
160+
161+
SBBreakpoint FindBreakpointByID(lldb::break_id_t);
162+
163+
void Append(const SBBreakpoint &sb_file);
164+
165+
bool AppendIfUnique(const SBBreakpoint &sb_file);
166+
167+
void AppendByID(lldb::break_id_t id);
168+
169+
void Clear();
170+
171+
protected:
172+
friend class SBTarget;
173+
174+
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list);
175+
176+
private:
177+
std::shared_ptr<SBBreakpointListImpl> m_opaque_sp;
178+
};
179+
142180
} // namespace lldb
143181

144182
#endif // LLDB_SBBreakpoint_h_

include/lldb/API/SBSourceManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class LLDB_API SBSourceManager {
3030
const lldb::SBFileSpec &file, uint32_t line, uint32_t context_before,
3131
uint32_t context_after, const char *current_line_cstr, lldb::SBStream &s);
3232

33+
size_t DisplaySourceLinesWithLineNumbersAndColumn(
34+
const lldb::SBFileSpec &file, uint32_t line, uint32_t column,
35+
uint32_t context_before, uint32_t context_after,
36+
const char *current_line_cstr, lldb::SBStream &s);
37+
3338
protected:
3439
friend class SBCommandInterpreter;
3540
friend class SBDebugger;

include/lldb/API/SBStringList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ class LLDB_API SBStringList {
4343
protected:
4444
friend class SBCommandInterpreter;
4545
friend class SBDebugger;
46+
friend class SBBreakpoint;
4647

4748
SBStringList(const lldb_private::StringList *lldb_strings);
4849

50+
void AppendList(const lldb_private::StringList &strings);
51+
4952
const lldb_private::StringList *operator->() const;
5053

5154
const lldb_private::StringList &operator*() const;

include/lldb/API/SBTarget.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Project includes
1717
#include "lldb/API/SBAddress.h"
1818
#include "lldb/API/SBAttachInfo.h"
19+
#include "lldb/API/SBBreakpoint.h"
1920
#include "lldb/API/SBBroadcaster.h"
2021
#include "lldb/API/SBDefines.h"
2122
#include "lldb/API/SBFileSpec.h"
@@ -563,6 +564,10 @@ class LLDB_API SBTarget {
563564
BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
564565
lldb::addr_t offset);
565566

567+
lldb::SBBreakpoint
568+
BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
569+
lldb::addr_t offset, SBFileSpecList &module_list);
570+
566571
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
567572
const char *module_name = nullptr);
568573

@@ -652,6 +657,75 @@ class LLDB_API SBTarget {
652657

653658
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
654659

660+
//------------------------------------------------------------------
661+
/// Read breakpoints from source_file and return the newly created
662+
/// breakpoints in bkpt_list.
663+
///
664+
/// @param[in] source_file
665+
/// The file from which to read the breakpoints.
666+
///
667+
/// @param[out] bkpt_list
668+
/// A list of the newly created breakpoints.
669+
///
670+
/// @return
671+
/// An SBError detailing any errors in reading in the breakpoints.
672+
//------------------------------------------------------------------
673+
lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
674+
SBBreakpointList &new_bps);
675+
676+
//------------------------------------------------------------------
677+
/// Read breakpoints from source_file and return the newly created
678+
/// breakpoints in bkpt_list.
679+
///
680+
/// @param[in] source_file
681+
/// The file from which to read the breakpoints.
682+
///
683+
/// @param[in] matching_names
684+
/// Only read in breakpoints whose names match one of the names in this
685+
/// list.
686+
///
687+
/// @param[out] bkpt_list
688+
/// A list of the newly created breakpoints.
689+
///
690+
/// @return
691+
/// An SBError detailing any errors in reading in the breakpoints.
692+
//------------------------------------------------------------------
693+
lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
694+
SBStringList &matching_names,
695+
SBBreakpointList &new_bps);
696+
697+
//------------------------------------------------------------------
698+
/// Write breakpoints to dest_file.
699+
///
700+
/// @param[in] dest_file
701+
/// The file to which to write the breakpoints.
702+
///
703+
/// @return
704+
/// An SBError detailing any errors in writing in the breakpoints.
705+
//------------------------------------------------------------------
706+
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file);
707+
708+
//------------------------------------------------------------------
709+
/// Write breakpoints listed in bkpt_list to dest_file.
710+
///
711+
/// @param[in] dest_file
712+
/// The file to which to write the breakpoints.
713+
///
714+
/// @param[in] bkpt_list
715+
/// Only write breakpoints from this list.
716+
///
717+
/// @param[in] append
718+
/// If \btrue, append the breakpoints in bkpt_list to the others
719+
/// serialized in dest_file. If dest_file doesn't exist, then a new
720+
/// file will be created and the breakpoints in bkpt_list written to it.
721+
///
722+
/// @return
723+
/// An SBError detailing any errors in writing in the breakpoints.
724+
//------------------------------------------------------------------
725+
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
726+
SBBreakpointList &bkpt_list,
727+
bool append = false);
728+
655729
uint32_t GetNumBreakpoints() const;
656730

657731
lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
@@ -660,6 +734,10 @@ class LLDB_API SBTarget {
660734

661735
lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id);
662736

737+
// Finds all breakpoints by name, returning the list in bkpt_list. Returns
738+
// false if the name is not a valid breakpoint name, true otherwise.
739+
bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
740+
663741
bool EnableAllBreakpoints();
664742

665743
bool DisableAllBreakpoints();
@@ -752,6 +830,7 @@ class LLDB_API SBTarget {
752830
protected:
753831
friend class SBAddress;
754832
friend class SBBlock;
833+
friend class SBBreakpointListImpl;
755834
friend class SBDebugger;
756835
friend class SBExecutionContext;
757836
friend class SBFunction;

0 commit comments

Comments
 (0)