Skip to content

Commit cfc1c45

Browse files
committed
[lldb] Adjust for upstream changes
1 parent d49ec45 commit cfc1c45

File tree

2 files changed

+50
-56
lines changed

2 files changed

+50
-56
lines changed

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,12 +3392,10 @@ class SwiftDWARFImporterDelegate : public swift::DWARFImporterDelegate {
33923392

33933393
// Import the type into the DWARFImporter's context.
33943394
clang::ASTContext &to_ctx = clang_importer->getClangASTContext();
3395-
clang::ASTContext *from_ctx = type_system->getASTContext();
3396-
if (!from_ctx)
3397-
return true;
3395+
clang::ASTContext &from_ctx = type_system->getASTContext();
33983396

33993397
clang::QualType qual_type = ClangUtil::GetQualType(compiler_type);
3400-
importType(qual_type, *from_ctx, to_ctx, kind, results);
3398+
importType(qual_type, from_ctx, to_ctx, kind, results);
34013399

34023400
// If this is a module context, cache the result for the scratch context.
34033401
if (m_swift_ast_ctx.GetModule())

lldb/source/Target/SwiftLanguageRuntime.cpp

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,7 @@ const CompilerType &SwiftLanguageRuntime::GetBoxMetadataType() {
12451245
ClangASTContext::GetScratch(GetProcess()->GetTarget())) {
12461246
CompilerType voidstar =
12471247
ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
1248-
CompilerType uint32 = ClangASTContext::GetIntTypeFromBitSize(
1249-
ast_ctx->getASTContext(), 32, false);
1248+
CompilerType uint32 = ast_ctx->GetIntTypeFromBitSize(32, false);
12501249

12511250
m_box_metadata_type = ast_ctx->GetOrCreateStructForIdentifier(
12521251
g_type_name, {{"kind", voidstar}, {"offset", uint32}}, is_packed);
@@ -1626,7 +1625,7 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type,
16261625
if (!scratch_ctx)
16271626
return llvm::None;
16281627
}
1629-
1628+
16301629
auto *remote_ast = &GetRemoteASTContext(*module_ctx);
16311630

16321631
if (log)
@@ -1696,7 +1695,7 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type,
16961695
bool safe_to_use_remote_ast = true;
16971696
if (swift::Decl *type_decl = swift_type->getNominalOrBoundGenericNominal())
16981697
safe_to_use_remote_ast &= ASTVerifier::Verify(type_decl);
1699-
1698+
17001699
// Use RemoteAST to determine the member offset.
17011700
if (safe_to_use_remote_ast) {
17021701
swift::remoteAST::Result<uint64_t> result = remote_ast->getOffsetOfMember(
@@ -2052,26 +2051,26 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
20522051
llvm::dyn_cast<swift::OpaqueTypeArchetypeType>(type);
20532052
if (!opaque_type)
20542053
return type;
2055-
2054+
20562055
// Try to find the symbol for the opaque type descriptor in the
20572056
// process.
20582057
auto mangled_name = ConstString(
20592058
mangler.mangleOpaqueTypeDescriptor(opaque_type->getDecl()));
2060-
2059+
20612060
SymbolContextList found;
20622061
target.GetImages().FindSymbolsWithNameAndType(mangled_name,
20632062
eSymbolTypeData, found);
2064-
2063+
20652064
if (found.GetSize() == 0)
20662065
return type;
2067-
2066+
20682067
swift::Type result_type;
2069-
2068+
20702069
for (unsigned i = 0, e = found.GetSize(); i < e; ++i) {
20712070
SymbolContext found_sc;
20722071
if (!found.GetContextAtIndex(i, found_sc))
20732072
continue;
2074-
2073+
20752074
// See if the symbol has an address.
20762075
if (!found_sc.symbol)
20772076
continue;
@@ -2088,7 +2087,7 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
20882087
swift::remote::RemoteAddress(addr),
20892088
opaque_type->getSubstitutions(),
20902089
opaque_type->getOrdinal());
2091-
2090+
20922091
if (!underlying_type_result)
20932092
continue;
20942093

@@ -2102,22 +2101,22 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
21022101
return type;
21032102
}
21042103
}
2105-
2104+
21062105
if (!result_type)
21072106
return type;
2108-
2107+
21092108
return result_type;
21102109
},
21112110
swift::LookUpConformanceInModule(module_decl),
21122111
swift::SubstFlags::DesugarMemberTypes
21132112
| swift::SubstFlags::SubstituteOpaqueArchetypes);
2114-
2113+
21152114
// Stop if we've reached a fixpoint where we can't further resolve opaque
21162115
// types.
21172116
if (old_type->isEqual(target_swift_type))
21182117
break;
21192118
}
2120-
2119+
21212120
target_swift_type = target_swift_type.subst(
21222121
[this, &stack_frame,
21232122
&scratch_ctx](swift::SubstitutableType *type) -> swift::Type {
@@ -2785,8 +2784,8 @@ GetThunkKind(llvm::StringRef symbol_name)
27852784
case swift::Demangle::Node::Kind::ProtocolWitness:
27862785
if (node_ptr->getNumChildren() == 0)
27872786
return ThunkKind::Unknown;
2788-
if (node_ptr->getFirstChild()->getKind()
2789-
== swift::Demangle::Node::Kind::ProtocolConformance)
2787+
if (node_ptr->getFirstChild()->getKind() ==
2788+
swift::Demangle::Node::Kind::ProtocolConformance)
27902789
return ThunkKind::ProtocolConformance;
27912790
break;
27922791
case swift::Demangle::Node::Kind::ReabstractionThunkHelper:
@@ -2796,8 +2795,8 @@ GetThunkKind(llvm::StringRef symbol_name)
27962795
case swift::Demangle::Node::Kind::Allocator:
27972796
if (node_ptr->getNumChildren() == 0)
27982797
return ThunkKind::Unknown;
2799-
if (node_ptr->getFirstChild()->getKind()
2800-
== swift::Demangle::Node::Kind::Class)
2798+
if (node_ptr->getFirstChild()->getKind() ==
2799+
swift::Demangle::Node::Kind::Class)
28012800
return ThunkKind::AllocatingInit;
28022801
break;
28032802
default:
@@ -2850,11 +2849,11 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc,
28502849
SymbolContext &sc) {
28512850
if (!curr_sc.module_sp)
28522851
return false;
2853-
2852+
28542853
SymbolContextList sc_list;
28552854
swift::Demangle::Context demangle_ctx;
28562855
// Make sure this is a partial apply:
2857-
2856+
28582857
std::string apply_target = demangle_ctx.getThunkTarget(apply_name.GetStringRef());
28592858
if (!apply_target.empty()) {
28602859
curr_sc.module_sp->FindFunctions(ConstString(apply_target), NULL,
@@ -2863,7 +2862,7 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc,
28632862
size_t num_symbols = sc_list.GetSize();
28642863
if (num_symbols == 0)
28652864
return false;
2866-
2865+
28672866
CompileUnit *curr_cu = curr_sc.comp_unit;
28682867

28692868
size_t num_found = 0;
@@ -2925,7 +2924,7 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
29252924
// keeps this list and the one in IsSymbolARuntimeThunk in sync.
29262925
if (!symbol || !IsSymbolARuntimeThunk(*symbol))
29272926
return new_thread_plan_sp;
2928-
2927+
29292928
// Only do this if you are at the beginning of the thunk function:
29302929
lldb::addr_t cur_addr = thread.GetRegisterContext()->GetPC();
29312930
lldb::addr_t symbol_addr = symbol->GetAddress().GetLoadAddress(
@@ -2937,10 +2936,9 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
29372936
Address target_address;
29382937
ConstString symbol_mangled_name = symbol->GetMangled().GetMangledName();
29392938
const char *symbol_name = symbol_mangled_name.AsCString();
2940-
2939+
29412940
ThunkKind thunk_kind = GetThunkKind(symbol_mangled_name.GetStringRef());
29422941
ThunkAction thunk_action = GetThunkAction(thunk_kind);
2943-
29442942

29452943
switch (thunk_action)
29462944
{
@@ -3091,7 +3089,7 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
30913089
}
30923090
break;
30933091
}
3094-
3092+
30953093
if (target_address.IsValid()) {
30963094
new_thread_plan_sp.reset(
30973095
new ThreadPlanRunToAddress(thread, target_address, stop_others));
@@ -3248,10 +3246,10 @@ SwiftLanguageRuntime::CalculateErrorValueObjectFromValue(
32483246

32493247
CompilerType swift_error_proto_type = ast_context->GetErrorType();
32503248
value.SetCompilerType(swift_error_proto_type);
3251-
3249+
32523250
error_valobj_sp = ValueObjectConstResult::Create(
32533251
m_process, value, name);
3254-
3252+
32553253
if (error_valobj_sp && error_valobj_sp->GetError().Success()) {
32563254
error_valobj_sp = error_valobj_sp->GetQualifiedRepresentationIfAvailable(
32573255
lldb::eDynamicCanRunTarget, true);
@@ -3580,7 +3578,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
35803578
return addr;
35813579

35823580
AppleObjCRuntime *objc_runtime = GetObjCRuntime();
3583-
3581+
35843582
if (objc_runtime) {
35853583
// tagged pointers don't perform any masking
35863584
if (objc_runtime->IsTaggedPointer(addr))
@@ -3627,16 +3625,16 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
36273625

36283626
if (strategy == SwiftASTContext::NonTriviallyManagedReferenceStrategy::eWeak) {
36293627
bool is_indirect = true;
3630-
3628+
36313629
// On non-objc platforms, the weak reference pointer always pointed to a
36323630
// runtime structure.
36333631
// For ObjC platforms, the masked value determines whether it is indirect.
3634-
3632+
36353633
uint32_t value = 0;
3636-
3634+
36373635
if (objc_runtime)
36383636
{
3639-
3637+
36403638
if (is_intel) {
36413639
if (is_64) {
36423640
mask = SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_MASK;
@@ -3661,17 +3659,17 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
36613659
mask = SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_MASK;
36623660
value = SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_VALUE;
36633661
}
3664-
3662+
36653663
is_indirect = ((addr & mask) == value);
3666-
3664+
36673665
if (!is_indirect)
36683666
return addr;
3669-
3667+
36703668
// The masked value of address is a pointer to the runtime structure.
36713669
// The first field of the structure is the actual pointer.
36723670
Process *process = GetProcess();
36733671
Status error;
3674-
3672+
36753673
lldb::addr_t masked_addr = addr & ~mask;
36763674
lldb::addr_t isa_addr = process->ReadPointerFromMemory(masked_addr, error);
36773675
if (error.Fail())
@@ -3680,8 +3678,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
36803678
return addr;
36813679
}
36823680
return isa_addr;
3683-
3684-
3681+
36853682
} else {
36863683
if (is_arm && is_64)
36873684
mask = SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS;
@@ -3694,7 +3691,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
36943691

36953692
return addr & ~mask;
36963693
}
3697-
3694+
36983695
return addr;
36993696
}
37003697

@@ -4014,24 +4011,23 @@ llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn(
40144011
default:
40154012
break;
40164013
}
4017-
4018-
4014+
40194015
if (error_reg_name.empty())
40204016
return error_val;
4021-
4017+
40224018
RegisterContextSP reg_ctx = frame_sp->GetRegisterContext();
40234019
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(error_reg_name);
40244020
lldbassert(reg_info && "didn't get the right register name for swift error register");
40254021
if (!reg_info)
40264022
return error_val;
4027-
4023+
40284024
RegisterValue reg_value;
40294025
if (!reg_ctx->ReadRegister(reg_info, reg_value))
40304026
{
40314027
// Do some logging here.
40324028
return error_val;
40334029
}
4034-
4030+
40354031
lldb::addr_t error_addr = reg_value.GetAsUInt64();
40364032
if (error_addr == 0)
40374033
return error_val;
@@ -4049,42 +4045,42 @@ llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn(
40494045
llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationBeforeReturn(
40504046
lldb::StackFrameSP frame_sp, bool &need_to_check_after_return) {
40514047
llvm::Optional<Value> error_val;
4052-
4048+
40534049
if (!frame_sp)
40544050
{
40554051
need_to_check_after_return = false;
40564052
return error_val;
40574053
}
4058-
4054+
40594055
// For Architectures where the error isn't returned in a register,
40604056
// there's a magic variable that points to the value. Check that first:
4061-
4057+
40624058
ConstString error_location_name("$error");
40634059
VariableListSP variables_sp = frame_sp->GetInScopeVariableList(false);
40644060
VariableSP error_loc_var_sp = variables_sp->FindVariable(
40654061
error_location_name, eValueTypeVariableArgument);
40664062
if (error_loc_var_sp) {
40674063
need_to_check_after_return = false;
4068-
4064+
40694065
ValueObjectSP error_loc_val_sp = frame_sp->GetValueObjectForFrameVariable(
40704066
error_loc_var_sp, eNoDynamicValues);
40714067
if (error_loc_val_sp && error_loc_val_sp->GetError().Success())
40724068
error_val = error_loc_val_sp->GetValue();
40734069

40744070
return error_val;
40754071
}
4076-
4072+
40774073
// Otherwise, see if we know which register it lives in from the calling convention.
40784074
// This should probably go in the ABI plugin not here, but the Swift ABI can change with
40794075
// swiftlang versions and that would make it awkward in the ABI.
4080-
4076+
40814077
Function *func = frame_sp->GetSymbolContext(eSymbolContextFunction).function;
40824078
if (!func)
40834079
{
40844080
need_to_check_after_return = false;
40854081
return error_val;
40864082
}
4087-
4083+
40884084
need_to_check_after_return = func->CanThrow();
40894085
return error_val;
40904086

0 commit comments

Comments
 (0)