[Crash-utility] [PATCH V2] Add -C option for search

Dave Anderson anderson at redhat.com
Thu Feb 9 20:58:52 UTC 2012


----- Original Message -----
> Hello Dave,
> 
> I made a new patch to implement the -C option for search. This time the
> patch is accomplished in a simple manner according to your advice.
> 
> Thanks.
> Zhang Yanfei
> 

Hello Zhang,

Well, you've cut the patch size in half, so we're making progress...  ;-)

Anyway, I find the output ugly and unmanageable.  For example:

crash> search -k deadbeef -C 20
ffff810018b12a58: 4647d0 8 7fff170fb080 0 bebf80 0 0 88f8c10 507403 6264616564206b2d 3220432d20666565 30 4a3e55 88e49d0 5 ffffffff88f
07000 0 100000000 14 1 
ffff810018b12af8: deadbeef 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
ffff810018b12b98: 0
crash>

Your output has a single line for the "pre" memory, and then 
appends the "post" output to the targeted memory display.  
Depending upon the -C argument, the line size can be absurdly
long.  It should restrict the output to 80 columns, and format
the display the same way that the "rd" command does. 

Secondly, to clarify things, I would prefer that the "pre" 
memory and "post" memory be separate from the "target" display.

So for example, here's an output example with your patch:

crash> search -k deadbeef -C 10
ffff810032448100: 0 0 18 2b5d2cd23490 0 0 0 0 58 2b5d2cd27ac0 
ffff810032448150: deadbeef 2b5d2cd293a0 2b5d2cd29700 2b5d2cd29570 2b5d2cd29470 1 1 0 20 2b5d2cd29790 
ffff8100324481a0: 0
crash>

I would prefer this:

crash> search -k deadbeef -C 10
ffff810032448100:  0000000000000000 0000000000000000   ................
ffff810032448110:  0000000000000018 00002b5d2cd23490   .........4.,]+..
ffff810032448120:  0000000000000000 0000000000000000   ................
ffff810032448130:  0000000000000000 0000000000000000   ................
ffff810032448140:  0000000000000058 00002b5d2cd27ac0   X........z.,]+..
ffff810032448150:  deadbeef
ffff810032448158:  00002b5d2cd293a0 00002b5d2cd29700   ...,]+.....,]+..
ffff810032448168:  00002b5d2cd29570 00002b5d2cd29470   p..,]+..p..,]+..
ffff810032448178:  0000000000000001 0000000000000001   ................
ffff810032448188:  0000000000000000 0000000000000020   ........ .......
ffff810032448198:  00002b5d2cd29790 0000000000000000   ...,]+..........
crash>

By doing that, you can signficantly simpify your new 
display_with_pre_and_post() function, and get rid of
that extra get_search_page() function.  All you would have
to do is determine the address, count, memory-type and
format of the "pre" and "post" sections, and pass that
information to the currently-existing display_memory() 
utility function.  

The display_memory() function will take care of all the 
readmem() and formatting details -- there's no need
to reinvent the wheel.

Dave




More information about the Crash-utility mailing list