- small fix, needs bigger overhaul later.
@@ -26,6 +26,36 @@ | ||
26 | 26 | #include <sdk/MemoryUtils.h> |
27 | 27 | #include <CFileSystem.common.stl.h> |
28 | 28 | |
29 | +// TODO: think about getting this to use Eir types. | |
30 | +#include <sstream> | |
31 | + | |
32 | +AINLINE std::string to_string_hex( size_t num ) | |
33 | +{ | |
34 | + std::stringstream stream; | |
35 | + | |
36 | + stream << std::hex << num; | |
37 | + | |
38 | + return stream.str(); | |
39 | +} | |
40 | + | |
41 | +struct CRTHeapAllocator | |
42 | +{ | |
43 | + static AINLINE void* Allocate( void *refPtr, size_t memSize, size_t alignment ) | |
44 | + { | |
45 | + return malloc( memSize ); | |
46 | + } | |
47 | + | |
48 | + static AINLINE bool Resize( void *refPtr, void *memPtr, size_t newSize ) | |
49 | + { | |
50 | + return false; | |
51 | + } | |
52 | + | |
53 | + static AINLINE void Free( void *refPtr, void *memPtr ) | |
54 | + { | |
55 | + free( memPtr ); | |
56 | + } | |
57 | +}; | |
58 | + | |
29 | 59 | // Specialized memory array. |
30 | 60 | template <typename dataType> |
31 | 61 | struct dbgtraceIterativeGrowableArrayManager |
@@ -47,7 +77,7 @@ | ||
47 | 77 | { |
48 | 78 | this->heapHandle = right.heapHandle; |
49 | 79 | |
50 | - right.heapHandle = NULL; | |
80 | + right.heapHandle = nullptr; | |
51 | 81 | } |
52 | 82 | |
53 | 83 | inline ~dbgtracePrivateHeapAllocator( void ) |
@@ -535,7 +565,7 @@ | ||
535 | 565 | if ( symbolName.size() == 0 ) |
536 | 566 | { |
537 | 567 | outputBuffer += "[0x"; |
538 | - outputBuffer += NumberUtil::to_string_hex( (size_t)csInfo.codePtr ); | |
568 | + outputBuffer += to_string_hex( (size_t)csInfo.codePtr ); | |
539 | 569 | outputBuffer += "]"; |
540 | 570 | } |
541 | 571 | else |
@@ -542,7 +572,7 @@ | ||
542 | 572 | { |
543 | 573 | outputBuffer += symbolName; |
544 | 574 | outputBuffer += " at 0x"; |
545 | - outputBuffer += NumberUtil::to_string_hex( (size_t)csInfo.codePtr ); | |
575 | + outputBuffer += to_string_hex( (size_t)csInfo.codePtr ); | |
546 | 576 | } |
547 | 577 | } |
548 | 578 | outputBuffer += " ("; |
@@ -550,12 +580,16 @@ | ||
550 | 580 | std::string fileName = csInfo.GetFileName(); |
551 | 581 | |
552 | 582 | // Since the filename can be pretty long, it needs special attention. |
553 | - filePath directoryPart; | |
583 | + eir::MultiString <CRTHeapAllocator> directoryPart; | |
554 | 584 | |
555 | - std::string fileNameItem = FileSystem::GetFileNameItem( fileName.c_str(), true, &directoryPart, NULL ); | |
585 | + auto fileNameItem = FileSystem::GetFileNameItem <CRTHeapAllocator> ( fileName.c_str(), true, &directoryPart, nullptr ); | |
556 | 586 | |
557 | 587 | // Trim the directory. |
558 | - outputBuffer += GetTrimmedString( directoryPart.convert_ansi(), 20 ) + fileNameItem; | |
588 | + auto ansiDirPart = directoryPart.convert_ansi(); | |
589 | + auto ansiFileNameItem = fileNameItem.convert_ansi(); | |
590 | + | |
591 | + outputBuffer += GetTrimmedString( ansiDirPart.GetConstString(), 20 ); | |
592 | + outputBuffer.append( ansiFileNameItem.GetConstString() ); | |
559 | 593 | } |
560 | 594 | outputBuffer += ":"; |
561 | 595 | outputBuffer += std::to_string( csInfo.GetLineNumber() ); |