Testing and debugging STREAMS Drivers

Using the crash command in STREAMS

The following crash functions are related to STREAMS.

Print the linkblk table.

Print pseudo ttys now configured. The -l option gives information on the line discipline module ldterm, the -h option provides information on the pseudo-tty emulation module ptem, and the -s option gives information on the packet module pckt.

Print a list of scheduled queues.

Print STREAMS queues.

Print the stdata table.

Print STREAMS statistics.

Print the tty table. The -l option prints out details about the line discipline module.
The crash functions linkblk, queue, and stream take an optional address that is the address of the data structure. The strstat command gives information about STREAMS event cells and linkblks in addition to message blocks, data blocks, queues, and Streams. On the output report, the CONFIG column represents the number of structures currently configured. It may change because resources are allocated as needed.

The following example illustrates the debugging of a line printer. Knowledge of the data structures of the driver is needed for debugging. The example starts with the following data structure of the line printer driver.

   struct lp {
   	short lp_flags;
   	queue_t *lp_qptr;	/* back pointer to write queue */
   extern struct lp lp_lp[];
The first command, nm lp_lp, prints the value and type for the line printer driver data structure. The second command, rd 40275750 20, prints 20 values starting from the location 40275750 (note that the rd command is an alias of od). The third command, size queue, gives the size of the queue structure. The next two functions again give the 20 values starting at the specified locations in the hexadecimal format. The command rd -c 4032bf40 32 gives the character representation of the value in the given location. The option -x gives a value in the hexadecimal representation and the option -a produces the same in the ASCII format.
   dumpfile - /dev/mem, namelist = /stand/unix, outfile = crash.out

> nm lp_lp lp_lp 40275750 bss

> rd 40275750 20 40275750: 00000000 00000000 00000000 40262f60 40275760: 00000000 00000000 00000000 00000000 40275770: 00000000 00000000 00000000 00000000 40275780: 00000000 00000000 00000000 00000000 40275790: 00000000 00000000 00000000 00000000

> size queue 36

> rd 40262f60 20 40262f60: 4017315c 402624a4 4026257c 00000000 40262f70: 00000000 40275758 0200002e 00000200 40262f80: 02000100 00000000 00000000 00000000 40262f90: 00000000 00000000 00000000 00000000 40262fa0: 00000000 00000000 00000000 00000000

> rd 402624a4 20 402624a4: 40262624 00000000 00000000 4032bf40 402624b4: 4032bf5f 40236884 4026233c 00000000 402624c4: 00000000 40331fd9 40331fd9 00000000 402624d4: 00000000 00000000 00000000 4032bf80 402623e4: 4032bf80 40236894 40262564 00000000

> rd -c 4032bf40 32 4032bf40: l i t t l e r e d l i g h t 4042bf50: o n t h e h i g h w a y \n

> rd -x 40262624 20 40252624: 40262594 402624a4 00000000 4032bd40 40262634: 4032bd5f 40236804 00000000 00000000 40262644: 00000000 4030c800 4030c800 402319e4 40262654: 00000000 00000000 00000000 4032be40 40262664: 4032be40 40236844 4026239c 00000000

> rd -a 4032bd40 31 little red light on the highway

© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005