Skip to content

Commit 28bf99e

Browse files
author
git apple-llvm automerger
committed
Merge commit '4b7dbf208f7e' from swift/release/6.1 into stable/20240723
2 parents e9fd15b + 4b7dbf2 commit 28bf99e

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

lldb/include/lldb/Utility/LLDBAssert.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,30 @@
1919
// __FILE__ but only renders the last path component (the filename) instead of
2020
// an invocation dependent full path to that file.
2121
#define lldbassert(x) \
22-
::lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, \
23-
__FILE_NAME__, __LINE__)
22+
lldb_private::_lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, \
23+
__FILE_NAME__, __LINE__)
2424
#else
2525
#define lldbassert(x) \
26-
lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \
27-
__LINE__)
26+
lldb_private::_lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \
27+
__LINE__)
2828
#endif
2929
#endif
3030

3131
namespace lldb_private {
32-
void lldb_assert(bool expression, const char *expr_text, const char *func,
33-
const char *file, unsigned int line);
3432

33+
/// Don't use _lldb_assert directly. Use the lldbassert macro instead so that
34+
/// LLDB asserts become regular asserts in NDEBUG builds.
35+
void _lldb_assert(bool expression, const char *expr_text, const char *func,
36+
const char *file, unsigned int line);
37+
38+
/// The default LLDB assert callback, which prints to stderr.
3539
typedef void (*LLDBAssertCallback)(llvm::StringRef message,
3640
llvm::StringRef backtrace,
3741
llvm::StringRef prompt);
3842

43+
/// Replace the LLDB assert callback.
3944
void SetLLDBAssertCallback(LLDBAssertCallback callback);
45+
4046
} // namespace lldb_private
4147

4248
#endif // LLDB_UTILITY_LLDBASSERT_H

lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,7 @@ lldb_private::formatters::swift::UnsafeTypeSyntheticFrontEnd::
546546

547547
m_unsafe_ptr = ::SwiftUnsafeType::Create(*valobj_sp.get());
548548

549-
lldb_assert(m_unsafe_ptr != nullptr, "Could not create Swift Unsafe Type",
550-
__FUNCTION__, __FILE__, __LINE__);
549+
lldbassert(m_unsafe_ptr != nullptr && "Could not create Swift Unsafe Type");
551550

552551
if (valobj_sp)
553552
Update();

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ LLDBMemoryReader::resolvePointer(swift::remote::RemoteAddress address,
297297
swift::remote::RemoteAbsolutePointer tagged_pointer("", tagged_address);
298298
if (tagged_address !=
299299
(uint64_t)signedPointerStripper(tagged_pointer).getOffset()) {
300-
lldb_assert(false, "Tagged pointer runs into pointer authentication mask!",
301-
__FUNCTION__, __FILE__, __LINE__);
300+
lldbassert(false &&
301+
"Tagged pointer runs into pointer authentication mask!");
302302
return process_pointer;
303303
}
304304

@@ -531,10 +531,9 @@ LLDBMemoryReader::addModuleToAddressMap(ModuleSP module,
531531
(uint64_t)signedPointerStripper(
532532
swift::remote::RemoteAbsolutePointer("", module_end_address))
533533
.getOffset()) {
534-
lldb_assert(false,
535-
"LLDBMemoryReader module to address map ran into pointer "
536-
"authentication mask!",
537-
__FUNCTION__, __FILE__, __LINE__);
534+
lldbassert(false &&
535+
"LLDBMemoryReader module to address map ran into pointer "
536+
"authentication mask!");
538537
return {};
539538
}
540539
// The address for the next image is the next pointer aligned address

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,10 +1943,8 @@ UserExpression *TypeSystemSwiftTypeRefForExpressions::GetUserExpression(
19431943
if (!target_sp)
19441944
return nullptr;
19451945
if (ctx_obj != nullptr) {
1946-
lldb_assert(0,
1947-
"Swift doesn't support 'evaluate in the context"
1948-
" of an object'.",
1949-
__FUNCTION__, __FILE__, __LINE__);
1946+
lldbassert(false &&
1947+
"Swift doesn't support 'evaluate in the context of an object'.");
19501948
return nullptr;
19511949
}
19521950

lldb/source/Utility/LLDBAssert.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
namespace lldb_private {
2222

23+
/// The default callback prints to stderr.
2324
static void DefaultAssertCallback(llvm::StringRef message,
2425
llvm::StringRef backtrace,
2526
llvm::StringRef prompt) {
@@ -31,8 +32,8 @@ static void DefaultAssertCallback(llvm::StringRef message,
3132
static std::atomic<LLDBAssertCallback> g_lldb_assert_callback =
3233
&DefaultAssertCallback;
3334

34-
void lldb_assert(bool expression, const char *expr_text, const char *func,
35-
const char *file, unsigned int line) {
35+
void _lldb_assert(bool expression, const char *expr_text, const char *func,
36+
const char *file, unsigned int line) {
3637
if (LLVM_LIKELY(expression))
3738
return;
3839

@@ -44,8 +45,6 @@ void lldb_assert(bool expression, const char *expr_text, const char *func,
4445
}
4546
#endif
4647

47-
// Print a warning and encourage the user to file a bug report, similar to
48-
// LLVM’s crash handler, and then return execution.
4948
std::string buffer;
5049
llvm::raw_string_ostream backtrace(buffer);
5150
llvm::sys::PrintStackTrace(backtrace);
@@ -54,7 +53,7 @@ void lldb_assert(bool expression, const char *expr_text, const char *func,
5453
llvm::formatv("Assertion failed: ({0}), function {1}, file {2}, line {3}",
5554
expr_text, func, file, line)
5655
.str(),
57-
backtrace.str(),
56+
buffer,
5857
"Please file a bug report against lldb reporting this failure log, and "
5958
"as many details as possible");
6059
}

0 commit comments

Comments
 (0)