Skip to content
Nayeem Zen edited this page Jul 3, 2014 · 6 revisions

This project consists of some tools to enhance the debugging experience of V8z (https://github.com/andrewlow/v8z). Here are some examples on using the tools:


which_stub_from_addr.pl

Given an address, the script tries to determine the name of the corresponding stub and the offset into that stub.

Usage:

which_stub_from_addr.pl 0xADDRESS print_stubs.txt

where 0xADDRESS is the address to search, and print_stubs.txt is generated by:

d8 --print_code_stubs --print_all_code > print_stubs.txt

If you are running under GDB, and hardcode the location of print_stubs.txt output, you can set up a GDB macro definition as such:

define whered8
  shell perl ../v8z-devtools/which_stub_from_addr.pl $arg0 print_stubs.txt
end
document whered8
Prints the stub name and offset of given addr.
end

During a live debugging session, you can then query at a failing offset:

(gdb) whered8 0x32e0a37a
0x32e0a37a - <CEntryStub+122>

annotate_sim_trace.pl

This script annotates a v8 simulator trace with the location of the stubs/builtins + offset. Note, this works best with snapshot=off. Haven't tested with snapshot=on.

Usage: Generate a v8 trace with:

 d8 --trace --trace_sim --print_code_stubs --print_all_code > sim_trace_output.txt

Run this script:

 annotate_sim_trace.pl sim_trace_output.txt > stubs.txt  2> sim_trace.txt

The script prints the stubs output to STDOUT and annotated trace to STDERR.

Here's a snippet of the annotated simulator trace.

04678  3da15338  1942           cr  r4,r2                     <JSEntryTrampoline+152>
04679  3da1533a  a784000b       brc 0x8,*+22 -> 0x3da15350    <JSEntryTrampoline+154>
04680  3da15350  c07f00000000   llilf r7,0                    <JSEntryTrampoline+176>
04681  3da15356  0de5           basr  r14,r5                  <JSEntryTrampoline+182>
04682  3da203e0  a77e0000       chi r7,0                      <ADD+0>
04683  3da203e4  a7840006       brc 0x8,*+12 -> 0x3da203f0    <ADD+4>
04684  3da203f0  a5e67fff       nilh  r14,32767               <ADD+16>
04685  3da203f4  e3f0fff0ff71   lay sp,-16(sp)                <ADD+20>
04686  3da203fa  50e0f00c       st  r14,12(sp)                <ADD+26>
04687  3da203fe  50b0f008       st  fp,8(sp)                  <ADD+30>
04688  3da20402  50d0f004       st  r13,4(sp)                 <ADD+34>
04689  3da20406  5030f000       st  r3,0(sp)                  <ADD+38>
04690  3da2040a  58c0a014       l ip,20(r10)                  <ADD+42>
04691  3da2040e  18bf           lr  fp,sp                     <ADD+46>
04692  3da20410  a7ba0008       ahi fp,8                      <ADD+48>
04693  3da20414  e3f0fffcff71   lay sp,-4(sp)                 <ADD+52>
04694  3da2041a  50c0f000       st  ip,0(sp)                  <ADD+58>
04695  3da2041e  e3f0fffcff71   lay sp,-4(sp)                 <ADD+62>
04696  3da20424  50c0f000       st  ip,0(sp)                  <ADD+68>
04697  3da20428  c02900000000   iilf  r2,0                    <ADD+72>
04698  3da2042e  c039085707f4   iilf  r3,139921396            <ADD+78>
04699  3da20434  c0c93da0a300   iilf  ip,1033937664           <ADD+84>
04700  3da2043a  0dec           basr  r14,ip                  <ADD+90>
04701  3da0a300  1882           lr  r8,r2                     <CEntryStub+0>
04702  3da0a302  89800002       sll r8,2                      <CEntryStub+2>
04703  3da0a306  e388fffcff71   lay r8,-4(r8,sp)              <CEntryStub+6>
Clone this wiki locally