Changeset 7457 for code/trunk/src/libraries/util
- Timestamp:
- Sep 16, 2010, 1:45:08 PM (14 years ago)
- Location:
- code/trunk/src/libraries/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/SignalHandler.cc
r7455 r7457 37 37 #include <cstdlib> 38 38 #include <cstring> 39 39 40 #include "Debug.h" 40 41 … … 344 345 345 346 #ifdef ORXONOX_COMPILER_GCC 347 /// Overwrite the original abort() function in MinGW to enable a break point. 346 348 _UtilExport void __cdecl abort() 347 349 { … … 352 354 } 353 355 356 /// Overwrite the original _abort() function in MinGW to enable a break point. 354 357 _UtilExport void __cdecl _assert(const char* expression, const char* file, int line) 355 358 { … … 391 394 // Install the unhandled exception filter function 392 395 this->prevExceptionFilter_ = SetUnhandledExceptionFilter(&SignalHandler::exceptionFilter); 393 394 // std::set_terminate(&myterminate);395 /*396 #ifdef ORXONOX_COMPILER_GCC397 MODULEENTRY32 module;398 memset(&module, 0, sizeof(MODULEENTRY32));399 module.dwSize = sizeof(MODULEENTRY32);400 401 HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);402 403 BOOL result = Module32First(snapshot, &module);404 405 COUT(0) << SignalHandler::pointerToString((unsigned)_assert) << std::endl;406 407 while (result)408 {409 COUT(0) << module.szModule << std::endl;410 COUT(0) << SignalHandler::pointerToString((unsigned)module.modBaseAddr) << " / " << SignalHandler::pointerToString(*module.modBaseAddr) << std::endl;;411 412 FARPROC procAssert = GetProcAddress(module.hModule, "__ZSt13set_terminatePFvvE");413 if (procAssert)414 {415 COUT(0) << "yes1 --------------------------------------------------------" << std::endl;416 COUT(0) << SignalHandler::pointerToString((unsigned)procAssert) << std::endl;417 // *(volatile unsigned*)procAssert = 0xcc;418 }419 420 result = Module32Next(snapshot, &module);421 }422 423 // *(volatile unsigned*)abort = 0xcc;424 // *(volatile unsigned*)_assert = 0xcc;425 #endif426 */427 396 } 428 397 } … … 606 575 607 576 // Get the symbol information from the address of the instruction pointer register: 608 if 577 bool bCorrected = false; 578 BOOL result = SymFromAddr 609 579 ( 610 SymFromAddr 580 GetCurrentProcess() , // Process to get symbol information for 581 frame.AddrPC.Offset , // Address to get symbol for: instruction pointer register 582 &displacement , // Displacement from the beginning of the symbol 583 symbol // Where to save the symbol 584 ); 585 586 // If the symbol was found, but the displacement is 0, we likely got the wrong symbol - decrease the program counter and try again 587 if (result && displacement == 0) 588 { 589 bCorrected = true; 590 result = SymFromAddr 611 591 ( 612 GetCurrentProcess() , // Process to get symbol information for 613 frame.AddrPC.Offset , // Address to get symbol for: instruction pointer register 614 &displacement , // Displacement from the beginning of the symbol 615 symbol // Where to save the symbol 616 ) 617 ) 592 GetCurrentProcess() , 593 frame.AddrPC.Offset - 1 , 594 &displacement , 595 symbol 596 ); 597 } 598 599 // Display the function name + offset 600 if (result) 618 601 { 619 602 // Add the name of the function to the function list: … … 635 618 636 619 output += " +" + SignalHandler::pointerToString(displacement, false); 620 if (bCorrected) 621 output += " (?)"; 637 622 } 638 623 639 /* 640 IMAGEHLP_MODULE64 module; 641 memset(&module, 0, sizeof(IMAGEHLP_MODULE64)); 642 module.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); 624 output += "\n"; 625 626 // Get the file name and line number 627 IMAGEHLP_LINE64 line; 628 memset(&line, 0, sizeof(IMAGEHLP_LINE64)); 629 line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); 630 631 DWORD displacement2 = 0; 643 632 644 633 if 645 634 ( 646 SymGet ModuleInfo64635 SymGetLineFromAddr64 647 636 ( 648 637 GetCurrentProcess(), 649 frame.AddrPC.Offset, 650 &module 638 frame.AddrPC.Offset - bCorrected ? 1 : 0, 639 &displacement2, 640 &line 651 641 ) 652 642 ) 653 643 { 654 IMAGEHLP_LINE64 line; 655 memset(&line, 0, sizeof(IMAGEHLP_LINE64)); 656 line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); 657 658 DWORD displacement2 = displacement; 659 660 if 661 ( 662 SymGetLineFromAddr64 663 ( 664 GetCurrentProcess(), 665 frame.AddrPC.Offset, 666 &displacement2, 667 &line 668 ) 669 ) 670 { 671 output += "\n"; 672 output += " "; 673 output += line.FileName; 674 output += ":"; 675 output += multi_cast<std::string>(line.LineNumber); 676 } 644 output += " "; 645 output += line.FileName; 646 output += ":"; 647 output += multi_cast<std::string>(line.LineNumber); 648 output += "\n"; 677 649 } 678 */679 output += "\n";680 650 } 681 651 -
code/trunk/src/libraries/util/SignalHandler.h
r7455 r7457 40 40 #include <cassert> 41 41 #include <string> 42 42 43 #include "Singleton.h" 43 44 #include "SpecialConfig.h" … … 72 73 { 73 74 friend class Singleton<SignalHandler>; 74 public:75 SignalHandler() { }76 ~SignalHandler() { }77 75 78 void registerCallback( SignalCallback cb, void * someData ); 76 public: 77 void registerCallback( SignalCallback cb, void * someData ); 79 78 80 void doCatch( const std::string & appName, const std::string & filename );81 void dontCatch();79 void doCatch( const std::string & appName, const std::string & filename ); 80 void dontCatch(); 82 81 83 private:84 static void sigHandler( int sig );82 private: 83 static void sigHandler( int sig ); 85 84 86 void catchSignal( int sig );87 SignalRecList sigRecList;85 void catchSignal( int sig ); 86 SignalRecList sigRecList; 88 87 89 SignalCallbackList callbackList;88 SignalCallbackList callbackList; 90 89 91 static SignalHandler* singletonPtr_s;90 static SignalHandler* singletonPtr_s; 92 91 93 std::string appName;94 std::string filename;92 std::string appName; 93 std::string filename; 95 94 }; 96 95 }
Note: See TracChangeset
for help on using the changeset viewer.