I'm not sure offhand how to do this.
I don't think ICorDebug will help you here. Some issues: 1. Step-out won't solve it. Steppers only complete in managed code, and so you can't "step out" of main to detect its exit. (In theory, you could write an interop-debugging to step out of main to the unmanaged caller, but that would be crazy here.) 2. ThreadExits come later than just when there's no managed code on the stack (http://blogs.msdn.com/jmstall/archive/2006/02/01/icordebugthread-trivia.aspx) There may even be goofy scenarios where them main thread executes managed code after main has returned. (I'm not 100% sure here, but it seems like something that could be arranged).
Possible options: 1. Launch the debuggee under a host which invokes main and then prints out the message when main returns. 2. Perhaps you can play some games with overriding stdin/stdout. Not exactly sure what though.
|