Skip to content

Commit

Permalink
add demangled stacktrace in exception logs (#860)
Browse files Browse the repository at this point in the history
add demangled stacktrace in exception by function from this pr #829
  • Loading branch information
astrophysik authored Jul 3, 2023
1 parent 8849baa commit 568bda1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions runtime/php_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,14 @@ const char *php_uncaught_exception_error(const class_instance<C$Throwable> &ex)
const int64_t current_time = time(nullptr);
const char *message = ex->$message.empty() ? "(empty)" : ex->$message.c_str();
const char *src_file = kbasename(ex->$file.c_str());
vk::singleton<JsonLogger>::get().write_log(
dl_pstr("Unhandled %s from %s:%" PRIi64 "; Error %" PRIi64 "; Message: %s", ex->get_class(), src_file, ex->$line, ex->$code, message),
E_ERROR, current_time, ex->raw_trace.get_const_vector_pointer(), ex->raw_trace.count(), true);
vk::string_view log_message = dl_pstr("Unhandled %s from %s:%" PRIi64 "; Error %" PRIi64 "; Message: %s", ex->get_class(), src_file, ex->$line, ex->$code, message);
if (is_demangled_stacktrace_logs_enabled) {
vk::singleton<JsonLogger>::get().write_log_with_demangled_backtrace(log_message, E_ERROR, current_time,
ex->raw_trace.get_const_vector_pointer(), ex->raw_trace.count(), true);
} else {
vk::singleton<JsonLogger>::get().write_log(log_message, E_ERROR, current_time,
ex->raw_trace.get_const_vector_pointer(), ex->raw_trace.count(), true);
}

const char *msg = dl_pstr("%s%" PRIi64 "%sError %" PRIi64 ": %s.\nUnhandled %s caught in file %s at line %" PRIi64 ".\n"
"Backtrace:\n%s",
Expand Down
1 change: 1 addition & 0 deletions runtime/runtime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}/runtime/
set_source_files_properties(
${BASE_DIR}/server/php-engine.cpp
${BASE_DIR}/server/signal-handlers.cpp
${BASE_DIR}/server/json-logger.cpp
${BASE_DIR}/runtime/interface.cpp
${COMMON_DIR}/dl-utils-lite.cpp
${COMMON_DIR}/netconf.cpp
Expand Down

0 comments on commit 568bda1

Please sign in to comment.