This commit is contained in:
@@ -127,8 +127,14 @@ void print_stacktrace() {
|
|||||||
void* addr1 = __builtin_return_address(1); // assert_failed
|
void* addr1 = __builtin_return_address(1); // assert_failed
|
||||||
void* addr2 = __builtin_return_address(2); // caller of ASSERT
|
void* addr2 = __builtin_return_address(2); // caller of ASSERT
|
||||||
|
|
||||||
if (addr1) addresses.push_back(addr1);
|
// Adjust addresses to point to call site instead of return address
|
||||||
if (addr2) addresses.push_back(addr2);
|
// 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()) {
|
if (addresses.empty()) {
|
||||||
std::cerr << " " << colors::red << "[no frames available]" << colors::reset << "\n";
|
std::cerr << " " << colors::red << "[no frames available]" << colors::reset << "\n";
|
||||||
@@ -160,13 +166,11 @@ void print_stacktrace() {
|
|||||||
void assert_failed(
|
void assert_failed(
|
||||||
bool condition,
|
bool condition,
|
||||||
std::string_view message,
|
std::string_view message,
|
||||||
std::source_location location = std::source_location::current()
|
std::source_location location
|
||||||
) {
|
) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
std::cerr << std::endl
|
std::cerr << colors::red << "Assertion failed at " << location.file_name() << ":" << location.line() << ": "
|
||||||
<< "Assertion failed at " << location.file_name() << ":" << location.line() << ": "
|
<< location.function_name() << ": " << message << colors::reset << "\n";
|
||||||
<< location.function_name() << ": " << std::endl
|
|
||||||
<< colors::red << message << colors::reset << std::endl << std::endl;
|
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
std::abort();
|
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;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
Reference in New Issue
Block a user