Skip to content
  • Aaron Patterson's avatar
    bca8952f
    Fix lldb disassembler so it works with core files · bca8952f
    Aaron Patterson authored
    This fixes the lldb disassembler script so that it doesn't need a live
    process when disassembling rb_iseq_t.  I also added the PC to the output
    so you can tell what the VM is executing when it crashed.
    
    For example:
    
    ```
    (lldb) rbdisasm ec->cfp->iseq
    PC             IDX  insn_name(operands)
    0x56039f0a1720 0000 nop
    0x56039f0a1728 0001 getlocal_WC_1( 5 )
    0x56039f0a1738 0003 branchunless( 7 )
    0x56039f0a1748 0005 getlocal_WC_0( 3 )
    0x56039f0a1758 0007 putstring( (VALUE)0x56039f0c7eb8 )
    0x56039f0a1768 0009 opt_send_without_block( (struct rb_call_data *)0x56039f09f140 )
    0x56039f0a1778 0011 pop
    0x56039f0a1780 0012 getglobal( ID: 0x7fd7 )
    0x56039f0a1790 0014 branchunless( 7 )
    0x56039f0a17a0 0016 getlocal_WC_0( 3 )
    0x56039f0a17b0 0018 putstring( (VALUE)0x56039f0c7e90 )
    0x56039f0a17c0 0020 opt_send_without_block( (struct rb_call_data *)0x56039f09f150 )
    0x56039f0a17d0 0022 pop
    0x56039f0a17d8 0023 getlocal_WC_0( 3 )
    0x56039f0a17e8 0025 putobject( (VALUE)0x56039f0c7e68 )
    0x56039f0a17f8 0027 getlocal_WC_1( 6 )
    0x56039f0a1808 0029 dup
    0x56039f0a1810 0030 checktype( 5 )
    0x56039f0a1820 0032 branchif( 4 )
    0x56039f0a1830 0034 dup
    0x56039f0a1838 0035 opt_send_without_block( (struct rb_call_data *)0x56039f09f160 )
    0x56039f0a1848 0037 tostring
    0x56039f0a1850 0038 putobject( (VALUE)0x56039f0c7e40 )
    0x56039f0a1860 0040 concatstrings( 3 )
    0x56039f0a1870 0042 opt_send_without_block( (struct rb_call_data *)0x56039f09f170 )
    0x56039f0a1880 0044 nop
    0x56039f0a1888 0045 leave
    (lldb) p ec->cfp->pc
    (const VALUE *) $146 = 0x000056039f0a1848
    ```
    
    Here we can see the VM is currently executing `opt_send_without_block`
    (because the PC is one ahead of the current instruction)
    bca8952f
    Fix lldb disassembler so it works with core files
    Aaron Patterson authored
    This fixes the lldb disassembler script so that it doesn't need a live
    process when disassembling rb_iseq_t.  I also added the PC to the output
    so you can tell what the VM is executing when it crashed.
    
    For example:
    
    ```
    (lldb) rbdisasm ec->cfp->iseq
    PC             IDX  insn_name(operands)
    0x56039f0a1720 0000 nop
    0x56039f0a1728 0001 getlocal_WC_1( 5 )
    0x56039f0a1738 0003 branchunless( 7 )
    0x56039f0a1748 0005 getlocal_WC_0( 3 )
    0x56039f0a1758 0007 putstring( (VALUE)0x56039f0c7eb8 )
    0x56039f0a1768 0009 opt_send_without_block( (struct rb_call_data *)0x56039f09f140 )
    0x56039f0a1778 0011 pop
    0x56039f0a1780 0012 getglobal( ID: 0x7fd7 )
    0x56039f0a1790 0014 branchunless( 7 )
    0x56039f0a17a0 0016 getlocal_WC_0( 3 )
    0x56039f0a17b0 0018 putstring( (VALUE)0x56039f0c7e90 )
    0x56039f0a17c0 0020 opt_send_without_block( (struct rb_call_data *)0x56039f09f150 )
    0x56039f0a17d0 0022 pop
    0x56039f0a17d8 0023 getlocal_WC_0( 3 )
    0x56039f0a17e8 0025 putobject( (VALUE)0x56039f0c7e68 )
    0x56039f0a17f8 0027 getlocal_WC_1( 6 )
    0x56039f0a1808 0029 dup
    0x56039f0a1810 0030 checktype( 5 )
    0x56039f0a1820 0032 branchif( 4 )
    0x56039f0a1830 0034 dup
    0x56039f0a1838 0035 opt_send_without_block( (struct rb_call_data *)0x56039f09f160 )
    0x56039f0a1848 0037 tostring
    0x56039f0a1850 0038 putobject( (VALUE)0x56039f0c7e40 )
    0x56039f0a1860 0040 concatstrings( 3 )
    0x56039f0a1870 0042 opt_send_without_block( (struct rb_call_data *)0x56039f09f170 )
    0x56039f0a1880 0044 nop
    0x56039f0a1888 0045 leave
    (lldb) p ec->cfp->pc
    (const VALUE *) $146 = 0x000056039f0a1848
    ```
    
    Here we can see the VM is currently executing `opt_send_without_block`
    (because the PC is one ahead of the current instruction)
Loading