views:

134

answers:

5

I'm wondering if it's possible to bypass the OutputDebugString? I'd like the OutputDebugString output showing up in DebugView and not in the internal Delphi Event Viewer window. But i can't find a way to tell Delphi not to swallow the OutputDebugString. Any ideas?

regards

A: 

Disabling "output messages" in the Event Log properties does not work?

ldsandon
Yes. It doesn't work.
splash
Result is that the messages aren't displayed in the internal Event Log. But they're still swallowed by the debugger.
pantarhei
I am afraid the once a debugger it attached to a process Windows sends the output to that debugger.
ldsandon
+1  A: 

I think there is no way around this. The situation is still the same in Delphi 2009. You should submit a feature request: http://qc.embarcadero.com

I'm wondering what the advantage instead of Delphi's internal event log window should be?

splash
The advantage is that you can filter the debug strings in DebugView. Makes the life much easier.
pantarhei
Do you really need more than the on/off filter in Delphi? ;-)
splash
Submitting a feature request for D7? Are you kidding me? I'm pretty sure that they are not going to add it do D7 if it isn't possible at the moment in D09.
pantarhei
Needless to say that I meant a feature request for future versions. It doesn't help you now, but it's a useful request.
splash
I'm pretty sure that way back in 1998 somebody said: "Submitting a feature request for D2? Are you kidding me? I'm pretty sure that they are not going to add it do D2 if it isn't possible at the moment in D4" :D That's why we still don't have this feature in D7 and D2010 and we'll never have it, since nobody cares about reporting it.
Alexander
Play a little with QC and see how many big bugs and needed features are there since Delphi 6 or 7 and never taken care of, many still only in "reported" state. QC is useful, but it is true that if you report against an old version instead of the latest one your bug may never be looked at and opened.
ldsandon
+2  A: 

That is not possible.

OutputDebugString sends string to debugger (as its name suggests). There can be only 1 active debugger per process. You run your application under Delphi - Delphi got the messages, since its a debugger. You run your application outside Delphi - DebugView can access them, since no debugger claimed it.

However: WHY do you need this? Just disable other types of events in Delphi event log - and you'll get the same functionality as DebugView has.

Alexander
I know that the output is send to the debugger. My question is how to bypass it. But it looks like there's no way to bypass it. And i don't get the same functionality if i disable the other types. I'm still receiving hundreds of debug messages. In DebugView i can filter the output and thus i'll only see what i'm interested at the moment. That makes a huge difference.
pantarhei
Lieven
@Lieven: That looks interesting. Will have a closer look if the time pressure is gone. Will it ever be gone? ;)
pantarhei
I think that you're asking too much from this simple debugging routine. Try to look to other logging solutions, like ETW ( http://msdn.microsoft.com/en-us/library/bb968803(VS.85).aspx ) or SmartInspect ( http://www.gurock.com/smartinspect/ ) or anything else.
Alexander
@Lieven Your link talks about different thing. It discusses tool, which acts as debugger reading output from OutputDebugString and transfer it to other session, where *actual* debugger is. There are 2 debuggers, each one is connected to *separate* sources. There are 2 sources and 2 debuggers. This is different from the situation in question, where pantarhei wants 2 debuggers (Delphi and DebugView) connect to *single* source. And you can't do that, since reading from source involves using *auto-reset* events. Once debugger use them - no other application can use them too for obvious reasons.
Alexander
If I understand correct, pantarhei really only wants the output of OutputdebugString to go to DebugView. In the end, if it's a matter of capturing the right event, attaching to the right mutex, I'd gather it *might* be possible to write a tray application that *steals* the information passed on by OutputDebugString.
Lieven
@Lieven Since Delphi already reads output of OutputDebugString - it's the same as reading from OutputDebugString by two independent applications. And this is not possible. If your application is going to wait on the same event, you will end up in random chaotic behaviour of having messages posted randomly to Delphi or your "hi-jack" application. You need either to ask Delphi to stop reading OutputDebugString (which is not possible) or ask it to cooperate with you (which is also not possible). I really do not see a way here.
Alexander
Also note that protocol for OutputDebugString uses mutex to guarantee exclusive access to reading OutputDebugString by only one application. Sure, your application can just not respect this mutex and access buffer directly, but you still can't get notification about changes in reliable way.
Alexander
@Alexander, I'm not going to argue about the inner workings, not really my cup of tea, but the line of text *redirects them to a debugger of your choice* implies to me that it should be possible. I didn't say it would be nice :)
Lieven
@Lieven You read sentence out of context then. Full statement is "DbgViewRedir allows you to **monitor other sessions than your own** and either displays these messages in a console or redirects them to a debugger of your choice". Surely, *this* is possible. But it is far different thing that pantarhei asks.
Alexander
A: 

Not what the original question asked, I realise, but it's worth taking a look at CodeSite from Raize Software. It takes OutputDebugString to a whole new level. Messages (can) get directed to a CodeSite viewer which is roughly equivalent to a highly souped up DebugView. Well worth every penny IMHO.

shunty
Sure. But it's not in my responsibility to order or introduce these tools. I've also looked at SmartInspect. Would be nice to have, for sure. But not at the moment.
pantarhei
On the contrary, Pantarhei, it's *everybody's* responsibility to introduce useful tools to their peers.
Rob Kennedy
Ok. Used the wrong words. So i introduced the tools already. But i can't decide if they will be bought and integrated into the existing tooling.
pantarhei
+1  A: 

Instead of DebugView you can try to use Process Monitor and its new "debug output" capability. It does not use OutputDebugString, it uses its own API, and there's also a Delphi wrapper here. You can use Process Monitor filtering features and Delphi won't trap that messages - but it's not a generic features as those of OutputDebugString.

ldsandon
Could use it for my own local tests. But i don't think that i will make it into the code base. But i'll take a look on it. Thanks.
pantarhei