未验证 提交 23439b16 编写于 作者: C Chen Weihang 提交者: GitHub

show cpp stack when catch signal (#28415)

上级 3c95acc3
...@@ -287,7 +287,7 @@ void SignalHandle(const char *data, int size) { ...@@ -287,7 +287,7 @@ void SignalHandle(const char *data, int size) {
// NOTE2: we only deal with the time info ane signal info, // NOTE2: we only deal with the time info ane signal info,
// the stack trace will generated by paddle self // the stack trace will generated by paddle self
if (StartsWith(data, "*** Aborted at")) { if (StartsWith(data, "*** Aborted at")) {
*signal_msg_dunmer_ptr << " [TimeInfo: " << std::string(data, size - 1) *signal_msg_dunmer_ptr << "\n [TimeInfo: " << std::string(data, size - 1)
<< "]\n"; << "]\n";
} else if (StartsWith(data, "***")) { } else if (StartsWith(data, "***")) {
std::string signal_info(data, size - 1); std::string signal_info(data, size - 1);
...@@ -295,14 +295,19 @@ void SignalHandle(const char *data, int size) { ...@@ -295,14 +295,19 @@ void SignalHandle(const char *data, int size) {
size_t start_pos = signal_info.rfind(useless_substr); size_t start_pos = signal_info.rfind(useless_substr);
signal_info.replace(start_pos, useless_substr.length(), ""); signal_info.replace(start_pos, useless_substr.length(), "");
*signal_msg_dunmer_ptr << " [SignalInfo: " << signal_info << "]\n"; *signal_msg_dunmer_ptr << " [SignalInfo: " << signal_info << "]\n";
// NOTE3: Here does not throw an exception,
// NOTE3: Final singal error message print.
// Here does not throw an exception,
// otherwise it will casue "terminate called recursively" // otherwise it will casue "terminate called recursively"
auto exp = platform::EnforceNotMet( std::ostringstream sout;
platform::errors::Fatal( sout << platform::GetCurrentTraceBackString();
"A serious error (%s) is detected by the operating system.", sout << "\n----------------------\nError Message "
ParseSignalErrorString(signal_info)), "Summary:\n----------------------\n";
__FILE__, __LINE__); sout << platform::errors::Fatal(
std::cout << exp.what() << (*signal_msg_dunmer_ptr).str() << std::endl; "`%s` is detected by the operating system.",
ParseSignalErrorString(signal_info))
.to_string();
std::cout << sout.str() << (*signal_msg_dunmer_ptr).str() << std::endl;
} }
} catch (...) { } catch (...) {
// Since the program has already triggered a system error, // Since the program has already triggered a system error,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册