summaryrefslogtreecommitdiff
path: root/addr2line.c
Commit message (Collapse)AuthorAgeFilesLines
* addr2line.c: Silence GCC 11 false -Wmaybe-uninitialized warningAlan Wu2023-01-161-1/+1
| | | | No warnings from GCC 12.
* addr2line.c: Don't special-case DWARF 5 parsing with GCCAlan Wu2023-01-161-5/+1
| | | | | | | | | | | | | | | | | While trying to fix YJIT's symbol hygiene issue over at GH-7115, I found that addr2line.c's DWARF 5 parsing is half-disabled when building with GCC. Rust's output contains some DW_AT_rnglists_base records, which the disabled code reads. Without DW_AT_rnglists_base, it crashes when generating a backtrace. In common Ruby build configurations, GCC opts to only use DW_FORM_sec_offset for the range lists, and so it doesn't generate DW_AT_rnglists_base records, so consuming GCC's DWARF 5 while building with GCC was not a problem. However, even when building with GCC, we might need to parse DWARF 5 generated by other compilers at runtime. They could come from C extensions built by Clang, or come from Rust extensions. This can happen even when building without YJIT.
* Fix backtrace beyond _singtramp on macOS arm64 (#7015)NARUSE, Yui2022-12-241-9/+0
| | | | * move ptrauth_strip logic into vm_dump.c * don't use _sigtramp special logic on arm64
* addr2line.c: Strip pointer authenticationYusuke Endoh2022-12-231-0/+10
| | | | | | | | We need to manually strip pointer authentication bits on M1 mac because libunwind leaks them out. Co-Authored-By: NARUSE, Yui <naruse@airemix.jp> Co-Authored-By: Yuta Saito <kateinoigakukun@gmail.com>
* addr2line.c: Support DW_FORM_rnglistxYusuke Endoh2022-12-231-6/+19
|
* addr2line.c: Implement DW_AT_*_baseYusuke Endoh2022-12-231-1/+113
| | | | | ... and add code to parse the sections of .debug_addr_base and .debug_rnglists_base.
* addr2line.c: Support DW_FORM_strx* formsYusuke Endoh2022-12-231-5/+19
|
* addr2line.c: Support DW_FORM_addrx* formsYusuke Endoh2022-12-231-11/+26
| | | | ... and add VAL_addr value type
* addr2line.c: Keep .debug_str_offsets and .debug_addr sections as wellYusuke Endoh2022-12-231-1/+9
| | | | clang generates DWARF with the sections
* addr2line.c: Fix another indexing bugYusuke Endoh2022-12-221-1/+1
|
* addr2line.c: Fix indexing bugYusuke Endoh2022-12-221-1/+1
|
* addr2info.c: Make it work with --enable-yjitYusuke Endoh2022-12-221-1/+3
| | | | | | | | | | | Background: GCC 12 generates DWARF 5 with .debug_rnglists, while rustc generates DWARF 4 with .debug_ranges. The previous logic always used .debug_rnglists if there is the section. However, we need to refer .debug_ranges for DWARF 4. This change keeps DWARF version of the current compilation unit and use a proper section depending on the version.
* addr2line.c: Support "Line Number Program Header" in DWARF 5Yusuke Endoh2022-12-221-40/+119
|
* addr2line.c: Keep .debug_line_str section as wellYusuke Endoh2022-12-221-6/+9
| | | | | | ... and properly support DW_FORM_line_strp. This is a prepartion to support DWARF 5.
* Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)Sergey Fedorov2022-10-191-1/+4
|
* Fix warnings by old gccNobuyoshi Nakada2022-06-231-5/+5
| | | | | | * Use PRIxSIZE instead of "z" * Fix sign-compare warning * Suppress unused-but-set-variable warning
* Skip `NULL` values from `dladdr(3)`xtkoba2022-06-091-5/+7
| | | Fixes [Bug #17810]
* Print function name in backtrace when availablePeter Zhu2022-05-131-1/+4
| | | | If we don't have `saddr` but have `sname` we should output `sname`.
* Cast to void pointer for `%p` in commented out code [ci skip]Nobuyoshi Nakada2021-10-201-1/+1
|
* Use the correct address sizextkoba2021-09-231-3/+3
|
* Interpret `DW_RLE_start_length`xtkoba2021-09-231-12/+15
| | | Fixes [Bug #17823]
* Fix return value when `base != 0`xtkoba2021-09-231-1/+1
|
* addr2line: DragonFlyBSD build update.David CARLIER2021-08-311-2/+2
| | | | same code path as FreeBSD's.
* Ignore `DW_FORM_ref_addr` [Bug #17052]xtkoba+ruby@gmail.com2021-08-141-3/+20
| | | | | Ignore `DW_FORM_ref_addr` form and other forms that are not supposed to be used currently.
* Constified addr2line.cNobuyoshi Nakada2021-08-141-68/+68
|
* Avoid `free(3)`ing invalid pointerxtkoba2021-06-281-0/+2
| | | Fixes [Bug #17794]
* solaris/illumos build fix.David Carlier2021-03-221-1/+1
|
* Support GCC's DWARF 5 [Bug #17585] (#4240)Yusuke Endoh2021-03-151-22/+97
| | | Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
* addr2line.c: DW_LNS_fixed_advance_pc takes a single uhalf operandYusuke Endoh2021-02-041-1/+2
| | | | | | Fixes [Bug #17609] Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
* NetBSD build update. (#4079)David CARLIER2021-02-021-2/+6
|
* addr2line.c: support debuglink by build_idYusuke Endoh2020-12-111-3/+59
| | | | | | | | | | | | | 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". https://github.com/Debian/debhelper/blob/5d1bb29841043d8e47ebbdd043e6cd086cad508e/dh_strip#L292 https://github.com/Debian/debhelper/blob/5d1bb29841043d8e47ebbdd043e6cd086cad508e/dh_strip#L353 This changeset makes ruby backtrace support the second format.
* Show C backtrace appropriately at core dump for GCC 8 or laterYusuke Endoh2020-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-2/+2
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-2/+2
| | | | This shall fix compile errors.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-2/+2
| | | Split ruby.h
* internal/stdbool.h rework卜部昌平2019-12-261-5/+1
| | | | | | 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.
* retrieve current path on macOSDavid Carlier2019-08-201-0/+13
|
* addr2line.c: clarify the type of integer expressionYusuke Endoh2019-07-151-1/+1
| | | | | | 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.
* addr2line.c (binary_filename): extend the buffer for NUL terminatorYusuke Endoh2019-07-141-1/+1
|
* addr2line.c (main_exe_path): avoid SEGV when /proc is not availableYusuke Endoh2019-07-141-0/+1
| | | | | readlink would return -1 if /proc is not mounted. Coverity Scan found this issue.
* Fix a typoKazuhiro NISHIYAMA2019-07-071-1/+1
|
* Suppress warnings by gcc 9.1Nobuyoshi Nakada2019-06-081-3/+3
|
* Use _NSGetMachExecuteHeader() instead of _mh_execute_headernaruse2019-01-311-4/+5
| | | | | | | | | | | _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
* addr2line.c: fix -Wextra-semik0kubun2019-01-101-1/+2
| | | | | | | 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
* addr2line.c: do not suppress -Wpedantick0kubun2019-01-101-3/+0
| | | | | | | 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
* revert r66768 for Ruby 2.7 due to Misc#15347k0kubun2019-01-101-6/+3
| | | | | | | 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
* Get rid of C99 feature for now [ruby-core:90949] [Bug #15519]nobu2019-01-101-3/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Show function name based on dladdrnaruse2018-11-201-0/+2
| | | | | | | 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
* Support Universal Binary for macOSnaruse2018-11-201-5/+39
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* addr2line.c: more on suppressing warningsshyouhei2018-11-131-0/+1
| | | | | | | 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