Thread::Backtrace::Location#inspect.
BTW, tests for `caller_locations' are not enough.
Any volunteers are welcome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This method is similart to `caller_locations' method for
specific method.
And fix to accept `level' and `n' parameters for `Thread#backtrace'
and `Thread#backtrace_locations'.
`caller' (and `caller_locations') do not return `caller' method
frame.
However, `Thread#backtrace' (and `Thread#backtrace_locations')
return `Thread#backtrace' method frame itself
if `Thread.current.backtrace' was called.
* vm_backtrace.c: ditto.
* internal.h: ditto.
* test/ruby/test_backtrace.rb: add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(1) Class name: RubyVM::FrameInfo -> RubyVM::Backtrace::Location.
(2) Method name: RubyVM::FrameInfo.caller ->
Kernel.caller_locations.
(3) Instance methods of
RubyVM::FrameInfo (RubyVM::Backtrace::Location)
(3-1) name -> label
(3-2) basename -> base_label (basename is confusing with
File.basename)
(3-3) line_no -> lineno (We have already similar name
File#lineno, commented by kou [ruby-dev:45686]).
(3-4) filename -> path.
(3-5) filepath -> absolute_path.
(3-5) iseq -> removed (we will make other APIs to access iseq
and other information of frame for debugging).
* test/ruby/test_backtrace.rb: apply above changes.
And apply comment from kou [ruby-dev:45686].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
information. You don't need to parse strings from caller().
FrameInfo has the following methods:
FrameInfo#name: method name, class name, etc with decorations.
FrameInfo#basename: name without decorations.
FrameInfo#line_no: line number.
FrameInfo#filename: file name.
FrameInfo#filepath: full filepath.
FrameInfo#iseq: iseq if it is iseq frame (defined by ruby script)
FrameInfo#to_s: return caller() method style string.
RubyVM::FrameInfoFrameInfo.caller(n, lev) returns array of
FrameInfo objects. The name "RubyVM::FrameInfoFrameInfo.caller"
is long and ambiguous (same as caller() method), we need to change
the name before Ruby 2.0 release.
Good names or comments are welcome.
* test/ruby/test_backtrace.rb: add a test for above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
argument `n' which specify how many frames should return.
For example, `caller(0, 1)' returns only one frame information
which calls caller() method. If there are less than n frame
information, then all frame information are returned. If n is 0,
then always return [].
This fix is part of [ruby-dev:42345] [Ruby 1.9-Feature#3917].
However, performance and features are not enough.
RDoc is also not available.
* test/ruby/test_backtrace.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(1) unify similar functions (rb_backtrace_each() and
backtrace_object()). backtrace_each() is a unified function.
variation:
a) backtrace_object(): create backtrace object.
b) vm_backtrace_str_ary(): create bt as an array of string.
c) vm_backtrace_print(): print backtrace to specified file.
d) rb_backtrace_print_as_bugreport(): print backtrace on
bugreport style.
(2) remove rb_backtrace_each(). Use backtrace_each() instead.
(3) chang the type of lev parameter to size_t.
a) lev == 0 means current frame (exception, etc use it).
b) lev == 1 means upper frame (caller(0) use it).
* vm_core.h, vm_dump.c, vm_eval.c: ditto.
* vm.c (backtrace_object(), vm_backtrace_str_ary()): fix to return a
correct size of caller(lev) array.
Let n be a "caller(0).size" then ln as caller(lev).size should be
(n - lev). However, the previous implementation returns a wrong
size array (ln > n - lev). [ruby-dev:45673]
* test/ruby/test_backtrace.rb: add tests for backtrace.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e