Created
September 29, 2015 15:52
-
-
Save gut/d716443d897710742a93 to your computer and use it in GitHub Desktop.
easily print VASMs of current code emission
This file contains 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
# auxiliary of print_vasms | |
define pvector | |
set $i = 0 | |
while($i < $arg0.size()) | |
printf "\t" | |
p $arg0[$i].$arg1 | |
set $i = $i + 1 | |
end | |
end | |
# this function is to be called on this scope: | |
# HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> | |
define print_vasms | |
printf "To be used on HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen>\n" | |
printf "==========================================================================\n\n" | |
set $j = 0 | |
while($j < unit.blocks.size()) | |
printf "unit.blocks[%d]:\n", $j | |
pvector unit.blocks[$j].code op | |
set $j = $j + 1 | |
end | |
end |
This file contains 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
$ cat ~/.gdbinit | |
# auxiliary of print_vasms | |
define pvector | |
set $i = 0 | |
while($i < $arg0.size()) | |
printf "\t" | |
p $arg0[$i].$arg1 | |
set $i = $i + 1 | |
end | |
end | |
# this function is to be called on this scope: | |
# HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> | |
define print_vasms | |
printf "To be used on HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen>\n" | |
printf "==========================================================================\n\n" | |
set $j = 0 | |
while($j < unit.blocks.size()) | |
printf "unit.blocks[%d]:\n", $j | |
pvector unit.blocks[$j].code op | |
set $j = $j + 1 | |
end | |
end | |
$ cat blank.php | |
<?php ?> | |
$ gdb hphp/hhvm/hhvm | |
GNU gdb (GDB) 7.10 | |
Copyright (C) 2015 Free Software Foundation, Inc. | |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | |
This is free software: you are free to change and redistribute it. | |
There is NO WARRANTY, to the extent permitted by law. Type "show copying" | |
and "show warranty" for details. | |
This GDB was configured as "powerpc64le-unknown-linux-gnu". | |
Type "show configuration" for configuration details. | |
For bug reporting instructions, please see: | |
<http://www.gnu.org/software/gdb/bugs/>. | |
Find the GDB manual and other documentation resources online at: | |
<http://www.gnu.org/software/gdb/documentation/>. | |
For help, type "help". | |
(gdb) b HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> | |
Breakpoint 1 at 0x141fdb6c: HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen>. (3 locations) | |
(gdb) r blank.php | |
Starting program: /home/hhvm/hphp/hhvm/hhvm blank.php | |
[Thread debugging using libthread_db enabled] | |
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1". | |
Breakpoint 1, HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> (unit=..., text=..., asm_info=0x0) at /home/hhvm/hphp/runtime/vm/jit/vasm-internal-inl.h:124 | |
124 Venv env { unit, text }; | |
(gdb) print_vasms | |
To be used on HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> | |
========================================================================== | |
unit.blocks[0]: | |
$1 = HPHP::jit::Vinstr::copy | |
$2 = HPHP::jit::Vinstr::copy | |
$3 = HPHP::jit::Vinstr::call | |
$4 = HPHP::jit::Vinstr::jmpr | |
unit.blocks[1]: | |
$5 = HPHP::jit::Vinstr::fallthru | |
(gdb) c | |
Continuing. | |
Breakpoint 1, HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> (unit=..., text=..., asm_info=0x0) at /home/hhvm/hphp/runtime/vm/jit/vasm-internal-inl.h:124 | |
124 Venv env { unit, text }; | |
(gdb) print_vasms | |
To be used on HPHP::jit::vasm_emit<HPHP::jit::(anonymous namespace)::Vgen> | |
========================================================================== | |
unit.blocks[0]: | |
$6 = HPHP::jit::Vinstr::copy | |
$7 = HPHP::jit::Vinstr::load | |
$8 = HPHP::jit::Vinstr::cmplim | |
$9 = HPHP::jit::Vinstr::jcc | |
unit.blocks[1]: | |
$10 = HPHP::jit::Vinstr::fallthru | |
unit.blocks[2]: | |
$11 = HPHP::jit::Vinstr::copy | |
$12 = HPHP::jit::Vinstr::jcc | |
unit.blocks[3]: | |
$13 = HPHP::jit::Vinstr::copy | |
$14 = HPHP::jit::Vinstr::ret | |
unit.blocks[4]: | |
$15 = HPHP::jit::Vinstr::copy | |
$16 = HPHP::jit::Vinstr::declm | |
$17 = HPHP::jit::Vinstr::ret | |
unit.blocks[5]: | |
$18 = HPHP::jit::Vinstr::copy | |
$19 = HPHP::jit::Vinstr::push | |
$20 = HPHP::jit::Vinstr::push | |
$21 = HPHP::jit::Vinstr::shrli | |
$22 = HPHP::jit::Vinstr::callm | |
$23 = HPHP::jit::Vinstr::syncpoint | |
$24 = HPHP::jit::Vinstr::pop | |
$25 = HPHP::jit::Vinstr::pop | |
$26 = HPHP::jit::Vinstr::jmp | |
unit.blocks[6]: | |
$27 = HPHP::jit::Vinstr::copy | |
$28 = HPHP::jit::Vinstr::jmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment