Skip to content

Commit 7a5fc24

Browse files
authored
Merge pull request #1301 from apple/swift/tensorflow-merge
Merge 2020-06-02 into swift/tensorflow
2 parents 3409f67 + da604d2 commit 7a5fc24

File tree

16 files changed

+172
-51
lines changed

16 files changed

+172
-51
lines changed

lldb/bindings/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
file(GLOB SWIG_INTERFACES interfaces/*.i)
1+
file(GLOB SWIG_INTERFACES interface/*.i)
22
file(GLOB_RECURSE SWIG_SOURCES *.swig)
33
file(GLOB SWIG_HEADERS
44
${LLDB_SOURCE_DIR}/include/lldb/API/*.h

lldb/bindings/interface/SBAddress.i

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,34 @@ public:
144144

145145
#ifdef SWIGPYTHON
146146
%pythoncode %{
147+
__runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'
148+
147149
def __get_load_addr_property__ (self):
148-
'''Get the load address for a lldb.SBAddress using the current target.'''
150+
'''Get the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
151+
if not target:
152+
raise RuntimeError(self.__runtime_error_str)
149153
return self.GetLoadAddress (target)
150154

151155
def __set_load_addr_property__ (self, load_addr):
152-
'''Set the load address for a lldb.SBAddress using the current target.'''
156+
'''Set the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
157+
if not target:
158+
raise RuntimeError(self.__runtime_error_str)
153159
return self.SetLoadAddress (load_addr, target)
154160

155161
def __int__(self):
156-
'''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.'''
157-
if process and process.is_alive:
162+
'''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
163+
if not process or not target:
164+
raise RuntimeError(self.__runtime_error_str)
165+
if process.is_alive:
158166
return self.GetLoadAddress (target)
159-
else:
160-
return self.GetFileAddress ()
167+
return self.GetFileAddress ()
161168

162169
def __oct__(self):
163-
'''Convert the address to an octal string'''
170+
'''Convert the address to an octal string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
164171
return '%o' % int(self)
165172

166173
def __hex__(self):
167-
'''Convert the address to an hex string'''
174+
'''Convert the address to an hex string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
168175
return '0x%x' % int(self)
169176

170177
module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
@@ -176,7 +183,7 @@ public:
176183
offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
177184
section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
178185
file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
179-
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')
186+
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''')
180187
%}
181188
#endif
182189

lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87267,6 +87267,7 @@ SWIG_init(void) {
8726787267
SWIG_Python_SetConstant(d, "eExpressionTimedOut",SWIG_From_int(static_cast< int >(lldb::eExpressionTimedOut)));
8726887268
SWIG_Python_SetConstant(d, "eExpressionResultUnavailable",SWIG_From_int(static_cast< int >(lldb::eExpressionResultUnavailable)));
8726987269
SWIG_Python_SetConstant(d, "eExpressionStoppedForDebug",SWIG_From_int(static_cast< int >(lldb::eExpressionStoppedForDebug)));
87270+
SWIG_Python_SetConstant(d, "eExpressionThreadVanished",SWIG_From_int(static_cast< int >(lldb::eExpressionThreadVanished)));
8727087271
SWIG_Python_SetConstant(d, "eSearchDepthInvalid",SWIG_From_int(static_cast< int >(lldb::eSearchDepthInvalid)));
8727187272
SWIG_Python_SetConstant(d, "eSearchDepthTarget",SWIG_From_int(static_cast< int >(lldb::eSearchDepthTarget)));
8727287273
SWIG_Python_SetConstant(d, "eSearchDepthModule",SWIG_From_int(static_cast< int >(lldb::eSearchDepthModule)));

lldb/bindings/python/static-binding/lldb.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def lldb_iter(obj, getsize, getelem):
298298
eExpressionTimedOut = _lldb.eExpressionTimedOut
299299
eExpressionResultUnavailable = _lldb.eExpressionResultUnavailable
300300
eExpressionStoppedForDebug = _lldb.eExpressionStoppedForDebug
301+
eExpressionThreadVanished = _lldb.eExpressionThreadVanished
301302
eSearchDepthInvalid = _lldb.eSearchDepthInvalid
302303
eSearchDepthTarget = _lldb.eSearchDepthTarget
303304
eSearchDepthModule = _lldb.eSearchDepthModule
@@ -1001,27 +1002,34 @@ def __str__(self):
10011002
return _lldb.SBAddress___str__(self)
10021003

10031004

1005+
__runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'
1006+
10041007
def __get_load_addr_property__ (self):
1005-
'''Get the load address for a lldb.SBAddress using the current target.'''
1008+
'''Get the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
1009+
if not target:
1010+
raise RuntimeError(self.__runtime_error_str)
10061011
return self.GetLoadAddress (target)
10071012

10081013
def __set_load_addr_property__ (self, load_addr):
1009-
'''Set the load address for a lldb.SBAddress using the current target.'''
1014+
'''Set the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
1015+
if not target:
1016+
raise RuntimeError(self.__runtime_error_str)
10101017
return self.SetLoadAddress (load_addr, target)
10111018

10121019
def __int__(self):
1013-
'''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.'''
1020+
'''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
1021+
if not process or not target:
1022+
raise RuntimeError(self.__runtime_error_str)
10141023
if process.is_alive:
10151024
return self.GetLoadAddress (target)
1016-
else:
1017-
return self.GetFileAddress ()
1025+
return self.GetFileAddress ()
10181026

10191027
def __oct__(self):
1020-
'''Convert the address to an octal string'''
1028+
'''Convert the address to an octal string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
10211029
return '%o' % int(self)
10221030

10231031
def __hex__(self):
1024-
'''Convert the address to an hex string'''
1032+
'''Convert the address to an hex string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
10251033
return '0x%x' % int(self)
10261034

10271035
module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
@@ -1033,7 +1041,7 @@ def __hex__(self):
10331041
offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
10341042
section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
10351043
file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
1036-
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')
1044+
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''')
10371045

10381046
SBAddress_swigregister = _lldb.SBAddress_swigregister
10391047
SBAddress_swigregister(SBAddress)

lldb/docs/man/lldb.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,17 @@ CONFIGURATION FILES
296296
-------------------
297297

298298
:program:`lldb` reads things like settings, aliases and commands from the
299-
.lldbinit file. First, it will read the application specific init file whose
300-
name is ~/.lldbinit followed by a "-" and the name of the current program. This
301-
would be ~/.lldbinit-lldb for the command line :program:`lldb` and
302-
~/.lldbinit-Xcode for Xcode. Secondly, the global ~/.lldbinit will be read.
303-
Finally, :program:`lldb` will look for an .lldbinit file in the current working
304-
directory. For security reasons, :program:`lldb` will print a warning and not
305-
source this file by default. This behavior can be changed by changing the
299+
.lldbinit file.
300+
301+
First, it will read the application specific init file whose name is
302+
~/.lldbinit followed by a "-" and the name of the current program. This would
303+
be ~/.lldbinit-lldb for the command line :program:`lldb` and ~/.lldbinit-Xcode
304+
for Xcode. If there is no application specific init file, the global
305+
~/.lldbinit is read.
306+
307+
Secondly, it will look for an .lldbinit file in the current working directory.
308+
For security reasons, :program:`lldb` will print a warning and not source this
309+
file by default. This behavior can be changed by changing the
306310
target.load-cwd-lldbinit setting.
307311

308312
To always load the .lldbinit file in the current working directory, add the

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,10 @@ def cleanupSubprocesses(self):
857857
del self.subprocesses[:]
858858
# Ensure any forked processes are cleaned up
859859
for pid in self.forkedProcessPids:
860-
if os.path.exists("/proc/" + str(pid)):
860+
try:
861861
os.kill(pid, signal.SIGTERM)
862+
except OSError:
863+
pass
862864

863865
def spawnSubprocess(self, executable, args=[], install_remote=True):
864866
""" Creates a subprocess.Popen object with the specified executable and arguments,

lldb/source/Core/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ add_lldb_library(lldbCore
9090
Demangle
9191
)
9292

93-
# Necessary to ensure that the SWIFT_INLINE_NAMESPACE macro is defined for
94-
# swiftDemangling inclusions.
95-
target_compile_definitions(lldbCore PRIVATE
96-
SWIFT_INLINE_NAMESPACE=compiler)
97-
9893
add_dependencies(lldbCore
9994
LLDBCorePropertiesGen
10095
LLDBCorePropertiesEnumGen)

lldb/source/Plugins/ExpressionParser/Swift/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,3 @@ add_lldb_library(lldbPluginExpressionParserSwift PLUGIN
4343
Support
4444
Core
4545
)
46-
47-
# Necessary to ensure that the SWIFT_INLINE_NAMESPACE macro is defined for
48-
# swiftDemangling inclusions.
49-
target_compile_definitions(lldbPluginExpressionParserSwift PRIVATE
50-
SWIFT_INLINE_NAMESPACE=compiler)

lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,3 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
6666
add_dependencies(lldbPluginSymbolFileDWARF
6767
LLDBPluginSymbolFileDWARFPropertiesGen
6868
LLDBPluginSymbolFileDWARFPropertiesEnumGen)
69-
70-
# Necessary to ensure that the SWIFT_INLINE_NAMESPACE macro is defined for
71-
# swiftDemangling inclusions.
72-
target_compile_definitions(lldbPluginSymbolFileDWARF PRIVATE
73-
SWIFT_INLINE_NAMESPACE=compiler)

lldb/source/Symbol/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,3 @@ add_lldb_library(lldbSymbol
6363
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT SWIFT_COMPILER_IS_MSVC_LIKE)
6464
target_compile_options(lldbSymbol PRIVATE -Wno-dollar-in-identifier-extension)
6565
endif()
66-
67-
# Necessary to ensure that the SWIFT_INLINE_NAMESPACE macro is defined for
68-
# swiftDemangling inclusions.
69-
target_compile_definitions(lldbSymbol PRIVATE
70-
SWIFT_INLINE_NAMESPACE=compiler)

lldb/source/Target/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,3 @@ endif()
9999
add_dependencies(lldbTarget
100100
LLDBTargetPropertiesGen
101101
LLDBTargetPropertiesEnumGen)
102-
103-
# Necessary to ensure that the SWIFT_INLINE_NAMESPACE macro is defined for
104-
# swiftDemangling inclusions.
105-
target_compile_definitions(lldbTarget PRIVATE
106-
SWIFT_INLINE_NAMESPACE=compiler)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import lldb
2+
3+
def test(debugger, command, result, internal_dict):
4+
return int(lldb.SBAddress())
5+
6+
def __lldb_init_module(debugger, internal_dict):
7+
debugger.HandleCommand('command script add -f sbaddress.test test')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# REQUIRES: python
2+
# UNSUPPORTED: lldb-repro
3+
#
4+
# Test that the SBAddress properties throw an exception when used outside of
5+
# the interactive script interpreter.
6+
#
7+
# RUN: %lldb --script-language python -o 'command script import %S/Inputs/sbaddress.py' -o 'test' 2>&1 | FileCheck %s
8+
# CHECK: RuntimeError: This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.

llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <vector>
2626

2727
namespace llvm {
28+
29+
class raw_ostream;
30+
2831
namespace orc {
2932

3033
/// A utility class for building TargetMachines for JITs.
@@ -136,6 +139,12 @@ class JITTargetMachineBuilder {
136139
/// Access Triple.
137140
const Triple &getTargetTriple() const { return TT; }
138141

142+
#ifndef NDEBUG
143+
/// Debug-dump a JITTargetMachineBuilder.
144+
friend raw_ostream &operator<<(raw_ostream &OS,
145+
const JITTargetMachineBuilder &JTMB);
146+
#endif
147+
139148
private:
140149
Triple TT;
141150
std::string CPU;

llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
#include "llvm/Support/Host.h"
1212
#include "llvm/Support/TargetRegistry.h"
13+
#include "llvm/Support/raw_ostream.h"
14+
15+
#define DEBUG_TYPE "orc"
1316

1417
namespace llvm {
1518
namespace orc {
@@ -63,5 +66,78 @@ JITTargetMachineBuilder &JITTargetMachineBuilder::addFeatures(
6366
return *this;
6467
}
6568

69+
#ifndef NDEBUG
70+
raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
71+
OS << "{ Triple = \"" << JTMB.TT.str() << "\", CPU = \"" << JTMB.CPU
72+
<< "\", Options = <not-printable>, Relocation Model = ";
73+
74+
if (JTMB.RM) {
75+
switch (*JTMB.RM) {
76+
case Reloc::Static:
77+
OS << "Static";
78+
break;
79+
case Reloc::PIC_:
80+
OS << "PIC_";
81+
break;
82+
case Reloc::DynamicNoPIC:
83+
OS << "DynamicNoPIC";
84+
break;
85+
case Reloc::ROPI:
86+
OS << "ROPI";
87+
break;
88+
case Reloc::RWPI:
89+
OS << "RWPI";
90+
break;
91+
case Reloc::ROPI_RWPI:
92+
OS << "ROPI_RWPI";
93+
break;
94+
}
95+
} else
96+
OS << "unspecified";
97+
98+
OS << ", Code Model = ";
99+
100+
if (JTMB.CM) {
101+
switch (*JTMB.CM) {
102+
case CodeModel::Tiny:
103+
OS << "Tiny";
104+
break;
105+
case CodeModel::Small:
106+
OS << "Small";
107+
break;
108+
case CodeModel::Kernel:
109+
OS << "Kernel";
110+
break;
111+
case CodeModel::Medium:
112+
OS << "Medium";
113+
break;
114+
case CodeModel::Large:
115+
OS << "Large";
116+
break;
117+
}
118+
} else
119+
OS << "unspecified";
120+
121+
OS << ", Optimization Level = ";
122+
switch (JTMB.OptLevel) {
123+
case CodeGenOpt::None:
124+
OS << "None";
125+
break;
126+
case CodeGenOpt::Less:
127+
OS << "Less";
128+
break;
129+
case CodeGenOpt::Default:
130+
OS << "Default";
131+
break;
132+
case CodeGenOpt::Aggressive:
133+
OS << "Aggressive";
134+
break;
135+
}
136+
137+
OS << " }";
138+
return OS;
139+
}
140+
#endif // NDEBUG
141+
66142
} // End namespace orc.
67143
} // End namespace llvm.

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,42 @@
1414
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
1515
#include "llvm/IR/Mangler.h"
1616

17+
#define DEBUG_TYPE "orc"
18+
1719
namespace llvm {
1820
namespace orc {
1921

2022
Error LLJITBuilderState::prepareForConstruction() {
2123

24+
LLVM_DEBUG(dbgs() << "Preparing to create LLIT instance...\n");
25+
2226
if (!JTMB) {
27+
LLVM_DEBUG({
28+
dbgs() << " No explicitly set JITTargetMachineBuilder. "
29+
"Detecting host...\n";
30+
});
2331
if (auto JTMBOrErr = JITTargetMachineBuilder::detectHost())
2432
JTMB = std::move(*JTMBOrErr);
2533
else
2634
return JTMBOrErr.takeError();
2735
}
2836

37+
LLVM_DEBUG({
38+
dbgs() << " JITTargetMachineBuilder is " << JTMB << "\n"
39+
<< " Pre-constructed ExecutionSession: " << (ES ? "Yes" : "No")
40+
<< "\n";
41+
42+
dbgs() << " Custom object-linking-layer creator: "
43+
<< (CreateObjectLinkingLayer ? "Yes" : "No") << "\n"
44+
<< " Custom compile-function creator: "
45+
<< (CreateCompileFunction ? "Yes" : "No") << "\n"
46+
<< " Number of compile threads: " << NumCompileThreads;
47+
if (!NumCompileThreads)
48+
dbgs() << " (code will be compiled on the execution thread)\n";
49+
else
50+
dbgs() << "\n";
51+
});
52+
2953
// If the client didn't configure any linker options then auto-configure the
3054
// JIT linker.
3155
if (!CreateObjectLinkingLayer && JTMB->getCodeModel() == None &&

0 commit comments

Comments
 (0)