Tuesday Mar 20, 2007

mdb pipes.

Sometimes I find my self doing things that I have been doing for years and just wonder whether by now there is some tool that I have missed that makes the old way of doing something redundant. So in the off chance that I have missed something I'll document the way I often drive mdb (or more often mdb+ a slightly improved mdb that I keep wishing would get open sourced) in the hope some bright spark will point me at a better way. Failing that someone might find this useful.

When looking at crash dumps I often want to process some data and then pipe it back into mdb via some text processing tool. Now given that the startup time for mdb, particularly when running under kenv is very significant you don't want to be doing the obvious of having mdb in a typical pipeline. So while I can do this:

nawk 'BEGIN { printf("::load chain\\n") }
/buf addr/ {
        printf("%s::print -at buf_t av_back | ::if scsi_pkt pkt_comp == ssdintr and pkt_address.a_hba_tran->tran_tgt_init == ssfcp_scsi_tgt_init |::print -at scsi_pkt  pkt_ha_private | ::print -at ssfcp_pkt cmd_flags cmd_timeout cmd_next\\n",
        $3) }'  act.0 | kenv -x explorer_dir mdb+ 0

It is a pain as kenv processes the explorer to build the correct environment and for large dumps loads the dump into memory only to throw it away.

So instead I start mdb as a cooperating process in the korn shell:

kenv -x explorer_dir mdb+ |&

Then I have a shell function called “mdbc” that will submit commands into the cooperating process and read the results back. So the above becomes:

nawk 'BEGIN { printf("::load chain\\n") }
/buf addr/ {
        printf("%s::print -at buf_t av_back | ::if scsi_pkt pkt_comp == ssdintr and pkt_address.a_hba_tran->tran_tgt_init == ssfcp_scsi_tgt_init |::print -at scsi_pkt  pkt_ha_private | ::print -at ssfcp_pkt cmd_flags cmd_timeout cmd_next\\n",
        $3) }'  act.0 | mdbc

or I can do

mdbc lbolt::print

Just by way of an example to show why I bother, compare the times of these two equivalent commands:

: dredd TS 243 $; time echo  lbolt::print | kenv -x explorer mdb+ 0

real    0m37.03s
user    0m7.02s
sys     0m7.26s
: dredd TS 244 $; time mdbc lbolt::print > /dev/null                                                              

real    0m0.01s
user    0m0.00s
sys     0m0.01s
: dredd TS 245 $; 


and just to show that I get the right results from the mdbc command.

: dredd TS 245 $; time mdbc lbolt::print            
0x496619a9

real    0m0.01s
user    0m0.00s
sys     0m0.01s
: dredd TS 246 $; 

However like talk it does have a 1980s feel to it so I look forward to hearing the error of my ways.

If you think you might find it useful the shell function is here.

Tags:

Friday Jan 26, 2007

UK statute Law On line

Dave has prompted me to post where you can actually find the definitive statue law or the U.K. on line.

It is here: http://www.statutelaw.gov.uk/

Interestingly, to me, searching for "road traffic act" in google still does not find it on the first page.

About

This is the old blog of Chris Gerhard. It has mostly moved to http://chrisgerhard.wordpress.com

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today