diff --git a/src/assert.hpp b/src/assert.hpp index a18dd67..a80a7fe 100644 --- a/src/assert.hpp +++ b/src/assert.hpp @@ -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(addr1) - 1); + } + if (addr2) { + addresses.push_back(static_cast(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(); } diff --git a/src/config.cpp b/src/config.cpp index 42e4829..e3f1e6b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -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) {