技术共享——CiscoIOS进程调试( 二 )


I didn"t have to test every command by hand.. let"s just say I have reliable sources and I know that in IOS 11.2-8 (hum hum), the following commands are supported:
RequestPacket
read registersg
write regsGXX..XXEach byte of register data
is described by two hex digits.
Registers are in the internal order
for GDB, and the bytes in a register
are in the same order the machine uses.
read memmAA..AA,LLLLAA..AA is address, LLLL is length.
write memMAA..AA,LLLL:XX..XX
AA..AA is address,
LLLL is number of bytes,
XX..XX is data
continuecAA.AAAA..AA is address to resume
IF AA..AA is omitted
resume at same address.
stepsAA..AAAA..AA is address to resume
If AA..AA is omitted,
resume at same address.
kill requestk
last signal?Reply the current reason for stopping.
This is the same reply as is generated
for step or cont : SAA where AA is the
signal number.
toggle debugdtoggle debug flag (see 386 & 68k stubs)
All other commands will be ignored... too bad "search" isn"t implemented.
The protocol is simple, quoting remote.c comments:
A debug packet whose contents are is encapsulated for transmission in the form.
$ # CSUM1 CSUM2
must be ASCII alphanumeric and cannot include characters
"$" or "#". If starts with two characters followed by
":", then the existing stubs interpret this as a sequence number.
CSUM1 and CSUM2 are ascii hex representation of an 8-bit checksum of , the most significant nibble is sent first.
the hex digits 0-9,a-f are used.
Before trying to make gdb work i wrote a little program that computed the right checksum:
#include
unsigned char const hexchars[] = "0123456789abcdef";
char tohexchar (unsigned char c)
{
c &= 0x0f;
return(hexchars[c]);
}
int main(int argc, char **argv)
{
unsigned char checksum;
int count;
char *command;
char ch;
if (argc <= 1)
exit(1);
printf("gdb protocol command: ");
command = argv[1];
putchar ("$");
checksum = count = 0;
while ((ch = command[count]))
{
putchar(ch);
checksum= ch;
count;
}
putchar("#");
putchar(tohexchar(checksum >> 4));
putchar(tohexchar(checksum));
putchar(" ");
}
./gdbproto g
gdb protocol command: $g#67
now paste that on theprompt and you get register output:
scep

推荐阅读