<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby.git/vm_backtrace.c, branch ruby_3_2</title>
<subtitle>github.com: ruby/ruby.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/'/>
<entry>
<title>merge revision(s) eab7f4623fbf0488e828b75843d70c8e02dc8aa5: [Backport #19336]</title>
<updated>2023-01-18T08:08:23+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-01-18T08:08:23+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=057eff7663a0a4bc95a4799336a2bc14ca2480f0'/>
<id>057eff7663a0a4bc95a4799336a2bc14ca2480f0</id>
<content type='text'>
	Return 0 if there is no CFP on the EC yet

	StackProf uses a signal handler to call `rb_profile_frames`.  Signals
	are delivered to threads randomly, and can be delivered after the thread
	has been created but before the CFP has been established on the EC.

	This commit returns early if there is no CFP to use.

	Here is some info from the core files we are seeing.  Here you can see
	the CFP on the current EC is 0x0:

	```
	(gdb) p ruby_current_ec
	$20 = (struct rb_execution_context_struct *) 0x7f3481301b50
	(gdb) p ruby_current_ec-&gt;cfp
	$21 = (rb_control_frame_t *) 0x0
	```

	Here is where VM_FRAME_CFRAME_P gets a 0x0 CFP:

	```
	6  VM_FRAME_CFRAME_P (cfp=0x0) at vm_core.h:1350
	7  VM_FRAME_RUBYFRAME_P (cfp=&lt;optimized out&gt;) at vm_core.h:1350
	8  rb_profile_frames (start=0, limit=2048, buff=0x7f3493809590, lines=0x7f349380d590) at vm_backtrace.c:1587
	```

	Down the stack we can see this is happening after thread creation:

	```
	19 0x00007f3495bf9420 in &lt;signal handler called&gt; () at /lib/x86_64-linux-gnu/libpthread.so.0
	20 0x000055d531574e55 in thread_start_func_2 (th=&lt;optimized out&gt;, stack_start=&lt;optimized out&gt;) at thread.c:676
	21 0x000055d531575b31 in thread_start_func_1 (th_ptr=&lt;optimized out&gt;) at thread_pthread.c:1170
	22 0x00007f3495bed609 in start_thread (arg=&lt;optimized out&gt;) at pthread_create.c:477
	23 0x00007f3495b12133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
	```
	---
	 vm_backtrace.c | 9 +++++++++
	 1 file changed, 9 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Return 0 if there is no CFP on the EC yet

	StackProf uses a signal handler to call `rb_profile_frames`.  Signals
	are delivered to threads randomly, and can be delivered after the thread
	has been created but before the CFP has been established on the EC.

	This commit returns early if there is no CFP to use.

	Here is some info from the core files we are seeing.  Here you can see
	the CFP on the current EC is 0x0:

	```
	(gdb) p ruby_current_ec
	$20 = (struct rb_execution_context_struct *) 0x7f3481301b50
	(gdb) p ruby_current_ec-&gt;cfp
	$21 = (rb_control_frame_t *) 0x0
	```

	Here is where VM_FRAME_CFRAME_P gets a 0x0 CFP:

	```
	6  VM_FRAME_CFRAME_P (cfp=0x0) at vm_core.h:1350
	7  VM_FRAME_RUBYFRAME_P (cfp=&lt;optimized out&gt;) at vm_core.h:1350
	8  rb_profile_frames (start=0, limit=2048, buff=0x7f3493809590, lines=0x7f349380d590) at vm_backtrace.c:1587
	```

	Down the stack we can see this is happening after thread creation:

	```
	19 0x00007f3495bf9420 in &lt;signal handler called&gt; () at /lib/x86_64-linux-gnu/libpthread.so.0
	20 0x000055d531574e55 in thread_start_func_2 (th=&lt;optimized out&gt;, stack_start=&lt;optimized out&gt;) at thread.c:676
	21 0x000055d531575b31 in thread_start_func_1 (th_ptr=&lt;optimized out&gt;) at thread_pthread.c:1170
	22 0x00007f3495bed609 in start_thread (arg=&lt;optimized out&gt;) at pthread_create.c:477
	23 0x00007f3495b12133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
	```
	---
	 vm_backtrace.c | 9 +++++++++
	 1 file changed, 9 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>add debug context APIs for debuggers (frame depth)</title>
<updated>2022-11-25T05:01:36+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2022-11-25T02:51:35+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=67766cd55c3a05f9888c8e2b9e34051a44b3e3fc'/>
<id>67766cd55c3a05f9888c8e2b9e34051a44b3e3fc</id>
<content type='text'>
The following new debug context APIs are for implementing debugger's
`next` (step over) and similar functionality.

* `rb_debug_inspector_frame_depth(dc, index)` returns `index`-th
  frame's depth.
* `rb_debug_inspector_current_depth()` returns current frame depth.

The frame depth is not related to the frame index because debug
context API skips some special frames but proposed `_depth()` APIs
returns the count of all frames (raw depth).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following new debug context APIs are for implementing debugger's
`next` (step over) and similar functionality.

* `rb_debug_inspector_frame_depth(dc, index)` returns `index`-th
  frame's depth.
* `rb_debug_inspector_current_depth()` returns current frame depth.

The frame depth is not related to the frame index because debug
context API skips some special frames but proposed `_depth()` APIs
returns the count of all frames (raw depth).
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typos (#6775)</title>
<updated>2022-11-21T05:07:18+00:00</updated>
<author>
<name>Yudai Takada</name>
<email>13041216+ydah@users.noreply.github.com</email>
</author>
<published>2022-11-21T05:07:18+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=29e6d97517bbd4dcc540464c8473172232f3e228'/>
<id>29e6d97517bbd4dcc540464c8473172232f3e228</id>
<content type='text'>
* s/Innteger/Integer/

* s/diretory/directory/

* s/Bufer/Buffer/

* s/defalt/default/

* s/covearge/coverage/</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* s/Innteger/Integer/

* s/diretory/directory/

* s/Bufer/Buffer/

* s/defalt/default/

* s/covearge/coverage/</pre>
</div>
</content>
</entry>
<entry>
<title>push dummy frame for loading process</title>
<updated>2022-10-20T08:38:28+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2022-10-17T08:50:42+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=e35c528d721d209ed8531b10b46c2ac725ea7bf5'/>
<id>e35c528d721d209ed8531b10b46c2ac725ea7bf5</id>
<content type='text'>
This patch pushes dummy frames when loading code for the
profiling purpose.

The following methods push a dummy frame:
* `Kernel#require`
* `Kernel#load`
* `RubyVM::InstructionSequence.compile_file`
* `RubyVM::InstructionSequence.load_from_binary`

https://bugs.ruby-lang.org/issues/18559
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch pushes dummy frames when loading code for the
profiling purpose.

The following methods push a dummy frame:
* `Kernel#require`
* `Kernel#load`
* `RubyVM::InstructionSequence.compile_file`
* `RubyVM::InstructionSequence.load_from_binary`

https://bugs.ruby-lang.org/issues/18559
</pre>
</div>
</content>
</entry>
<entry>
<title>Rework vm_core to use `int first_lineno` struct member.</title>
<updated>2022-09-25T11:41:16+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2022-09-25T08:07:18+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=22af2e9084d869b0d1eb24e4c11bc1fd62b7c50d'/>
<id>22af2e9084d869b0d1eb24e4c11bc1fd62b7c50d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Adjust styles [ci skip]</title>
<updated>2022-08-06T01:13:20+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-08-06T01:13:20+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=58c8b6e86273ccb7a1b903d9ab35956b69b3b1bf'/>
<id>58c8b6e86273ccb7a1b903d9ab35956b69b3b1bf</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix `rb_profile_frames` output includes dummy main thread frame</title>
<updated>2022-07-26T01:43:44+00:00</updated>
<author>
<name>Ivo Anjo</name>
<email>ivo.anjo@datadoghq.com</email>
</author>
<published>2022-07-11T13:51:44+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=649bfbe00d8032fa2c0536e596a284f69926e87f'/>
<id>649bfbe00d8032fa2c0536e596a284f69926e87f</id>
<content type='text'>
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] (&lt;https://bugs.ruby-lang.org/issues/18907&gt;)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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] (&lt;https://bugs.ruby-lang.org/issues/18907&gt;)
</pre>
</div>
</content>
</entry>
<entry>
<title>Expand tabs [ci skip]</title>
<updated>2022-07-21T16:42:04+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-07-21T16:23:58+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=5b21e94bebed90180d8ff63dad03b8b948361089'/>
<id>5b21e94bebed90180d8ff63dad03b8b948361089</id>
<content type='text'>
[Misc #18891]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Misc #18891]
</pre>
</div>
</content>
</entry>
<entry>
<title>Write Thread instead of Threade</title>
<updated>2022-05-11T22:53:17+00:00</updated>
<author>
<name>Kaíque Kandy Koga</name>
<email>kaiquekandykoga@gmail.com</email>
</author>
<published>2022-05-11T20:32:33+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=f6cc4b9737a75bf3883bb7f86aa8acffaa1710cf'/>
<id>f6cc4b9737a75bf3883bb7f86aa8acffaa1710cf</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add ISEQ_BODY macro</title>
<updated>2022-03-24T14:03:51+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2022-03-23T19:19:48+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=5f10bd634fb6ae8f74a4ea730176233b0ca96954'/>
<id>5f10bd634fb6ae8f74a4ea730176233b0ca96954</id>
<content type='text'>
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using
this macro will make it easier for us to change the allocation strategy
of rb_iseq_constant_body when using Variable Width Allocation.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using
this macro will make it easier for us to change the allocation strategy
of rb_iseq_constant_body when using Variable Width Allocation.
</pre>
</div>
</content>
</entry>
</feed>
