Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
debug_stack.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(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
20// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug_stack.h $
21// $Author: mhoffe $
22// $Revision: #1 $
23// $DateTime: 2003/07/03 11:55:26 $
24//
25// ©2003 Electronic Arts
26//
27// Stack walker
29#ifdef _MSC_VER
30# pragma once
31#endif
32#ifndef DEBUG_STACK_H // Include guard
33#define DEBUG_STACK_H
34
36class DebugStackwalk
37{
38 friend class Debug;
39
40 DebugStackwalk(const DebugStackwalk&);
41 DebugStackwalk& operator=(DebugStackwalk&);
42
43 // private so that only Debug can create and destroy us
44 DebugStackwalk(void);
45 ~DebugStackwalk();
46
47public:
48
51 {
52 // makes life easier :)
53 friend class DebugStackwalk;
54
56 enum { MAX_ADDR = 256 };
57
59 unsigned m_numAddr;
60
62 unsigned m_addr[MAX_ADDR];
63
64 public:
65 explicit Signature(void): m_numAddr(0) {}
66 Signature(const Signature &src);
67 Signature& operator=(const Signature& src);
68
74 unsigned Size(void) const { return m_numAddr; }
75
84 unsigned GetAddress(int n) const;
85
93 bool operator<(const Signature &other) const
94 {
95 unsigned m=m_numAddr<other.m_numAddr?m_numAddr:other.m_numAddr;
96 for (unsigned k=0;k<m;k++)
97 {
98 if (m_addr[m_numAddr-k-1]<other.m_addr[other.m_numAddr-k-1])
99 return true;
100 if (m_addr[m_numAddr-k-1]>other.m_addr[other.m_numAddr-k-1])
101 return false;
102 }
103 return m_numAddr<other.m_numAddr;
104 }
105
116 static void GetSymbol(unsigned addr, char *buf, unsigned bufSize);
117
133 static void GetSymbol(unsigned addr,
134 char *bufMod, unsigned sizeMod, unsigned *relMod,
135 char *bufSym, unsigned sizeSym, unsigned *relSym,
136 char *bufFile, unsigned sizeFile, unsigned *line, unsigned *relLine);
137 };
138
144 static void *GetDbghelpHandle(void);
145
151 static bool IsOldDbghelp(void);
152
160 static int StackWalk(Signature &sig, struct _CONTEXT *ctx=0);
161};
162
171
172#endif // DEBUG_STACK_H
Debug module main class (singleton).
Definition debug_debug.h:45
a stack trace signature
Definition debug_stack.h:51
static void GetSymbol(unsigned addr, char *buf, unsigned bufSize)
Determines symbol for given address.
Signature & operator=(const Signature &src)
bool operator<(const Signature &other) const
Strong ordering operator.
Definition debug_stack.h:93
friend class DebugStackwalk
Definition debug_stack.h:53
unsigned GetAddress(int n) const
Get a single address from the signature.
unsigned Size(void) const
Determine the number of addresses in this signature.
Definition debug_stack.h:74
static int StackWalk(Signature &sig, struct _CONTEXT *ctx=0)
Walks the stack from the given address.
friend class Debug
Definition debug_stack.h:38
static void * GetDbghelpHandle(void)
static bool IsOldDbghelp(void)
Debug & operator<<(Debug &dbg, const DebugStackwalk::Signature &sig)
Dumps a complete signature with symbols.