This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Module editing; debugging with gdb


>>>>> "Greg" == Greg Badros <gjb@cs.washington.edu> writes:

Greg> Cool.  Your other snippet has turned out to be incredibly useful, too.
Greg> Where, though is the example gdbinit? I can't seem to find it in the
Greg> late June snapshot I've been using since then.

Actually, when I think about it, it may have been something posted to
the list or found in the archives, perhaps from Per Bothner. My
current gdbinit is included below:

    # -*- sh -*- 
    # Define a bunch of useful functions for debugging Guile.
    # Add more as required.

    define dp
    set $gp=gdb_print($arg0)
    output gdb_output
    echo \n
    end
    document dp
    Executes (display $arg0) to stdout.
    end

    define xcar
    set $last=((scm_cell*) $arg0)->car
    output $last
    echo \n
    end
    document xcar
    Print the CAR of $.
    end

    define xcdr
    set $last=((scm_cell*) $arg0)->cdr
    output $last
    echo \n
    end
    document xcdr
    Print the CDR of $.
    end

    define xgccdr
    set $last=~1L & ((scm_cell*) $arg0)->cdr
    output $last
    echo \n
    end
    document xgccdr
    Print the CDR of $.
    end

    define xacar
    set $last=&(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xacar
    Print the address of the CAR of $.
    end

    define xacdr
    set $last=&(((scm_cell*) $arg0)->cdr)
    output $last
    echo \n
    end
    document xacdr
    Print the address of the CDR of $.
    end

    define ximp
    set $last=($ & 6) ? 1 : 0
    output $last
    echo \n
    end
    document ximp
    Print 1 if $ is immediate, 0 otherwise.
    end

    define xvarvcell
    xcdr
    end
    document xvarvcell
    Print variable cell of $.
    end

    define xvariablep
    set $last=(((scm_cell*) $arg0)->car) == scm_tc16_variable
    output $last
    echo \n
    end
    document xvariablep
    Print 1 if $ is a variable, 0 otherwise
    end

    define xuchars
    set $last=(unsigned char *) (((scm_cell*) $arg0)->cdr)
    output $last
    echo \n
    end
    document xuchars
    Print string slot of $.
    end

    set $NumIsyms = 16
    set $BoolF = (((0 + $NumIsyms) << 9) + 0x174L)
    set $BoolT = (((1 + $NumIsyms) << 9) + 0x174L)

    define xboolp
    set $last=($ == $BoolF) || ($ == $BoolT)
    output $last
    echo \n
    end
    document xboolp
    Print 1 if $ is a boolean, 0 otherwise.
    end

    define xvelts
    set $last=(long *)((scm_cell*) $arg0)->cdr
    output $last
    echo \n
    end
    document xvelts
    Print the VELTS of $.
    end

    define xlength
    set $last=(((unsigned long)((scm_cell*) $arg0)->car)>>8)
    output $last
    echo \n
    end
    document xlength
    Print the LENGTH of $.
    end

    define xncellp
    set $last=((sizeof(scm_cell)-1) & (int)$arg0)
    output $last
    echo \n
    end
    document xncellp
    Is $ a not a cell?
    end

    define xcellp
    set $last=!((sizeof(scm_cell)-1) & (int)$arg0)
    output $last
    echo \n
    end
    document xcellp
    Is $ a a cell?
    end

    define xchars
    set $last=(char *)(((scm_cell*) $arg0)->cdr)
    output $last
    echo \n
    end
    document xchars
    The CHARS of $
    end

    define xslots
    set $last=((long *)(*((long *)(char *)(((scm_cell*) $arg0)->cdr)-1)))
    output $last
    echo \n
    end
    document xslots
    The SLOTS of $
    end

    define xfunc
    set $last=((long *)(*((long *)(char *)(((scm_cell*) $arg0)->cdr)-1))))[0]
    output $last
    echo \n
    end
    document xfunc
    The FUNC of $
    end

    define xprops
    set $last=((long *)(*((long *)(char *)(((scm_cell*) $arg0)->cdr)-1))))[1]
    output $last
    echo \n
    end
    document xprops
    The PROPS of $
    end

    define xaprops
    set $last=&(((long *)(*((long *)(char *)(((scm_cell*) $arg0)->cdr)-1)))[1])
    output $last
    echo \n
    end
    document xprops
    The PROPS of $
    end

    define xtyp3
    set $last=(7 & (int)(((scm_cell*) $arg0)->car))
    output $last
    echo \n
    end
    document xtyp3
    Print the xtyp3 of $
    end

    define xtyp7
    set $last=0x7f & (int)(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xtyp7
    Print the TYP7 of $
    end

    define xtyp7s
    set $last=0x7d & (int)(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xtyp7s
    Print the TYP77s of $
    end

    define xtyp16
    set $last=0xffff & (int)(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xtyp16
    Print the TYP16 of $
    end

    define xtyp16s
    set $last=0xfeff & (int)(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xtyp16s
    Print the TYP16S of $
    end

    define xgctyp16
    set $last=0xff7f & (int)(((scm_cell*) $arg0)->car)
    output $last
    echo \n
    end
    document xgctyp16
    Print the GCTYP16 of $
    end


---------------------------+--------------------------------------------------
Christian Lynbech          | Telebit Communications A/S                       
Fax:   +45 8628 8186       | Fabrik 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28  | email: chl@tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic@hal.com (Michael A. Petonic)