• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Debugging

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
gvector1
Asked:
gvector1
  • 5
  • 4
1 Solution
 
gregoryyoungCommented:
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
 
DeanHorakCommented:
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
 
gvector1Author Commented:
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
gregoryyoungCommented:
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
 
gvector1Author Commented:
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
 
gvector1Author Commented:
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
 
gregoryyoungCommented:
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
 
gvector1Author Commented:
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
 
gregoryyoungCommented:
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
 
gvector1Author Commented:
Sorry I haven't answered before now....I lost track of this post.

Thanks,
Kendal
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now