Solved

Tracing a run-time error to a line of source code

Posted on 1998-06-02
3
219 Views
Last Modified: 2010-08-05
I am using MSVC 5.0.  I made a release build of my project ( 1 exe and several dlls).  I get a run-time error in one of the DLLs consistently when running the release build.  The run-time error does not happen with a debug build.  

My question is:

Is there a way for me to take the CS:EIP pointer that i'm given at the time of the error and somehow trace it back to a line of source code?  I've made a map file, but I haven't been able to get anything useful out of it.

thanks in advance for any help
Bob Brickhouse
Product Developement
Grayson Wireless
0
Comment
Question by:brickb
[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 Comments
 

Expert Comment

by:alfredj
ID: 1165121
I can't answer your question specifically, but you might be able to
solve your problem by downloading (if you havent already)  the
<A HREF=www.microsoft.com/visualc/download> Visual C++ service pack</A>  from  www.microsoft.com/visualc/download.  Many strange
optimizer problems went away when I upgraded.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1165122
You don't need the CS value.  But the EIP should be one of the addresses in your map file.

Unfortunately, it could be an address from the run-time library, or from a DLL.  So it might not help.

This is not the best way to debug.  Can you print "progress" messages to find out where the problem is occurring.   OutputDebugString is great in this capacity.
0
 
LVL 2

Accepted Solution

by:
abesoft earned 200 total points
ID: 1165123
The major problem with tracing an instruction pointer back to a map file is that the DLL is (actually, it may be) re-mapped when it is loaded into memory.  So the register is pointing at a location that is offset from the actual code in the map file.

So, in order to get back to the actual line, you will need to figure out the offset that the DLL was loaded at.  Matt Pietrek wrote a utility for MSJ that did this: it was called LoadProf32, but I can't seem to find it at the MS site right now- their search engine makes my proxy gag somehow, or maybe it's the other way around ;)  Anyway, one of the things that LoadProf32 would do is report on the offset that each DLL is loaded at.  (It also reported a lot of useful info about the initialization time for each module loaded:  I highly recommend this utility...)

Taking the load offset, and seeing if it was different from the anticipated load offset, you will know where the fault actually happened.  This should let you look back into your map file to find out where it happened.  

If you combine this with a good post-mortem (like a stack dump from Dr Watson) you should be able to trace into things a little more.

Of course, you will still be only getting to the function level- the actual line won't be available to you, since that info is completely missing from a release build.  But you WILL be able to either read through the assembler (if you're comfortable with that) or go back to the source and add extra logging statements to track down the actual line.

Good luck!
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sorting efficency of sorting algorithm 30 151
Dialogbox API leak? 18 119
Can Live bindings change TGrid Cell Colour ? 1 64
using interface in TLB 3 31
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

752 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