Specifications

D
evice Driver Programming
15-2
4. ioctl(D2), read(D2), write(D2) and/or strategy(D2) and
print(D2)
When the driver seems to be functioning properly under normal conditions, begin testing
the error logs by provoking failures. For instance, take a tape or disk off-line while a
read/write operation is going.
After you are comfortable that both the hardware and software behaves as it should during
error situations, it is time to concentrate on formal performance testing.
General Guidelines 15
CAUTION
Before trying to install or debug the driver, back up all files in
your file system(s). Drivers can cause serious problems with disk
sanity should an unanticipated problem occur.
Compile your driver and produce an up-to-date listing and an object file. The following
conventions must be observed:
Ensure that all your cmn_err(D3) calls direct output to at least the
putbuf memory array. (putbuf defaults to a maximum size of 10,000
bytes.)
Compile your driver without the optimizer, with the -g option enabled.
Use the pr(1) command with the -n option to produce a listing of the
source code with line numbers. Alternatively, list can be used to pull line
number information out of the driver object file.
Use dis(1) to produce a disassembly listing. This is useful to have on
hand, even though you get the same information using the crash dis
command.
Using the instructions described earlier in this book, install your driver. If the UNIX
system does not come up, divide your driver into separate sections and install each part
separately until you find the problem. Fix the problem and install the driver.
After the driver is installed, use idbuild(1M) to create the /stand/unix file.
Putting Debug Statements in a Driver 15
Use the cmn_err(D3) function to put debugging comments in the driver code; when the
driver executes, you can use these to tell what part of the driver is executing. The
cmn_err function is similar to the printf(3S) system call but it executes from inside
the kernel.
cmn_err statements for debugging should be written to the putbuf where they can be
viewed using crash. Because they are written by the kernel, they cannot be redirected to