aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
Commit message (Collapse)AuthorAgeFilesLines
* M:N thread scheduler for RactorsKoichi Sasada2023-10-121-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduce M:N thread scheduler for Ractor system. In general, M:N thread scheduler employs N native threads (OS threads) to manage M user-level threads (Ruby threads in this case). On the Ruby interpreter, 1 native thread is provided for 1 Ractor and all Ruby threads are managed by the native thread. From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means 1 Ruby thread has 1 native thread. M:N scheduler change this strategy. Because of compatibility issue (and stableness issue of the implementation) main Ractor doesn't use M:N scheduler on default. On the other words, threads on the main Ractor will be managed with 1:1 thread scheduler. There are additional settings by environment variables: `RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor. Note that non-main ractors use the M:N scheduler without this configuration. With this configuration, single ractor applications run threads on M:1 thread scheduler (green threads, user-level threads). `RUBY_MAX_CPU=n` specifies maximum number of native threads for M:N scheduler (default: 8). This patch will be reverted soon if non-easy issues are found. [Bug #19842]
* `RUBY_DEBUG_LOG` supports `%p` for pidKoichi Sasada2023-10-121-1/+40
|
* Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams2023-06-011-1/+1
| | | This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility.
* Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui2023-06-011-1/+1
| | | | | | | | | This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
* Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams2023-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
* Rename `rb_node_name` to the original nameyui-knk2023-05-241-1/+1
| | | | | | 98637d421dbe8bcf86cc2effae5e26bb96a6a4da changes the name of the function. However this function is exported as global, then change the name to origin one for keeping compatibility.
* Move `ruby_node_name` to node.c and rename prefix of the functionyui-knk2023-05-231-1/+1
|
* `rb_bug` prints a newline after the messageNobuyoshi Nakada2023-05-201-7/+7
|
* show a separator even if `ec` is NULL.Koichi Sasada2023-04-261-13/+12
| | | | | `RUBY_DEBUG_LOG()` doesn't show anything if `GET_EC()` returns NULL, but print a separator "\t" to make consistent TSV.
* `RUBY_DEBUG_LOG_PID` for `RUBY_DEBUG_LOG()`Koichi Sasada2023-04-261-0/+11
| | | | | `RUBY_DEBUG_LOG=stderr RUBY_DEBUG_LOG_PID=1 ruby ...` will prints debug logs with PID.
* [Feature #19579] Remove !USE_RVARGC code (#7655)Peter Zhu2023-04-041-6/+0
| | | | | | | | | | | Remove !USE_RVARGC code [Feature #19579] The Variable Width Allocation feature was turned on by default in Ruby 3.2. Since then, we haven't received bug reports or backports to the non-Variable Width Allocation code paths, so we assume that nobody is using it. We also don't plan on maintaining the non-Variable Width Allocation code, so we are going to remove it.
* `nt->serial` for `RUBY_DEBUG_LOG`Koichi Sasada2023-03-311-7/+33
| | | | | | Show native thread's serial on `RUBY_DEBUG_LOG`. `nt->serial` is also stored into `ruby_nt_serial` if the compiler supports `RB_THREAD_LOCAL_SPECIFIER`.
* Fix spelling (#7389)John Bampton2023-02-271-1/+1
|
* Merge gc.h and internal/gc.hMatt Valentine-House2023-02-091-1/+1
| | | | [Feature #19425]
* Undefine `ruby_debug_log` macro before the function definitionNobuyoshi Nakada2022-08-301-0/+1
| | | | Fix up 27173e3735ff.
* Adjust styles [ci skip]Nobuyoshi Nakada2022-07-271-1/+2
|
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-59/+59
| | | | [Misc #18891]
* Implement Objects on VWAPeter Zhu2022-07-151-0/+2
| | | | | | This commit implements Objects on Variable Width Allocation. This allows Objects with more ivars to be embedded (i.e. contents directly follow the object header) which improves performance through better cache locality.
* small fix on `setup_debug_log()`Koichi Sasada2022-06-101-30/+38
| | | | | * print `ruby_debug_log_mode` at first. * show filters when `ruby_debug_log_mode` is not "disabled".
* func: and file: prefix for `RUBY_DEBUG_LOG_FILTER`Koichi Sasada2022-06-091-45/+121
| | | | | | | | | | | | | | | | | | | | `RUBY_DEBUG_LOG_FILTER` specified only function names but this patch also check file names for each log events. If you specify `file:` or `func:` prefix, it's only filter file names or func names (otherwize check both). foo # show log when file or func names are mached with foo func:foo # show log when func name matches foo file:foo # show log when file name matches foo -file:foo,func:bar # show log when file name does not contains foo # and func name matches bar
* add `rb_th_serial()`Koichi Sasada2022-05-241-1/+1
| | | | `rb_th_serial(th)` returns th's serial for debug print purpose.
* extend `RUBY_DEBUG_LOG_FILTER` to reject wordsKoichi Sasada2022-05-211-11/+46
| | | | | support reject words with `-word` like RUBY_DEBUG_LOG_FILTER=-foo,-bar,baz,boo`.
* `rb_thread_t::serial` for debugKoichi Sasada2022-05-201-24/+24
| | | | | | | | | | | `rb_thread_t::serial` is auto-incremented serial number for threads and it can overflow, it means the serial is not a ID for each thread, it is only for debug print. `RUBY_DEBUG_LOG` shows this information. Also skip EC related information if EC is NULL. This patch enable to use `RUBY_DEBUG_LOG` without setup EC.
* `USE_RUBY_DEBUG_LOG` doesn't check `RUBY_DEVEL`Koichi Sasada2021-12-291-7/+3
| | | | | | | | `USE_RUBY_DEBUG_LOG` was only defined when `RUBY_DEVEL` is defined. This patch removes this dependency (`USE_RUBY_DEBUG_LOG` is defined independently from `RUBY_DEVEL`). Do not commit a patch which enables `USE_RUBY_DEBUG_LOG`.
* [Feature #18239] Implement VWA for stringsPeter Zhu2021-10-251-0/+2
| | | | | This commit adds support for embedded strings with variable capacity and uses Variable Width Allocation to allocate strings.
* lldb: Show encoding of String [ci skip]Nobuyoshi Nakada2021-09-281-0/+2
|
* Moved exported symbols in internal/util.h to ruby/util.hNobuyoshi Nakada2021-08-241-1/+0
| | | | [Feature #18051]
* Revert "Enclose crtitical sections in `thread_exclusive` block"Nobuyoshi Nakada2021-02-241-1/+0
| | | | 19cc24b34b0490b7c2779eec521fe0089e05f183 and fixups.
* Use the system getenv in setup_debug_logNobuyoshi Nakada2021-02-231-0/+1
| | | | | As ruby_set_debug_option() is called before ruby_sysinit(), CRITICAL_SECTIONs are not initialized yet.
* USE_RUBY_DEBUG_LOG is not defined !devel buildKoichi Sasada2020-12-251-0/+2
|
* show ractor info on non-single ractor modeKoichi Sasada2020-12-071-1/+1
| | | | | | | Without this patch, Ruby doesn't show ractor's information when there is only 1 ractor. However it is hard to read the log when some ractors are created and terminated. This patch makes to keep showing ractor's information on multi-ractor mode.
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-2/+1
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* ruby_debug_log: suppress warning卜部昌平2020-08-131-1/+1
| | | | | | | | | | | Old gcc (< 5 maybe?) warns that this variable is not initialized: debug.c: In function 'ruby_debug_log': debug.c:441:13: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized] if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) { ^ I don't know if that is true, but adding "= 0" here must harm no one.
* remove accidentally introduced debug codeKoichi Sasada2020-08-021-2/+2
|
* support multiple filters by RUBY_DEBUG_LOG_FILTERKoichi Sasada2020-08-021-16/+45
| | | | | | Now you can specify multiple filters for RUBY_DEBUG_LOG output by RUBY_DEBUG_LOG_FILTER=a,b,c (in this case, logs that the function name contains a, b or c).
* RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)Koichi Sasada2020-07-031-0/+231
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * RUBY_DEBUG_LOG: Logging debug information mechanism This feature provides a mechanism to store logging information to a file, stderr or memory space with simple macros. The following information will be stored. * (1) __FILE__, __LINE__ in C * (2) __FILE__, __LINE__ in Ruby * (3) __func__ in C (message title) * (4) given string with sprintf format * (5) Thread number (if multiple threads are running) This feature is enabled only USE_RUBY_DEBUG_LOG is enabled. Release version should not enable it. Running with the `RUBY_DEBUG_LOG` environment variable enables this feature. # logging into a file RUBY_DEBUG_LOG=/path/to/file STDERR # logging into STDERR RUBY_DEBUG_LOG=stderr # logging into memory space (check with a debugger) # It will help if the timing is important. RUBY_DEBUG_LOG=mem RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string. If "(3) __func__ in C (message title)" contains the specified string, the infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable only on str related information). In a MRI source code, you can use the following macros: * RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged. * RUBY_DEBUG_LOG2(file, line, fmt, ...): Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* More enums are mandatory for rp in lldb_cruby.pyNobuyoshi Nakada2020-04-251-0/+4
|
* RUBY_SPECIAL_SHIFT and RUBY_FL_USHIFT are mandatory for rp in lldb_cruby.pyNobuyoshi Nakada2020-04-181-0/+1
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* VALUE size packed callinfo (ci).Koichi Sasada2020-02-221-0/+1
| | | | | | | | | | | | | | | | | | | | Now, rb_call_info contains how to call the method with tuple of (mid, orig_argc, flags, kwarg). Most of cases, kwarg == NULL and mid+argc+flags only requires 64bits. So this patch packed rb_call_info to VALUE (1 word) on such cases. If we can not represent it in VALUE, then use imemo_callinfo which contains conventional callinfo (rb_callinfo, renamed from rb_call_info). iseq->body->ci_kw_size is removed because all of callinfo is VALUE size (packed ci or a pointer to imemo_callinfo). To access ci information, we need to use these functions: vm_ci_mid(ci), _flag(ci), _argc(ci), _kwarg(ci). struct rb_call_info_kw_arg is renamed to rb_callinfo_kwarg. rb_funcallv_with_cc() and rb_method_basic_definition_p_with_cc() is temporary removed because cd->ci should be marked.
* move internal/debug.h definitions to internal.hKoichi Sasada2020-01-031-1/+0
| | | | Debug utilities should be accessible from any internal code.
* decouple internal.h headers卜部昌平2019-12-261-5/+12
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* internal/imemo.h rework卜部昌平2019-12-261-0/+9
| | | | | | Arrange contents and eliminate macros, to make them readable. Macro IFUNC_NEW was deleted because there was only one usage.
* add additional CF info for CI envKoichi Sasada2019-12-051-0/+2
| | | | | | | | | Introduce new RUBY_DEBUG option 'ci' to inform Ruby interpreter that an interpreter is running on CI environment. With this option, `rb_bug()` shows more information includes method entry information, local variables information for each control frame.
* internal.h: remove dependecy on ruby/io.hnobu2018-01-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* debug.c: include RIMemo in ruby_dummy_gdb_enumsnobu2017-11-231-2/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* debug.c: vm call flagsnobu2017-11-021-0/+1
| | | | | | * debug.c (ruby_dummy_gdb_enums): include vm_call_flag_bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e