views:

169

answers:

2

When I'm running my COM Office add-in from within the Delphi 5 IDE (using any of the office applications as the host), breakpoints work fine (when using remote debugging symbols and a properly set output folder), but none of the non-delphi exceptions (like access violations) in my code triggers the IDE to break at that point. In stead, the IDE stops at the manual re-raise in the try...except wrappers in any of my outer safecall methods.

I noticed that for some reason the DebugHook global was set to 0 (while as far as I know it should always be set to 1 when running from within the IDE). Moreover, setting it to 1 manually during the initialization of my DLL actually fixes the issue: the IDE now neatly stops at the line where my experimental (read: crappy) code triggers the exception.

The questions is: why? Why do I need to do this manually? Shouldn't the IDE set this for me? Did I forget a major important setting somewhere triggering this behaviour?

+1  A: 

In recent versions of Delphi there's an Option under Debugger for "Debug spawned processes" or something to that effect. Is that option present in Delphi5, and is it set?

Not sure whether this will help, because I have not encountered the behavior you describe.

Argalatyr
I don't think it does, but your answer inspired me to try an "attach to process" (as opposed to setting the Office application as a Host), and that _did_ trigger the DebugHook to become 1. Not as convenient as my current quick hack to set it manually from the code, but interesting!
Paul-Jan
@Paul-Jan: if you have a good answer, go ahead and post it. You may earn some rep, and the point of SO is to generate a searchable repository of high-quality questions and answers. Your solution may be useful to someone else...
Argalatyr
+3  A: 

If for some reason the Delphi evaluator is unable to lookup the DebugHook global, it would be unable to set that value. Try to compile/run the DLL from the IDE and set the "host application" in the Run|Parameters dialog to the the Office app you intend to call your DLL from. It is possible that this may be a bug in how the evaluator uses the remote debug symbols.

Allen Bauer
Thanks for the suggestion, but that is exactly what I'm already doing (is there any other sensible setup for development that I am unwaware of?). However, the lookup of the remote debug symbols is faulty anyway in Delphi 5 (from XP onwards, it requires the current directory of the IDE to be set to the output folder, or else the symbols have to manually reloaded from the modules dialog), so you might be onto something there. Thanks again!
Paul-Jan