Monday 7 February 2011

How to start with WinDBG

There are different ways to debug an application using WinDbg.


1.  Start the application you want to debug.
2. Start WinDbg from start-> program -> Debugging tools for windows(x86)->WinDbg
3. From File -> attach to process,  select the process you want to debug.


Or
You can start an application directly from WinDbg as follows.
1. Start WinDbg select File --> Open Executable, and point to the exe path where the application is located.


or
after starting  WinDbg
type the following command 
.attach PID
PID --> Process ID of the application. This can get from task manager. Press the following key combination 
"Ctrl+Shift+Escape"  --> processes then search for relevant application you want to debug. If PID is not visible for the application. Go to View--> Select columns and select PID. Then you can find the PID of the process.


The SOS Debugging Extension (SOS.dll) helps you debug managed programs in the WinDbg.exe debugger and in Visual Studio by providing information about the internal common language runtime (CLR) environment.

Saturday 29 January 2011

Purpose of *.vshost.exe in .Net and disable

The hosting process is a feature in Visual Studio 2005 that improves debugging performance, enables partial trust debugging, and enables design time expression evaluation.


Please follow the link below to get more info
The purpose of *.vshost.exe in .net


Other resources


If you want  to disable the generation of the vshost files  please follow the below steps:



 in the Project Properties->Debug-> uncheck "Enable the Visual Studio hosting process"


Installing WinDbg


To start with WinDbg we need to install it
Please follow the link below:

(I am using  
OS: Windows vista Enterprise 64 bit
Processor: AMD)

Go to --> Debugging Tools: More Information and Previous Versions section
Select the type of debugging tools version (x86 or x64 based on your requirement) and click on the link.
As I am using a x64 bit Windows Vista Enterprise I clicked on 64-bit version.
Check the system requirements. Whether your OS supports this version.

If yes click on the "Download Debugging Tools from the Windows SDK" link.
Click on download, save the package and run. Follow as below.

The Debugging Tools are listed in two places on the Installation Options screen in the Windows SDK Setup Wizard:
Select the Debugging Tools option under the Common Utilities if you want the x64 version of the Debugging Tools and you are installing on an x64 computer. This option automatically detects the CPU architecture of the computer on which you are installing the tools and it is the fastest method of installing the tools.
Select the Debugging Tools option under the Redistributable Packages to download all three versions of the Debugging Tools (x86, x64, Itanium).
After you select the appropriate Debugging Tools option as described above, clear the check boxes for the other options so that you do not install unnecessary items. The Common Utilities option downloads the Debugging Tools into a Debugging Tools for Windows folder under your Program Files folder. The Redistributable Packages option downloads the Debugging Tools to C:\Program Files\Microsoft SDKs\Windows\v7.1\Redist\Debugging Tools for Windows.
I selected "Debugging Tools option under the Redistributable Packages" and clicked on install.
On the Installation Options screen make sure that 'Debugging Tools' is selected under 'Redistributable Packages'. You may deselect everything else if you don't need it.

If you used the default installation directory, you should find the binaries for x86 and x64 here: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Redist\Debugging Tools for Windows"

Find the Type of Processor from my previous posts.
I am using an AMD processor.
Ran dbg_amd64.msi package .
Select complete to click install the complete features.

You can go to the start menu and see "Debugging tools for windows X64" is installed on your machine.


Happy installing WindDbg...................


Determine type of processor on your windows machine

Information about the processor type is stored in the PROCESSOR_IDENTIFIER registry entry in the following registry subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment
The PROCESSOR_IDENTIFIER registry entry uses a string value that is described as follows:
  • If the string value contains "AMD64" (without the quotation marks), the computer has an Advanced Micro Devices (AMD) AMD64 processor.
  • If the string value contains "EM64T" (without the quotation marks), the computer has an Intel Extended Memory 64 Technology (EM64T) processor.
Note The value of the PROCESSOR_ARCHITECTURE registry entry in the following registry subkey is set to AMD64 regardless of the type of processor that the computer uses:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
To determine the processor type, use one of the following methods.

Method 1: Use the set command

To use the set command to determine the processor type, follow these steps:
  1. Click Start, click Run, type cmd in the Open box, and then press ENTER.
  2. At the command prompt, type set, and then press ENTER.
  3. Note the string that is displayed next to PROCESSOR_IDENTIFIER.
Method 2: Use Registry Editor
To use Registry Editor to determine the processor type, follow these steps:
  1. Click Start, click Run, type regedit in the Open box, and then click OK.
  2. Locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment
  3. In the right pane, note the string that is displayed in the Data column for the PROCESSOR_IDENTIFIER registry entry.
  4. Quit Registry Editor.
For more info please follow the link below: