@@ -1245,8 +1245,7 @@ const CompilerType &SwiftLanguageRuntime::GetBoxMetadataType() {
1245
1245
ClangASTContext::GetScratch (GetProcess ()->GetTarget ())) {
1246
1246
CompilerType voidstar =
1247
1247
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 );
1250
1249
1251
1250
m_box_metadata_type = ast_ctx->GetOrCreateStructForIdentifier (
1252
1251
g_type_name, {{" kind" , voidstar}, {" offset" , uint32}}, is_packed);
@@ -1626,7 +1625,7 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type,
1626
1625
if (!scratch_ctx)
1627
1626
return llvm::None;
1628
1627
}
1629
-
1628
+
1630
1629
auto *remote_ast = &GetRemoteASTContext (*module_ctx);
1631
1630
1632
1631
if (log)
@@ -1696,7 +1695,7 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type,
1696
1695
bool safe_to_use_remote_ast = true ;
1697
1696
if (swift::Decl *type_decl = swift_type->getNominalOrBoundGenericNominal ())
1698
1697
safe_to_use_remote_ast &= ASTVerifier::Verify (type_decl);
1699
-
1698
+
1700
1699
// Use RemoteAST to determine the member offset.
1701
1700
if (safe_to_use_remote_ast) {
1702
1701
swift::remoteAST::Result<uint64_t > result = remote_ast->getOffsetOfMember (
@@ -2052,26 +2051,26 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
2052
2051
llvm::dyn_cast<swift::OpaqueTypeArchetypeType>(type);
2053
2052
if (!opaque_type)
2054
2053
return type;
2055
-
2054
+
2056
2055
// Try to find the symbol for the opaque type descriptor in the
2057
2056
// process.
2058
2057
auto mangled_name = ConstString (
2059
2058
mangler.mangleOpaqueTypeDescriptor (opaque_type->getDecl ()));
2060
-
2059
+
2061
2060
SymbolContextList found;
2062
2061
target.GetImages ().FindSymbolsWithNameAndType (mangled_name,
2063
2062
eSymbolTypeData, found);
2064
-
2063
+
2065
2064
if (found.GetSize () == 0 )
2066
2065
return type;
2067
-
2066
+
2068
2067
swift::Type result_type;
2069
-
2068
+
2070
2069
for (unsigned i = 0 , e = found.GetSize (); i < e; ++i) {
2071
2070
SymbolContext found_sc;
2072
2071
if (!found.GetContextAtIndex (i, found_sc))
2073
2072
continue ;
2074
-
2073
+
2075
2074
// See if the symbol has an address.
2076
2075
if (!found_sc.symbol )
2077
2076
continue ;
@@ -2088,7 +2087,7 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
2088
2087
swift::remote::RemoteAddress (addr),
2089
2088
opaque_type->getSubstitutions (),
2090
2089
opaque_type->getOrdinal ());
2091
-
2090
+
2092
2091
if (!underlying_type_result)
2093
2092
continue ;
2094
2093
@@ -2102,22 +2101,22 @@ SwiftLanguageRuntime::DoArchetypeBindingForType(StackFrame &stack_frame,
2102
2101
return type;
2103
2102
}
2104
2103
}
2105
-
2104
+
2106
2105
if (!result_type)
2107
2106
return type;
2108
-
2107
+
2109
2108
return result_type;
2110
2109
},
2111
2110
swift::LookUpConformanceInModule (module_decl),
2112
2111
swift::SubstFlags::DesugarMemberTypes
2113
2112
| swift::SubstFlags::SubstituteOpaqueArchetypes);
2114
-
2113
+
2115
2114
// Stop if we've reached a fixpoint where we can't further resolve opaque
2116
2115
// types.
2117
2116
if (old_type->isEqual (target_swift_type))
2118
2117
break ;
2119
2118
}
2120
-
2119
+
2121
2120
target_swift_type = target_swift_type.subst (
2122
2121
[this , &stack_frame,
2123
2122
&scratch_ctx](swift::SubstitutableType *type) -> swift::Type {
@@ -2785,8 +2784,8 @@ GetThunkKind(llvm::StringRef symbol_name)
2785
2784
case swift::Demangle::Node::Kind::ProtocolWitness:
2786
2785
if (node_ptr->getNumChildren () == 0 )
2787
2786
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)
2790
2789
return ThunkKind::ProtocolConformance;
2791
2790
break ;
2792
2791
case swift::Demangle::Node::Kind::ReabstractionThunkHelper:
@@ -2796,8 +2795,8 @@ GetThunkKind(llvm::StringRef symbol_name)
2796
2795
case swift::Demangle::Node::Kind::Allocator:
2797
2796
if (node_ptr->getNumChildren () == 0 )
2798
2797
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)
2801
2800
return ThunkKind::AllocatingInit;
2802
2801
break ;
2803
2802
default :
@@ -2850,11 +2849,11 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc,
2850
2849
SymbolContext &sc) {
2851
2850
if (!curr_sc.module_sp )
2852
2851
return false ;
2853
-
2852
+
2854
2853
SymbolContextList sc_list;
2855
2854
swift::Demangle::Context demangle_ctx;
2856
2855
// Make sure this is a partial apply:
2857
-
2856
+
2858
2857
std::string apply_target = demangle_ctx.getThunkTarget (apply_name.GetStringRef ());
2859
2858
if (!apply_target.empty ()) {
2860
2859
curr_sc.module_sp ->FindFunctions (ConstString (apply_target), NULL ,
@@ -2863,7 +2862,7 @@ bool SwiftLanguageRuntime::GetTargetOfPartialApply(SymbolContext &curr_sc,
2863
2862
size_t num_symbols = sc_list.GetSize ();
2864
2863
if (num_symbols == 0 )
2865
2864
return false ;
2866
-
2865
+
2867
2866
CompileUnit *curr_cu = curr_sc.comp_unit ;
2868
2867
2869
2868
size_t num_found = 0 ;
@@ -2925,7 +2924,7 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
2925
2924
// keeps this list and the one in IsSymbolARuntimeThunk in sync.
2926
2925
if (!symbol || !IsSymbolARuntimeThunk (*symbol))
2927
2926
return new_thread_plan_sp;
2928
-
2927
+
2929
2928
// Only do this if you are at the beginning of the thunk function:
2930
2929
lldb::addr_t cur_addr = thread.GetRegisterContext ()->GetPC ();
2931
2930
lldb::addr_t symbol_addr = symbol->GetAddress ().GetLoadAddress (
@@ -2937,10 +2936,9 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
2937
2936
Address target_address;
2938
2937
ConstString symbol_mangled_name = symbol->GetMangled ().GetMangledName ();
2939
2938
const char *symbol_name = symbol_mangled_name.AsCString ();
2940
-
2939
+
2941
2940
ThunkKind thunk_kind = GetThunkKind (symbol_mangled_name.GetStringRef ());
2942
2941
ThunkAction thunk_action = GetThunkAction (thunk_kind);
2943
-
2944
2942
2945
2943
switch (thunk_action)
2946
2944
{
@@ -3091,7 +3089,7 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
3091
3089
}
3092
3090
break ;
3093
3091
}
3094
-
3092
+
3095
3093
if (target_address.IsValid ()) {
3096
3094
new_thread_plan_sp.reset (
3097
3095
new ThreadPlanRunToAddress (thread, target_address, stop_others));
@@ -3248,10 +3246,10 @@ SwiftLanguageRuntime::CalculateErrorValueObjectFromValue(
3248
3246
3249
3247
CompilerType swift_error_proto_type = ast_context->GetErrorType ();
3250
3248
value.SetCompilerType (swift_error_proto_type);
3251
-
3249
+
3252
3250
error_valobj_sp = ValueObjectConstResult::Create (
3253
3251
m_process, value, name);
3254
-
3252
+
3255
3253
if (error_valobj_sp && error_valobj_sp->GetError ().Success ()) {
3256
3254
error_valobj_sp = error_valobj_sp->GetQualifiedRepresentationIfAvailable (
3257
3255
lldb::eDynamicCanRunTarget, true );
@@ -3580,7 +3578,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
3580
3578
return addr;
3581
3579
3582
3580
AppleObjCRuntime *objc_runtime = GetObjCRuntime ();
3583
-
3581
+
3584
3582
if (objc_runtime) {
3585
3583
// tagged pointers don't perform any masking
3586
3584
if (objc_runtime->IsTaggedPointer (addr))
@@ -3627,16 +3625,16 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
3627
3625
3628
3626
if (strategy == SwiftASTContext::NonTriviallyManagedReferenceStrategy::eWeak) {
3629
3627
bool is_indirect = true ;
3630
-
3628
+
3631
3629
// On non-objc platforms, the weak reference pointer always pointed to a
3632
3630
// runtime structure.
3633
3631
// For ObjC platforms, the masked value determines whether it is indirect.
3634
-
3632
+
3635
3633
uint32_t value = 0 ;
3636
-
3634
+
3637
3635
if (objc_runtime)
3638
3636
{
3639
-
3637
+
3640
3638
if (is_intel) {
3641
3639
if (is_64) {
3642
3640
mask = SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_MASK;
@@ -3661,17 +3659,17 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
3661
3659
mask = SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_MASK;
3662
3660
value = SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_VALUE;
3663
3661
}
3664
-
3662
+
3665
3663
is_indirect = ((addr & mask) == value);
3666
-
3664
+
3667
3665
if (!is_indirect)
3668
3666
return addr;
3669
-
3667
+
3670
3668
// The masked value of address is a pointer to the runtime structure.
3671
3669
// The first field of the structure is the actual pointer.
3672
3670
Process *process = GetProcess ();
3673
3671
Status error;
3674
-
3672
+
3675
3673
lldb::addr_t masked_addr = addr & ~mask;
3676
3674
lldb::addr_t isa_addr = process->ReadPointerFromMemory (masked_addr, error);
3677
3675
if (error.Fail ())
@@ -3680,8 +3678,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
3680
3678
return addr;
3681
3679
}
3682
3680
return isa_addr;
3683
-
3684
-
3681
+
3685
3682
} else {
3686
3683
if (is_arm && is_64)
3687
3684
mask = SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS;
@@ -3694,7 +3691,7 @@ SwiftLanguageRuntime::MaybeMaskNonTrivialReferencePointer(
3694
3691
3695
3692
return addr & ~mask;
3696
3693
}
3697
-
3694
+
3698
3695
return addr;
3699
3696
}
3700
3697
@@ -4014,24 +4011,23 @@ llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn(
4014
4011
default :
4015
4012
break ;
4016
4013
}
4017
-
4018
-
4014
+
4019
4015
if (error_reg_name.empty ())
4020
4016
return error_val;
4021
-
4017
+
4022
4018
RegisterContextSP reg_ctx = frame_sp->GetRegisterContext ();
4023
4019
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName (error_reg_name);
4024
4020
lldbassert (reg_info && " didn't get the right register name for swift error register" );
4025
4021
if (!reg_info)
4026
4022
return error_val;
4027
-
4023
+
4028
4024
RegisterValue reg_value;
4029
4025
if (!reg_ctx->ReadRegister (reg_info, reg_value))
4030
4026
{
4031
4027
// Do some logging here.
4032
4028
return error_val;
4033
4029
}
4034
-
4030
+
4035
4031
lldb::addr_t error_addr = reg_value.GetAsUInt64 ();
4036
4032
if (error_addr == 0 )
4037
4033
return error_val;
@@ -4049,42 +4045,42 @@ llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn(
4049
4045
llvm::Optional<Value> SwiftLanguageRuntime::GetErrorReturnLocationBeforeReturn (
4050
4046
lldb::StackFrameSP frame_sp, bool &need_to_check_after_return) {
4051
4047
llvm::Optional<Value> error_val;
4052
-
4048
+
4053
4049
if (!frame_sp)
4054
4050
{
4055
4051
need_to_check_after_return = false ;
4056
4052
return error_val;
4057
4053
}
4058
-
4054
+
4059
4055
// For Architectures where the error isn't returned in a register,
4060
4056
// there's a magic variable that points to the value. Check that first:
4061
-
4057
+
4062
4058
ConstString error_location_name (" $error" );
4063
4059
VariableListSP variables_sp = frame_sp->GetInScopeVariableList (false );
4064
4060
VariableSP error_loc_var_sp = variables_sp->FindVariable (
4065
4061
error_location_name, eValueTypeVariableArgument);
4066
4062
if (error_loc_var_sp) {
4067
4063
need_to_check_after_return = false ;
4068
-
4064
+
4069
4065
ValueObjectSP error_loc_val_sp = frame_sp->GetValueObjectForFrameVariable (
4070
4066
error_loc_var_sp, eNoDynamicValues);
4071
4067
if (error_loc_val_sp && error_loc_val_sp->GetError ().Success ())
4072
4068
error_val = error_loc_val_sp->GetValue ();
4073
4069
4074
4070
return error_val;
4075
4071
}
4076
-
4072
+
4077
4073
// Otherwise, see if we know which register it lives in from the calling convention.
4078
4074
// This should probably go in the ABI plugin not here, but the Swift ABI can change with
4079
4075
// swiftlang versions and that would make it awkward in the ABI.
4080
-
4076
+
4081
4077
Function *func = frame_sp->GetSymbolContext (eSymbolContextFunction).function ;
4082
4078
if (!func)
4083
4079
{
4084
4080
need_to_check_after_return = false ;
4085
4081
return error_val;
4086
4082
}
4087
-
4083
+
4088
4084
need_to_check_after_return = func->CanThrow ();
4089
4085
return error_val;
4090
4086
0 commit comments