Skip to content

Commit f920543

Browse files
committed
Merge commit '3aaa71720ea5' from apple/stable/20200714 into swift/main
2 parents 98050f7 + ea50a44 commit f920543

File tree

17 files changed

+87
-18
lines changed

17 files changed

+87
-18
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,29 @@
1919
]
2020

2121
all_categories = {
22+
'basic_process': 'Basic process execution sniff tests.',
23+
'cmdline': 'Tests related to the LLDB command-line interface',
24+
'darwin-log': 'Darwin log tests',
2225
'dataformatters': 'Tests related to the type command and the data formatters subsystem',
26+
'dsym': 'Tests that can be run with DSYM debug information',
2327
'dwarf': 'Tests that can be run with DWARF debug information',
2428
'dwo': 'Tests that can be run with DWO debug information',
25-
'dsym': 'Tests that can be run with DSYM debug information',
26-
'gmodules': 'Tests that can be run with -gmodules debug information',
29+
'dyntype': 'Tests related to dynamic type support',
2730
'expression': 'Tests related to the expression parser',
31+
'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution',
32+
'gmodules': 'Tests that can be run with -gmodules debug information',
33+
'instrumentation-runtime': 'Tests for the instrumentation runtime plugins',
2834
'libc++': 'Test for libc++ data formatters',
2935
'libstdcxx': 'Test for libstdcxx data formatters',
36+
'lldb-server': 'Tests related to lldb-server',
37+
'lldb-vscode': 'Visual Studio Code debug adaptor tests',
3038
'objc': 'Tests related to the Objective-C programming language support',
3139
'pyapi': 'Tests related to the Python API',
32-
'basic_process': 'Basic process execution sniff tests.',
33-
'cmdline': 'Tests related to the LLDB command-line interface',
34-
'dyntype': 'Tests related to dynamic type support',
35-
'stresstest': 'Tests related to stressing lldb limits',
36-
'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution',
37-
'frame-diagnose': 'Frame diagnose tests',
38-
'darwin-log': 'Darwin log tests',
3940
'std-module': 'Tests related to importing the std module',
41+
'stresstest': 'Tests related to stressing lldb limits',
4042
'watchpoint': 'Watchpoint-related tests',
41-
'lldb-vscode': 'Visual Studio Code debug adaptor tests',
42-
'lldb-server': 'Tests related to lldb-server',
43+
44+
'frame-diagnose': 'Frame diagnose tests',
4345
}
4446

4547

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "lldb/Core/ModuleSpec.h"
2020
#include "lldb/Core/ValueObjectConstResult.h"
2121
#include "lldb/Core/ValueObjectVariable.h"
22+
#include "lldb/Expression/DiagnosticManager.h"
2223
#include "lldb/Expression/Materializer.h"
2324
#include "lldb/Symbol/CompileUnit.h"
2425
#include "lldb/Symbol/CompilerDecl.h"
@@ -125,6 +126,12 @@ void ClangExpressionDeclMap::InstallCodeGenerator(
125126
m_parser_vars->m_code_gen = code_gen;
126127
}
127128

129+
void ClangExpressionDeclMap::InstallDiagnosticManager(
130+
DiagnosticManager &diag_manager) {
131+
assert(m_parser_vars);
132+
m_parser_vars->m_diagnostics = &diag_manager;
133+
}
134+
128135
void ClangExpressionDeclMap::DidParse() {
129136
if (m_parser_vars && m_parser_vars->m_persistent_vars) {
130137
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
@@ -196,6 +203,17 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
196203
if (ast == nullptr)
197204
return false;
198205

206+
// Check if we already declared a persistent variable with the same name.
207+
if (lldb::ExpressionVariableSP conflicting_var =
208+
m_parser_vars->m_persistent_vars->GetVariable(name)) {
209+
std::string msg = llvm::formatv("redefinition of persistent variable '{0}'",
210+
name).str();
211+
m_parser_vars->m_diagnostics->AddDiagnostic(
212+
msg, DiagnosticSeverity::eDiagnosticSeverityError,
213+
DiagnosticOrigin::eDiagnosticOriginLLDB);
214+
return false;
215+
}
216+
199217
if (m_parser_vars->m_materializer && is_result) {
200218
Status err;
201219

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class ClangExpressionDeclMap : public ClangASTSource {
102102

103103
void InstallCodeGenerator(clang::ASTConsumer *code_gen);
104104

105+
void InstallDiagnosticManager(DiagnosticManager &diag_manager);
106+
105107
/// Disable the state needed for parsing and IR transformation.
106108
void DidParse();
107109

@@ -330,6 +332,8 @@ class ClangExpressionDeclMap : public ClangASTSource {
330332
clang::ASTConsumer *m_code_gen = nullptr; ///< If non-NULL, a code generator
331333
///that receives new top-level
332334
///functions.
335+
DiagnosticManager *m_diagnostics = nullptr;
336+
333337
private:
334338
ParserVars(const ParserVars &) = delete;
335339
const ParserVars &operator=(const ParserVars &) = delete;

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
10741074
ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
10751075
if (decl_map) {
10761076
decl_map->InstallCodeGenerator(&m_compiler->getASTConsumer());
1077+
decl_map->InstallDiagnosticManager(diagnostic_manager);
10771078

10781079
clang::ExternalASTSource *ast_source = decl_map->CreateProxy();
10791080

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
32503250

32513251
if (tag == DW_TAG_variable && mangled &&
32523252
sc.comp_unit->GetLanguage() == eLanguageTypeSwift)
3253-
mangled = NULL;
3253+
mangled = nullptr;
32543254

32553255
// Prefer DW_AT_location over DW_AT_const_value. Both can be emitted e.g.
32563256
// for static constexpr member variables -- DW_AT_const_value will be

lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ def test_persistent_variables(self):
4141
# Test that $200 wasn't created by the previous expression.
4242
self.expect("expr $200", error=True,
4343
substrs=["use of undeclared identifier '$200'"])
44+
45+
# Try redeclaring the persistent variable with the same type.
46+
# This should be rejected as we treat them as if they are globals.
47+
self.expect("expr int $i = 123", error=True,
48+
substrs=["error: redefinition of persistent variable '$i'"])
49+
self.expect_expr("$i", result_type="int", result_value="5")
50+
51+
# Try redeclaring the persistent variable with another type. Should
52+
# also be rejected.
53+
self.expect("expr long $i = 123", error=True,
54+
substrs=["error: redefinition of persistent variable '$i'"])
55+
self.expect_expr("$i", result_type="int", result_value="5")
56+
57+
# Try assigning the persistent variable a new value.
58+
self.expect("expr $i = 55")
59+
self.expect_expr("$i", result_type="int", result_value="55")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instrumentation-runtime
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instrumentation-runtime
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instrumentation-runtime
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instrumentation-runtime

lldb/test/Shell/Process/TestAbortExitCode.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ UNSUPPORTED: system-windows
33
RUN: %clang_host %p/Inputs/abort.c -o %t
44
RUN: %lldb %t -o run -o continue | FileCheck %s
55

6-
CHECK: status = 6 (0x00000006)
6+
CHECK: {{status = 6 \(0x00000006\)|status = 0 \(0x00000000\) Terminated due to signal 6}}

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,9 +2037,10 @@ function(llvm_codesign name)
20372037
set(ARG_BUNDLE_PATH $<TARGET_FILE:${name}>)
20382038
endif()
20392039

2040-
if(ARG_FORCE)
2041-
set(force_flag "-f")
2042-
endif()
2040+
# ld64 now always codesigns the binaries it creates. Apply the force arg
2041+
# unconditionally so that we can - for example - add entitlements to the
2042+
# targets that need it.
2043+
set(force_flag "-f")
20432044

20442045
add_custom_command(
20452046
TARGET ${name} POST_BUILD

llvm/cmake/modules/LLVMConfig.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ set(LLVM_USE_CRT_MINSIZEREL @LLVM_USE_CRT_MINSIZEREL@)
1616
set(LLVM_USE_CRT_RELEASE @LLVM_USE_CRT_RELEASE@)
1717
set(LLVM_USE_CRT_RELWITHDEBINFO @LLVM_USE_CRT_RELWITHDEBINFO@)
1818

19+
set(LLVM_USE_SPLIT_DWARF @LLVM_USE_SPLIT_DWARF@)
20+
1921
set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
2022

2123
set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)

llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ enum class coveragemap_error {
5555
unsupported_version,
5656
truncated,
5757
malformed,
58-
decompression_failed
58+
decompression_failed,
59+
invalid_or_missing_arch_specifier
5960
};
6061

6162
const std::error_category &coveragemap_category();

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ static std::string getCoverageMapErrString(coveragemap_error Err) {
807807
return "Malformed coverage data";
808808
case coveragemap_error::decompression_failed:
809809
return "Failed to decompress coverage data (zlib)";
810+
case coveragemap_error::invalid_or_missing_arch_specifier:
811+
return "`-arch` specifier is invalid or missing for universal binary";
810812
}
811813
llvm_unreachable("A value of coveragemap_error has no message.");
812814
}

llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,19 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch) {
950950
BytesInAddress, Endian);
951951
}
952952

953+
/// Determine whether \p Arch is invalid or empty, given \p Bin.
954+
static bool isArchSpecifierInvalidOrMissing(Binary *Bin, StringRef Arch) {
955+
// If we have a universal binary and Arch doesn't identify any of its slices,
956+
// it's user error.
957+
if (auto *Universal = dyn_cast<MachOUniversalBinary>(Bin)) {
958+
for (auto &ObjForArch : Universal->objects())
959+
if (Arch == ObjForArch.getArchFlagName())
960+
return false;
961+
return true;
962+
}
963+
return false;
964+
}
965+
953966
Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
954967
BinaryCoverageReader::create(
955968
MemoryBufferRef ObjectBuffer, StringRef Arch,
@@ -970,6 +983,10 @@ BinaryCoverageReader::create(
970983
return BinOrErr.takeError();
971984
std::unique_ptr<Binary> Bin = std::move(BinOrErr.get());
972985

986+
if (isArchSpecifierInvalidOrMissing(Bin.get(), Arch))
987+
return make_error<CoverageMapError>(
988+
coveragemap_error::invalid_or_missing_arch_specifier);
989+
973990
// MachO universal binaries which contain archives need to be treated as
974991
// archives, not as regular binaries.
975992
if (auto *Universal = dyn_cast<MachOUniversalBinary>(Bin.get())) {

llvm/test/tools/llvm-cov/universal-binary.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ int main(int argc, const char *argv[]) {}
1010
// COMBINED: showTemplateInstantiations.cpp
1111
// COMBINED-NEXT: universal-binary.c
1212

13+
// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s
1314
// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch i386 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s
14-
// WRONG-ARCH: Failed to load coverage
15+
// WRONG-ARCH: Failed to load coverage: `-arch` specifier is invalid or missing for universal binary
1516

1617
// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch definitly_a_made_up_architecture 2>&1 | FileCheck --check-prefix=MADE-UP-ARCH %s
1718
// MADE-UP-ARCH: Unknown architecture: definitly_a_made_up_architecture

0 commit comments

Comments
 (0)