Skip to content

Instantly share code, notes, and snippets.

@miura1729
Last active August 29, 2015 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miura1729/5d25abb78b998aa974c7 to your computer and use it in GitHub Desktop.
Save miura1729/5d25abb78b998aa974c7 to your computer and use it in GitHub Desktop.
mruby backtrace
define mbt
set $p = mrb->c->ci
while ($p > mrb->c->cibase)
if (($p->proc->flags & 128) != 0 )
printf "0x%x C FUNCTION ", $p
output $p->proc->body.func
printf "\n"
else
set $irep = $p->proc->body.irep
set $filename = $irep->filename
set $lines = $irep->lines
if ($filename && $lines)
if ($p == mrb->c->ci)
set $lineno = $lines[pc - $irep->iseq]
else
set $lineno = $lines[($p + 1)->pc - $irep->iseq]
end
printf "0x%x MRUBY FUNCTION : %d %s\n", $p, $lineno, $filename
else
printf "0x%x MRUBY FUNCTION : \n", $p
end
end
set $p = $p - 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment