@@ -91,7 +91,7 @@ namespace RTE {
91
91
92
92
if (SymFromAddr (procHandle, exceptAddr, nullptr , symbolInfo)) {
93
93
std::string symbolName = symbolInfo->Name ;
94
- return " The symbol name at this address is " + (symbolName.empty () ? " empty for reasons unknown to man." : " ' " + symbolName + " '. " );
94
+ return " The symbol name at this address is" + (symbolName.empty () ? " empty for reasons unknown to man." : " : \" " + symbolName + " \" " );
95
95
} else {
96
96
return " Unable to get symbol name at address because:\n\n " + getLastWinErrorAsString ();
97
97
}
@@ -112,7 +112,10 @@ namespace RTE {
112
112
return EXCEPTION_CONTINUE_EXECUTION;
113
113
}
114
114
115
- exceptionDescription << getExceptionDescriptionFromCode (exceptionCode) << " at address 0x" << std::uppercase << std::hex << exceptionAddress << " .\n\n " << getSymbolNameFromAddress (processHandle, exceptionAddress) << std::endl;
115
+ std::string symbolNameAtAddress = getSymbolNameFromAddress (processHandle, exceptionAddress);
116
+ RTEError::FormatFunctionSignature (symbolNameAtAddress);
117
+
118
+ exceptionDescription << getExceptionDescriptionFromCode (exceptionCode) << " at address 0x" << std::uppercase << std::hex << exceptionAddress << " .\n\n " << symbolNameAtAddress << std::endl;
116
119
117
120
RTEStackTrace stackTrace;
118
121
@@ -291,6 +294,7 @@ namespace RTE {
291
294
292
295
std::string lineNum = std::to_string (srcLocation.line ());
293
296
std::string funcName = srcLocation.function_name ();
297
+ FormatFunctionSignature (funcName);
294
298
295
299
std::string abortMessage = " Runtime Error in file '" + fileName + " ', line " + lineNum + " ,\n in function '" + funcName + " '\n because:\n\n " + description + " \n " ;
296
300
@@ -406,4 +410,28 @@ namespace RTE {
406
410
}
407
411
return success;
408
412
}
413
+
414
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
415
+
416
+ void RTEError::FormatFunctionSignature (std::string &symbolName) {
417
+ // TODO: Expand this with more dumb signatures, or make something that makes more sense.
418
+ static const std::array<std::pair<std::regex, std::string>, 3 > stlSigs {{
419
+ {std::regex (" ( >)" ), " >" },
420
+ {std::regex (" (std::basic_string<char,std::char_traits<char>,std::allocator<char>>)" ), " std::string" },
421
+ {std::regex (" (class ?std::basic_string<char,struct ?std::char_traits<char>,class ?std::allocator<char>>)" ), " std::string" }
422
+ }};
423
+ for (const auto &[fullSig, simpleSig] : stlSigs) {
424
+ symbolName = std::regex_replace (symbolName, fullSig, simpleSig);
425
+ }
426
+ for (size_t pos = 0 ;;) {
427
+ pos += 100 ;
428
+ if (pos < symbolName.size ()) {
429
+ if (size_t lastCommaPos = symbolName.find_last_of (' ,' , pos); lastCommaPos != std::string::npos) {
430
+ symbolName.insert (lastCommaPos + 1 , " \n " );
431
+ }
432
+ } else {
433
+ break ;
434
+ }
435
+ }
436
+ }
409
437
}
0 commit comments