Solved

Debugging function in dll in a run time

Posted on 2010-11-18
8
949 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
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!

 
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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Intel debugger, idb, only seeing .c and .h, but no .f90 1 536
An API detour question 7 106
Using ANSI C how to Read a .csv file 10 131
Reactjs with .NET 3 124
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
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.

739 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