Created
April 22, 2012 10:59
-
-
Save k-tsj/2463559 to your computer and use it in GitHub Desktop.
.gdbinit for mruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define dump_irep | |
set $i = 0 | |
set $irep = ($arg0) | |
while ($i < $irep->ilen) | |
set $code = $irep->iseq[$i] | |
set $OPCODE = ((mrb_code)($code) & 0x7f) | |
set $ARG_A = ((((mrb_code)($code)) >> 23) & 0x1ff) | |
set $ARG_B = ((((mrb_code)($code)) >> 14) & 0x1ff) | |
set $ARG_C = ((((mrb_code)($code)) >> 7) & 0x7f) | |
set $ARG_Bx = ((((mrb_code)($code)) >> 7) & 0xffff) | |
set $ARG_sBx = (((((mrb_code)($code)) >> 7) & 0xffff)-(((1<<16)-1)>>1)) | |
set $ARG_b = ((((mrb_code)($code)) >> (7+2)) & (((1<<14)-1))) | |
set $ARG_c = ((((mrb_code)($code)) >> 7) & (((1<<2)-1))) | |
if $OPCODE == OP_NOP | |
printf "OP_NOP=0,/* */\n" | |
else | |
if $OPCODE == OP_MOVE | |
printf "OP_MOVE,/* A B R(A) := R(B) */ A: %d, B: %d\n", $ARG_A, $ARG_B | |
else | |
if $OPCODE == OP_LOADL | |
printf "OP_LOADL,/* A Bx R(A) := Lit(Bx) */\n" | |
else | |
if $OPCODE == OP_LOADI | |
printf "OP_LOADI,/* A sBx R(A) := sBx */ A: %d, B: %d\n", $ARG_A, $ARG_sBx | |
else | |
if $OPCODE == OP_LOADSYM | |
printf "OP_LOADSYM,/* A Bx R(A) := Sym(Bx) */\n" | |
else | |
if $OPCODE == OP_LOADNIL | |
printf "OP_LOADNIL,/* A R(A) := nil */ A: %d\n", $ARG_A | |
else | |
if $OPCODE == OP_LOADSELF | |
printf "OP_LOADSELF,/* A R(A) := self */\n" | |
else | |
if $OPCODE == OP_LOADT | |
printf "OP_LOADT,/* A R(A) := true */\n" | |
else | |
if $OPCODE == OP_LOADF | |
printf "OP_LOADF,/* A R(A) := false */\n" | |
else | |
if $OPCODE == OP_GETGLOBAL | |
printf "OP_GETGLOBAL,/* A Bx R(A) := getglobal(Sym(Bx)) */\n" | |
else | |
if $OPCODE == OP_SETGLOBAL | |
printf "OP_SETGLOBAL,/* A Bx setglobal(Sym(Bx), R(A)) */\n" | |
else | |
if $OPCODE == OP_GETSPECIAL | |
printf "OP_GETSPECIAL,/*A Bx R(A) := Special[Bx] */\n" | |
else | |
if $OPCODE == OP_SETSPECIAL | |
printf "OP_SETSPECIAL,/*A Bx Special[Bx] := R(A) */\n" | |
else | |
if $OPCODE == OP_GETIV | |
printf "OP_GETIV,/* A Bx R(A) := ivget(Sym(Bx)) */\n" | |
else | |
if $OPCODE == OP_SETIV | |
printf "OP_SETIV,/* A Bx ivset(Sym(Bx),R(A)) */\n" | |
else | |
if $OPCODE == OP_GETCV | |
printf "OP_GETCV,/* A Bx R(A) := cvget(Sym(Bx)) */\n" | |
else | |
if $OPCODE == OP_SETCV | |
printf "OP_SETCV,/* A Bx cvset(Sym(Bx),R(A)) */\n" | |
else | |
if $OPCODE == OP_GETCONST | |
printf "OP_GETCONST,/* A Bx R(A) := constget(Sym(Bx)) */ A: %d, Bx: %d\n", $ARG_A, $ARG_Bx | |
else | |
if $OPCODE == OP_SETCONST | |
printf "OP_SETCONST,/* A Bx constset(Sym(Bx),R(A)) */\n" | |
else | |
if $OPCODE == OP_GETMCNST | |
printf "OP_GETMCNST,/* A Bx R(A) := R(A)::Sym(B) */\n" | |
else | |
if $OPCODE == OP_SETMCNST | |
printf "OP_SETMCNST,/* A Bx R(A+1)::Sym(B) := R(A) */\n" | |
else | |
if $OPCODE == OP_GETUPVAR | |
printf "OP_GETUPVAR,/* A B C R(A) := uvget(B,C) */\n" | |
else | |
if $OPCODE == OP_SETUPVAR | |
printf "OP_SETUPVAR,/* A B C uvset(B,C,R(A)) */\n" | |
else | |
if $OPCODE == OP_JMP | |
printf "OP_JMP,/* sBx pc+=sBx */\n" | |
else | |
if $OPCODE == OP_JMPIF | |
printf "OP_JMPIF,/* A sBx if R(A) pc+=sBx */\n" | |
else | |
if $OPCODE == OP_JMPNOT | |
printf "OP_JMPNOT,/* A sBx if !R(A) pc+=sBx */\n" | |
else | |
if $OPCODE == OP_ONERR | |
printf "OP_ONERR,/* sBx rescue_push(pc+sBx) */\n" | |
else | |
if $OPCODE == OP_RESCUE | |
printf "OP_RESCUE,/* A clear(exc); R(A) := exception (ignore when A=0) */\n" | |
else | |
if $OPCODE == OP_POPERR | |
printf "OP_POPERR,/* A A.times{rescue_pop()} */\n" | |
else | |
if $OPCODE == OP_RAISE | |
printf "OP_RAISE,/* A raise(R(A)) */\n" | |
else | |
if $OPCODE == OP_EPUSH | |
printf "OP_EPUSH,/* Bx ensure_push(SEQ[Bx]) */\n" | |
else | |
if $OPCODE == OP_EPOP | |
printf "OP_EPOP,/* A A.times{ensure_pop().call} */\n" | |
else | |
if $OPCODE == OP_SEND | |
printf "OP_SEND,/* A B C R(A) := call(R(A),mSym(B),R(A+1),...,R(A+C)) */ A: %d, B: %d, C: %d\n", $ARG_A, $ARG_B, $ARG_C | |
else | |
if $OPCODE == OP_FSEND | |
printf "OP_FSEND,/* A B C R(A) := fcall(R(A),mSym(B),R(A+1),...,R(A+C-1)) */\n" | |
else | |
if $OPCODE == OP_VSEND | |
printf "OP_VSEND,/* A B R(A) := vcall(R(A),mSym(B)) */\n" | |
else | |
if $OPCODE == OP_CALL | |
printf "OP_CALL,/* A B C R(A) := self.call(R(A),.., R(A+C)) */\n" | |
else | |
if $OPCODE == OP_SUPER | |
printf "OP_SUPER,/* A B C R(A) := super(R(A+1),... ,R(A+C-1)) */\n" | |
else | |
if $OPCODE == OP_ARGARY | |
printf "OP_ARGARY,/* A Bx R(A) := argument array (16=6:1:5:4) */\n" | |
else | |
if $OPCODE == OP_ENTER | |
printf "OP_ENTER,/* Ax arg setup according to flags (24=5:5:1:5:5:1:1) */\n" | |
else | |
if $OPCODE == OP_KARG | |
printf "OP_KARG,/* A B C R(A) := kdict[mSym(B)]; if C kdict.rm(mSym(B)) */\n" | |
else | |
if $OPCODE == OP_KDICT | |
printf "OP_KDICT,/* A C R(A) := kdict */\n" | |
else | |
if $OPCODE == OP_RETURN | |
printf "OP_RETURN,/* A B return R(A) (B=normal,in-block return/break) */ A: %d, B: %d\n", $ARG_A, $ARG_B | |
else | |
if $OPCODE == OP_TAILCALL | |
printf "OP_TAILCALL,/* A B C return call(R(A),mSym(B),*R(C)) */\n" | |
else | |
if $OPCODE == OP_BLKPUSH | |
printf "OP_BLKPUSH,/* A Bx R(A) := block (16=6:1:5:4) */\n" | |
else | |
if $OPCODE == OP_ADD | |
printf "OP_ADD,/* A B C R(A) := R(A)+R(A+1) (mSyms[B]=:+,C=1) */\n" | |
else | |
if $OPCODE == OP_ADDI | |
printf "OP_ADDI,/* A B C R(A) := R(A)+C (mSyms[B]=:+) */\n" | |
else | |
if $OPCODE == OP_SUB | |
printf "OP_SUB,/* A B C R(A) := R(A)-R(A+1) (mSyms[B]=:-,C=1) */\n" | |
else | |
if $OPCODE == OP_SUBI | |
printf "OP_SUBI,/* A B C R(A) := R(A)-C (mSyms[B]=:-) */\n" | |
else | |
if $OPCODE == OP_MUL | |
printf "OP_MUL,/* A B C R(A) := R(A)*R(A+1) (mSyms[B]=:*,C=1) */\n" | |
else | |
if $OPCODE == OP_DIV | |
printf "OP_DIV,/* A B C R(A) := R(A)/R(A+1) (mSyms[B]=:/,C=1) */\n" | |
else | |
if $OPCODE == OP_EQ | |
printf "OP_EQ,/* A B C R(A) := R(A)==R(A+1) (mSyms[B]=:==,C=1) */\n" | |
else | |
if $OPCODE == OP_LT | |
printf "OP_LT,/* A B C R(A) := R(A)<R(A+1) (mSyms[B]=:<,C=1) */\n" | |
else | |
if $OPCODE == OP_LE | |
printf "OP_LE,/* A B C R(A) := R(A)<=R(A+1) (mSyms[B]=:<=,C=1) */\n" | |
else | |
if $OPCODE == OP_GT | |
printf "OP_GT,/* A B C R(A) := R(A)>R(A+1) (mSyms[B]=:>,C=1) */\n" | |
else | |
if $OPCODE == OP_GE | |
printf "OP_GE,/* A B C R(A) := R(A)>=R(A+1) (mSyms[B]=:>=,C=1) */\n" | |
else | |
if $OPCODE == OP_ARRAY | |
printf "OP_ARRAY,/* A B C R(A) := ary_new(R(B),R(B+1)..R(B+C)) */\n" | |
else | |
if $OPCODE == OP_ARYCAT | |
printf "OP_ARYCAT,/* A B ary_cat(R(A),R(B)) */\n" | |
else | |
if $OPCODE == OP_ARYPUSH | |
printf "OP_ARYPUSH,/* A B ary_push(R(A),R(B)) */\n" | |
else | |
if $OPCODE == OP_AREF | |
printf "OP_AREF,/* A B C R(A) := R(B)[C] */\n" | |
else | |
if $OPCODE == OP_ASET | |
printf "OP_ASET,/* A B C R(B)[C] := R(A) */\n" | |
else | |
if $OPCODE == OP_APOST | |
printf "OP_APOST,/* A B C *R(A),R(A+1)..R(A+C) := R(A) */\n" | |
else | |
if $OPCODE == OP_STRING | |
printf "OP_STRING,/* A Bx R(A) := str_dup(Lit(Bx)) */\n" | |
else | |
if $OPCODE == OP_STRCAT | |
printf "OP_STRCAT,/* A B str_cat(R(A),R(B)) */\n" | |
else | |
if $OPCODE == OP_HASH | |
printf "OP_HASH,/* A B C R(A) := hash_new(R(B),R(B+1)..R(B+C)) */\n" | |
else | |
if $OPCODE == OP_LAMBDA | |
printf "OP_LAMBDA,/* A Bz Cz R(A) := lambda(SEQ[Bz],Cm) */ A: %d, Bz: %d, Cz: %d\n", $ARG_A, $ARG_b, $ARG_c | |
else | |
if $OPCODE == OP_RANGE | |
printf "OP_RANGE,/* A B C R(A) := range_new(R(B),R(B+1),C) */\n" | |
else | |
if $OPCODE == OP_OCLASS | |
printf "OP_OCLASS,/* A R(A) := ::Object */\n" | |
else | |
if $OPCODE == OP_CLASS | |
printf "OP_CLASS,/* A B R(A) := newclass(R(A),mSym(B),R(A+1)) */\n" | |
else | |
if $OPCODE == OP_MODULE | |
printf "OP_MODULE,/* A B R(A) := newmodule(R(A),mSym(B)) */\n" | |
else | |
if $OPCODE == OP_EXEC | |
printf "OP_EXEC,/* A Bx R(A) := blockexec(R(A),SEQ[Bx]) */\n" | |
else | |
if $OPCODE == OP_METHOD | |
printf "OP_METHOD,/* A B R(A).newmethod(mSym(B),R(A+1)) */ A: %d, B: %d\n", $ARG_A, $ARG_B | |
else | |
if $OPCODE == OP_SCLASS | |
printf "OP_SCLASS,/* A B R(A) := R(B).singleton_class */\n" | |
else | |
if $OPCODE == OP_TCLASS | |
printf "OP_TCLASS,/* A R(A) := target_class */ A: %d\n", $ARG_A | |
else | |
if $OPCODE == OP_DEBUG | |
printf "OP_DEBUG,/* A print R(A) */\n" | |
else | |
if $OPCODE == OP_STOP | |
printf "OP_STOP,/* stop VM */\n" | |
else | |
if $OPCODE == OP_ERR | |
printf "OP_ERR,/* Bx raise RuntimeError with message Lit(Bx) */\n" | |
else | |
if $OPCODE == OP_RSVD1 | |
printf "OP_RSVD1,/* reserved instruction #1 */\n" | |
else | |
if $OPCODE == OP_RSVD2 | |
printf "OP_RSVD2,/* reserved instruction #2 */\n" | |
else | |
if $OPCODE == OP_RSVD3 | |
printf "OP_RSVD3,/* reserved instruction #3 */\n" | |
else | |
if $OPCODE == OP_RSVD4 | |
printf "OP_RSVD4,/* reserved instruction #4 */\n" | |
else | |
if $OPCODE == OP_RSVD5 | |
printf "OP_RSVD5,/* reserved instruction #5 */\n" | |
else | |
printf "UNKNOWN\n" | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
set $i = $i + 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment