[ros-kernel] kernel debugging howto
timjobling at lycos.co.uk
Tue Nov 25 20:30:29 CET 2003
Since we are all in a sharing mood ;-)
Here is a trivial little app I use to watch the debug log from VMware in
just set your VM to connect COM1 \\.\pipe\com_1 and set DEBUGPORT=COM1 in
with your VM running in VMware, run PipeListen and you'll see the debug
output exactly as you do in the console window in Bochs.
----- Original Message -----
From: "Ge van Geldorp" <ge at gse.nl>
To: "'ReactOS Kernel List'" <ros-kernel at reactos.com>
Sent: Tuesday, November 25, 2003 7:24 PM
Subject: RE: [ros-kernel] kernel debugging howto
> Well, it seems like I'm just about the only one with a more-or-less
> working GDB setup. I usually run ReactOS inside VMware, booting using
> freeldr. My freeldr.ini section for GDB debugging:
> Options=/DEBUGPORT=GDB /DEBUGPORT=COM1
> In VMware, I have Serial 1 directed to a file and Serial 2 set to use
> physical serial port COM2. This is so I can have both a debug log (the
> file attached to Serial 1) and use GDB at the same time. There is a null
> modem cable between physical ports COM2 and COM1.
> I use a very old GDB, gdb --version says "GNU gdb 5.0 (20010428-3)" and
> it has the RedHat Insight graphical interface. I would be happy to zip
> up the directory and put it up somewhere, if someone can tell me how I
> can fulfill the GPL requirement of also offering the source (only have
> the binaries here).
> My gdb.ini file contains lines like this:
> directory /cygdrive/r/ros/reactos/ntoskrnl
> symbol-file /cygdrive/r/ros/reactos/ntoskrnl/ntoskrnl.nostrip.exe
> directory /cygdrive/r/ros/reactos/drivers/dd/videoprt
> directory /cygdrive/r/ros/reactos/subsys/win32k
> add-symbol-file /cygdrive/r/ros/reactos/subsys/win32k/win32k.nostrip.sys
> set remotebaud 115200
> target remote com1
> where r:\ros\reactos is my "ReactOS source root". The hex addresses you
> see at the end are the load addresses you see displayed during start-up,
> plus 0x1000 (the .text segment which we need to pass to GDB normally
> starts at offset 0x1000 into the image). So, I see the line:
> DriverBase for \SystemRoot\system32\win32k.sys: df85a000
> in my debug log and therefore put 0xdf85b000 in gdb.ini. It's important
> to use the ".nostrip." versions to get symbolic info. Oh, not sure if
> it's relevant, but I always build with "DBG := 1" in reactos/config, I
> think you need that to get symbolic information.
> Well, the rest is easy as pie. First, I change the source code to
> include a '__asm__("int $3\n")' where I want to start debugging, rebuild
> and install. Then I startup the virtual ReactOS machine in VMware, wait
> until it displays "Module 'hal.dll' loaded at 0x..." and start up GDB.
> It will show that ReactOS at that point is in DbgBreakPointWithStatus.
> Just give a "c" to continue and do whatever I need to do to get to my
> breakpoint. From there on, debug as normal with gdb. (The reason I
> change te source to set a breakpoint is that most drivers and for my
> work more importantly win32k is not loaded yet when the initial
> DbgBreakPointWithStatus is hit, so at that point you can't set
> breakpoints from gdb on e.g. NtUserCreateWindowEx yet.)
> There are some restrictions. Sometimes gdb just crashes, some
> nostrip.dll's can't be loaded (trying to load them will give a gdb
> internal error), looking at registers doesn't work and you can't look at
> static variables. It is possible to set breakpoints (using the
> '__asm__("int $3\n")' technique) in usermode code. You can do stack
> backtraces when such a breakpoint is hit, but for some reason you can't
> single-step. Once you have hit a usermode breakpoint, you can set new
> breakpoints using gdb, so often I find myself setting breakpoints on
> every line to emulate single-stepping. Looking at usermode variables
> sometimes works, sometimes doesn't work. When an exception is generated
> (either in kernel or in usermode) you are put into gdb.
> Although I use a null modem cable and VMware, the same kind of setup
> should also work with Bochs and between two physical machines (I
> actually know it works between two physical machines, I've done that
> too). You can also setup 2 VMware machines and pipe the serial ports
> Hope this is of some use, maybe Jason or KJK::Hyperion can put this in
> our KB somewhere?
> Gé van Geldorp.
> Ros-kernel mailing list
> Ros-kernel at reactos.com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1082 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20031125/4dbe9df0/PipeListen-0001.obj
More information about the Ros-kernel