summaryrefslogtreecommitdiffhomepage
path: root/src/backtrace.c
AgeCommit message (Collapse)Author
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-25Silence 'loss of data' warnings.Yukihiro "Matz" Matsumoto
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-21Merge branch 'avoid-including-presym.inc-in-existing-header-files' of ↵Yukihiro "Matz" Matsumoto
https://github.com/shuujii/mruby into shuujii-avoid-including-presym.inc-in-existing-header-files
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2021-01-10Unified `pc` and `err` of `mrb_callinfo`dearblue
This enhances self-containment. - Changed the `mrb_callinfo::pc` field to point to itself. Previously it indicated the return destination of the previous call level. `mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`. - Removed `mrb_callinfo::err` field. This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`. - The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted. - It removes the argument because `cipush()` doesn't need to save the previous `pc`.
2020-11-21Rename `MRB_{ENABLE,DISABLE}_` to `MRB_{USE,NO}_`; close #5163KOBAYASHI Shuji
| Previous Name | New Name | |------------------------------|-------------------------| | MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI | | MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION | | MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK | | MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING | | MRB_DISABLE_STDIO | MRB_NO_STDIO | | ENABLE_LINENOISE | MRB_USE_LINENOISE | | ENABLE_READLINE | MRB_USE_READLINE | | DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE | | DISABLE_GEMS | MRB_NO_GEMS | * `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed. * `MRB_` prefix is added to those without. * The previous names can also be used for compatibility.
2020-10-12Constify `irep` members.Yukihiro "Matz" Matsumoto
- `pool` - `syms` - `reps`
2020-10-12Add `MRB_SYM()` for inline symbols.Yukihiro "Matz" Matsumoto
2020-01-31Avoid implicit integer casting in `backtrace.c` and `hash.c`.Yukihiro "Matz" Matsumoto
2019-12-18Simplify `print_backtrace()`KOBAYASHI Shuji
2019-12-17Refine output of `mrb_print_error()`KOBAYASHI Shuji
The following improvements are made according to Ruby's behavior: - Match location number to index. - Remove duplicate most recent call output. - Fix that first call is not output when array (unpacked) backtrace. ### Example ```ruby def a; raise "error!" end def b; a end begin b rescue => e e.backtrace if ARGV[0] == "unpack" # unpack backtrace raise e end ``` #### Before this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [0] example.rb:2:in b [1] example.rb:1:in a example.rb:1: error! (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [2] example.rb:4 [1] example.rb:2:in b example.rb:1:in a: error! (RuntimeError) ```
2019-12-16Remove unneeded null checks to `struct backtrace_location::filename`KOBAYASHI Shuji
`struct backtrace_location` is created only in `each_backtrace()`, and the `filename` field will never be null (it will be `(unknown)` if null).
2019-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-08-18Prohibit changes to iseq in principledearblue
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-07-15Unify type of line number to `uint16_t`KOBAYASHI Shuji
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-03-27Remove unused variable in `each_backtrace()`KOBAYASHI Shuji
2019-02-25Refactor `src/backtrace.c`KOBAYASHI Shuji
- Move calling `mrb_debug_get_filename()` to after `lineno` check. - Remove unneeded array check in `print_backtrace()`. - Add a few `const` qualifier.
2019-02-18Merge pull request #4283 from ↵Yukihiro "Matz" Matsumoto
shuujii/reorder-members-in-struct-backtrace_location Reorder members in `struct backtrace_location`
2019-02-18Reorder members in `struct backtrace_location`KOBAYASHI Shuji
`sizeof(struct backtrace_location)` is 24 bytes -> 16 bytes in LP64 data model etc.
2019-02-18Remove unneeded `memset()` in `src/backtrace.c`KOBAYASHI Shuji
2018-04-23Fix undefined error of pointer dereference.Takeshi Watanabe
2017-11-29Add `most recent call last` message to the backtrace.Yukihiro "Matz" Matsumoto
2017-11-04Avoid pointer arithmetic in backtrace.c; #3816Yukihiro "Matz" Matsumoto
2017-11-02don't overwrite backtrace info.Tomoyuki Sahara
2017-09-27fix: src\backtrace.c(83): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-08-12Reduce integer type mismatch warnings in VC.Yukihiro "Matz" Matsumoto
2017-08-11Remove an unused argument from `each_backtrace_func`.Yukihiro "Matz" Matsumoto
2017-08-11Avoid possible data loss by using `ptrdiff_t`.Yukihiro "Matz" Matsumoto
2017-08-08Check if `ptr` is NULL before calling `memset`; fix #3765Yukihiro "Matz" Matsumoto
2017-07-06Reduce allocation size of backtrace arrays.Yukihiro "Matz" Matsumoto
2017-07-06Avoid out-of-bounds access of the backtrace array.Yukihiro "Matz" Matsumoto
2017-06-02Make `break` in lambdas work as `return` according to CRuby behavior.Yukihiro "Matz" Matsumoto
2017-06-01Print most recent call last as CPython does.Yukihiro "Matz" Matsumoto
2017-05-31Restore MRB_API function `mrb_exc_backtrace(mrb, exc)`; ref 9644ad5Yukihiro "Matz" Matsumoto
2017-05-26Use RData instead of String to represent backtrace.Yukihiro "Matz" Matsumoto
2017-05-25Check backtrace info may not be set (esp. NoMemError); fix #3663Yukihiro "Matz" Matsumoto
2017-05-23Simplify backtrace mechanism; fix #3633 #3634 #3644Yukihiro "Matz" Matsumoto
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set` keeps packed backtrace in an exception object. `#backtrace` unpacks it to an array of strings.
2017-05-23Remove class info from backtrace lines.Yukihiro "Matz" Matsumoto
2017-05-23Type check before `print_backtrace()`Yukihiro "Matz" Matsumoto
2017-05-15Avoid call to_s during backtrace traversalCraig Lehmann
2017-04-25Avoid use of `snprintf()` when DISABLE_STDIO is set; fix #3632Yukihiro "Matz" Matsumoto
ref #3492 #3515 #3517
2017-04-03Unify `else` clause styleYukihiro "Matz" Matsumoto
2017-03-25Fix lost linenoksss
2017-03-20Use `snprintf()` to stringify fixnum numbers; fix #3492Yukihiro "Matz" Matsumoto
2017-03-04Save/restore arena index in the loop.Yukihiro "Matz" Matsumoto
2017-02-15Preallocate SystemStackError; ref #3421Yukihiro "Matz" Matsumoto
2017-02-08Check if irep is NULL before print_backtrace()Yukihiro "Matz" Matsumoto
According to the valgrind log attached to #3438, proc->body.irep may be NULL in some cases.