• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 955
  • Last Modified:

Debugging function in dll in a run time

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
panJames
Asked:
panJames
  • 4
  • 4
1 Solution
 
ZoppoCommented:
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
 
ZoppoCommented:
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
 
panJamesAuthor Commented:
I did it and it says that it cannot hit the breakpoint because "No symbols have been loaded for this document"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ZoppoCommented:
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
 
panJamesAuthor Commented:
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
 
ZoppoCommented:
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
 
panJamesAuthor Commented:
'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
 
panJamesAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now