Subcomando pr

El submandato pr muestra la memoria como si fuera de un tipo especificado (estructura de datos c).

Formato

pr [tipo] dirección

pr -l Desplazamiento |Nombre [–e Valor_final] [Tipo] Dirección

pr -a recuento [tipo] dirección

pr -d tipo_predeterminado

pr -p patrón

Parámetros

Elemento Descripción
-l Muestra datos a continuación de una lista enlazada. El submandato pr sigue a la lista enlazada hasta que el valor del puntero de lista enlazado es igual al valor final. El valor final es cero, a menos que se cambie con el parámetro -e .
-e Cambia el valor final utilizado al visualizar una lista enlazada.
-a Muestra los datos como si se tratara de una matriz cuyos elementos son del tipo especificado.
-d Establece el tipo predeterminado.
tipo_predeterminado Indica el tipo (estructura de datos c) para el que desea visualizar información. Después de establecer el tipo predeterminado utilizando el parámetro -d, es el único tipo para el que se visualiza la información.
-p Muestra los símbolos definidos que coinciden con un patrón especificado.
tipo Especifica el tipo utilizado para visualizar los datos.
dirección Especifica la dirección efectiva de los datos que se van a visualizar.
offset Especifica el desplazamiento del puntero de lista enlazado en la estructura de datos.
Nombre Especifica el nombre del puntero de lista enlazado en la estructura de datos.
end_val Especifica el nuevo valor final.
Recuento Especifica el número de elementos a visualizar.
patrón Especifica el patrón.

Para poder utilizar un tipo , debe cargarse en el kernel con el mandato bosdebug -l . El mandato bosdebug debe emitirse fuera de kdb como usuario root. No es necesario reiniciar la máquina después de ejecutar el mandato bosdebug .

Otro

print

Ejemplos

A continuación se muestra un ejemplo de cómo utilizar el submandato pr :

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