Solved

Debugging

Posted on 2007-03-23
11
259 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:gvector1
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry I haven't answered before now....I lost track of this post.

Thanks,
Kendal
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now