Skip to content

Commit 2063882

Browse files
committed
[lldb] Fix issues in LanguageRuntime/Swift (NFC)
- Add missing ASCII art to header and implementation files - Remove trailing whilespace - Reflow comments - Fix clang formatting issues
1 parent e47653c commit 2063882

10 files changed

+106
-52
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===-- LLDBMemoryReader.cpp ----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
#include "LLDBMemoryReader.h"
214
#include "lldb/Core/Address.h"
315
#include "lldb/Core/Section.h"
@@ -475,8 +487,8 @@ LLDBMemoryReader::addModuleToAddressMap(ModuleSP module,
475487
auto last_section =
476488
section_list->GetSectionAtIndex(section_list->GetSize() - 1);
477489

478-
// The total size is the last section's file address plus size, subtracting the
479-
// first section's file address.
490+
// The total size is the last section's file address plus size, subtracting
491+
// the first section's file address.
480492
auto start_file_address = first_section->GetFileAddress();
481493
uint64_t end_file_address =
482494
last_section->GetFileAddress() + last_section->GetByteSize();
@@ -551,7 +563,7 @@ LLDBMemoryReader::getFileAddressAndModuleForTaggedAddress(
551563
// when constructing the range to module map.
552564
file_address = tagged_address - std::prev(pair_iterator)->first;
553565

554-
// We also need to add the module's file address, since we subtract it when
566+
// We also need to add the module's file address, since we subtract it when
555567
// building the range to module map.
556568
file_address += section_list->GetSectionAtIndex(0)->GetFileAddress();
557569
return {{file_address, module}};

lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.h

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
//===-- LLDBMemoryReader.h --------------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
112

213
#ifndef liblldb_LLDBMemoryReader_h_
314
#define liblldb_LLDBMemoryReader_h_
415

5-
616
#include "SwiftLanguageRuntime.h"
717

818
// We need to include ReflectionContext.h before TypeLowering.h to avoid
@@ -13,7 +23,6 @@
1323
#include "llvm/ADT/SmallSet.h"
1424
#include "llvm/Support/Memory.h"
1525

16-
1726
namespace lldb_private {
1827
class LLDBMemoryReader : public swift::remote::MemoryReader {
1928
public:
@@ -67,19 +76,19 @@ class LLDBMemoryReader : public swift::remote::MemoryReader {
6776
llvm::Optional<std::pair<uint64_t, lldb::ModuleSP>>
6877
getFileAddressAndModuleForTaggedAddress(uint64_t tagged_address) const;
6978

70-
/// Resolves the address by either mapping a tagged address back to an LLDB
71-
/// Address with section + offset, or, in case the address is not tagged,
79+
/// Resolves the address by either mapping a tagged address back to an LLDB
80+
/// Address with section + offset, or, in case the address is not tagged,
7281
/// constructing an LLDB address with just the offset.
73-
/// \return an Address with Section + offset if we succesfully converted a tagged
74-
/// address back, an Address with just an offset if the address was not tagged,
75-
/// and None if the address was tagged but we couldn't convert it back to an
76-
/// Address.
82+
/// \return an Address with Section + offset if we succesfully converted a
83+
/// tagged address back, an Address with just an offset if the address was not
84+
/// tagged, and None if the address was tagged but we couldn't convert it back
85+
/// to an Address.
7786
llvm::Optional<Address> resolveRemoteAddress(uint64_t address) const;
7887

79-
/// Reads memory from the symbol rich binary from the address into dest.
80-
/// \return true if it was able to successfully read memory.
81-
llvm::Optional<Address> resolveRemoteAddressFromSymbolObjectFile(uint64_t address) const;
82-
88+
/// Reads memory from the symbol rich binary from the address into dest.
89+
/// \return true if it was able to successfully read memory.
90+
llvm::Optional<Address>
91+
resolveRemoteAddressFromSymbolObjectFile(uint64_t address) const;
8392

8493
private:
8594
Process &m_process;
@@ -104,17 +113,15 @@ llvm::Optional<Address> resolveRemoteAddressFromSymbolObjectFile(uint64_t addres
104113

105114
/// The set of modules where we should read memory from the symbol file's
106115
/// object file instead of the main object file.
107-
llvm::SmallSet<lldb::ModuleSP, 8>
108-
m_modules_with_metadata_in_symbol_obj_file;
116+
llvm::SmallSet<lldb::ModuleSP, 8> m_modules_with_metadata_in_symbol_obj_file;
109117

110118
/// The bit used to tag LLDB's virtual addresses as such. See \c
111119
/// m_range_module_map.
112120
const static uint64_t LLDB_FILE_ADDRESS_BIT = 0x2000000000000000;
113121
static_assert(LLDB_FILE_ADDRESS_BIT & SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK,
114-
"LLDB file address bit not in spare bits mask!");
122+
"LLDB file address bit not in spare bits mask!");
115123
static_assert(LLDB_FILE_ADDRESS_BIT & SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK,
116-
"LLDB file address bit not in spare bits mask!");
117-
124+
"LLDB file address bit not in spare bits mask!");
118125
};
119126
} // namespace lldb_private
120127
#endif

lldb/source/Plugins/LanguageRuntime/Swift/ReflectionContextInterface.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===-- ReflectionContextInterface.h ----------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
#ifndef liblldb_SwiftReflectionContextInterface_h_
214
#define liblldb_SwiftReflectionContextInterface_h_
315

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static bool HasReflectionInfo(ObjectFile *obj_file) {
451451
return hasReflectionSection;
452452
}
453453

454-
ThreadSafeReflectionContext
454+
ThreadSafeReflectionContext
455455
SwiftLanguageRuntimeImpl::GetReflectionContext() {
456456
m_reflection_ctx_mutex.lock();
457457
SetupReflection();
@@ -502,7 +502,7 @@ void SwiftLanguageRuntimeImpl::SetupReflection() {
502502
std::lock_guard<std::recursive_mutex> lock(m_reflection_ctx_mutex);
503503
if (m_initialized_reflection_ctx)
504504
return;
505-
505+
506506
// The global ABI bit is read by the Swift runtime library.
507507
SetupABIBit();
508508

@@ -929,7 +929,7 @@ void SwiftLanguageRuntimeImpl::ModulesDidLoad(const ModuleList &module_list) {
929929
m_modules_to_add.AppendIfNeeded(module_list);
930930
}
931931

932-
std::string
932+
std::string
933933
SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Result(ValueObject &object) {
934934
Log *log(GetLog(LLDBLog::DataFormatters | LLDBLog::Expressions));
935935
std::string expr_string
@@ -941,12 +941,12 @@ SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Result(ValueObject &object) {
941941
return expr_string;
942942
}
943943

944-
std::string
944+
std::string
945945
SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Ref(ValueObject &object) {
946946
Log *log(GetLog(LLDBLog::DataFormatters | LLDBLog::Expressions));
947947

948948
StreamString expr_string;
949-
std::string expr_str
949+
std::string expr_str
950950
= llvm::formatv("Swift._DebuggerSupport.stringForPrintObject(Swift."
951951
"unsafeBitCast({0:x}, to: AnyObject.self))",
952952
object.GetValueAsUnsigned(0)).str();
@@ -963,7 +963,7 @@ static const ExecutionContextRef *GetSwiftExeCtx(ValueObject &valobj) {
963963
: nullptr;
964964
}
965965

966-
std::string
966+
std::string
967967
SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Copy(ValueObject &object,
968968
lldb::addr_t &copy_location)
969969
{
@@ -981,7 +981,7 @@ SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Copy(ValueObject &object,
981981
// printing, as IRGen requires a fully realized type to work on.
982982
StackFrameSP frame_sp = object.GetFrameSP();
983983
if (!frame_sp)
984-
frame_sp
984+
frame_sp
985985
= m_process.GetThreadList().GetSelectedThread()
986986
->GetSelectedFrame(DoNoSelectMostRelevantFrame);
987987

@@ -1020,20 +1020,20 @@ SwiftLanguageRuntimeImpl::GetObjectDescriptionExpr_Copy(ValueObject &object,
10201020
return {};
10211021
}
10221022

1023-
std::string expr_string
1023+
std::string expr_string
10241024
= llvm::formatv("Swift._DebuggerSupport.stringForPrintObject(Swift."
10251025
"UnsafePointer<{0}>(bitPattern: {1:x})!.pointee)",
10261026
static_type.GetTypeName().GetCString(), copy_location).str();
10271027
if (log)
10281028
log->Printf("[GetObjectDescriptionExpr_Copy] expression: %s",
10291029
expr_string.c_str());
1030-
1030+
10311031
return expr_string;
10321032
}
10331033

1034-
bool
1035-
SwiftLanguageRuntimeImpl::RunObjectDescriptionExpr(ValueObject &object,
1036-
std::string &expr_string,
1034+
bool
1035+
SwiftLanguageRuntimeImpl::RunObjectDescriptionExpr(ValueObject &object,
1036+
std::string &expr_string,
10371037
Stream &result)
10381038
{
10391039
Log *log(GetLog(LLDBLog::DataFormatters | LLDBLog::Expressions));
@@ -1043,10 +1043,10 @@ SwiftLanguageRuntimeImpl::RunObjectDescriptionExpr(ValueObject &object,
10431043
eval_options.SetSuppressPersistentResult(true);
10441044
eval_options.SetGenerateDebugInfo(true);
10451045
eval_options.SetTimeout(m_process.GetUtilityExpressionTimeout());
1046-
1046+
10471047
StackFrameSP frame_sp = object.GetFrameSP();
10481048
if (!frame_sp)
1049-
frame_sp
1049+
frame_sp
10501050
= m_process.GetThreadList().GetSelectedThread()
10511051
->GetSelectedFrame(DoNoSelectMostRelevantFrame);
10521052
if (!frame_sp) {
@@ -1059,7 +1059,7 @@ SwiftLanguageRuntimeImpl::RunObjectDescriptionExpr(ValueObject &object,
10591059
result_sp, eval_options);
10601060

10611061
if (log) {
1062-
const char *eval_result_str
1062+
const char *eval_result_str
10631063
= m_process.ExecutionResultAsCString(eval_result);
10641064
log->Printf("[RunObjectDescriptionExpr] %s", eval_result_str);
10651065
}
@@ -1902,7 +1902,7 @@ void SwiftLanguageRuntimeImpl::WillStartExecutingUserExpression(
19021902
if (!ts) {
19031903
LLDB_LOG(log, "type system no longer live");
19041904
return;
1905-
}
1905+
}
19061906
ConstString BoolName("bool");
19071907
llvm::Optional<uint64_t> bool_size =
19081908
ts->GetBuiltinTypeByName(BoolName).GetByteSize(nullptr);
@@ -1977,7 +1977,7 @@ void SwiftLanguageRuntimeImpl::DidFinishExecutingUserExpression(
19771977
if (!ts) {
19781978
LLDB_LOG(log, "type system no longer live");
19791979
return;
1980-
}
1980+
}
19811981
ConstString BoolName("bool");
19821982
llvm::Optional<uint64_t> bool_size =
19831983
ts->GetBuiltinTypeByName(BoolName).GetByteSize(nullptr);
@@ -2581,7 +2581,7 @@ SwiftLanguageRuntime::GetRuntimeUnwindPlan(ProcessSP process_sp,
25812581
RegisterContext *regctx,
25822582
bool &behaves_like_zeroth_frame) {
25832583
LLDB_SCOPED_TIMER();
2584-
2584+
25852585
Target &target(process_sp->GetTarget());
25862586
auto arch = target.GetArchitecture();
25872587
llvm::Optional<AsyncUnwindRegisterNumbers> regnums =
@@ -2757,7 +2757,7 @@ static UnwindPlanSP
27572757
GetFollowAsyncContextUnwindPlan(RegisterContext *regctx, ArchSpec &arch,
27582758
bool &behaves_like_zeroth_frame) {
27592759
LLDB_SCOPED_TIMER();
2760-
2760+
27612761
UnwindPlan::RowSP row(new UnwindPlan::Row);
27622762
const int32_t ptr_size = 8;
27632763
row->SetOffset(0);

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class SwiftLanguageRuntime : public LanguageRuntime {
132132
/// Return true if name is a Swift async function, await resume partial
133133
/// function, or suspend resume partial function symbol.
134134
static bool IsAnySwiftAsyncFunctionSymbol(llvm::StringRef name);
135-
135+
136136
/// Return the async context address using the target's specific register.
137137
static lldb::addr_t GetAsyncContext(RegisterContext *regctx);
138138

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ class LLDBTypeInfoProvider : public swift::remote::TypeInfoProvider {
312312
mangledName.str().c_str());
313313
return nullptr;
314314
}
315-
315+
316316
return GetOrCreateTypeInfo(clang_type);
317317
}
318-
318+
319319
const swift::reflection::TypeInfo *
320320
GetOrCreateTypeInfo(CompilerType clang_type) {
321321
if (auto ti = m_runtime.lookupClangTypeInfo(clang_type))
@@ -1239,7 +1239,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
12391239
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext();
12401240
if (!reflection_ctx)
12411241
return false;
1242-
1242+
12431243
// Return a tuple type, with one element per pack element and its
12441244
// type has all DependentGenericParamType that appear in type packs
12451245
// substituted.
@@ -1269,7 +1269,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
12691269

12701270
Target &target = m_process.GetTarget();
12711271
size_t ptr_size = m_process.GetAddressByteSize();
1272-
1272+
12731273
swift::Demangle::Demangler dem;
12741274

12751275
auto expand_pack_type = [&](ConstString mangled_pack_type,
@@ -1535,7 +1535,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
15351535
if (auto *tr = sc.get_typeref()) {
15361536
swift::Demangle::Demangler dem;
15371537
swift::Demangle::NodePointer node = tr->getDemangling(dem);
1538-
// Skip private Foundation types since it's unlikely that would be
1538+
// Skip private Foundation types since it's unlikely that would be
15391539
// useful to users.
15401540
if (IsPrivateNSClass(node))
15411541
return false;
@@ -2067,7 +2067,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_IndirectEnumCase(
20672067
lldb::addr_t box_location = m_process.ReadPointerFromMemory(box_addr, error);
20682068
if (box_location == LLDB_INVALID_ADDRESS)
20692069
return false;
2070-
2070+
20712071
box_location = MaskMaybeBridgedPointer(m_process, box_location);
20722072
lldb::addr_t box_value = box_addr + in_value.GetByteOffset();
20732073
Flags type_info(child_type.GetTypeInfo());
@@ -2539,7 +2539,7 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type,
25392539
{"$s14CoreFoundation7CGFloatVD", "$s12CoreGraphics7CGFloatVD"}};
25402540

25412541
auto it = known_types_with_redefined_modules.find(mangled_name);
2542-
if (it != known_types_with_redefined_modules.end())
2542+
if (it != known_types_with_redefined_modules.end())
25432543
mangled_name = it->second;
25442544

25452545
swift::Demangle::NodePointer node =

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ class SwiftLanguageRuntimeImpl {
316316
// types of swift objects.
317317
std::string GetObjectDescriptionExpr_Result(ValueObject &object);
318318
std::string GetObjectDescriptionExpr_Ref(ValueObject &object);
319-
std::string GetObjectDescriptionExpr_Copy(ValueObject &object,
319+
std::string GetObjectDescriptionExpr_Copy(ValueObject &object,
320320
lldb::addr_t &copy_location);
321-
bool RunObjectDescriptionExpr(ValueObject &object, std::string &expr_string,
321+
bool RunObjectDescriptionExpr(ValueObject &object, std::string &expr_string,
322322
Stream &result);
323323
/// We have to load swift dependent libraries by hand, but if they
324324
/// are missing, we shouldn't keep trying.

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ std::string SwiftLanguageRuntime::DemangleSymbolAsString(
716716
options.DisplayLocalNameContexts = false;
717717
options.DisplayDebuggerGeneratedModule = false;
718718
options.ShowFunctionArgumentTypes = true;
719-
break;
719+
break;
720720
}
721721

722722
if (sc) {
@@ -1315,7 +1315,7 @@ SwiftLanguageRuntime::GetGenericSignature(StringRef function_name,
13151315

13161316
if (error)
13171317
return {};
1318-
1318+
13191319
// Build the maps associating value and type packs with their count
13201320
// arguments.
13211321
unsigned next_count = 0;

lldb/source/Plugins/LanguageRuntime/Swift/SwiftMetadataCache.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===-- SwiftMetadataCache.cpp --------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
#include "SwiftMetadataCache.h"
214

315
#include "lldb/Utility/DataEncoder.h"

0 commit comments

Comments
 (0)