Skip to content

Commit 375d913

Browse files
committed
debugger catches exceptions in debug mode
#refactor
1 parent e1110fe commit 375d913

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/test/TestMain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ int test_main(int argc, char const** argv)
118118
return EXIT_SUCCESS;
119119
}
120120

121+
#ifdef _NDEBUG
121122
static void reportUnhandledException(
122123
std::exception const& ex)
123124
{
@@ -126,12 +127,16 @@ static void reportUnhandledException(
126127
report::error("Unhandled exception: {}\n", ex.what());
127128
sys::PrintStackTrace(llvm::errs());
128129
}
130+
#endif
129131

130132
} // mrdocs
131133
} // clang
132134

133135
int main(int argc, char const** argv)
134136
{
137+
#ifndef _NDEBUG
138+
return clang::mrdocs::test_main(argc, argv);
139+
#else
135140
try
136141
{
137142
return clang::mrdocs::test_main(argc, argv);
@@ -146,4 +151,5 @@ int main(int argc, char const** argv)
146151
clang::mrdocs::reportUnhandledException(ex);
147152
}
148153
return EXIT_FAILURE;
154+
#endif
149155
}

src/tool/ToolMain.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ mrdocs_main(int argc, char const** argv)
153153
return EXIT_SUCCESS;
154154
}
155155

156+
#ifdef _NDEBUG
156157
static
157158
void
158159
reportUnhandledException(
@@ -163,24 +164,29 @@ reportUnhandledException(
163164
report::fatal("Unhandled exception: {}\n", ex.what());
164165
sys::PrintStackTrace(llvm::errs());
165166
}
167+
#endif
166168

167169
} // clang::mrdocs
168170

169171
int
170172
main(int argc, char const** argv)
171173
{
172-
// try
173-
// {
174+
#ifndef _NDEBUG
175+
return clang::mrdocs::mrdocs_main(argc, argv);
176+
#else
177+
try
178+
{
174179
return clang::mrdocs::mrdocs_main(argc, argv);
175-
// }
176-
// catch(clang::mrdocs::Exception const& ex)
177-
// {
180+
}
181+
catch(clang::mrdocs::Exception const& ex)
182+
{
178183
// Thrown Exception should never get here.
179-
// clang::mrdocs::reportUnhandledException(ex);
180-
// }
181-
// catch(std::exception const& ex)
182-
// {
183-
// clang::mrdocs::reportUnhandledException(ex);
184-
// }
185-
// return EXIT_FAILURE;
184+
clang::mrdocs::reportUnhandledException(ex);
185+
}
186+
catch(std::exception const& ex)
187+
{
188+
clang::mrdocs::reportUnhandledException(ex);
189+
}
190+
return EXIT_FAILURE;
191+
#endif
186192
}

0 commit comments

Comments
 (0)