Граф коммитов

94 Коммитов

Автор SHA1 Сообщение Дата
nobu c6fb7c1f33 eval_error.c: should not escapce newline and tab
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-24 10:10:18 +00:00
svn 497075b3a1 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08 09:08:37 +00:00
nobu 50784a0a44 Defer escaping control char in error messages
* eval_error.c (print_errinfo): defer escaping control char in
  error messages until writing to stderr, instead of quoting at
  building the message.  [ruby-core:90853] [Bug #15497]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08 09:08:31 +00:00
nobu 1849288722 Fix for circular causes
* eval_error.c (show_cause): get rid of infinite recursion on
  circular causes.  [Bug #15447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 07:14:14 +00:00
mame 010a742cb6 eval_error.c (show_cause): check if cause is an Exception or not
Fixes [Bug #15447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-21 11:44:21 +00:00
shyouhei 06e2873ed1 eval_error.c: log10(0) is ERANGE
By definition, the logarithm of 0 is negative infinity.  This is a
pole error (cf: cf: ISO/IEC 9899:1999 section 7.12.1 paragraph 3) and
of course, cannot fit into an `int` value.  We have to resort to
INT_MIN.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15 09:03:03 +00:00
naruse 7594a8df75 fix error message and backtrace order
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-27 23:13:34 +00:00
naruse 48af6fd544 Print exception's cause like Java
Print `cause` of the exception if the exception is not caught and printed
its backtraces and error message [Feature #8257]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-27 21:45:30 +00:00
normal 62c3610583 rb_execution_context_t: pack bits, 256 -> 252 bytes (on 32-bit)
Maybe execution contexts will become more common.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 20:56:10 +00:00
nobu fa8b08b424 Prefer `rb_fstring_lit` over `rb_fstring_cstr`
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 09:59:22 +00:00
nobu aa2b32ae4b eval_error.c: fix loop on exception in message
* error.c (rb_get_message): accessor to the message.

* eval_error.c (rb_ec_error_print): handle exceptions on fetching
  the message.  [Bug #14566]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-11 08:03:43 +00:00
nobu 1032f093cc eval_error.c: reset attributes
* eval_error.c (print_errinfo): reset all attributes for each
  lines before newlines.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 03:48:56 +00:00
nobu b07e4af869 eval_error.c: last newline
* eval_error.c (print_errinfo): do not print an empty line at the
  end when the message ends with a newline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 03:40:10 +00:00
nobu 2851b2c55f eval_error.c: fix underflow
* eval_error.c (print_errinfo): get rid of negative string length.
  [ruby-core:86086] [Bug #14598]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-12 13:04:28 +00:00
nobu daad618740 eval_error.c: rb_error_write flags
* eval_error.c (rb_error_write): add highlight and reverse mode
  flags.  defaulted to rb_stderr_tty_p() if Qnil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23 08:39:03 +00:00
nobu 89f0419575 eval_error.c: reset in each line
* eval_error.c (print_errinfo): reset in each line, so that
  Exception#full_message ends with a newline and puts will not
  print an extra newline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 05:38:37 +00:00
nobu ac4d348d45 eval_error.c: concat directly
* eval_error.c (write_warn, write_warn2): get rid of unnecessary
  intermediate string objects, concat directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 04:57:04 +00:00
nobu 23a0a9b90d eval_error.c: renamed an argument
* eval_error.c (print_errinfo): renamed argument `colored` as
  `highlight`, as it does not use colors.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 04:16:31 +00:00
shyouhei 13af45c0d6 fix uninitialized variable
Likewise this can easily be noticed if you read the warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:42:03 +00:00
ngoto d088cb2727 eval_error.c: Fix compile error on Solaris 10
* eval_error.c (write_warn, write_warn2, write_warn_str): Fix compile
  error "operands have incompatible types" with Oracle Solaris Studio
  12.4 on Solaris 10.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 15:46:56 +00:00
sorah d18fb887ea error.c(rb_error_write): Remove ec_ from its name
It's unrelated to rb_execution_context_t during writing the patch
r61154

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 12:17:38 +00:00
sorah 2ce0847e9e hotfix implicit-function-declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 12:10:21 +00:00
sorah 0d7718896c error.c(exc_full_message): Exception#full_message
Add a method to retrieve a String expression of an exception,
formatted in the same way that Ruby prints an uncaught exception out.

[Feature #14141]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:47:16 +00:00
sorah b5e0ca4730 Log exception with bold and underline for TTYs
Print error message in bold/underlined text if STDERR is unchanged and a tty.
[Feature #14160] [experimental]

Screenshot: https://img.sorah.jp/s/2017-11-29_1711_xj2fu.png

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29 11:14:23 +00:00
ko1 7a666c6766 rb_source_location() may return nil.
* vm.c (rb_source_location): return nil if path is not found.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 05:35:58 +00:00
ko1 48ce4cb414 * eval_intern.h: rename macros rb_thread_raised_* to
rb_ec_raised_*.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:22:09 +00:00
ko1 ee189904f0 rename to rb_ec_set_raised().
* thread.c (rb_threadptr_set_raised): rename to rb_ec_set_raised
  and accepts `ec`


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:12:39 +00:00
ko1 b6ecdf5fc8 th->ec: rb_threadptr_reset_raised()
* thread.c (rb_threadptr_reset_raised): rename to `rb_ec_reset_raised`
  and accepts `ec`.

* vm_trace.c: the following functions accept `ec` instead of `th`
  * exec_hooks_body
  * exec_hooks_precheck
  * exec_hooks_unprotected
  * exec_hooks_protected


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 04:01:13 +00:00
ko1 a93c650312 `rb_ec_error_print()`.
* eval_error.c (rb_threadptr_error_print): renamed to
  rb_ec_error_print() and it accepts `ec`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 14:06:58 +00:00
ko1 4552f74715 introduce EC_*_TAG() instead of TH_*_TAG()
* eval_intern.h:
  introduce EC_*_TAG() macros instead of TH_*_TAG() macros.
  * TH_PUSH_TAG() -> EC_PUSH_TAG()
  * TH_POP_TAG() -> EC_POP_TAG()
  * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG()
  * TH_REPUSH_TAG() -> EC_REPUSH_TAG()
  * TH_EXEC_TAG() -> EC_EXEC_TAG()
  * TH_JUMP_TAG() -> EC_JUMP_TAG()

  rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 11:02:13 +00:00
ko1 837fd5e494 Use rb_execution_context_t instead of rb_thread_t
to represent execution context [Feature #14038]

* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
  There are many code using `th` to represent execution context
  (such as cfp, VM stack and so on). To access `ec`, they need to
  use `th->ec->...` (adding one indirection) so that we need to
  replace them by passing `ec` instead of `th`.

* vm_core.h (GET_EC()): introduced to access current ec. Also
  remove `ruby_current_thread` global variable.

* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
  rb_context_t::thread_value.

* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.

* cont.c (ec_switch): added to switch ec explicitly.

* cont.c (rb_fiber_close): added to terminate fibers explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 08:32:49 +00:00
ko1 8dd9c12c58 move fields to ec.
* vm_core.h (rb_thread.h): move errinfo and trace_arg to
  rb_execution_context_t.

* cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 14:27:49 +00:00
ko1 1939d097e6 move several fields from rb_thread_t to rb_execution_context_t.
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c
  to rb_execution_context_t.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26 07:56:44 +00:00
ko1 2108e55c0b use "enum ruby_tag_type" and TAG_NONE.
Return value of EXEC_TAG() is saved by "int state".
Instead of "int", use "enum ruby_tag_type". First EXEC_TAG()
value should be 0, so that define TAG_NONE (= 0) and use it.

Some code used "status" instead of "state". To make them clear,
rename them to state.

We can change variable name from "state" to "tag_state", but this
ticket doesn't contain it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 07:25:52 +00:00
nobu aea98ff0d5 removed ruby_error_print
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16 01:53:15 +00:00
nobu 6c9027e03f fix syntax error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19 07:34:05 +00:00
nobu 87023a1dcc eval_error.c: enrich backtrace
* eval_error.c (print_backtrace): add frame number when printing
  in reverse order.  [Feature #8661]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19 07:12:45 +00:00
nobu 5318154fe1 eval_error.c: backstrace in reverse order
* eval_error.c (rb_threadptr_error_print): print backtrace and
  error message in reverse order if STDERR is unchanged and a tty.
  [Feature #8661]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22 08:50:25 +00:00
nobu 14a730e91e immediate message mode of compile error
* compile.c (append_compile_error): set Qtrue for erred state with
  showing the message immediately.

* iseq.c (prepare_iseq_build): make immediate message mode if main
  or top level context, not to show the failed path twice in the
  first line.

* iseq.c (cleanup_iseq_build): raise default message exception if
  immediate message mode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-12 07:41:35 +00:00
shugo 472959f9c2 Add clang volatile fixes from FreeBSD and NetBSD.
Use volatile instead of optnone to avoid optimization which causes
segmentation faults.
Patch by Dimitry Andric.  [ruby-core:78531] [Bug #13014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07 23:27:51 +00:00
nobu d432839cbd error.c: rb_get_backtrace
* error.c (rb_get_backtrace): move from eval_error.c to call
  exc_backtrace directly.  [ruby-core:78097] [Bug #12925]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-13 05:25:53 +00:00
nobu 2e71c75278 Thread.report_on_exception
* thread.c (thread_start_func_2): report raised exception if
  report_on_exception flag is set.  [Feature #6647]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-06 00:25:38 +00:00
nobu b9e392fbed vm_core.h: rb_exc_set_backtrace declaration
* vm_core.h (rb_exc_set_backtrace): move declaration from
  eval_error.c and vm_args.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-29 10:18:20 +00:00
ngoto 2b97ab88e0 Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
  macros for skipping __extension__ on non-GCC compilers.
* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
  __extension__ because __extension__ is a GNU extension.
  Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
  [Bug #12397] [ruby-dev:49629].
* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
  rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
  rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
  rb_external_str_new_cstr, rb_locale_str_new_cstr,
  rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20 12:29:06 +00:00
naruse ac11f944e1 Use HAVE_BUILTIN___BUILTIN_CONSTANT_P
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-12 18:12:46 +00:00
nobu 53d5f865e6 eval_error.c: reuse threadptr
* eval_error.c (error_print, error_handle): reuse same threadptr
  by passing as an argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-23 03:23:28 +00:00
nobu 62f20b9d58 eval_error.c: trivial optimization
* eval_error.c (warn_print): optimize warn_print with a string
  literal, with rb_write_error2 instead of rb_write_error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-06 08:34:50 +00:00
nobu 5fa5b50e58 eval_error.c: constify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-25 12:36:25 +00:00
nobu 37d6a4dd99 eval_error.c: remove warn_printf
* eval_error.c (warn_printf): remove.

* eval_error.c (error_pos_str): return error position string,
  split from error_pos.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-25 12:36:24 +00:00
nobu aa40518b44 eval_error.c: error position format
* eval_error.c (error_print): use same error position format when
  no backtrace too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-25 07:22:01 +00:00