"Randy.Dunlap" (on Tue, 15 May 2007 16:42:45 -0700) wrote:
>2.  I'd like to be able to "bc all" (or "bca").  or I can put
>that into a custom defcmd...  Should I just do the latter?

"bc *".  man linux/Documentation/kdb/kdb_bp.man

>3.  I often need to use what some debuggers call "step over",
>i.e., execute a call instruction and break after it returns,
>immediately after the call instruction.  Does kdb already have
>this command and I just don't see it?  Currently I just use:
>
>defcmd soc "" "step over call"
>  bp %rip+5 # CPU-specific
>  go
>endefcmd
>
>but that leaves me with (should be temporary) breakpoints that
>should be deleted ASAP.  Can I determine what bpnum was used and
>then clear it later?  (although I don't know when I would clear it)

AFAIK, the "step over" function of a debugger does :-

* single step the call
* get the return address
* set a breakpoint on the return address
* allow the cpu(s) to run
* when the breakpoint trips, delete the breakpoint.

That can almost be automated as a kdb command, the problem areas are
SMP, interrupts and preemption.  When the cpus are allowed to run, any
of them can hit the breakpoint, not just the current cpu.  Even the
current cpu can hit the breakpoint if the task is interrupted or
preempted and other code runs on the same cpu before your original code
gets a chance to run.  I never found an acceptable solution to work
around the reentrancy problems for kernel code.

>4.  Is there a way to print (decode) the CPU flags register so that
>I can see which bits (conditions) are set/clear?

No.  Feel free to write one for kdb, but I usually handle this sort of
problem by taking the hex value and feeding it to an external script.
Like this one for decoding the IA64 psr bits.

#!/usr/bin/perl -w
use strict;
use integer;

my @fields = (
        [ 0, 6, "User mask" ],
        [ 0, 1, "rv" ],
        [ 1, 1, "be" ],
        [ 2, 1, "up" ],
        [ 3, 1, "ac" ],
        [ 4, 1, "mfl" ],
        [ 5, 1, "mfh" ],
        [ 0, 24, "System mask" ],
        [ 6, 7, "rv" ],
        [ 13, 1, "ic" ],
        [ 14, 1, "i" ],
        [ 15, 1, "pk" ],
        [ 16, 1, "rv" ],
        [ 17, 1, "dt" ],
        [ 18, 1, "dfl" ],
        [ 19, 1, "dfh" ],
        [ 20, 1, "sp" ],
        [ 21, 1, "pp" ],
        [ 22, 1, "di" ],
        [ 23, 1, "si" ],
        [ 24, 1, "db" ],
        [ 25, 1, "lp" ],
        [ 26, 1, "tb" ],
        [ 27, 1, "rt" ],
        [ 28, 4, "rv" ],
        [ 32, 2, "cpl" ],
        [ 34, 1, "is" ],
        [ 35, 1, "mc" ],
        [ 36, 1, "it" ],
        [ 37, 1, "id" ],
        [ 38, 1, "da" ],
        [ 39, 1, "dd" ],
        [ 40, 1, "ss" ],
        [ 41, 2, "ri" ],
        [ 43, 1, "ed" ],
        [ 44, 1, "bn" ],
        [ 45, 1, "ia" ],
        [ 46, 1, "vm" ],
        [ 47, 17, "rv" ],
        );

while (defined($_ = <STDIN>)) {
        chomp();
        my $w0 = hex(substr($_, 0, -8));
        my $w1 = hex(substr($_, -8));
        printf("psr %s\n", $_);
        &ia64_word($w1, 0, 32);
        &ia64_word($w0, 32, 64);
}

sub ia64_word()
{
        my ($w, $s, $e) = @_;
        my $v;
        foreach (@fields) {
                next if ($_->[0] >= $e);
                next if ($_->[0] < $s);
                # use integer implies signed shift, I want unsigned
                no integer;
                $v = ($w >> ($_->[0] - $s)) & (~0 >> (32 - $_->[1]));
                printf("%2d %2d %12s %x\n", $_->[0], $_->[1], $_->[2], $v);
        }
}

---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.

Reply via email to