test: Add an option for triggering a breakpoint with hello-exception.cpp
This commit is contained in:
1 parent
33fe419247
commit
bbbdab6e27
1 file changed
+11
-2
@@ -35,12 +35,16 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool crash = false;
|
bool crash = false;
|
||||||
|
bool breakpoint = false;
|
||||||
|
|
||||||
void recurse(int val) {
|
void recurse(int val) {
|
||||||
RecurseClass obj(val);
|
RecurseClass obj(val);
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
if (crash)
|
if (crash)
|
||||||
*(volatile int*)NULL = 0x42;
|
*(volatile int*)NULL = 0x42;
|
||||||
|
else if (breakpoint)
|
||||||
|
__debugbreak();
|
||||||
|
else
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
if (val == 5) {
|
if (val == 5) {
|
||||||
@@ -58,10 +62,15 @@ void recurse(int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc > 1 && !strcmp(argv[1], "-crash")) {
|
for (int i = 1; i < argc; i++) {
|
||||||
/* This mode is useful for testing backtraces in a debugger. */
|
/* These modes are useful for testing backtraces in a debugger. */
|
||||||
|
if (!strcmp(argv[i], "-crash")) {
|
||||||
crash = true;
|
crash = true;
|
||||||
fprintf(stderr, "Crashing instead of throwing an exception\n");
|
fprintf(stderr, "Crashing instead of throwing an exception\n");
|
||||||
|
} else if (!strcmp(argv[i], "-breakpoint")) {
|
||||||
|
breakpoint = true;
|
||||||
|
fprintf(stderr, "Triggering breakpoint instead of throwing an exception\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recurse(10);
|
recurse(10);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user