StackDump.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. #pragma once
  24. #ifndef __STACKDUMP_H_
  25. #define __STACKDUMP_H_
  26. #ifndef IG_DEGBUG_STACKTRACE
  27. #define IG_DEBUG_STACKTRACE 1
  28. #endif
  29. #if defined(_DEBUG) || defined(_INTERNAL) || defined(IG_DEBUG_STACKTRACE)
  30. // Writes a stackdump (provide a callback : gets called per line)
  31. // If callback is NULL then will write using OuputDebugString
  32. void StackDump(void (*callback)(const char*));
  33. // Writes a stackdump (provide a callback : gets called per line)
  34. // If callback is NULL then will write using OuputDebugString
  35. void StackDumpFromContext(DWORD eip,DWORD esp,DWORD ebp, void (*callback)(const char*));
  36. // Gets count* addresses from the current stack
  37. void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip = 0);
  38. // Do full stack dump using an address array
  39. void StackDumpFromAddresses(void**addresses, unsigned int count, void (*callback)(const char*));
  40. void GetFunctionDetails(void *pointer, char*name, char*filename, unsigned int* linenumber, unsigned int* address);
  41. // Dumps out the exception info and stack trace.
  42. void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info );
  43. #else
  44. __inline void StackDump(void (*callback)(const char*)) {};
  45. // Gets count* addresses from the current stack
  46. __inline void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip = 0) {}
  47. // Do full stack dump using an address array
  48. __inline void StackDumpFromAddresses(void**addresses, unsigned int count, void (*callback)(const char*)) {}
  49. __inline void GetFunctionDetails(void *pointer, char*name, char*filename, unsigned int* linenumber, unsigned int* address) {}
  50. // Dumps out the exception info and stack trace.
  51. __inline void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info ) {};
  52. #endif
  53. extern AsciiString g_LastErrorDump;
  54. #endif // __STACKDUMP_H_