Click here to Skip to main content
15,911,360 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCATCH_ALL and OnCtlColor Pin
Coremn12-May-04 15:01
Coremn12-May-04 15:01 
GeneralRe: CATCH_ALL and OnCtlColor Pin
monrobot1312-May-04 15:29
monrobot1312-May-04 15:29 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Coremn12-May-04 15:42
Coremn12-May-04 15:42 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Coremn12-May-04 16:17
Coremn12-May-04 16:17 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Ryan Binns12-May-04 18:02
Ryan Binns12-May-04 18:02 
GeneralInterface Methods Pin
monrobot1312-May-04 14:20
monrobot1312-May-04 14:20 
GeneralRe: Interface Methods Pin
Milton Karimbekallil12-May-04 21:06
Milton Karimbekallil12-May-04 21:06 
GeneralEXCEPTION_BREAKPOINT not raised Pin
Brian Tietz12-May-04 14:18
Brian Tietz12-May-04 14:18 
In a support library I'm developing which is serving as the foundation of an application I'm working on, I've provided a whole bunch of augmented debug functionality. For example, if I hit an assert, the replacement assert implementation logs this sort of thing to a file and to OutputDebugString:

---- ASSERT LOG OPENED ----
Version 0.7.4.1
assertion failure 5/12/04, 16:49:42.353738
File: btlocalclient.cpp
Line: 1086
Expression: Unrecognized command in BTLocalClient_t::AsynchMessageReceived
Call stack: 0x00417B93 (BTLocalClient_t::AsynchMessageReceived +0x542, btlocalclient.cpp line 1086)
0x004F15D1 (AsynchMessageTrigger_t::Triggered +0x60, asynchmessagetrigger.cpp line 93)
0x004F6E88 (EventServer_t::ThreadFunction +0x387, eventserver.cpp line 284)
0x0042F8BF (BTServer_t::ThreadFunction +0x2E, btserver.cpp line 93)
0x004F6A01 (EventServer_t::ThreadFunctionEntryPoint +0x70, eventserver.cpp line 174)
0x1020BFD2 (UNKNOWN)
0x7C57B382 (UNKNOWN)

I'm providing that detail so no one asks "why are you replacing assert" - the utility should be clear and MS should have done a better job of providing this sort of info.

Anyway... One part of this support library is an EventServer object running in a thread, servicing EventTrigger objects by WaitForMultipleObjects - EventTriggers have an associated triggler HANDLE of one kind or another - could be an event, could be a TCP/IP socket, could be a device handle doing asynchronous I/O, that sort of thing. The server thread is servicing a remote client server and device objects controlling Bluetooth ASICs. An EventServer running at critical priority is a necessary part of the application I'm working on. Anyway every once in a while during the development process I introduce a bug where the code gets stuck in a loop. At critical priority, that brings my system to its knees and depending on how bad it is, I can't get over to Visual Studio to hit the pause button on the debugger. So I just added a feature to the event server where, optionally, another thread watches it and if the event server stops punching a watchdog (to borrow a metaphor from hardware engineering) then the watcher thread suspends the event server and pops up a dialog indicating that the event server stalled, abort retry ignore, all that.

I caught the case where the event server has hit an assert and is therefore legitimately not punching the watchdog...assert puts the watchdog to sleep. But what if I set a breakpoint? Once I start stepping through code, the watcher thread fires almost immediately.

What I wanted to do was catch EXCEPTION_BREAKPOINT and put the watchdog to sleep in that situation. I already have a __try exception handler so that address exceptions for example get turned into asserts and log the info shown up above, the call stack and everything. I augmented it as follows:

int
ExceptionFilter( unsigned int code, struct _EXCEPTION_POINTERS *ep )
{
g_exception_context = ep->ContextRecord;
if(code == EXCEPTION_ACCESS_VIOLATION)
release_error("Access violation");
else if(code == EXCEPTION_INT_DIVIDE_BY_ZERO)
release_error("Integer divide by zero");
else if(code == EXCEPTION_PRIV_INSTRUCTION)
release_error("Privileged instruction");
else if(code == EXCEPTION_ILLEGAL_INSTRUCTION)
release_error("Illegal instruction");
else if(code == EXCEPTION_NONCONTINUABLE_EXCEPTION)
release_error("Noncontinuable exception");
else if(code == EXCEPTION_GUARD_PAGE)
release_error("Guard page violation");
ADD else if(code == EXCEPTION_BREAKPOINT)
ADD {
ADD debug_printf("Why isn't this working???\n");
ADD EventServer_t::PauseCurrentThreadStallWatcher();
ADD }
g_exception_context = NULL;
return EXCEPTION_CONTINUE_SEARCH;
}


But it didn't work...EXCEPTION_BREAKPOINT isn't raised, or at least isn't able to be caught using __try.

Does anyone know what EXCEPTION_BREAKPOINT is for, will it work for what I'm trying to do if I do something a bit different?

Alternatively, does anyone know of a way that the watcher thread can determine whether the debugger has been active recently, like having just set a breakpoint and released the debuggee to do a "step out of function"? IsDebuggerPresent() isn't good enough because that returns TRUE whenever I'm in the debugger, that says nothing as to whether I'm stepping through code.

Thanks,
Brian
GeneralRe: EXCEPTION_BREAKPOINT not raised Pin
Ryan Binns12-May-04 18:21
Ryan Binns12-May-04 18:21 
GeneralATL 7 WTL 7.1 Pin
monrobot1312-May-04 13:59
monrobot1312-May-04 13:59 
GeneralRe: ATL 7 WTL 7.1 Pin
Michael Dunn12-May-04 15:37
sitebuilderMichael Dunn12-May-04 15:37 
GeneralRe: ATL 7 WTL 7.1 Pin
monrobot1312-May-04 16:09
monrobot1312-May-04 16:09 
QuestionMessageBox Not Displayed from Destructor? Pin
Justin Cooke12-May-04 11:56
Justin Cooke12-May-04 11:56 
AnswerRe: MessageBox Not Displayed from Destructor? Pin
Diddy14-May-04 0:56
Diddy14-May-04 0:56 
GeneralRe: MessageBox Not Displayed from Destructor? Pin
Justin Cooke14-May-04 6:41
Justin Cooke14-May-04 6:41 
GeneralRe: MessageBox Not Displayed from Destructor? Pin
Diddy18-May-04 1:19
Diddy18-May-04 1:19 
GeneralRemoval of source control (VSS) Pin
Janovetz12-May-04 11:56
Janovetz12-May-04 11:56 
Generalfade screen Pin
johansmits12-May-04 11:16
johansmits12-May-04 11:16 
GeneralRe: fade screen Pin
Christian Graus12-May-04 12:13
protectorChristian Graus12-May-04 12:13 
Generalglobal #define !!! Pin
Hesham Amin12-May-04 10:42
Hesham Amin12-May-04 10:42 
GeneralRe: global #define !!! Pin
Christopher Lloyd12-May-04 11:07
Christopher Lloyd12-May-04 11:07 
Generalthank you but... Pin
Hesham Amin12-May-04 11:14
Hesham Amin12-May-04 11:14 
GeneralRe: thank you but... Pin
Christopher Lloyd13-May-04 1:52
Christopher Lloyd13-May-04 1:52 
GeneralRe: thank you but... Pin
Hesham Amin13-May-04 4:14
Hesham Amin13-May-04 4:14 
GeneralRe: global #define !!! Pin
Christian Graus12-May-04 12:14
protectorChristian Graus12-May-04 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.