Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Ariman on January 23, 2009, 10:35:49 am

Title: Debugging DLL for console app.
Post by: Ariman on January 23, 2009, 10:35:49 am
I'm trying to debug a plugin for third-party console application. Plugin is written as a DLL. When I start debugger host process is created (I can see new process in process list) but there is no console window appears.
Codeblocks version: svn 5382 (nightly build)
OS: Windows
Compiler: mingw (gcc 3.4.5) + gdb 6.8
Should I make some additional adjustment in settings or my library or debugger options to actually make console appear?
Title: Re: Debugging DLL for console app.
Post by: ollydbg on January 23, 2009, 10:49:36 am
I'm sure the way below works, you can have a try.
Debug from the host application :D, then trace into your DLL.
Title: Re: Debugging DLL for console app.
Post by: Ariman on January 23, 2009, 11:23:09 am
I'm sure the way below works, you can have a try.
Debug from the host application :D, then trace into your DLL.
I wish it was so simple. But host app has no debug symbols let alone source code. :(
Title: Re: Debugging DLL for console app.
Post by: ollydbg on January 23, 2009, 01:20:20 pm
You can download the sample programming from :
http://forums.codeblocks.org/index.php?action=dlattach;topic=4896.0;attach=1707
And set DLL as main target, and set the exe has a host applications. It works fine. :D, see my screenshot below.


[attachment deleted by admin]
Title: Re: Debugging DLL for console app.
Post by: Ariman on January 23, 2009, 02:53:48 pm
Thanks for the sample. It works fine indeed.  :)

I did some more experiments and found interesting thing. I've found all stuff that should be printed on console in debugger log ("Debugger (debug)" window). Seems that stdout handle of the host app is redirected. But breakpoints in DLL are working properly.
Does anybody know how to change this behavior? I need console to be shown as usual.

I've attached sample projects (one for console app and one for DLL for more clean experiment  :D).

[attachment deleted by admin]
Title: Re: Debugging DLL for console app.
Post by: ollydbg on January 23, 2009, 04:04:37 pm
Yes, I tested it.
You are right, the APP.exe's output was redirect to gdb's log.
Sorry, I can't help you to solve the problem. :(