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

142 Коммитов

Автор SHA1 Сообщение Дата
David CARLIER 3ffca65047 addr2line: DragonFlyBSD build update.
same code path as FreeBSD's.
2021-08-31 20:52:49 +09:00
xtkoba+ruby@gmail.com 72317b333b
Ignore `DW_FORM_ref_addr` [Bug #17052]
Ignore `DW_FORM_ref_addr` form and other forms that are not supposed
to be used currently.
2021-08-14 23:57:52 +09:00
Nobuyoshi Nakada a9977ba2f9 Constified addr2line.c 2021-08-14 11:34:31 +09:00
xtkoba d795f494a8 Avoid `free(3)`ing invalid pointer
Fixes [Bug #17794]
2021-06-28 14:06:28 -07:00
David Carlier 5e16c3a12a solaris/illumos build fix. 2021-03-22 22:51:15 +09:00
Yusuke Endoh 9e5105ca45
Support GCC's DWARF 5 [Bug #17585] (#4240)
Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
2021-03-15 15:22:34 +09:00
Yusuke Endoh 7d22060c14 addr2line.c: DW_LNS_fixed_advance_pc takes a single uhalf operand
Fixes [Bug #17609]

Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
2021-02-04 17:45:54 +09:00
David CARLIER 739f9297c5
NetBSD build update. (#4079) 2021-02-02 22:05:19 +09:00
Yusuke Endoh c718c30007 addr2line.c: support debuglink by build_id
Currently, addr2line.c supports only one path format of debuglink:
"/usr/lib/debug/usr/bin/ruby.debug".

However, recent debian packages seem to use another format by build_id:
"/usr/lib/debug/.build-id/ab/cdef1234.debug".

5d1bb29841/dh_strip (L292)
5d1bb29841/dh_strip (L353)

This changeset makes ruby backtrace support the second format.
2020-12-11 14:08:33 +09:00
Yusuke Endoh f3c19ddfbc Show C backtrace appropriately at core dump for GCC 8 or later
When ruby is compiled by GCC 8 or later, some frames of C level
backtrace information lacks.

```
$ ./miniruby -e '1.times { Process.kill(:SEGV, $$) }'

...

-- C level backtrace information
-------------------------------------------
/home/mame/work/ruby-gcc-9/miniruby(rb_vm_bugreport+0x611) [0x558a5fdcbc21] ../ruby/vm_dump.c:758
[0x558a5fbc789a]
/home/mame/work/ruby-gcc-9/miniruby(sigsegv+0x4d) [0x558a5fd1eaed] ../ruby/signal.c:959
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f687e6713c0]
/lib/x86_64-linux-gnu/libc.so.6(kill+0xb) [0x7f687e31355b] ../sysdeps/unix/syscall-template.S:78
/home/mame/work/ruby-gcc-9/miniruby(rb_f_kill+0x350) [0x558a5fd1fe60] ../ruby/signal.c:480
[0x558a5fda50d3]
[0x558a5fdb085c]
[0x558a5fdb0fe7]
[0x558a5fdbae1a]
[0x558a5fdaf484]
/home/mame/work/ruby-gcc-9/miniruby(rb_yield_1+0x29f) [0x558a5fdb2fbf] ../ruby/vm.c:1265
/home/mame/work/ruby-gcc-9/miniruby(int_dotimes+0x5c) [0x558a5fc72f2c] ../ruby/numeric.c:5198
[0x558a5fda50d3]
[0x558a5fdb085c]
[0x558a5fdb0fe7]
[0x558a5fdbaf21]
[0x558a5fdaf484]
/home/mame/work/ruby-gcc-9/miniruby(rb_ec_exec_node+0xed) [0x558a5fbcc4fd] ../ruby/eval.c:317
/home/mame/work/ruby-gcc-9/miniruby(ruby_run_node+0x4f) [0x558a5fbd110f] ../ruby/eval.c:375
/home/mame/work/ruby-gcc-9/miniruby(main+0x73) [0x558a5fb2c083] ../ruby/main.c:50
```

By this one-line change, it shows all locations.

```
$ ./miniruby -e '1.times { Process.kill(:SEGV, $$) }'

...

-- C level backtrace information -------------------------------------------
/home/mame/work/ruby-gcc-9/miniruby(rb_print_backtrace+0x11) [0x558247adec21] ../ruby/vm_dump.c:758
/home/mame/work/ruby-gcc-9/miniruby(rb_vm_bugreport) ../ruby/vm_dump.c:956
/home/mame/work/ruby-gcc-9/miniruby(rb_bug_for_fatal_signal+0x15a) [0x5582478da89a] ../ruby/error.c:773
/home/mame/work/ruby-gcc-9/miniruby(sigsegv+0x4d) [0x558247a31aed] ../ruby/signal.c:959
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f82202f73c0]
/lib/x86_64-linux-gnu/libc.so.6(kill+0xb) [0x7f821ff9955b] ../sysdeps/unix/syscall-template.S:78
/home/mame/work/ruby-gcc-9/miniruby(rb_f_kill+0x350) [0x558247a32e60] ../ruby/signal.c:480
/home/mame/work/ruby-gcc-9/miniruby(vm_call_cfunc_with_frame+0x123) [0x558247ab80d3] ../ruby/vm_insnhelper.c:2821
/home/mame/work/ruby-gcc-9/miniruby(vm_call_method_each_type+0x7c) [0x558247ac385c] ../ruby/vm_insnhelper.c:3324
/home/mame/work/ruby-gcc-9/miniruby(vm_call_method+0xc7) [0x558247ac3fe7] ../ruby/vm_insnhelper.c:3428
/home/mame/work/ruby-gcc-9/miniruby(vm_sendish+0x14) [0x558247acde1a] ../ruby/vm_insnhelper.c:4412
/home/mame/work/ruby-gcc-9/miniruby(vm_exec_core) ../ruby/insns.def:789
/home/mame/work/ruby-gcc-9/miniruby(rb_vm_exec+0x1a4) [0x558247ac2484] ../ruby/vm.c:2165
/home/mame/work/ruby-gcc-9/miniruby(rb_yield_1+0x29f) [0x558247ac5fbf] ../ruby/vm.c:1265
/home/mame/work/ruby-gcc-9/miniruby(int_dotimes+0x5c) [0x558247985f2c] ../ruby/numeric.c:5198
/home/mame/work/ruby-gcc-9/miniruby(vm_call_cfunc_with_frame+0x123) [0x558247ab80d3] ../ruby/vm_insnhelper.c:2821
/home/mame/work/ruby-gcc-9/miniruby(vm_call_method_each_type+0x7c) [0x558247ac385c] ../ruby/vm_insnhelper.c:3324
/home/mame/work/ruby-gcc-9/miniruby(vm_call_method+0xc7) [0x558247ac3fe7] ../ruby/vm_insnhelper.c:3428
/home/mame/work/ruby-gcc-9/miniruby(vm_sendish+0x14) [0x558247acdf21] ../ruby/vm_insnhelper.c:4412
/home/mame/work/ruby-gcc-9/miniruby(vm_exec_core) ../ruby/insns.def:770
/home/mame/work/ruby-gcc-9/miniruby(rb_vm_exec+0x1a4) [0x558247ac2484] ../ruby/vm.c:2165
/home/mame/work/ruby-gcc-9/miniruby(rb_ec_exec_node+0xed) [0x5582478df4fd] ../ruby/eval.c:317
/home/mame/work/ruby-gcc-9/miniruby(ruby_run_node+0x4f) [0x5582478e410f] ../ruby/eval.c:375
/home/mame/work/ruby-gcc-9/miniruby(main+0x73) [0x55824783f083] ../ruby/main.c:50
```

Details:

In short, it is an uninitialized variable bug.

Until GCC 7, all function locations are represented by a pair of
DW_AT_low_pc and DW_AT_high_pc in DWARF information.
But since GCC 8, some functions are split to multiple chunks, which are
represented by DW_AT_ranges.
DW_AT_ranges are represented as offsets from a base address.
According to DWARF specification, it is the base address of the
compilation unit, but GCC seems to use zero as default.
The function "di_read_cu" in addr2line.c had a comment about the fact.
However, the base address wasn't initialized as zero.
2020-12-11 01:32:20 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
卜部昌平 8184adabe5 internal/stdbool.h rework
Noticed that internal/stdbool.h and addr2line.c are the only two place
where missing/stdbool.h is included.  Why not delete the file so that
we can merge internal/stdbool.h and missing/stdbool.h into one.
2019-12-26 20:45:12 +09:00
David Carlier e6b72e8cae retrieve current path on macOS 2019-08-20 02:05:10 +09:00
Yusuke Endoh a197579073 addr2line.c: clarify the type of integer expression
to suppress Coverity Scan warning.
This expression converted uint8_t to int, and then int to unsigned long.
Now it directly converts uint8_t to unsigned long.
2019-07-15 08:38:37 +09:00
Yusuke Endoh 41e09ca4be addr2line.c (binary_filename): extend the buffer for NUL terminator 2019-07-14 20:23:29 +09:00
Yusuke Endoh db1c30b37f addr2line.c (main_exe_path): avoid SEGV when /proc is not available
readlink would return -1 if /proc is not mounted.
Coverity Scan found this issue.
2019-07-14 17:54:48 +09:00
Kazuhiro NISHIYAMA c1ebb384fd
Fix a typo 2019-07-07 20:16:31 +09:00
Nobuyoshi Nakada 1ca03dc4f7
Suppress warnings by gcc 9.1 2019-06-08 19:46:32 +09:00
naruse 1f64192494 Use _NSGetMachExecuteHeader() instead of _mh_execute_header
_mh_execute_header is not accessible from a dylib unless libruby.dylib is
built with -undefined dynamic_lookup. And using -undefined
dynamic_lookup is not good style.

Reported by Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-31 12:58:33 +00:00
k0kubun dd67af4892 addr2line.c: fix -Wextra-semi
and ignore only -Wgnu-empty-initializer.
https://travis-ci.org/ruby/ruby/jobs/477867392

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 15:42:44 +00:00
k0kubun d74fc1b175 addr2line.c: do not suppress -Wpedantic
because it was for "-assi -Wpedantic" on Travis, but we changed the
Travis build to "-std=c99 -Wpedantic".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 15:02:35 +00:00
k0kubun 299e9cd91a revert r66768 for Ruby 2.7 due to Misc#15347
It's safer to backport r66768 to 2.6 branch, but for 2.7 it's not
needed anymore.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 15:00:40 +00:00
nobu 671ef4e9e3 Get rid of C99 feature for now [ruby-core:90949] [Bug #15519]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 00:36:28 +00:00
naruse b755c26146 Show function name based on dladdr
If there's no dwarf and symbol table, this will be a last resort.
(mainly on macOS)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 22:40:21 +00:00
naruse 529adb6872 Support Universal Binary for macOS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 22:40:20 +00:00
shyouhei 9d9e1a4d65 addr2line.c: more on suppressing warnings
See also: https://travis-ci.org/ruby/ruby/jobs/454269559#L1898


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13 02:19:49 +00:00
nobu 9d2f88fc13 addr2line.c: fix compilation for i386-darwin
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09 11:19:23 +00:00
naruse fc1f476b61 addr2line.c uses c99ism
https://travis-ci.org/ruby/ruby/jobs/450505006

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04 22:36:05 +00:00
naruse e6d63ac606 Use symtab if there's no .dSYM file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04 15:14:42 +00:00
naruse 5bc93ec743 Use C90 comments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-31 11:08:07 +00:00
mame ab20aee573 addr2line.c: add explicit casts for clang on 32bit environment
Assigning uint64_t to size_t or uintptr_t caused a build error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23 12:38:48 +00:00
naruse 879b42b043 check VLIW case
If maximum_operations_per_instruction != 1, it is VLIW.
But there seems no need to support such architecture now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 20:01:22 +00:00
naruse 448a014d42 initialize is_stmt with default_is_stmt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 16:42:23 +00:00
naruse 6018bc5e73 Use inline function with stable code instead of macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 16:37:24 +00:00
naruse e01c9c743f fix sign of integer variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 10:46:56 +00:00
naruse ec91ea5c16 check version of .debug_info
and refactor related code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 00:08:02 +00:00
naruse 69e328b532 Skip dwarf if its version is not supported
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 00:07:53 +00:00
naruse 5b1bbc9af0 fix header_length's type to unsigned long
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 06:56:51 +00:00
naruse d79f72521e fix r65202 on ELF environment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 06:45:51 +00:00
naruse 595056135f Support Mach-O on backtrace with DWARF
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 06:35:25 +00:00
naruse fe735bd30f Support DWARF4's .debug_line
ICC uses DWARF4 for .debug_line which adds
maximum_operations_per_instruction in its header.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 06:18:41 +00:00
shyouhei ad564b87ad addr2line.c: minimal workaround to prevent parse error
"//*" is super dangerous for non-C++ compiler.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 02:01:46 +00:00
shyouhei c102e5e0ea addr2line.c: this file has no portability
It seems nobody on earth is interested in such thing for it.
Ignore compiler warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 00:35:42 +00:00
naruse 2a59b579fe Check the end of Compilation Unit by unit length instead of level of tree
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-17 01:29:49 +00:00
naruse 0f92eba17f Support base address selection entry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16 23:57:47 +00:00
naruse e9a284ab94 Correct the handling of .debug_ranges
Though DWARF specifies "the applicable base address defaults to the base
address of the compilation unit", but GCC seems to use zero as default.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16 23:52:28 +00:00
naruse 447d7a394f The value of .debug_ranges are uintptr_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16 23:52:28 +00:00
naruse f60c2d396d If high_pc uses DW_FORM_addr, it's not size but address
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16 23:52:26 +00:00