views:

108

answers:

4

I am getting a lot of occurences of the message "Debug session in progress. Terminate?" when trying to re-run my application after routine editing in Delphi 2010. My Application has already been run (maybe several times) and quits without any problem back into my editing mode, yet after completing my edit sometimes the Run option is disabled and I get this "Debug session in progress. Terminate?" message. I then have to be careful to save my edits, and then use the Windows 'Close Window' to abort Delphi and restart the IDE. My Application is quite large and uses FastMM4. I'd like to eliminate problem but would be happy with a neater way of detatching the debugger from whatever it is latched on to. Any suggestions?

Incidently, my App compiles fully (and is released using) Delphi 7 in which I have no problems at all, not even when I Ctrl-F2 from within the middle of executing my App.

A: 

Perhaps the menu item Run/Detach from Program?

Alan Clark
@Alan Clark: There is no menu option of this name.
Brian Frost
It is present in Delphi 2007-2010, I don't know about XE but I assume it is there as well. In 2010, it is only visible when the application is running. Please remove the downvote!
Alan Clark
@Alan Clark: I'm sorry, I *do* see this option when the program is running, but my observation is that when I have the problem, *Run* and this option are greyed out.
Brian Frost
P.S I cant remove the vote - it says you need to edit the answer.
Brian Frost
No worries Brian.
Alan Clark
+1  A: 

Are you sure your application and all its threads have completely terminated? What happens if you press Control-F2 when you get back to edit mode? Is there any change in the main window caption when you do this?

frogb
@frogb: When I press Ctrl-F2 I get a message about ".... save your work and restart Delphi..." (I have not got the exact text here). If you click ok in this dialog, the IDE locks completely and you lose any edits, so you have to use 'cancel', save your changes and then kill the process. Incidently, my App compiles fully (and is released using) DElphi 7 in which I have no problems at all, not even when I Ctrl-F2 from within the middle of executing my App.
Brian Frost
@frogb: I cant say about the 'window caption' you mention, but the IDE is back in the edit state because I actually cant tell that this has happened until after I finished a visual form edit and press F9 to compile and run again.
Brian Frost
Then my suggestion would be to try to fix the problem, because your alternative of working around it is likely to fail. Do you have MadExcept? If you install this in the IDE you can usually get a stack trace when the IDE fails, which may lead you to a component or add-in that is causing the problem. I have used this technique to find out what to disable in similar circumstances.
frogb
@frogb: Yes, MadExcept is built into my program. Thanks for the suggestion.
Brian Frost
+1  A: 

Chances are some thread in your app is still running keeping your appl from terminating fully and thus keeping the debug session alive. Depending on the state of your app and the rest of the app's termination process, you could in that case still have "running" in the IDE's caption.

frogb's question about hitting Ctrl-F2, was (I am guessing) to see whether that was indeed the case. If you hit Ctrl-F2 when your app is fully terminated, nothing should happen. However, if some thread is somehow still active and keeping the debug session alive, Ctrl-F2 should terminate it and if your IDE's caption showed "running" that should now disappear.

The fact that you can hit Ctrl-F2 in D7 even when your app is still running and have it end correctly is to be expected. That is exactly what Ctrl-F2 is for: ending all still running threads (pretty roughly I might add).

Marjan Venema
@Marjan: Yes, but when I press Ctrl-F2 in D2010 I'm offered the option to abort but if I say yes, the IDE tells me to save my work and then locks up. D7 aborts the process fine (however dirty).
Brian Frost
@Brian: Yes, the offer to terminate the debug session doesn't always succeed... Depends on the state of the debugged app. We have had occassions where Delphi can't terminate the debug session any more and we couldn't terminate Delphi any more because it couldn't terminate... etc. Catch 22 if there ever was one.
Marjan Venema
@Brian: The point remains that you may think your app was finished, but actually it wasn't and you need to address whatever is causing that. Then the problem with the IDE will solve itself. In order to find the root cause, in addition to madExcept, I'd suggest using a good logging library (CodeSite, SmartInspect, Jedi logging stuff) to find which thread(s) are hanging about longer than they should.
Marjan Venema
@marjan: Great stuff, thanks.
Brian Frost
A: 

I can work around the problem (it does not happen too much) but I have further information showing the problem in some captured images. This is what I see after the program is stopped..note the greyed out 'Detatch from program'..

alt text

Then this next set of messages appear, leading to being forced to terminate the IDE... alt text

alt text

alt text

Brian Frost