Solved

Debugging function in dll in a run time

Posted on 2010-11-18
8
942 Views
Last Modified: 2012-05-10
Hello experts.

I have DLL and function there.

I would like to test this function in a run time i. e. run a program that calls my function and once it is called to go through it line by line.

Is it possible in VC++ 2008 Pro?
How?

THX

panJames
0
Comment
Question by:panJames
  • 4
  • 4
8 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 34165432
Hi panJames,

that's possible and simple - you just have to call a program which calls the function in the DLL - there are some ways to do so, the easiest is to debug an EXE which is a project of the solution where the DLL is another project.

In this case you can simply put a breakpoint into the DLL function in question and start the EXE with the debugger - as soon as the EXE calls the function from the DLL the breakpoint should be hit.

If you have an EXE which calls the DLL function but is not part of the DLL project/solution you can set the DLL project's property 'Debugging->Command' to the full path of the EXE - then set a breakpoint in the DLL function in question and start debugging as usual - the EXE will be started thus calling the function in the DLL which again should hit the breakpoint.

Hope that helps,

ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34165579
JFI: Here's a link to a MSDN artice about how to debug a DLL, might be that's helpful: http://msdn.microsoft.com/en-us/library/ms164704.aspx
0
 

Author Comment

by:panJames
ID: 34165582
I did it and it says that it cannot hit the breakpoint because "No symbols have been loaded for this document"
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34170916
Maybe youre DLL has no debug info - you'll have to use a DEBUG build and you should check whether debug info is built in the DLLs project settings:
- 'C/C++ -> General -> Debug information format' should be 'Program database'
- 'Linker -> Debugging ->Generate Debug Info' should be 'Yes'
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:panJames
ID: 34171453
Didn't help.

I tried this way:

http://bytes.com/topic/c-sharp/answers/238429-no-symbols-have-been-loaded-document-answer-anyone

and it didn't help either.

panJames
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34172204
Take a look at the debug-output: There should be a line saying something like:

> '<Your EXE's name>': Loaded '<Your DLL's full path>', Symbols loaded
or
> '<Your EXE's name>': Loaded '<Your DLL's full path>', Symbols not loaded (out of memory)
or
> '<Your EXE's name>': Loaded '<Your DLL's full path>', Cannot find or open the PDB file

or anything else - is there such a line? And if so, what's the message at the end?
0
 

Author Comment

by:panJames
ID: 34186997
'test.exe': Loaded 'C:\Documents and Settings\aaa.bbb\My Documents\Visual Studio 2008\Projects\DLL\test\test\Debug\test.exe', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'test.exe': Loaded 'C:\Documents and Settings\aaa.bbb\My Documents\Visual Studio 2008\Projects\DLL\test\test\Debug\source.dll'
'test.exe': Loaded 'C:\Program Files\OpenCV-2.1.0\build\bin\Debug\cv210d.dll', Symbols loaded.
'test.exe': Loaded 'C:\Program Files\OpenCV-2.1.0\build\bin\Debug\cxcore210d.dll', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
'test.exe': Loaded 'C:\Program Files\OpenCV-2.1.0\build\bin\Debug\highgui210d.dll', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\avifil32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\winmm.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\msvfw32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\avicap32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\olepro32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
'test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.
'test.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\EntAPI.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll'
'test.exe': Unloaded 'C:\WINDOWS\system32\EntAPI.dll'
'test.exe': Unloaded 'C:\WINDOWS\system32\netapi32.dll'
'test.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
'test.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'

0
 

Author Comment

by:panJames
ID: 34187041
Wow!

Solution to my problem was easy!

I copied test.exe to debug folder for my dll project and made added it to my dll's command line.

Now it works.

My bad!

thx for help!

panJames
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to connect an iphone application to mysql database 10 187
memory leak detection 9 69
An API detour question 7 79
Super Scope, DHCP 5 51
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now