Solved

Why Cant I debug an extern C function in my Project?

Posted on 2009-05-07
6
264 Views
Last Modified: 2012-05-06
Im developing a windows application (not web-based) using Visual Studio 2008 and Visual C#.

One of the projects within the solution builds into a DLL. One of the source files of this DLL contains a function as shown below;

extern "C" __declspec(dllexport) double* getTriggerWaveform_DLL(long channelNo, long noOfPoints, double* timeIncrement, double* startTime) throw(exception)
{
   // sample code
   int a = 2;
   a = a + 2;
}


Im trying to debug my solution but I am not being allowed to set a breakpoint in the code within this function. Instead I get the following message

"The breakpoint will not currently be hit. No symbols have been loaded for this document."

When I select the solution then do Project->Properties->Configuration Properties I note that the Platform for the DLL is set as "Win32" whereas all the other projects in the solution have Platform set to "Any CPU". Im not sure if that is significant.

Also note that Build is set to "Debug" for all the projects in the solution so that is not the reason.

I really need to be able to debug this function because my application hangs somewhere inside it !

Any ideas?
0
Comment
Question by:rangers99
[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
  • 3
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
CuteBug earned 125 total points
ID: 24324398
When you try to attach to a process, Visual studio displays a dialog titled "Attach To Process"

1. Select the process you want to attach to.
2. In that dialog, in the "Attach To" section, there is a button called "Select". Click on that.
3. It shows up a new dialog.
4. Select the "Debug these code types" radio box.
5. From the list, select "Managed" and "Native".
6. Click OK.
7. Click Attach.
8. Now you should be able to set a breakpoint in your dll.


0
 

Author Comment

by:rangers99
ID: 24324880
CuteBug

Thanks for the reply.

Unfortunately I don' understand what you mean you say "Select the process you want to attach to". By process do you mean the DLL.
0
 
LVL 16

Expert Comment

by:CuteBug
ID: 24325005
When you start the application which uses your DLL, that application will be listed in the Attach to Process dialog.
Select that process...

By the way you must attach before your application call the DLL's method.
One way to do this is to add a MessageBox.Show("Attach"); before your DLL's method is called.

Once you have attached the debugger to the process, then you can click Ok on the message box that is displayed.
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:rangers99
ID: 24325229
CuteBug

Thanks I tried that. Unfortunatley the process is greyed out and has a type of "Managed" (all the other processes listed have type x86). The "Attach" button is disabled for my process and I cant attach the debugger. Any way round this?
0
 
LVL 16

Expert Comment

by:CuteBug
ID: 24334902
Hi,
Sorry for the late reply.

If the process appears greyed out in your Attach to Process dialog, it means that you have already attached to that process.
(Could you please show a screenshot of the Attach to Process Dialog to confirm this?)

If that is the case then you can detach the process (the option is under Debug menu).

Now attach again using the method described in my previous comment.
0
 

Author Comment

by:rangers99
ID: 24336509
Fantastic, thanks Cutebug
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

733 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