News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Debugging DLL for console app.

Started by Ariman, January 23, 2009, 10:35:49 AM

Previous topic - Next topic

Ariman

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?

ollydbg

I'm sure the way below works, you can have a try.
Debug from the host application :D, then trace into your DLL.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Ariman

Quote from: 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.
I wish it was so simple. But host app has no debug symbols let alone source code. :(

ollydbg

You can download the sample programming from :
http://forums.next.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]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Ariman

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]

ollydbg

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. :(

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.