Code::Blocks  SVN r11506
debuggergdb_test_backtrace.cpp
Go to the documentation of this file.
2 
3 #include "gdb_commands.h"
4 
5 SUITE(GDBStackFrameParser)
6 {
7 
8 TEST(match0_flag)
9 {
10  cbStackFrame sf;
11  bool hasLineInfo;
12  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 wxEntry () at main.cpp:5")));
13  CHECK(hasLineInfo);
14 }
15 TEST(match0_number)
16 {
17  cbStackFrame sf;
18  bool hasLineInfo;
19  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 wxEntry () at main.cpp:5"));
20  CHECK_EQUAL(0, sf.GetNumber());
21 }
22 TEST(match0_symbol)
23 {
24  cbStackFrame sf;
25  bool hasLineInfo;
26  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 wxEntry () at main.cpp:5"));
27  CHECK_EQUAL(wxT("wxEntry ()"), sf.GetSymbol());
28 }
29 TEST(match0_file)
30 {
31  cbStackFrame sf;
32  bool hasLineInfo;
33  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 wxEntry () at main.cpp:5"));
34  CHECK_EQUAL(wxT("main.cpp"), sf.GetFilename());
35  CHECK_EQUAL(wxT("5"), sf.GetLine());
36 }
37 
38 //#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll
39 TEST(match1_flag)
40 {
41  cbStackFrame sf;
42  bool hasLineInfo;
43  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll")));
44  CHECK(!hasLineInfo);
45 }
46 TEST(match1_number)
47 {
48  cbStackFrame sf;
49  bool hasLineInfo;
50  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll"));
51  CHECK_EQUAL(8, sf.GetNumber());
52 }
53 TEST(match1_address)
54 {
55  cbStackFrame sf;
56  bool hasLineInfo;
57  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll"));
58  CHECK_EQUAL(0x77d48734ul, sf.GetAddress());
59 }
60 TEST(match1_symbol)
61 {
62  cbStackFrame sf;
63  bool hasLineInfo;
64  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll"));
65  CHECK_EQUAL(wxT("USER32!GetDC()"), sf.GetSymbol());
66 }
67 TEST(match1_file)
68 {
69  cbStackFrame sf;
70  bool hasLineInfo;
71  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#8 0x77d48734 in USER32!GetDC () from C:\\WINDOWS\\system32\\user32.dll"));
72  CHECK_EQUAL(wxT("C:\\WINDOWS\\system32\\user32.dll"), sf.GetFilename());
73  CHECK_EQUAL(wxEmptyString, sf.GetLine());
74 }
75 
76 //#9 0x001b04fe in ?? ()
77 //#11 0x00406810 in main ()
78 TEST(match2_flag)
79 {
80  cbStackFrame sf;
81  bool hasLineInfo;
82  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#9 0x001b04fe in ?? ()")));
83  CHECK(!hasLineInfo);
84 }
85 TEST(match2_number)
86 {
87  cbStackFrame sf;
88  bool hasLineInfo;
89  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#9 0x001b04fe in ?? ()"));
90  CHECK_EQUAL(9, sf.GetNumber());
91 }
92 TEST(match2_address)
93 {
94  cbStackFrame sf;
95  bool hasLineInfo;
96  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#9 0x001b04fe in ?? ()"));
97  CHECK_EQUAL(0x001b04feul, sf.GetAddress());
98 }
99 TEST(match2_symbol)
100 {
101  cbStackFrame sf;
102  bool hasLineInfo;
103  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#9 0x001b04fe in ?? ()"));
104  CHECK_EQUAL(wxT("?? ()"), sf.GetSymbol());
105 }
106 TEST(match2_file)
107 {
108  cbStackFrame sf;
109  bool hasLineInfo;
110  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#9 0x001b04fe in ?? ()"));
111  CHECK_EQUAL(wxEmptyString, sf.GetFilename());
112  CHECK_EQUAL(wxEmptyString, sf.GetLine());
113 }
114 
115 //#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297
116 TEST(match3_flag)
117 {
118  cbStackFrame sf;
119  bool hasLineInfo;
120  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297")));
121  CHECK(hasLineInfo);
122 }
123 TEST(match3_number)
124 {
125  cbStackFrame sf;
126  bool hasLineInfo;
127  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297"));
128  CHECK_EQUAL(30, sf.GetNumber());
129 }
130 TEST(match3_address)
131 {
132  cbStackFrame sf;
133  bool hasLineInfo;
134  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297"));
135  CHECK_EQUAL(0x00403c0aul, sf.GetAddress());
136 }
137 TEST(match3_symbol)
138 {
139  cbStackFrame sf;
140  bool hasLineInfo;
141  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297"));
142  CHECK_EQUAL(wxT("WinMain(hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10)"), sf.GetSymbol());
143 }
144 TEST(match3_file)
145 {
146  cbStackFrame sf;
147  bool hasLineInfo;
148  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#30 0x00403c0a in WinMain (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x241ef9 "", nCmdShow=10) at C:/Devel/wxSmithTest/app.cpp:297"));
149  CHECK_EQUAL(wxT("C:/Devel/wxSmithTest/app.cpp"), sf.GetFilename());
150  CHECK_EQUAL(wxT("297"), sf.GetLine());
151 }
152 
153 //#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555
154 TEST(match4_flag)
155 {
156  cbStackFrame sf;
157  bool hasLineInfo;
158  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555")));
159  CHECK(hasLineInfo);
160 }
161 TEST(match4_number)
162 {
163  cbStackFrame sf;
164  bool hasLineInfo;
165  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555"));
166  CHECK_EQUAL(31, sf.GetNumber());
167 }
168 TEST(match4_address)
169 {
170  cbStackFrame sf;
171  bool hasLineInfo;
172  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555"));
173  CHECK_EQUAL(0x004076caul, sf.GetAddress());
174 }
175 TEST(match4_symbol)
176 {
177  cbStackFrame sf;
178  bool hasLineInfo;
179  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555"));
180  CHECK_EQUAL(wxT("main()"), sf.GetSymbol());
181 }
182 TEST(match4_file)
183 {
184  cbStackFrame sf;
185  bool hasLineInfo;
186  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#31 0x004076ca in main () at C:/Devel/wxWidgets-2.6.1/include/wx/intl.h:555"));
187  CHECK_EQUAL(wxT("C:/Devel/wxWidgets-2.6.1/include/wx/intl.h"), sf.GetFilename());
188  CHECK_EQUAL(wxT("555"), sf.GetLine());
189 }
190 
191 //#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14
192 TEST(match5_flag)
193 {
194  cbStackFrame sf;
195  bool hasLineInfo;
196  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14")));
197  CHECK(hasLineInfo);
198 }
199 TEST(match5_number)
200 {
201  cbStackFrame sf;
202  bool hasLineInfo;
203  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14"));
204  CHECK_EQUAL(50, sf.GetNumber());
205 }
206 TEST(match5_address)
207 {
208  cbStackFrame sf;
209  bool hasLineInfo;
210  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14"));
211  CHECK_EQUAL(0x00410c8cul, sf.GetAddress());
212 }
213 TEST(match5_symbol)
214 {
215  cbStackFrame sf;
216  bool hasLineInfo;
217  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14"));
218  CHECK_EQUAL(wxT("one::~one() (this=0x3d24c8)"), sf.GetSymbol());
219 }
220 TEST(match5_file)
221 {
222  cbStackFrame sf;
223  bool hasLineInfo;
224  GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#50 0x00410c8c in one::~one() (this=0x3d24c8) at main.cpp:14"));
225  CHECK_EQUAL(wxT("main.cpp"), sf.GetFilename());
226  CHECK_EQUAL(wxT("14"), sf.GetLine());
227 }
228 
229 // #0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0, stmt=0xb9d7160, stmtSubsts=...) at Foo/Bar/apply.cpp:219
230 TEST(match6_flag)
231 {
232  cbStackFrame sf;
233  bool hasLineInfo;
234  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0")
235  wxT(", stmt=0xb9d7160, stmtSubsts=...) ")
236  wxT("at Foo/Bar/apply.cpp:219")));
237  CHECK(hasLineInfo);
238 }
239 TEST(match6_number)
240 {
241  cbStackFrame sf;
242  bool hasLineInfo;
243  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0")
244  wxT(", stmt=0xb9d7160, stmtSubsts=...) ")
245  wxT("at Foo/Bar/apply.cpp:219")));
246  CHECK_EQUAL(0, sf.GetNumber());
247 }
248 TEST(match6_address)
249 {
250  cbStackFrame sf;
251  bool hasLineInfo;
252  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0")
253  wxT(", stmt=0xb9d7160, stmtSubsts=...) ")
254  wxT("at Foo/Bar/apply.cpp:219")));
255  CHECK_EQUAL(0x0ul, sf.GetAddress());
256 }
257 TEST(match6_symbol)
258 {
259  cbStackFrame sf;
260  bool hasLineInfo;
261  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0")
262  wxT(", stmt=0xb9d7160, stmtSubsts=...) ")
263  wxT("at Foo/Bar/apply.cpp:219")));
264  CHECK_EQUAL(wxT("Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0, stmt=0xb9d7160, stmtSubsts=...)"),
265  sf.GetSymbol());
266 }
267 TEST(match6_file)
268 {
269  cbStackFrame sf;
270  bool hasLineInfo;
271  CHECK(GdbCmd_Backtrace::MatchLine(sf, hasLineInfo, wxT("#0 Foo::Bar::(anonymous namespace)::apply (this=0xbaf6cf0")
272  wxT(", stmt=0xb9d7160, stmtSubsts=...) ")
273  wxT("at Foo/Bar/apply.cpp:219")));
274  CHECK_EQUAL(wxT("Foo/Bar/apply.cpp"), sf.GetFilename());
275  CHECK_EQUAL(wxT("219"), sf.GetLine());
276 }
277 
278 } // SUITE(GDBStackFrameParser)
int GetNumber() const
const wxString & GetLine() const
#define wxT(string)
const wxString & GetFilename() const
const wxString & GetSymbol() const
wxString wxEmptyString
SUITE(GDBStackFrameParser)
uint64_t GetAddress() const
static bool MatchLine(cbStackFrame &sf, bool &hasLineInfo, const wxString &line)