background preloader

Debugging

Facebook Twitter

Create a new Fiddle - jsFiddle - Online Editor for the Web (JavaScript, MooTools, jQuery, Prototype, YUI, Glow and Dojo, HTML, CSS)

.Net

Configuring Visual Studio to Debug .NET Framework Source Code - Shawn Burke's Blog. It's finally here - the launch of the .NET Reference Source project. This post (hopefully!) Contains everything you need to know. Over the past few weeks, we ran a pilot of this feature and collected lots of great data that helped us work through some issues and understand where people were likely to have problems. First, though, if you have any problems, please make sure you've followed all of the steps exactly as described. Note this functionality is not available on the Express versions of the Visual Studio 2008 products. 1) Install the Visual Studio 2008 QFE. UPDATE: If you get an error installing the Hotfix , try inserting your VS 2008 DVD and then running the Hotfix EXE again.

UPDATE (1/18): There were some problems with the QFE link above that have been addressed, sorry for the inconvenience, it's fixed now. 2) Start Visual Studio 2008 and bring up Tools > Options > Debugging > General. Set the following two settings: Your settings should be as below: Setup is done! That's it! Insider: Secrets of Debugging. Practical .NET Insider: Secrets of Debugging Faced with reviewing large swaths of other people's code, Peter Vogel is left to ask: what does it really take to be good at debugging? Even with following a Test Driven Development regime, my code doesn't work the first time (pretend you're surprised). So debugging is a critical skill for me.

Also, as a hired gun, I'm frequently having to deal with someone else's code, which often isn't working the way everyone expected it to. One thing I have noticed: I'm better at debugging than a lot of the people I work with. My first step is to look at the evidence to make sure that I know what the problem is. Lately, however, I've been reviewing a large whack of code with an eye to improving its quality and performance. But I wonder: Can people learn to "debug better? " About the Author Peter Vogel is a principal in PH&V Information Services, specializing in Web development with expertise in SOA, client-side development, and user interface design. Using Fiddler to debug HTTP. Justin James offers tips and strategies on how to use Fiddler for debugging HTTP sessions.

He says this should cover your needs for most scenarios. I use Fiddler on a regular basis for debugging HTTP sessions, and in this post, I will give a brief walk-through of how you can use Fiddler as well. First, you will need to download Fiddler (you may want to check out some of the various Fiddler add-ons). Once you go through the easy installation, you will be able to start Fiddler (Figure A). Figure A Fiddler after starting up (Click the image to enlarge.) In the lower left corner of Figure A, you will see "Capturing," which means that it is recording HTTP traffic. Each line on the left represents an HTTP connection that was made. Something that you will want to take care of pretty quickly is to set Fiddler up to work with HTTPS traffic; after all, a lot of the services and applications that you will want to debug use encryption. J.Ja. .NET Memory Profiler - Find Memory Leaks and Optimize Memory Usage in Programs Written in C#, VB.NET or any other .NET Language.

Memory Leak - Trouble figuring out with windbg.exe what causes the memory leak. ADPlus Command-Line Options. How to use ADPlus to troubleshoot "hangs" and "crashes" System requirements ADPlus has the following minimum requirements: Windows NT 4.0 Service Pack 4 or laterWindows Scripting Host version 5.6 or laterAt least 10 megabytes (MB) of free space on the disk or network share where ADPlus will put the output filesMicrosoft Debugging Tools for Windows installed Where do you obtain ADPlus? ADPlus is included with the latest Microsoft Debugging Tools for Windows. To obtain the latest Microsoft Debugging Tools for Windows, visit the following Microsoft website: The Debugging Tools are listed in two locations on the Installation Options screen in the Windows SDK Setup Wizard. Note The most recent version of Microsoft Debugging Tools for Windows is provided as part of the Windows SDK. New features for ADPlus Version 6.0 ADPlus V6.0 has been completely rewritten.

Debugger.chm is located in the same folder as ADPlus.vbs. What does ADPlus do? ADPlus is console-based Microsoft Visual Basic script. The following are some of the features of ADPlus: Hang mode. Undocumented PSSCOR2 functions « Naveen's Blog. With the latest release of PSSCOR2 release from Microsoft comes with a set Undocumented functions.

FYI PSSCOR2 is a superset of sos.dll for .NET framework 2.0/3.5, it also has bunch of functions which are available in the .NET 4.0 sos.dll. The .NET 4.0 also has few undocumented functions and PSSCOR2 does have them. But these functions are totally new and is not even available in .NET 4.0 sos ! FindInterestingStrings! SaveSnapshot! I did manage to figure out the usage of few of these, but I let you explore them before I blog about this. Like this: Like Loading... First Look at Psscor2 the new WinDBG Debugging Extension for Managed Code | Cory Foy. About two weeks ago Microsoft announced the release of Psscor2 – a managed debugging extension for WinDBG which is a superset of the awesome SOS debugging extension.

This is an insanely useful tool when you are trying to debug problems on Production machines where you don’t (and can’t) install Visual Studio, or when you need a deeper understanding of what is going on with your managed code. While there are several articles listing out the commands and a detailed command help view, there isn’t much else. I’m teaching my .NET Debugging class in two weeks for a client in NYC and wanted to include a section on Psscor2. Since I was going through the commands, I thought it would be fun to post them for the world to see as well. (Note: Don’t leave this blog post without looking at the FindDebugTrue and FindDebugModules commands!) Loading Psscor2 First, download it from the download site above. Once you have it loaded, you can type “! ! The first new command is ! 0:000> ! Total 10 exceptions ! 0:000> ! ! ASP.NET Debugging. Getting full user mode dumps automatically when your process crashes - If broken it is, fix it you should.

I recently got a question about if it is possible to generate full user mode dumps automatically every time the process crashes (without having debug diag or adplus installed and monitoring your system). This would be useful for example if you are setting up a site, and you want to make sure you get dumps if it ever crashes so that you don’t have to repro the issue at that point, just to get data. It turns out that starting with Windows Server 2008 and Vista + SP1, Windows Error Reporting (WER) will let you do just that. It even worked on my Win 7 machine. The documentation here says that “Applications that do their own custom crash reporting, including .NET applications, are not supported by this feature”. Setting this up HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\w3wp.exe Under this key I added 3 values (types and descriptions can be found in the MSDN article) A word of caution Have a good one, Tess.

Investigating ASP.Net Memory Issues using WinDbg and SOS. Troubleshooting System.OutOfMemoryExceptions in ASP.NET - WebTopics. When the .NET Framework was first released, many developers believed the introduction of the garbage collector meant never having to worry about memory management ever again. In fact, while the garbage collector is efficient in managing memory in a managed application, it's still possible for an application's design to cause memory problems.

One of the more common issues we see regarding memory involves System.OutOfMemoryExceptions. After years of helping developers troubleshoot OutOfMemoryExceptions, we've accumulated a short list of the more common causes of these exceptions. Before I go over that list, it's important to first understand the cause of an OutOfMemoryException from a 30,000 foot view. A 32-bit operating system can address 4GB of virtual address space, regardless of the amount of physical memory that is installed in the box.

Out of that, 2GB is reserved for the operating system (Kernel-mode memory) and 2GB is allocated to user-mode processes. Large DataTables. Crash Dump Analysis » Blog Archive » Crash Dump Analysis Checklist. Software Diagnostics Library: LoginIf you have previously purchased courses and books from Software Diagnostics Services please use this contact form for information regarding membership: Contact. Visual Studio » Advanced .NET Debugging. Did you know that you can use SOS from within Visual Studio 2005, not just from WinDbg? It has been previously discussed in a couple of places but most people don’t know it is possible to do that.

“Why should I use the SOS extension from within Visual Studio?” , you are probably asking. The answer is quite simple. Visual Studio is a rich debugger that shows us most of the information we want to know but it doesn’t show us a few important things like the actual size of an object and all of its references and who is referencing our object. While these things are not straight forward in Visual Studio, they are very easy to accomplish in SOS. ! So, how do we actually do that? Well, the first thing you need to do is enable “unmanaged debugging” by going to the “Project Properties” -> “Debugging” -> “Enable Unmanaged Debugging”. After doing that, you can stop somewhere in your program, open the “Immediate” window (Debug -> Windows -> Immediate) and type: .load sos This will load the SOS extension. Not reproducible Windows Forms Hang - If your application has hung once it will hang again | Debugging + Random Stuff.

Problem Description At one of our customer site, windows forms business application hung for a business user. This issue occurred only on one machine out of 100s of users. The way we look at it is, If your application has hung once on any machine that means it will hang again, so I volunteered to look into his machine armed with WinDBG. Note Executed command to check for syncblock/locks are for illustration purpose only 1. 2. 3. 4. Analysis 1. 2. 0:000> ! CritSec <Unloaded_PI32.dll>+a00a92f at 0a00a930 LockCount 0 RecursionCount 0 OwningThread 0 *** Locked 3. 0:000> ~*e!

0012eda4 0167834e MyApp.UI.RunStartup() 0012eff0 7b1c8906 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef) 0012f3ac 7b195911 System.Windows.Forms.Application.Run(System.Windows.Forms.Form) 0012f3c0 01676974 MyApp.Program.RunSelectPlanForm() 0012f400 0187b525 MyApp.Program.Main(System.String[]) 4. 0:009> ~0kb ChildEBP RetAddr Args to Child 0012e07c 7c90df2c 7c809574 00000002 0012e0a8 ntdll! 5. ASP.NET Case Study: Hang on WaitOne, WaitAny or WaitMultiple - If broken it is, fix it you should. One of the synchronization methods in .NET is the ResetEvent. It comes in two flavors, the AutoResetEvent which resets itself immediately after it is set, and the ManualResetEvent which as the name suggests you have to manually reset.

Lets say you have a team of developers that can implement different parts of an application simultaneously without interaction, then the work order might look something like this Ask Bob to implement X Ask Belinda to implement Y Ask Ben to implement Z Integrate X, Y and Z when you get a notification that they are done with their work In code (using a reset event) this would look something like this ImplementApp(){ ImplementX(); //spawns off implementation of X on another thread, signals when ready ImplementY(); //spawns off implementation of Y on another thread, signals when ready ImplementZ(); //spawns off implementation of Z on another thread, signals when ready WaitHandle.WaitAll(autoEvents); IntegrateXYandZ(); //uses the results of the Imlement methods }

.NET Hang Debugging Walkthrough - If broken it is, fix it you should. I have talked about a number of different hang/performance issues in my posts. This post is a generic debugging walkthrough for hangs. It applies to all types of .NET processes and to some extent also to non-.net processes even though it has some .net specific items. Define the hang/performance issue The first step in troubleshooting a performance issue/hang of any kind, whether it is .NET or native is to find out what we are dealing with and what the expected resolution is. Asking yourself a few standard questions may help you zone in on the problem without even attaching a debugger, and if you need to attach a debugger you will have a lot better understanding of what data you should collect and what you should be looking for. If you call into support with a hang situation it is also very good to have the answers to these questions handy.

My Standard questions are (in no particular order): What is the user experience? Gathering dumps: adplus -hang -pn <process name.exe> Debugging: Lock WaitOne. Using Fiddler to debug HTTP.