Introduction

DbgShell allows writing of scripts which manipulate the output of a debugger, and is intended to replace WinDbg.

Usage

Before First Use

Modify DbgShellUI.config
  • Modify the parameter "DbgPath" to match the path were the debugging tools are installed.
  • Modify the parameter "Startup" to list commands which should be ran when the dump file is open.

Using DbgShellUi

Select a dump file to open. In the bottom text box write standard dbgcommands, which are to be run on the dump file. All standard commands should be supported (including running scripts). The current directory for the debugger is the debugger directory, therefore if you have scripts in a subdirectory of where the debugger tools are installed, you can still run commands like "$$>a<scripts\testscript1.txt"
In the top pane you have a list of classes which have methods you can run. Select a class, and a method, and click Run. If the method expects parameters, pass the parameters in the text box (separated by a space).
The debugger output window can be cleared by the menu (command File/Clear Output) or by typing the ".cls" command in the command text box.
Assembly script methods can also be run from the command text box using the syntax "Run FullClassName.MethodName Params"

Writing Scripts

The scripts should be written in Visual Studio.Net. The scripts can use the static methods of Output (Write, AddDbgLink, AddScriptLink) and Dbg (Execute), defined in the DbgShell assembly. The assembly/assemblies containing the scripts should be copied to the directory where DbgShell is installed. Once the script assembly is copied to the destination directory, all scripts should be reloaded (menu command Scripts/Reload). If a script should be modified, scripts can be unloaded (menu command Scripts/Unload) and then their assembly file can be overwritten.
A demo script is available as part of this project (DemoXtension.dll). You may use this project as a template for further scripts development.

Debugging Scripts

VS.Net can be used to debug scripts. All script files can be unloaded, and then overwritten. Scripts can also be manually reloaded. You can then use VS.Net to attach to DbgShellUI.exe to live debug the script as you would debug any assembly.

Limitations

  • DML is not supported. However DbgShell provides its own version of DML using Output.AddDbgLink and Output.AddScriptLink.
  • Only strings are supported as parameters for script methods.
  • Overloading script methods is not supported.
  • Space in parameters value will cause failure of parsing (e.g. if a script method parameter is "some value", it will be parsed as 2 parameters, "some" and "value"

Credits

The idea for this project came from using WinDbg that Tess Ferrandez wrote (http://blogs.msdn.com/tess/default.aspx).
The idea of hooking to the standard Input/Output of CDB was inspired by the PowerDBG project (http://www.codeplex.com/powerdbg), by Roberto Farah (http://blogs.msdn.com/debuggingtoolbox/default.aspx).
The scripts in the DemoXtension.dll are also inspired by scripts written by Tess Fernandez and Roberto Farah.

Last edited Feb 22, 2010 at 11:03 AM by DavidSch, version 6

Comments

No comments yet.