MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / write_demangled_frame

Function write_demangled_frame

src/debug.cpp:1012–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1010
1011#if !defined(_WIN32) && !defined(__ANDROID__)
1012static void write_demangled_frame( std::ostream &out, const char *frame )
1013{
1014#if defined(__linux__)
1015 // ./cataclysm(_ZN4game13handle_actionEv+0x47e8) [0xaaaae91e80fc]
1016 static const std::regex symbol_regex( R"(^(.*)\((.*)\+(0x?[a-f0-9]*)\)\s\[(0x[a-f0-9]+)\]$)" );
1017 std::cmatch match_result;
1018 if( std::regex_search( frame, match_result, symbol_regex ) && match_result.size() == 5 ) {
1019 std::csub_match file_name = match_result[1];
1020 std::csub_match raw_symbol_name = match_result[2];
1021 std::csub_match offset = match_result[3];
1022 std::csub_match address = match_result[4];
1023 out << "\n " << file_name.str() << "(" << demangle( raw_symbol_name.str().c_str() ) << "+" <<
1024 offset.str() << ") [" << address.str() << "]";
1025 } else {
1026 out << "\n " << frame;
1027 }
1028#elif defined(MACOSX)
1029 //1 cataclysm-tiles 0x0000000102ba2244 _ZL9log_crashPKcS0_ + 608
1030 static const std::regex symbol_regex( R"(^(.*)(0x[a-f0-9]{16})\s(.*)\s\+\s([0-9]+)$)" );
1031 std::cmatch match_result;
1032 if( std::regex_search( frame, match_result, symbol_regex ) && match_result.size() == 5 ) {
1033 std::csub_match prefix = match_result[1];
1034 std::csub_match address = match_result[2];
1035 std::csub_match raw_symbol_name = match_result[3];
1036 std::csub_match offset = match_result[4];
1037 out << "\n " << prefix.str() << address.str() << ' ' << demangle( raw_symbol_name.str().c_str() )
1038 << " + " << offset.str();
1039 } else {
1040 out << "\n " << frame;
1041 }
1042#elif defined(BSD)
1043 static const std::regex symbol_regex( R"(^(0x[a-f0-9]+)\s<(.*)\+(0?x?[a-f0-9]*)>\sat\s(.*)$)" );
1044 std::cmatch match_result;
1045 if( std::regex_search( frame, match_result, symbol_regex ) && match_result.size() == 5 ) {
1046 std::csub_match address = match_result[1];
1047 std::csub_match raw_symbol_name = match_result[2];
1048 std::csub_match offset = match_result[3];
1049 std::csub_match file_name = match_result[4];
1050 out << "\n " << address.str() << " <" << demangle( raw_symbol_name.str().c_str() ) << "+" <<
1051 offset.str() << "> at " << file_name.str();
1052 } else {
1053 out << "\n " << frame;
1054 }
1055#else
1056 out << "\n " << frame;
1057#endif
1058}
1059#endif // !defined(_WIN32) && !defined(__ANDROID__)
1060
1061#if !defined(__ANDROID__)

Callers 1

debug_write_backtraceFunction · 0.85

Calls 4

demangleFunction · 0.85
sizeMethod · 0.45
strMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected