473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Debugging mixed DLL called from legacy code

I'm writing a mixed-mode C++ DLL which is used by an old C++
application that I don't have the source code to. I'm amazed by the
ease of interoperability, but the one problem I'm having is debugging
the DLL, as the C++ app crashes if loaded into the debugger.

If I could just get the line number on which an exception occurred
that would be enough to fix most bugs. At the moment I use
exception.ToString() and get a stack trace but it's very hard to find
the bug in a large function without knowing which line.

Anyone have any tips, either on how to get the legacy app to run under
the debugger (so I can step through my DLL when called), or get the
line number an exception occurred on?

Many thanks indeed,

Max Christian
Nov 17 '05 #1
3 2107
"Max Christian" <ne**@maxuk.net> wrote in message
news:c6**************************@posting.google.c om...
I'm writing a mixed-mode C++ DLL which is used by an old C++
application that I don't have the source code to. I'm amazed by the
ease of interoperability, but the one problem I'm having is debugging
the DLL, as the C++ app crashes if loaded into the debugger.
...
Anyone have any tips, either on how to get the legacy app to run under
the debugger (so I can step through my DLL when called), or get the
line number an exception occurred on?


Well, if you can't run under the debugger can you put a DebugBreak() line at
some point when your DLL gets invoked and step through from there?

Still, I'm not sure I understand what crashes when. The crash occurs only
when you debug?

Did you

1) build the DLL with VS.Net?
2) specify the "legacy" executable in the "command"
edit box on the Debugging properties page
3) launch the executable by starting the debugger

Is that the sequence that crashes? Does it crash immediately?

Regards,
Will

Nov 17 '05 #2
"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message news:<#q**************@TK2MSFTNGP10.phx.gbl>...

Well, if you can't run under the debugger can you put a DebugBreak() line at
some point when your DLL gets invoked and step through from there?
Unfortunately that causes the C++ app to crash immediately, which
surprised me as it's obviously my code that's running when
DebugBreak() is called.

Still, I'm not sure I understand what crashes when. The crash occurs only
when you debug?
Yes, only when debugging. I do exactly the three things you've listed
below (using VS.NET 2003), I get a warning about no debug info in EXE,
I click OK to debug anyway, and then I get this msg box:

"The application failed to initalize properly (0xc0000142). Click on
OK to terminate the application."

As I say, the app works fine when not under the debugger.

M

Did you

1) build the DLL with VS.Net?
2) specify the "legacy" executable in the "command"
edit box on the Debugging properties page
3) launch the executable by starting the debugger


(Yes, I did all of those.)
Nov 17 '05 #3
"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message news:<#q**************@TK2MSFTNGP10.phx.gbl>...

Did you

1) build the DLL with VS.Net?
2) specify the "legacy" executable in the "command"
edit box on the Debugging properties page
3) launch the executable by starting the debugger


I've found an answer to this -- I changed the Debugger Type from Auto
to Managed Only in Configuration Properties|Debugging and now it
works. (It crashes as before under both the Mixed and Native Only
modes.)

I hope that's useful to a future googler...

M
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
5
by: John E Katich | last post by:
I'm just getting into VC++ managed code (VS 2003). Using the App Wizard I build a VC++ .NET Console Application. When I press F5 it takes 30 seconds to get to the Console::Writeline(). ...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
4
by: Lonewolf | last post by:
hi, I'm still in the process of transiting from MFC/VC6 to vs2005, and a lot of things are very alien to me. So hope you could bear with me if my question sounds stupid. Basically I have native...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
4
by: Edson Tadeu | last post by:
I have imported a project from Visual Studio .Net 2003, consisting only of native (unmanaged) C++ code. Debugging was very fast in that IDE, and I didn't even notice a delay when stepping over...
5
by: phnimx | last post by:
Hi , We have developed a number of plug-in .NET Library Components that we typically deploy with our various applications by installing them into the GAC. Each of the applications contains an...
0
by: Brian | last post by:
Hi. I need to place wrappers around a set of legacy VC++ 6 dlls and call them via Asp.Net. This works but I can't step into them. Every time I do, they step over, which is a bit of a nightmare. ...
3
by: Pixel.to.life | last post by:
All, A question on JIT debugging with VS2005. I have a managed app that builds great on one machine (Vista Home basic, VS2005, JIT enabled for managed/unmanaged code). I can also debug it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.