Posts

Showing posts from August, 2020

Viewing variables in a stackframe

Image
This is in continuation to my previous post about getting started with WinDbg. Today, we will take a look at ways to look at the values of variables using SOS extension. We will start with the usual stuff that we did in the last post. 1. Start the process 2. Attach WinDbg to that process 3. Add a breakpoint to Method1  4. Get there Now, I will reintroduce !CLRStack with a few parameters.  !CLRStack -l Displays all the local variables !CLRStack -p Displays all the parameters  !CLRStack -a is same as adding both -p and -l SO, let's do that !CLRStack -a I see two different methods here. The one I am interested in is Method1. Let us try to see the arguement that we have here: !DumpObj /d 028149c4 Tada. You have the value of the string there :)

Getting started with WinDbg

Image
 You can install it directly from the Windows Store using the guide here . If you are sitting behind a corporate proxy, then forget it. You can use old WinDbg for your job. I will cut back on a lot of talking and jump straight into debugging.  I will start with creating an application. Nothing fancy. The code does not have to make any sense. I have pasted it here. So, I will fire up the exe and wait for the program to naturally halt at Console.Readline. Now attach the debugger and press g. Now enter the following command. This will load sos extension that helps us a lot with debugging managed code. .loadby sos clr Use the below command to display the stack of all the managed threads in the process. !EEStack This should display the current stack trace. The program has paused at Console.Readline in our Main method. Let's now set a breakpoint at the method we want to look at: private static void Method1(string v) In order to do that, let us look that up using the following c...