13-Jun-2009

CMKRNL and /DEBUG

This post is unfortunately being prompted by a report of a site running one of my utilities and experiencing a system crash.

On investigation, it appears that the user had compiled the utility (which performs routines in kernel mode) with CC/DEBUG and then just executed the code. Additionally, because I hadn't made is abundantly clear how to run the code (assuming anyone with CMKRNL would have the knowledge to read the code and figure it out), the user was running the code with strange parameters, which while they wouldn't have crashed the system, certainly would not have accomplished what the user intended.

Lesson 1 (for me): describe the code's usage better.

Lesson 2 (for anyone thinking of running kernel mode code): Running kernel mode code under control of the standard debugger is strictly unsupported!

There are two versions of a low level system debugger suitable for executing code with elevated processor mode and/or elevated IPL. These are DELTA and XDELTA respectively.

Here's a quick example of what a DELTA session looks like (buckle your seatbelt Dorathy, 'cause Kansas is going bye-bye):


$ create test.c
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    (void)printf ("hello, world\n");
}
^Z
$ cc/debug/noopt/list/machine test
$ link/debug test
$ define lib$debug sys$share:delta.exe
$ run test
OpenVMS Alpha DELTA Debugger

Brk 0 at 00020000

00020000!       LDA             SP,#XFF90(SP) s
00020004!       STQ             R31,#X0008(SP) s
00020008!       STQ             R27,(SP) s
0002000C!       STQ             R26,#X0050(SP) s
00020010!       STQ             R2,#X0058(SP) s
00020014!       STQ             FP,#X0060(SP) exit

As you can see, the debugger is instruction oriented. You will certainly want to include the /LIST/MACHINE qualifiers on the compiler command.

DELTA can be used by non-privileged users (although it would just be an exercise in learning and following machine instructions). Obviously, to use DELTA with a program that elevates processor mode, you require the appropriate privilege tp get to that mode.

The big difference between DELTA and XDELTA is that XDELTA can deal with elevated IPL. This is the tool that is used to debug the kernel of the operating system, device drivers, and so forth, and hence it is loaded at boot time

For further information about DELTA/XDELTA, see the "HP OpenVMS Delta/XDelta Debugger Manual".

Posted at June 13, 2009 12:21 PM
Tag Set:
Comments

Truely there are no limits to the ingenuity of lUsers :-)

But why were they using the debugger?
Shirley, your code is bug free ;-)

Posted by: Ian at June 13, 2009 9:18 PM

There's no such thing as "Bug free", and don't call me Shirley.

Posted by: Jim Duff at June 14, 2009 2:57 PM

There are three system debuggers, one of which is definitely not low-level. Wander over to the HP OpenVMS System Analysis Tools Manual, and take a look at the System Code Debugger (SCD).

And coincidently, I was implementing probe operations in a UWSS quite recently to specifically avoid argument problems. And I neglected to mention you shouldn't use the standard debugger; I will add that to the checklist for the next update.

Posted by: Stephen Hoffman at June 15, 2009 12:12 PM

Comments are closed