Dave, I often do analysis on network-releated crashes and often find myself doing mental byte swapping to convert from host to network and back - I think crash can do it much better then me, so I wrote a patch to teach rd how to do this. I'm only doing byte swapping on 16 and 32 bit types because 64 bit integers don't have a "standard" network representation. max
diff -r -u crash-5.1.5.orig/help.c crash-5.1.5/help.c --- crash-5.1.5.orig/help.c 2011-05-12 00:38:42.000000000 +1000 +++ crash-5.1.5/help.c 2011-05-23 18:04:56.689023856 +1000 @@ -1393,7 +1393,7 @@ char *help_rd[] = { "rd", "read memory", -"[-dDsSupxmf][-8|-16|-32|-64][-o offs][-e addr] [address|symbol] [count]", +"[-dDsSupxmfN][-8|-16|-32|-64][-o offs][-e addr] [address|symbol] [count]", " This command displays the contents of memory, with the output formatted", " in several different manners. The starting address may be entered either", " symbolically or by address. The default output size is the size of a long", @@ -1418,6 +1418,8 @@ " -16 display output in 16-bit values.", " -32 display output in 32-bit values (default on 32-bit machines).", " -64 display output in 64-bit values (default on 64-bit machines).", +" -N display output in network byte order (only valid for 16 and", +" 32 bit values)", " -o offs offset the starting address by offs.", " -e addr display memory until reaching specified ending hexadecimal address.", " address starting hexadecimal address:", diff -r -u crash-5.1.5.orig/memory.c crash-5.1.5/memory.c --- crash-5.1.5.orig/memory.c 2011-05-12 00:38:42.000000000 +1000 +++ crash-5.1.5/memory.c 2011-05-23 18:08:39.674123538 +1000 @@ -259,6 +259,7 @@ #define ASCII_ENDLINE (0x400) #define NO_ASCII (0x800) #define SLAB_CACHE (0x1000) +#define NET_ENDIAN (0x2000) static ulong DISPLAY_DEFAULT; @@ -965,7 +966,7 @@ memtype = KVADDR; count = -1; - while ((c = getopt(argcnt, args, "xme:pfudDusSo:81:3:6:")) != EOF) { + while ((c = getopt(argcnt, args, "xme:pfudDusSNo:81:3:6:")) != EOF) { switch(c) { case '8': @@ -1069,6 +1070,10 @@ flag |= NO_ASCII; break; + case 'N': + flag |= NET_ENDIAN; + break; + default: argerrs++; break; @@ -1343,6 +1348,8 @@ break; } } + if (flag & NET_ENDIAN) + mem.u32 = htonl(mem.u32); if (flag & HEXADECIMAL) { fprintf(fp, "%.*x ", INT_PRLEN, mem.u32 ); linelen += (INT_PRLEN + 1); @@ -1354,6 +1361,8 @@ break; case DISPLAY_16: + if (flag & NET_ENDIAN) + mem.u16 = htons(mem.u16); if (flag & HEXADECIMAL) { fprintf(fp, "%.*x ", SHORT_PRLEN, mem.u16); linelen += (SHORT_PRLEN + 1);
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility