pr subcommand

The pr subcommand displays memory as if it were of a specified type (c data structure).

Format

pr [type] address

pr -l offset |name [–e end_val] [type] address

pr -a count [type] address

pr -d default_type

pr -p pattern

Parameters

Item Description
-l Displays data following a linked list. The pr subcommand follows the linked list until the value in the linked list pointer equals the ending value. The ending value is zero, unless it is changed with the -e parameter.
-e Changes the ending value used when you are displaying a linked list.
-a Displays the data as if it were an array whose elements are of the specified type.
-d Sets the default type.
default_type Indicates the type (c data structure) for which you want to display information. After you set the default type by using the –d parameter, it is the only type for which information is displayed.
-p Displays the defined symbols that match a specified pattern.
type Specifies the type used to display the data.
address Specifies the effective address of the data to be displayed.
offset Specifies the offset of the linked list pointer in the data structure.
name Specifies the name of the linked list pointer in the data structure.
end_val Specifies the new ending value.
count Specifies the number of elements to display.
pattern Specifies the pattern.

Before a type can be used, it must be loaded into the kernel with the bosdebug -l command. The bosdebug command must be issued outside of kdb as the root user. It is not necessary to reboot the machine after running the bosdebug command.

Other

print

Examples

The following is an example of how to use the pr subcommand:

KDB(0)> pr integer 3000               //use 'pr' without loading symbols
type definition not found

//Run the following as 'root' to load the symbols in intr.h into the kernel
# echo "#include <sys/intr.h>" >sym.c     //symbol file to load into kernel
# echo "main() { }" >>sym.c
# cc -g -o sym sym.c -qdbxextra          //for 32-bit kernel
# cc -g -q64 -o sym sym.c -qdbxextra     //for 64-bit kernel
# bosdebug -l sym               (load symbols into kernel)
Symbol table initialized. Loaded 297 symbols.

KDB(0)> pr integer 3000               //print data at 0x3000 as an integer
integer foo[0]  = 0x4C696365;
KDB(0)> intr 19                    //show interrupt handler table, slot 19
              SLT INTRADDR HANDLER  TYPE LEVEL    PRIO BID     FLAGS

i_data+00004C  19 30047A80 00000000 0004 00000001 0000 900100C0 0040
i_data+00004C  19 0200C360 0200A908 0004 00000003 0000 900100C0 0040
i_data+00004C  19 319A9020 02041AB8 0004 00000003 0000 900100C0 0040
KDB(0)> intr 30047A80               //show interrupt handler information at 0x30047A80
addr........... 30047A80 handler........ 00000000 
bid............ 900100C0 bus_type....... 00000004 BID
next........... 0200C360 flags.......... 00000040 LEVEL
level.......... 00000001 priority....... 00000000 INTMAX
i_count........ 00000000
KDB(0)> pr intr 30047A80          //print this data as an 'intr' structure
struct intr {
    struct intr *next   = 0x0200C360;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000001;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo[0];
KDB(0)> pr 30047A80               //print data using default type
char foo[0]     = 0x02 '';
KDB(0)> pr -d intr                //change default type to 'intr' structure
KDB(0)> pr 30047A80               //print data using new default type
struct intr {
    struct intr *next   = 0x0200C360;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000001;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo[0];
KDB(0)> pr -l next intr 30047A80     //print following the 'next' pointer
struct intr {
    struct intr *next   = 0x0200C360;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000001;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo;
struct intr {
    struct intr *next   = 0x319A9020;
    int (*handler)()    = 0x0200A908;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000003;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo;
struct intr {
    struct intr *next   = 0x00000000;
    int (*handler)()    = 0x02041AB8;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000003;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo;
KDB(0)> pr -e 319A9020 -l next intr 30047A80     //print following the 'next' pointer, 
                                                 //ending when 'next' equals 0x319A9020
struct intr {
    struct intr *next   = 0x0200C360;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000001;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo;
struct intr {
    struct intr *next   = 0x319A9020;
    int (*handler)()    = 0x0200A908;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000003;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo;
KDB(0)> pr -a 2 intr 30047A80          //print two 'intr' stuctures starting at 0x30047A80
struct intr {
    struct intr *next   = 0x0200C360;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0004;
    unsigned short flags        = 0x0040;
    int level   = 0x00000001;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x900100C0;
    unsigned long i_count       = 0x00000000;
} foo[0];
struct intr {
    struct intr *next   = 0x00000000;
    int (*handler)()    = 0x00000000;
    unsigned short bus_type     = 0x0000;
    unsigned short flags        = 0x0000;
    int level   = 0x00000000;
    int priority        = 0x00000000;
    ulong32int64_t bid  = 0x00000000;
    unsigned long i_count       = 0x00000000;
} foo[1];
KDB(0)> pr -p intr               //show symbol 'intr'
     intr
KDB(0)> pr -p *r                 //show symbols matching '*r'
     char
     unsigned char
     signed char
     integer
     character
     wchar
     __default_char
     intr
     u_char
     physadr
     uchar
     UTF32Char
     UniChar
KDB(0)> g

# bosdebug -f                    //unload symbols from kernel
Flushed out all the symbols.

KDB(0)> pr integer 3000               //print after symbols unloaded
type definition not found