Skip to content

Commit 373f789

Browse files
authored
Merge pull request ruby#1 from ruby/trunk
Update from original
2 parents 7c14876 + 0984808 commit 373f789

File tree

1,916 files changed

+41221
-264407
lines changed

Some content is hidden

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

1,916 files changed

+41221
-264407
lines changed

.gdbinit

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ document rp_id
413413
Print an ID.
414414
end
415415

416+
define output_string
417+
set $flags = ((struct RBasic*)($arg0))->flags
418+
printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
419+
((struct RString*)($arg0))->as.heap.ptr : \
420+
((struct RString*)($arg0))->as.ary)
421+
end
422+
416423
define rp_string
417424
set $flags = ((struct RBasic*)($arg0))->flags
418425
set print address off
@@ -936,11 +943,230 @@ document rb_ps_vm
936943
Dump all threads in a (rb_vm_t*) and their callstacks
937944
end
938945

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

9461172
# Details: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/MachineInstructionsTraceWithGDB

.gitignore

Lines changed: 4 additions & 4 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
@@ -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

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ script:
6464
branches:
6565
only:
6666
- trunk
67-
- ruby_2_0_0
6867
- ruby_2_1
6968
- ruby_2_2
7069
- ruby_2_3
70+
- /^feature\//
71+
- /^bug\//
7172

7273
# We want to be notified when something happens.
7374
notifications:

COPYING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ You can redistribute it and/or modify it under either the terms of the
4444
For the list of those files and their copying conditions, see the
4545
file LEGAL.
4646

47-
5. The scripts and library files supplied as input to or produced as
47+
5. The scripts and library files supplied as input to or produced as
4848
output from the software do not automatically fall under the
49-
copyright of the software, but belong to whomever generated them,
49+
copyright of the software, but belong to whomever generated them,
5050
and may be sold commercially, and may be aggregated with this
5151
software.
5252

0 commit comments

Comments
 (0)