Solved

Debugging

Posted on 2007-03-23
11
263 Views
Last Modified: 2013-11-26
I am attempting to debug an application written in C# with Studio 2005.  I am having a serious problem where my application will freeze up completely and I cannot determine where it is happening at.  There will be no respose at all.  Is there a tool of some sort that can monitor code and keep track of the last line of code executed, so I can run my application and find out the last line executed when it locks up????
0
Comment
Question by:gvector1
  • 5
  • 4
11 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 18781974
Yes take a look at using a minidump. http://www.codeproject.com/debug/postmortemdebug_standalone1.asp?df=100&forumid=3419&exp=0&fr=26 you can then open it in VS and load SOS ... once you do that type in the immediate window !CLRStack and you will see the exact call stack at the time the minidump was taken .. you can see this for all threads.

Cheers,

Greg
0
 
LVL 11

Expert Comment

by:DeanHorak
ID: 18781990
I  don't have any magic tool to recommend for you, but I'll share the technique I use in these cases.

The way I usually handle these kinds of issues is to run the app in debug mode with a breakpoint at the last place I know that things are still ok (start at the very first line of the app if you have to).

Then I "step over" each code section (making a note of where I am before I do the step-over) until it locks up. I then go back and restart the process in debug mode, setting a breakpoint at the point where I was last before the "step-over" that resulted in a lockup. This time I do a "Step Into" and then repeat the "step-over" technique as before until it locks again. I just repeat this process, each time drilling down a little deeper into the logic until I find the exact statement causing the lockup.

Hope this helps...
0
 

Author Comment

by:gvector1
ID: 18782455
The problem is that if I set a breakpoint in the area the lockup occurs and then continue after the breakpoint, I NEVER get a lockup.  I only get a lockup if it runs straight through without a breakpoint, and even then, it is not consistent.  It seems to happen at different points.  I determined this by using Debug.Writeline in different spots.  Like I said I was looking for something that can possibly tell me the last lines of code executed.

GregoryYoung,
That is a very interesting article, but it only seems to work with applications that generate an exception.  I only with my application was generating an exception.  It locks up and is unresponsive, therefore I get no information as to the cause or location of the problem.

Any suggestions.....
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 18782498
gvector its all about opening a minidump ... it shows you how to get a minidump at an exception but you can take a minidump at any point ... There are even small utilities that will take a minidump of your app for your (dr watson comes to mind) .. once you have that minidump the process is the same (i.e. load it up in debugger etc)
0
 

Author Comment

by:gvector1
ID: 18782976
All I can seem to find is Dr Watson For Windows.  The codeproject article is all about C++ and not working from a C# standpoint.  How can I get Dr Watson and use it to take a minidump when my application is locked up???
0
 

Author Comment

by:gvector1
ID: 18783022
I also have an issue with the same application where all of a sudden the application closes completely out with no warning and no error message.  It is as if you clicked the X to close the application.  I have exception handling code, but it is never excuted, so I take it that it is not an exception.  Any recommendations on how to debug this problem as well.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 18783102
well the second problem would be a bit more difficult since taking a minidump would be tough .. i would start logging in my app to try to find that.

minidumps can be taken by any outside process or your own process ... adplus is a common example, so is WER, windbg, cdb, etc etc. Taking a minidump isnt that tough I promise :)

http://msdn.microsoft.com/msdnmag/issues/05/03/Bugslayer/ includes some further information and may be of some use .. that whole article series is pretty good (there is also one on SOS). You also might want to check out a book by the author of those John Robbins which goes into much more detail on this kind of debugging.
0
 

Author Comment

by:gvector1
ID: 18795600
Can a dump help me if my application is not actually throwing an exception.  It just appears to be locking up and not responding to the point that I have to kill it through the Task Manager.  How can lockup situations like that be efficiently debugged.  A problem in some spots is that using breakpoints and stepping through the code does not lead me to a lockup, I think it is because some of the problems may be threading issues and if I breakpoint one of the threads, it ends up allowing the other thread to finish.  In some spots I think I am having threads clashing.  Any suggestions on how to get through this????
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 18795777
Yes it can.

see above ... a dump is nothing more than a snapshot of your application at a given point in time which you can then load up in a debugger (its kind of like hooking up a debugger without needing the debugger on the machine, it saves the state for you). In fact this is THE way to debug such issues as thread deadlocks.

0
 

Author Comment

by:gvector1
ID: 19126666
Sorry I haven't answered before now....I lost track of this post.

Thanks,
Kendal
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

810 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