1+ set startup-with-shell off
2+
13define hook-run
24 set $color_type = 0
35 set $color_highlite = 0
@@ -154,8 +156,12 @@ define rp
154156 else
155157 if ($flags & RUBY_T_MASK) == RUBY_T_HASH
156158 printf " %sT_HASH%s: " , $color_type , $color_end ,
157- if ((struct RHash *)($arg0 ))->ntbl
158- printf " len=%ld " , ((struct RHash *)($arg0 ))->ntbl->num_entries
159+ if (((struct RHash *)($arg0 ))->basic->flags & RHASH_ST_TABLE_FLAG)
160+ printf " st len=%ld " , ((struct RHash *)($arg0 ))->as.st->num_entries
161+ else
162+ printf " li len=%ld bound=%ld " , \
163+ ((((struct RHash *)($arg0 ))->basic->flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT), \
164+ ((((struct RHash *)($arg0 ))->basic->flags & RHASH_AR_TABLE_BOUND_MASK) >> RHASH_AR_TABLE_BOUND_SHIFT)
159165 end
160166 print (struct RHash *)($arg0 )
161167 else
@@ -698,12 +704,6 @@ define nd_cval
698704 rp ($arg0 ).u3.value
699705end
700706
701-
702- define nd_cnt
703- printf " %su3.cnt%s: " , $color_highlite , $color_end
704- p ($arg0 ).u3.cnt
705- end
706-
707707define nd_tbl
708708 printf " %su1.tbl%s: " , $color_highlite , $color_end
709709 p ($arg0 ).u1.tbl
@@ -742,12 +742,6 @@ define nd_lit
742742 rp ($arg0 ).u1.value
743743end
744744
745-
746- define nd_frml
747- printf " %su1.node%s: " , $color_highlite , $color_end
748- rp ($arg0 ).u1.node
749- end
750-
751745define nd_rest
752746 printf " %su2.argc%s: " , $color_highlite , $color_end
753747 p ($arg0 ).u2.argc
@@ -774,12 +768,6 @@ define nd_args
774768 rp ($arg0 ).u3.node
775769end
776770
777-
778- define nd_noex
779- printf " %su1.id%s: " , $color_highlite , $color_end
780- p ($arg0 ).u1.id
781- end
782-
783771define nd_defn
784772 printf " %su3.node%s: " , $color_highlite , $color_end
785773 rp ($arg0 ).u3.node
@@ -797,17 +785,6 @@ define nd_new
797785end
798786
799787
800- define nd_cfnc
801- printf " %su1.cfunc%s: " , $color_highlite , $color_end
802- p ($arg0 ).u1.cfunc
803- end
804-
805- define nd_argc
806- printf " %su2.argc%s: " , $color_highlite , $color_end
807- p ($arg0 ).u2.argc
808- end
809-
810-
811788define nd_cname
812789 printf " %su1.id%s: " , $color_highlite , $color_end
813790 p ($arg0 ).u1.id
@@ -1021,24 +998,55 @@ define print_lineno
1021998 set $pos = $pos - 1
1022999 end
10231000
1024- set $i = 0
1025- set $size = $iseq ->body->insns_info_size
1026- set $table = $iseq ->body->insns_info
1001+ set $index = 0
1002+ set $size = $iseq ->body->insns_info.size
1003+ set $table = $iseq ->body->insns_info.body
1004+ set $positions = $iseq ->body->insns_info.positions
10271005 # printf "size: %d\n", $size
10281006 if $size == 0
10291007 else
1030- set $i = 1
1031- while $i < $size
1032- # printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $table[$i].position, $table[$i].line_no, $pos
1033- if $table [$i ].position > $pos
1034- loop_break
1008+ if $size == 1
1009+ printf " %d" , $table [0 ].line_no
1010+ else
1011+ if $positions
1012+ # get_insn_info_linear_search
1013+ set $index = 1
1014+ while $index < $size
1015+ # printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $positions[$i], $table[$i].line_no, $pos
1016+ if $positions [$index ] > $pos
1017+ loop_break
1018+ end
1019+ set $index = $index + 1
1020+ if $positions [$index ] == $pos
1021+ loop_break
1022+ end
10351023 end
1036- set $i = $i + 1
1037- if $table [$i ].position == $pos
1038- loop_break
1024+ else
1025+ # get_insn_info_succinct_bitvector
1026+ set $sd = $iseq ->body->insns_info.succ_index_table
1027+ set $immediate_table_size = sizeof($sd ->imm_part) / sizeof(uint64_t) * 9
1028+ if $pos < $immediate_table_size
1029+ set $i = $pos / 9
1030+ set $j = $pos % 9
1031+ set $index = ((int)($sd ->imm_part[$i ] >> ($j * 7 ))) & 0x7f
1032+ else
1033+ set $block_index = ($pos - $immediate_table_size ) / 512
1034+ set $block = &$sd ->succ_part[$block_index ]
1035+ set $block_bit_index = ($pos - $immediate_table_size ) % 512
1036+ set $small_block_index = $block_bit_index / 64
1037+ set $small_block_popcount = $small_block_index == 0 ? 0 : (((int)($block ->small_block_ranks >> (($small_block_index - 1 ) * 9 ))) & 0x1ff )
1038+ set $x = $block ->bits[$small_block_index ] << (63 - $block_bit_index % 64 )
1039+ set $x = ($x & 0x5555555555555555 ) + ($x >> 1 & 0x5555555555555555 )
1040+ set $x = ($x & 0x3333333333333333 ) + ($x >> 2 & 0x3333333333333333 )
1041+ set $x = ($x & 0x0707070707070707 ) + ($x >> 4 & 0x0707070707070707 )
1042+ set $x = ($x & 0x001f001f001f001f ) + ($x >> 8 & 0x001f001f001f001f )
1043+ set $x = ($x & 0x0000003f0000003f ) + ($x >>16 & 0x0000003f0000003f )
1044+ set $popcnt = ($x & 0x7f ) + ($x >>32 & 0x7f )
1045+ set $index = $block ->rank + $small_block_popcount + $popcnt
10391046 end
10401047 end
1041- printf " %d" , $table [$i -1 ].line_no
1048+ printf " %d" , $table [$index -1 ].line_no
1049+ end
10421050 end
10431051end
10441052
@@ -1065,9 +1073,9 @@ define print_id
10651073 else
10661074 set $serial = (rb_id_serial_t)$id
10671075 end
1068- if $serial && $serial <= global_symbols .last_id
1076+ if $serial && $serial <= ruby_global_symbols .last_id
10691077 set $idx = $serial / ID_ENTRY_UNIT
1070- set $ids = (struct RArray *)global_symbols .ids
1078+ set $ids = (struct RArray *)ruby_global_symbols .ids
10711079 set $flags = $ids ->basic.flags
10721080 if ($flags & RUBY_FL_USER1)
10731081 set $idsptr = $ids ->as.ary
@@ -1305,3 +1313,34 @@ define dump_node
13051313 ((struct RString*)$str )->as.heap.ptr : \
13061314 ((struct RString*)$str )->as.ary)
13071315end
1316+
1317+ define print_flags
1318+ printf " RUBY_FL_WB_PROTECTED: %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_WB_PROTECTED ? " 1" : " 0"
1319+ printf " RUBY_FL_PROMOTED0 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_PROMOTED0 ? " 1" : " 0"
1320+ printf " RUBY_FL_PROMOTED1 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_PROMOTED1 ? " 1" : " 0"
1321+ printf " RUBY_FL_FINALIZE : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_FINALIZE ? " 1" : " 0"
1322+ printf " RUBY_FL_TAINT : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_TAINT ? " 1" : " 0"
1323+ printf " RUBY_FL_UNTRUSTED : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_UNTRUSTED ? " 1" : " 0"
1324+ printf " RUBY_FL_EXIVAR : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_EXIVAR ? " 1" : " 0"
1325+ printf " RUBY_FL_FREEZE : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_FREEZE ? " 1" : " 0"
1326+
1327+ printf " RUBY_FL_USER0 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER0 ? " 1" : " 0"
1328+ printf " RUBY_FL_USER1 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER1 ? " 1" : " 0"
1329+ printf " RUBY_FL_USER2 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER2 ? " 1" : " 0"
1330+ printf " RUBY_FL_USER3 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER3 ? " 1" : " 0"
1331+ printf " RUBY_FL_USER4 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER4 ? " 1" : " 0"
1332+ printf " RUBY_FL_USER5 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER5 ? " 1" : " 0"
1333+ printf " RUBY_FL_USER6 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER6 ? " 1" : " 0"
1334+ printf " RUBY_FL_USER7 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER7 ? " 1" : " 0"
1335+ printf " RUBY_FL_USER8 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER8 ? " 1" : " 0"
1336+ printf " RUBY_FL_USER9 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER9 ? " 1" : " 0"
1337+ printf " RUBY_FL_USER10 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER10 ? " 1" : " 0"
1338+ printf " RUBY_FL_USER11 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER11 ? " 1" : " 0"
1339+ printf " RUBY_FL_USER12 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER12 ? " 1" : " 0"
1340+ printf " RUBY_FL_USER13 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER13 ? " 1" : " 0"
1341+ printf " RUBY_FL_USER14 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER14 ? " 1" : " 0"
1342+ printf " RUBY_FL_USER15 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER15 ? " 1" : " 0"
1343+ printf " RUBY_FL_USER16 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER16 ? " 1" : " 0"
1344+ printf " RUBY_FL_USER17 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER17 ? " 1" : " 0"
1345+ printf " RUBY_FL_USER18 : %s\n " , ((struct RBasic*)($arg0 ))->flags & RUBY_FL_USER18 ? " 1" : " 0"
1346+ end
0 commit comments