puts$B$G(BSEGV

e$B$k$S$-$A$G$9!#e(B

$stdoute$B$KJL$N%*%V%8%’%/%H$r;XDj$7$?>l9g!"e(Bputse$B$Ge(BSEGVe$B$j$^$9!#e(B
Ruby 1.9.0e$B$G$OBg>fIW$G$9!#e(B

class Logger
def write(obj)
STDOUT.print Time.now.strftime("%Y/%m/%d %H:%M:%S:"), obj
end
end
$stdout = Logger.new

print 1,2
puts 1,2

(gdb) bt
#0 0x080d5208 in st_lookup (table=0x4, key=1000, value=0xbf4090c4) at
st.c:282
#1 0x08059820 in search_method (klass=3083118216, id=1000, klassp=0x0)
at eval_method.c:219
#2 0x0805985d in rb_get_method_body (klass=3083118216, id=1000,
idp=0xbf409144)
at eval_method.c:246
#3 0x0805d119 in rb_call0 (klass=3083118216, recv=3083006680, mid=1000,
argc=1,
argv=0xbf4091c0, scope=3, self=3082638840) at eval.c:1383
#4 0x0805d364 in rb_call (klass=3083118216, recv=3083006680, mid=1000,
argc=1,
argv=0xbf4091c0, scope=3) at eval.c:1449
#5 0x0805d5af in rb_funcall (recv=3083006680, mid=1000, n=1) at
eval.c:1541
#6 0x0812d889 in rb_exc_new (etype=3083006680,
ptr=0xbf409264 “method <fe$B!e(B’ called on terminated object
(0xb7c2f47c)”, len=54)
at error.c:340
#7 0x0812d8c0 in rb_exc_new2 (etype=3083006680,
s=0xbf409264 “method <fe$B!e(B’ called on terminated object
(0xb7c2f47c)”)
at error.c:346
#8 0x0812f13e in rb_raise (exc=3083006680,
fmt=0x814a54c “method `%s’ called on terminated object (%p)”) at
error.c:1078
#9 0x0805d03f in rb_call0 (klass=0, recv=3083007100, mid=1000, argc=1,
argv=0xbf40b320, scope=3, self=3082638840) at eval.c:1367
#10 0x0805d364 in rb_call (klass=0, recv=3083007100, mid=1000, argc=1,
argv=0xbf40b320, scope=3) at eval.c:1449
#11 0x0805d5af in rb_funcall (recv=3083007100, mid=1000, n=1) at
eval.c:1541
#12 0x0812d889 in rb_exc_new (etype=3083007100,
ptr=0xbf40b3c4 “wrong number of arguments(2 for 0)”, len=34) at
error.c:340
#13 0x0812d8c0 in rb_exc_new2 (etype=3083007100,
s=0xbf40b3c4 “wrong number of arguments(2 for 0)”) at error.c:346
#14 0x0812f13e in rb_raise (exc=3083007100,
fmt=0x81662d0 “wrong number of arguments(%d for %d)”) at
error.c:1078
#15 0x08101593 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=0,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:273
#16 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#17 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#18 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#19 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#20 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#21 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#22 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
—Type to continue, or q to quit—
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#23 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#24 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#25 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#26 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#27 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#28 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#29 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#30 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#31 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#32 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#33 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#34 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#35 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#36 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#37 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#38 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#39 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#40 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#41 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#42 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#43 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#44 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#45 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
—Type to continue, or q to quit—
#46 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#47 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#48 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#49 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#50 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#51 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#52 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#53 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#54 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#55 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#56 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#57 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#58 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#59 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#60 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#61 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#62 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#63 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#64 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#65 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#66 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#67 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#68 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#69 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
—Type to continue, or q to quit—
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#70 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#71 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#72 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#73 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#74 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#75 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#76 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#77 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#78 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#79 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#80 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#81 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#82 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#83 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#84 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#85 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#86 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#87 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#88 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#89 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#90 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#91 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#92 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
—Type to continue, or q to quit—
#93 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#94 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#95 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#96 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#97 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#98 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#99 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#100 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#101 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840,
mid=6712, argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#102 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#103 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#104 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#105 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#106 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#107 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840,
mid=6712, argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#108 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#109 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548
#110 0x08071970 in rb_f_puts (argc=2, argv=0xb7c37024) at io.c:4567
#111 0x08101600 in call_cfunc (func=0x807192a <rb_f_puts>,
recv=3082638840, len=-1,
argc=2, argv=0xb7c37024) at vm_insnhelper.c:282
#112 0x08101112 in vm_call0 (th=0x819c990, klass=3083036220,
recv=3082638840,
id=6712, oid=0, argc=2, argv=0xb7c37024, body=0xb7c24090, nosuper=0)
at vm.c:457
#113 0x0805d315 in rb_call0 (klass=3083036220, recv=3082638840,
mid=6712, argc=2,
argv=0xb7c37024, scope=3, self=3082638840) at eval.c:1435
#114 0x0805d364 in rb_call (klass=3082638980, recv=3082638840, mid=6712,
argc=2,
argv=0xb7c37024, scope=3) at eval.c:1449
#115 0x0805d5f0 in rb_funcall2 (recv=3082638840, mid=6712, argc=2,
argv=0xb7c37024)
at eval.c:1548

[email protected]$G$9!#e(B

At Sat, 15 Mar 2008 12:43:25 +0900,
[email protected] wrote in [ruby-dev:34059]:

$stdoute$B$KJL$N%*%V%8%’%/%H$r;XDj$7$?>l9g!"e(Bputse$B$Ge(BSEGVe$B$j$^$9!#e(B
Ruby 1.9.0e$B$G$OBg>fIW$G$9!#e(B

e$B%9%?%C%/%*!<%P!<%U%m!<$7$F$^$9$M!#860x$O!“e(Br15564e$B$Ge(BKernel#putse$B$,e(B
$stdout.putse$B$r8F$V$h$&$K$J$C$?$N$G$9$,!”$3$Ne(BLoggere$B$Oe(Bputse$B%a%=%C%Ie(B
e$B$r;}$C$F$$$J$$$N$Ge(BKernel#putse$B$,$^$?8F$P$l$k$3$H$K$J$k$?$a$G$9!#e(B

class Logger
def write(obj)
STDOUT.print Time.now.strftime("%Y/%m/%d %H:%M:%S:"), obj
end
end
$stdout = Logger.new

e$BBP1~$H$7$F$OFs$D$[$I;W$$IU$-$^$9$,!"$I$&$7$^$7$g$&$+!#e(B

  1. r15564e$B$re(Breverte$B$9$k!#e(B

$stdoute$B$N;EMM$rJQ$($F!"e([email protected]$1$G$J$/e(Bputs,putce$B$bDj5AI,?$K$9e(B
e$B$k!#e(BKernel#putse$B$r8F$s$G$7$^$&$N$rKI$0$?$a$K!"e(Brb_f_putce$B$He(B
rb_f_putse$B$G$Oe(Brb_funcall2e$B$G$O$J$/e(Brb_funcall3e$B$r;H$&$h$&$K$9$k!#e(B

[email protected]$G$9!#e(B

At Sat, 15 Mar 2008 15:18:33 +0900,
Nobuyoshi N. wrote in [ruby-dev:34061]:

def write(obj)
e$B$k!#e(BKernel#putse$B$r8F$s$G$7$^$&$N$rKI$0$?$a$K!"e(Brb_f_putce$B$He(B
rb_f_putse$B$G$Oe(Brb_funcall2e$B$G$O$J$/e(Brb_funcall3e$B$r;H$&$h$&$K$9$k!#e(B

e$B$b$&0l$D;W$$IU$-$^$7$?!#e(B

selfe$B$,e(B$stdoute$B$J$ie(BIO#putc,IO#putse$B$rD>@\8F$V!"e(B$stdoute$B0J30$J$ie(B
$stdoute$B$N%a%=%C%I$r8F$V!#e(B

Index: io.c

— io.c (revision 15780)
+++ io.c (working copy)
@@ -4486,4 +4486,7 @@ static VALUE
rb_f_putc(VALUE recv, VALUE ch)
{

  • if (recv == rb_stdout) {
  • return rb_io_putc(recv, ch);
  • }
    return rb_funcall2(rb_stdout, rb_intern(“putc”), 1, &ch);
    }
    @@ -4563,6 +4566,9 @@ rb_io_puts(int argc, VALUE *argv, VALUE

static VALUE
-rb_f_puts(int argc, VALUE *argv)
+rb_f_puts(int argc, VALUE *argv, VALUE recv)
{

  • if (recv == rb_stdout) {
  • return rb_io_puts(argc, argv, recv);
  • }
    return rb_funcall2(rb_stdout, rb_intern(“puts”), argc, argv);
    }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs