This commit is contained in:
@@ -127,8 +127,14 @@ void print_stacktrace() {
|
||||
void* addr1 = __builtin_return_address(1); // assert_failed
|
||||
void* addr2 = __builtin_return_address(2); // caller of ASSERT
|
||||
|
||||
if (addr1) addresses.push_back(addr1);
|
||||
if (addr2) addresses.push_back(addr2);
|
||||
// Adjust addresses to point to call site instead of return address
|
||||
// Subtract a small offset to get the call instruction instead of the return address
|
||||
if (addr1) {
|
||||
addresses.push_back(static_cast<char*>(addr1) - 1);
|
||||
}
|
||||
if (addr2) {
|
||||
addresses.push_back(static_cast<char*>(addr2) - 1);
|
||||
}
|
||||
|
||||
if (addresses.empty()) {
|
||||
std::cerr << " " << colors::red << "[no frames available]" << colors::reset << "\n";
|
||||
@@ -160,13 +166,11 @@ void print_stacktrace() {
|
||||
void assert_failed(
|
||||
bool condition,
|
||||
std::string_view message,
|
||||
std::source_location location = std::source_location::current()
|
||||
std::source_location location
|
||||
) {
|
||||
if (!condition) {
|
||||
std::cerr << std::endl
|
||||
<< "Assertion failed at " << location.file_name() << ":" << location.line() << ": "
|
||||
<< location.function_name() << ": " << std::endl
|
||||
<< colors::red << message << colors::reset << std::endl << std::endl;
|
||||
std::cerr << colors::red << "Assertion failed at " << location.file_name() << ":" << location.line() << ": "
|
||||
<< location.function_name() << ": " << message << colors::reset << "\n";
|
||||
print_stacktrace();
|
||||
std::abort();
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ bool load_config(const std::string& config_path, ServerConfig& config) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test incremental build comment
|
||||
// Line number accuracy improved
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
|
Reference in New Issue
Block a user