?
Solved

Debugging function in dll in a run time

Posted on 2010-11-18
8
Medium Priority
?
960 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 2000 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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

590 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