Solved

Debugging function in dll in a run time

Posted on 2010-11-18
8
951 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

695 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