summaryrefslogtreecommitdiff
path: root/test/-ext-/debug
AgeCommit message (Collapse)Author
2024-02-15Show the method owner in backtracesYusuke Endoh
``` test.rb:1:in 'Object#toplevel_meth': unhandled exception from test.rb:4:in 'Foo.class_meth' from test.rb:6:in 'Foo#instance_meth' from test.rb:11:in 'singleton_meth' from test.rb:13:in '<main>' ``` [Feature #19117]
2023-12-28Fix use of the rb_profile_frames start parameterDylan Thacker-Smith
Previously, it was decrementing the start argument until it reached zero without actually changing the control frame pointer. [Bug #14607]
2023-11-03Fix thread leakageNobuyoshi Nakada
Wait for the worker thread to finish.
2023-10-31[Feature #10602] Add new API rb_profile_thread_frames()Daisuke Aritomo
Add a new API rb_profile_thread_frames(), which is essentialy a per-thread version of rb_profile_frames(). While the original rb_profile_frames() always returns results about the current active thread obtained by GET_EC(), this new API takes a Thread to be profiled as an argument. This should come in handy when profiling I/O-bound programs such as webapps, since this new API allows us to learn about Threads performing I/O (which do not have the GVL). Profiling worker threads (such as Sidekiq workers) may be another application. Implements [Feature #10602] Co-authored-by: Mike Perham <mike@perham.net>
2023-10-18Show backtraces when failedKoichi Sasada
If `assert_equal(backtrace_locations.size, profile_frames.size)` in `TestProfileFrames#test_matches_backtrace_locations_main_thread` failed, we do not have enough information about it like that: ``` 1) Failure: TestProfileFrames#test_matches_backtrace_locations_main_thread [/home/runner/work/ruby/ruby/src/test/-ext-/debug/test_profile_frames.rb:148]: <31> expected but was <30>. ``` This patch shows both `backtrace_locations` and `profile_frames` if failed.
2023-07-24Use the caller location as default filename for eval family of methodsJean Boussier
[Feature #19755] Before (in /tmp/test.rb): ```ruby Object.class_eval("p __FILE__") # => "(eval)" ``` After: ```ruby Object.class_eval("p __FILE__") # => "(eval at /tmp/test.rb:1)" ``` This makes it much easier to track down generated code in case the author forgot to provide a filename argument. Notes: Merged: https://github.com/ruby/ruby/pull/8070
2022-07-26Fix `rb_profile_frames` output includes dummy main thread frameIvo Anjo
The `rb_profile_frames` API did not skip the two dummy frames that each thread has at its beginning. This was unlike `backtrace_each` and `rb_ec_parcial_backtrace_object`, which do skip them. This does not seem to be a problem for non-main thread frames, because both `VM_FRAME_RUBYFRAME_P(cfp)` and `rb_vm_frame_method_entry(cfp)` are NULL for them. BUT, on the main thread `VM_FRAME_RUBYFRAME_P(cfp)` was true and thus the dummy thread was still included in the output of `rb_profile_frames`. I've now made `rb_profile_frames` skip this extra frame (like `backtrace_each` and friends), as well as add a test that asserts the size and contents of `rb_profile_frames`. Fixes [Bug #18907] (<https://bugs.ruby-lang.org/issues/18907>) Notes: Merged: https://github.com/ruby/ruby/pull/6114
2020-07-28vm_backtrace.c: let rb_profile_frames show cfunc framesYusuke Endoh
... in addition to normal iseq frames. It is sometimes useful to point the bottleneck more precisely. Notes: Merged: https://github.com/ruby/ruby/pull/3299
2020-05-07Fix rb_profile_frame_classpath to handle module singletonsJean Boussier
Right now `SomeClass.method` is properly named, but `SomeModule.method` is displayed as `#<Module:0x000055eb5d95adc8>.method` which makes profiling annoying. Notes: Merged: https://github.com/ruby/ruby/pull/3084
2019-05-10Adjust indentNobuyoshi Nakada
2018-09-21* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21escape all env properly.ko1
* vm_backtrace.c (rb_debug_inspector_open): escape all env using `rb_vm_stack_to_heap()` before making bindings. [Bug #15105] There is a complicated story of this issue: Without this patch, IFUNC frame does not escaped. A IFUNC frame points to CFUNC ep as previous ep. However, CFUNC ep can be escaped because of making bindings of Ruby level frames. IFUNC's ep can points to invalidated ep and `rb_iter_break()` will fail. This is why `any?` fails. * test/-ext-/debug/test_debug.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-27Revert "Fix use of `rb_profile_frames` start parameter"tenderlove
This reverts commit r63265. ko1 said I should not have committed this! I'm sorry! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-26Fix use of `rb_profile_frames` start parametertenderlove
rb_profile_frames was always behaving as if the value given for the start parameter was 0. The reason for this was that it would check if (start > 0) { then continue without updating the control frame pointer or anything other than decrementing start. [ruby-core:86147] [Bug #14607] Co-authored-by: Dylan Thacker-Smith <Dylan.Smith@shopify.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21vm_backtrace.c: ignore ifunc framesnobu
* vm_backtrace.c (rb_profile_frames): ignore ifunc frames as it did before. [ruby-core:72409] [Bug #11851] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06* vm_core.h: remove rb_iseq_t::klass to reduce dynamic data.ko1
* internal.h, iseq.c (rb_iseq_klass): remove it because rb_iseq_t::klass is removed. * vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but check callable method entry on a frame. This fix simplify the logic to search super class. * test/ruby/test_method.rb: support super() from Proc. Now, [Bug #4881] and [Bug #3136] was solved. * proc.c (rb_mod_define_method): catch up this change. * vm.c (vm_define_method): ditto. * vm_backtrace.c (rb_profile_frames): now, each `frame' objects are rb_callable_method_entry_t data or iseq VALUEs. This fix introduce minor compatibility issue that rb_profile_frame_label() always returns rb_profile_frame_base_label(). * test/-ext-/debug/test_profile_frames.rb: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-27* vm_backtrace.c (rb_profile_frame_classpath): handle singletontmm1
methods defined directly on an object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-14test/-ext-: suppress warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-14test_profile_frames.rb: assert first_linenonobu
* test/-ext-/debug/test_profile_frames.rb (test_profile_frames): assert first_lineno, only the top level of methods for the time being. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-14test_profile_frames.rb: fix typonobu
* test/-ext-/debug/test_profile_frames.rb (test_profile_frames): fix typo, methdo_names to method_names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09* include/ruby/debug.h,ko1
vm_backtrace.c (rb_profile_frame_full_label): add new C API rb_profile_frame_full_label() which returns label with qualified method name. Note that in future version of Ruby label() may return same return value of full_label(). * ext/-test-/debug/profile_frames.c, test/-ext-/debug/test_profile_frames.rb: fix a test for this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08* vm_backtrace.c, include/ruby/debug.h: add new APIsko1
* VALUE rb_profile_frame_method_name(VALUE frame) * VALUE rb_profile_frame_qualified_method_name(VALUE frame) * iseq.c (rb_iseq_klass), internal.h: add new internal function rb_iseq_method_name(). * ext/-test-/debug/profile_frames.c (profile_frames), test/-ext-/debug/test_profile_frames.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07* test/-ext-/debug/test_profile_frames.rb: rename class C toko1
something long name because one test depends on absence of class ::C. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07* ext/-test-/debug/profile_frames.c:ko1
test/-ext-/debug/test_profile_frames.rb: add a test for new C-APIs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29* vm_backtrace.c: fix issue of rb_debug_inspector_open().ko1
The order of making binding should be stack (frame) top to bottom. [Bug #7635] And also fix issue of collecting klass. Collecting klass is same as TracePoint#defined_class. (previous version, it returns T_ICLASS (internal objects). * test/-ext-/debug/test_debug.rb: add a test. * ext/-test-/debug/extconf.rb, init.c, inspector.c: ditto. * vm_backtrace.c: remove magic number and add enum CALLER_BINDING_*. * vm_backtrace.c, include/ruby/debug.h: add new C api (experimental) rb_debug_inspector_frame_self_get(). * vm.c, vm_core.h, vm_trace.c: move decl. of rb_vm_control_frame_id_and_class() and constify first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e