Click here to Skip to main content
Click here to Skip to main content

Visual Studio X86 Assembly Debugger (C# Open Source Managed Operating System)

, 4 Jul 2011 BSD
Rate this:
Please Sign up or sign in to vote.
Several users have written to me requesting information on the new Cosmos X86 assembly level debugger. Because of the great interest I have written this short preview article.

Introduction

Several users have written to me requesting information on the new Cosmos X86 assembly level debugger. Because of the great interest, I have written this short preview article.

Cosmos already has an integrated Visual Studio debugger for debugging C# and VB.NET code. However, to debug, X86 assembly users need to resort to GDB. Cosmos also includes a partial GDB front end, but the linkage between the IL and C# code was lost and requires a lot of mental parsing.

Eventually, we hope to expand our new assembly debugger so that GDB will only rarely be needed and only for very deep debugging such as the debug stub. The X86 debugger allows you to set a breakpoint in C#, and then see the IL as well as X86 ASM, as well as registers.

What is Cosmos?

Cosmos is an Operating System development kit (more info) which uses Visual Studio as its development environment. Despite C# in the name, any .NET based language can be used, including VB.NET, Fortran, Delphi Prism, IronPython, F#, and more. Cosmos itself and the kernel routines are primarily written in C#, and thus the Cosmos name. Besides that, NOSMOS (.NET Open Source Managed Operating System) sounds stupid.

Cosmos is not an Operating System in the traditional sense, but instead it is an "Operating System Kit", or as I like to say, "Operating System Legos". Cosmos lets you create Operating Systems just as Visual Studio and C# normally let you create applications. Most users can write and boot their own Operating System in just a few minutes, all using Visual Studio. Cosmos supports integrated project types in Visual Studio, and an integrated debugger, breakpoints, watches, and more. You can debug your Operating System the same way that you debug a normal C# or VB.NET application.

Using the Assembly Debugger

First open the new Cosmos tool windows.

Menu.png

Currently, only the assembly and registers window are functional. The stack / frame window will be functional in the next few days. We will also be adding additional windows allowing direct memory inspection, and eventually assembly level stepping.

Now set a breakpoint in the C# code and run your Operating System. If you have the defaults, VMWare will appear with your Operating System, and Visual Studio will stop on the breakpoint.

Debugger.png

You will notice that the local watch window is functional. This is part of the Cosmos Visual Studio debugger. What is new though are the two assembly debugger windows shown on the right. The assembly window shows the IL and X86 assembly for the line with the breakpoint. If more breakpoints are set, or stepping is used and the assembly debugger windows will update each time. Note that there is a small bug and it shows in this screenshot. It only shows one IL op in the assembly window. It should read:

System_Void__BreakpointsKernel_BreakpointsOS_Run____DOT__00000001:
        call DebugStub_TracerEntry
        ; [Cosmos.IL2CPU.X86.IL.Ldc_I4]
        push dword 0x0
        ; Stack contains 1 items: (4)

System_Void__BreakpointsKernel_BreakpointsOS_Run____DOT__00000002:
        ; [Cosmos.IL2CPU.X86.IL.Stloc]
        ; EBPOffset = 4
        pop dword EAX
        mov dword [EBP + -4], EAX
        ; Stack contains 0 items: ()

The registers window shows the X86 registers at the beginning of the assembly window. Values are shown in red if they have changed since the last display. This is very useful in monitoring changes.

Why an Assembly Level Debugger?

If Cosmos is written in C#, why do we need such a low level debugger? Most users we hope will only need to use the C# debugger. However, for users who are working on the compiler (IL2CPU) or for debugging direct hardware interactions, the assembly level debugger is a huge help.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

Chad Z. Hower, a.k.a. Kudzu
"Programming is an art form that fights back"
www.KudzuWorld.com
 
Formerly the Regional Developer Adviser (DPE) for Microsoft Middle East and Africa, he was responsible for 85 countries spanning 4 continents and 10 time zones. Now Chad is a Microsoft MVP.
 
Chad is the chair of several popular open source projects including Indy and Cosmos (C# Open Source Managed Operating System).
 
Chad is the author of the book Indy in Depth and has contributed to several other books on network communications and general programming.
 
Chad has lived in Canada, Cyprus, Switzerland, France, Jordan, Russia, Turkey, and the United States. Chad has visited more than 60 countries, visiting most of them several times.

Comments and Discussions

 
QuestionX86 Pinmembergoogleexpert30-Aug-12 2:46 
GeneralMy vote of 4 Pinmemberfredatcodeproject5-Jul-11 0:22 
GeneralRe: My vote of 4 PinmemberChad Z. Hower aka Kudzu5-Jul-11 4:12 
Thanks!
Chad Z. Hower, a.k.a. Kudzu
"Programming is an art form that fights back"
 
My Technical Stuff:
http://www.KudzuWorld.com
 
My Blogs:
http://www.KudzuWorld.com/blogs/

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 5 Jul 2011
Article Copyright 2011 by Chad Z. Hower aka Kudzu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid