[Crash-utility] add print raw data capability for rd

Dave Anderson anderson at redhat.com
Fri Sep 30 18:18:52 UTC 2011



----- Original Message -----
> 
> 
> ----- Original Message -----
> > Hi,
> > 
> > I recent make a patch which give the rd command to dump the raw data.  With this,
> > we could then do the dump the specified range of memory to the file with console's
> > redirection feature like: rd -r 0x7000000 -e 0x8000000 > dump.img.
> > 
> > What about this idea? Could it be accepted?
> > 
> > Thanks,
> > Lei
> 
> I think it's a pretty good idea.
> 
> However, one problem with the patch is that if you forget to append
> the "> dump.img" part, it would end up spewing non-ASCII data to
> the terminal.  I would suggest using a construct like "-r dump.img",
> which would force the user to supply a filename argument with
> the -r.
> 
> Also, maybe you could write a more efficient output function that
> ignores the "typesz", and fwrite()'s larger fixed-size blocks of
> data until it reaches the end of the desired memory chunk.

Just to clarify -- don't put the output loop in the main "for"
loop at the bottom of display_memory(), put it up near the
beginning:

static void
display_memory(ulonglong addr, long count, ulong flag, int memtype)
{
       ... 
       
       if (CRASHDEBUG(4))
                fprintf(fp, "<addr: %llx count: %ld flag: %lx (%s)>\n",
                        addr, count, flag, addrtype);
 
+      if (flag & DISPLAY_RAW) {
+              < your output loop here>
+              return;
+      } 

Dave




More information about the Crash-utility mailing list