Skip to content

Commit a7608a9

Browse files
committed
Imported Upstream version 2.4.0
1 parent 4049490 commit a7608a9

File tree

2,237 files changed

+79681
-288301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,237 files changed

+79681
-288301
lines changed

.document

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# prelude
1010
prelude.rb
1111

12+
rbconfig.rb
13+
1214
# the lib/ directory (which has its own .document file)
1315
lib
1416

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ end_of_line = crlf
1414
[**.rb]
1515
indent_style = space
1616
indent_size = 2
17+
18+
[*.yml]
19+
indent_size = 2
20+
indent_style = space

.gdbinit

Lines changed: 254 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ define rp
6363
else
6464
if ($flags & RUBY_T_MASK) == RUBY_T_OBJECT
6565
printf "%sT_OBJECT%s: ", $color_type, $color_end
66-
print (struct RObject *)($arg0)
66+
print ((struct RObject *)($arg0))->basic
67+
if ($flags & ROBJECT_EMBED)
68+
print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
69+
else
70+
print (((struct RObject *)($arg0))->as.heap)
71+
print/x *(((struct RObject*)($arg0))->as.heap.ivptr) @ (((struct RObject*)($arg0))->as.heap.numiv)
72+
end
6773
else
6874
if ($flags & RUBY_T_MASK) == RUBY_T_CLASS
6975
printf "%sT_CLASS%s%s: ", $color_type, ($flags & RUBY_FL_SINGLETON) ? "*" : "", $color_end
@@ -413,6 +419,13 @@ document rp_id
413419
Print an ID.
414420
end
415421

422+
define output_string
423+
set $flags = ((struct RBasic*)($arg0))->flags
424+
printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
425+
((struct RString*)($arg0))->as.heap.ptr : \
426+
((struct RString*)($arg0))->as.ary)
427+
end
428+
416429
define rp_string
417430
set $flags = ((struct RBasic*)($arg0))->flags
418431
set print address off
@@ -460,15 +473,15 @@ define rp_class
460473
end
461474
printf "\n"
462475
rb_classname $arg0
463-
print *(struct RClass *)($arg0)
476+
print/x *(struct RClass *)($arg0)
464477
print *((struct RClass *)($arg0))->ptr
465478
end
466479
document rp_class
467480
Print the content of a Class/Module.
468481
end
469482

470483
define rp_imemo
471-
set $flags = (((struct RBasic *)($arg0))->flags >> RUBY_FL_USHIFT) & imemo_mask
484+
set $flags = (enum imemo_type)((((struct RBasic *)($arg0))->flags >> RUBY_FL_USHIFT) & imemo_mask)
472485
if $flags == imemo_cref
473486
printf "(rb_cref_t *) %p\n", (void*)$arg0
474487
print *(rb_cref_t *)$arg0
@@ -488,6 +501,14 @@ define rp_imemo
488501
if $flags == imemo_memo
489502
printf "(struct MEMO *) %p\n", (void*)$arg0
490503
print *(struct MEMO *)$arg0
504+
else
505+
if $flags == imemo_ment
506+
printf "(rb_method_entry_t *) %p\n", (void*)$arg0
507+
print *(rb_method_entry_t *)$arg0
508+
else
509+
if $flags == imemo_iseq
510+
printf "(rb_iseq_t *) %p\n", (void*)$arg0
511+
print *(rb_iseq_t *)$arg0
491512
else
492513
printf "(struct RIMemo *) %p\n", (void*)$arg0
493514
print *(struct RIMemo *)$arg0
@@ -496,6 +517,8 @@ define rp_imemo
496517
end
497518
end
498519
end
520+
end
521+
end
499522
end
500523
document rp_imemo
501524
Print the content of a memo
@@ -852,8 +875,7 @@ end
852875

853876
define rb_classname
854877
# up to 128bit int
855-
set $rb_classname_permanent = "0123456789ABCDEF"
856-
set $rb_classname = classname($arg0, $rb_classname_permanent)
878+
set $rb_classname = rb_mod_name($arg0)
857879
if $rb_classname != RUBY_Qnil
858880
rp $rb_classname
859881
else
@@ -926,11 +948,230 @@ document rb_ps_vm
926948
Dump all threads in a (rb_vm_t*) and their callstacks
927949
end
928950

951+
define print_lineno
952+
set $cfp = $arg0
953+
set $iseq = $cfp->iseq
954+
set $pos = $cfp->pc - $iseq->body->iseq_encoded
955+
if $pos != 0
956+
set $pos = $pos - 1
957+
end
958+
959+
set $i = 0
960+
set $size = $iseq->body->line_info_size
961+
set $table = $iseq->body->line_info_table
962+
#printf "size: %d\n", $size
963+
if $size == 0
964+
else
965+
set $i = 1
966+
while $i < $size
967+
#printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $table[$i].position, $table[$i].line_no, $pos
968+
if $table[$i].position > $pos
969+
loop_break
970+
end
971+
set $i = $i + 1
972+
if $table[$i].position == $pos
973+
loop_break
974+
end
975+
end
976+
printf "%d", $table[$i-1].line_no
977+
end
978+
end
979+
980+
define check_method_entry
981+
# get $immeo and $can_be_svar and return $me
982+
set $imemo = (struct RBasic *)$arg0
983+
set $can_be_svar = $arg1
984+
if $imemo != RUBY_Qfalse
985+
set $type = ($imemo->flags >> 12) & 0x07
986+
if $type == imemo_ment
987+
set $me = (rb_callable_method_entry_t *)$imemo
988+
else
989+
if $type == imemo_svar
990+
set $imemo == ((struct vm_svar *)$imemo)->cref_or_me
991+
check_method_entry $imemo 0
992+
end
993+
end
994+
end
995+
end
996+
997+
define output_id
998+
set $id = $arg0
999+
# rb_id_to_serial
1000+
if $id > tLAST_OP_ID
1001+
set $serial = (rb_id_serial_t)($id >> RUBY_ID_SCOPE_SHIFT)
1002+
else
1003+
set $serial = (rb_id_serial_t)$id
1004+
end
1005+
if $serial && $serial <= global_symbols.last_id
1006+
set $idx = $serial / ID_ENTRY_UNIT
1007+
set $ids = (struct RArray *)global_symbols.ids
1008+
set $flags = $ids->basic.flags
1009+
if ($flags & RUBY_FL_USER1)
1010+
set $idsptr = $ids->as.ary
1011+
set $idslen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1012+
else
1013+
set $idsptr = $ids->as.heap.ptr
1014+
set $idslen = $ids->as.heap.len
1015+
end
1016+
if $idx < $idslen
1017+
set $t = 0
1018+
set $ary = (struct RArray *)$idsptr[$idx]
1019+
if $ary != RUBY_Qnil
1020+
set $flags = $ary->basic.flags
1021+
if ($flags & RUBY_FL_USER1)
1022+
set $aryptr = $ary->as.ary
1023+
set $arylen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1024+
else
1025+
set $aryptr = $ary->as.heap.ptr
1026+
set $arylen = $ary->as.heap.len
1027+
end
1028+
set $result = $aryptr[($serial % ID_ENTRY_UNIT) * ID_ENTRY_SIZE + $t]
1029+
output_string $result
1030+
end
1031+
end
1032+
end
1033+
end
1034+
9291035
define rb_ps_thread
9301036
set $ps_thread = (struct RTypedData*)$arg0
9311037
set $ps_thread_th = (rb_thread_t*)$ps_thread->data
9321038
printf "* #<Thread:%p rb_thread_t:%p native_thread:%p>\n", \
9331039
$ps_thread, $ps_thread_th, $ps_thread_th->thread_id
1040+
set $cfp = $ps_thread_th->cfp
1041+
set $cfpend = (rb_control_frame_t *)($ps_thread_th->stack + $ps_thread_th->stack_size)-1
1042+
while $cfp < $cfpend
1043+
if $cfp->iseq
1044+
if $cfp->pc
1045+
set $location = $cfp->iseq->body->location
1046+
output_string $location.path
1047+
printf ":"
1048+
print_lineno $cfp
1049+
printf ":in `"
1050+
output_string $location.label
1051+
printf "'\n"
1052+
else
1053+
printf "???.rb:???:in `???'\n"
1054+
end
1055+
else
1056+
# if VM_FRAME_TYPE($cfp->flag) == VM_FRAME_MAGIC_CFUNC
1057+
set $ep = $cfp->ep
1058+
if ($ep[0] & 0xffff0001) == 0x55550001
1059+
#define VM_ENV_FLAG_LOCAL 0x02
1060+
#define VM_ENV_PREV_EP(ep) GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL])
1061+
set $me = 0
1062+
set $env_specval = $ep[-1]
1063+
set $env_me_cref = $ep[-2]
1064+
while ($env_specval & 0x02) != 0
1065+
check_method_entry $env_me_cref 0
1066+
if $me != 0
1067+
loop_break
1068+
end
1069+
set $ep = $ep[0]
1070+
set $env_specval = $ep[-1]
1071+
set $env_me_cref = $ep[-2]
1072+
end
1073+
if $me == 0
1074+
check_method_entry $env_me_cref 1
1075+
end
1076+
set print symbol-filename on
1077+
output/a $me->def->body.cfunc.func
1078+
set print symbol-filename off
1079+
set $mid = $me->def->original_id
1080+
printf ":in `"
1081+
output_id $mid
1082+
printf "'\n"
1083+
else
1084+
printf "unknown_frame:???:in `???'\n"
1085+
end
1086+
end
1087+
set $cfp = $cfp + 1
1088+
end
1089+
end
1090+
1091+
define rb_count_objects
1092+
set $objspace = ruby_current_vm->objspace
1093+
set $counts_00 = 0
1094+
set $counts_01 = 0
1095+
set $counts_02 = 0
1096+
set $counts_03 = 0
1097+
set $counts_04 = 0
1098+
set $counts_05 = 0
1099+
set $counts_06 = 0
1100+
set $counts_07 = 0
1101+
set $counts_08 = 0
1102+
set $counts_09 = 0
1103+
set $counts_0a = 0
1104+
set $counts_0b = 0
1105+
set $counts_0c = 0
1106+
set $counts_0d = 0
1107+
set $counts_0e = 0
1108+
set $counts_0f = 0
1109+
set $counts_10 = 0
1110+
set $counts_11 = 0
1111+
set $counts_12 = 0
1112+
set $counts_13 = 0
1113+
set $counts_14 = 0
1114+
set $counts_15 = 0
1115+
set $counts_16 = 0
1116+
set $counts_17 = 0
1117+
set $counts_18 = 0
1118+
set $counts_19 = 0
1119+
set $counts_1a = 0
1120+
set $counts_1b = 0
1121+
set $counts_1c = 0
1122+
set $counts_1d = 0
1123+
set $counts_1e = 0
1124+
set $counts_1f = 0
1125+
set $total = 0
1126+
set $i = 0
1127+
while $i < $objspace->heap_pages.allocated_pages
1128+
printf "\rcounting... %d/%d", $i, $objspace->heap_pages.allocated_pages
1129+
set $page = $objspace->heap_pages.sorted[$i]
1130+
set $p = $page->start
1131+
set $pend = $p + $page->total_slots
1132+
while $p < $pend
1133+
set $flags = $p->as.basic.flags & 0x1f
1134+
eval "set $counts_%02x = $counts_%02x + 1", $flags, $flags
1135+
set $p = $p + 1
1136+
end
1137+
set $total = $total + $page->total_slots
1138+
set $i = $i + 1
1139+
end
1140+
printf "\rTOTAL: %d, FREE: %d\n", $total, $counts_00
1141+
printf "T_OBJECT: %d\n", $counts_01
1142+
printf "T_CLASS: %d\n", $counts_02
1143+
printf "T_MODULE: %d\n", $counts_03
1144+
printf "T_FLOAT: %d\n", $counts_04
1145+
printf "T_STRING: %d\n", $counts_05
1146+
printf "T_REGEXP: %d\n", $counts_06
1147+
printf "T_ARRAY: %d\n", $counts_07
1148+
printf "T_HASH: %d\n", $counts_08
1149+
printf "T_STRUCT: %d\n", $counts_09
1150+
printf "T_BIGNUM: %d\n", $counts_0a
1151+
printf "T_FILE: %d\n", $counts_0b
1152+
printf "T_DATA: %d\n", $counts_0c
1153+
printf "T_MATCH: %d\n", $counts_0d
1154+
printf "T_COMPLEX: %d\n", $counts_0e
1155+
printf "T_RATIONAL: %d\n", $counts_0f
1156+
#printf "UNKNOWN_10: %d\n", $counts_10
1157+
printf "T_NIL: %d\n", $counts_11
1158+
printf "T_TRUE: %d\n", $counts_12
1159+
printf "T_FALSE: %d\n", $counts_13
1160+
printf "T_SYMBOL: %d\n", $counts_14
1161+
printf "T_FIXNUM: %d\n", $counts_15
1162+
printf "T_UNDEF: %d\n", $counts_16
1163+
#printf "UNKNOWN_17: %d\n", $counts_17
1164+
#printf "UNKNOWN_18: %d\n", $counts_18
1165+
#printf "UNKNOWN_19: %d\n", $counts_19
1166+
printf "T_IMEMO: %d\n", $counts_1a
1167+
printf "T_NODE: %d\n", $counts_1b
1168+
printf "T_ICLASS: %d\n", $counts_1c
1169+
printf "T_ZOMBIE: %d\n", $counts_1d
1170+
#printf "UNKNOWN_1E: %d\n", $counts_1e
1171+
printf "T_MASK: %d\n", $counts_1f
1172+
end
1173+
document rb_count_objects
1174+
Counts all objects grouped by type.
9341175
end
9351176

9361177
# Details: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/MachineInstructionsTraceWithGDB
@@ -964,3 +1205,11 @@ define rbi
9641205
end
9651206
end
9661207
end
1208+
1209+
define dump_node
1210+
set $str = rb_parser_dump_tree($arg0, 0)
1211+
set $flags = ((struct RBasic*)($str))->flags
1212+
printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
1213+
((struct RString*)$str)->as.heap.ptr : \
1214+
((struct RString*)$str)->as.ary)
1215+
end

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
*-*-*.lib
44
*.a
55
*.bak
6+
*.bc
67
*.dSYM
78
*.dmyh
89
*.dylib
910
*.elc
11+
*.i
1012
*.inc
1113
*.log
1214
*.o
1315
*.obj
1416
*.orig
1517
*.pdb
1618
*.rej
19+
*.s
1720
*.sav
1821
*.swp
1922
*.yarb
@@ -103,7 +106,7 @@ y.tab.c
103106
/rubicon
104107
/ruby
105108
/ruby-runner
106-
/ruby-runner.c
109+
/ruby-runner.h
107110
/ruby-man.rd.gz
108111
/sizes.c
109112
/test.rb
@@ -123,7 +126,7 @@ y.tab.c
123126
/enc/*.def
124127
/enc/*.exp
125128
/enc/*.lib
126-
/enc/unicode/data
129+
/enc/unicode/data/*/*.txt
127130

128131
# /enc/trans/
129132
/enc/trans/*.c
@@ -164,9 +167,6 @@ y.tab.c
164167
/ext/socket/constdefs.h
165168
/ext/socket/constdefs.c
166169

167-
# /ext/tk/
168-
/ext/tk/config_list
169-
170170
# /gems
171171
/gems/*.gem
172172

0 commit comments

Comments
 (0)