summaryrefslogtreecommitdiff
path: root/addr2line.c
AgeCommit message (Collapse)Author
2021-02-04addr2line.c: DW_LNS_fixed_advance_pc takes a single uhalf operandYusuke Endoh
Fixes [Bug #17609] Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
2021-02-02NetBSD build update. (#4079)David CARLIER
Notes: Merged-By: nurse <naruse@airemix.jp>
2020-12-11addr2line.c: support debuglink by build_idYusuke Endoh
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. Notes: Merged: https://github.com/ruby/ruby/pull/3627
2020-12-11Show C backtrace appropriately at core dump for GCC 8 or laterYusuke Endoh
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. Notes: Merged: https://github.com/ruby/ruby/pull/3881
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2019-12-26internal/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. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-08-20retrieve current path on macOSDavid Carlier
Notes: Merged: https://github.com/ruby/ruby/pull/2390
2019-07-15addr2line.c: clarify the type of integer expressionYusuke Endoh
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-14addr2line.c (binary_filename): extend the buffer for NUL terminatorYusuke Endoh
2019-07-14addr2line.c (main_exe_path): avoid SEGV when /proc is not availableYusuke Endoh
readlink would return -1 if /proc is not mounted. Coverity Scan found this issue.
2019-07-07Fix a typoKazuhiro NISHIYAMA
2019-06-08Suppress warnings by gcc 9.1Nobuyoshi Nakada
2019-01-31Use _NSGetMachExecuteHeader() instead of _mh_execute_headernaruse
_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-10addr2line.c: fix -Wextra-semik0kubun
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-10addr2line.c: do not suppress -Wpedantick0kubun
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-10revert r66768 for Ruby 2.7 due to Misc#15347k0kubun
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-10Get rid of C99 feature for now [ruby-core:90949] [Bug #15519]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20Show function name based on dladdrnaruse
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-20Support Universal Binary for macOSnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13addr2line.c: more on suppressing warningsshyouhei
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-09addr2line.c: fix compilation for i386-darwinnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04addr2line.c uses c99ismnaruse
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-04Use symtab if there's no .dSYM filenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-31Use C90 commentsnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23addr2line.c: add explicit casts for clang on 32bit environmentmame
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-21check VLIW casenaruse
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-21initialize is_stmt with default_is_stmtnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21Use inline function with stable code instead of macronaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21fix sign of integer variablenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21check version of .debug_infonaruse
and refactor related code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21Skip dwarf if its version is not supportednaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20fix header_length's type to unsigned longnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20fix r65202 on ELF environmentnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20Support Mach-O on backtrace with DWARFnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20Support DWARF4's .debug_linenaruse
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-19addr2line.c: minimal workaround to prevent parse errorshyouhei
"//*" 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-19addr2line.c: this file has no portabilityshyouhei
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-17Check the end of Compilation Unit by unit length instead of level of treenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16Support base address selection entrynaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16Correct the handling of .debug_rangesnaruse
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-16The value of .debug_ranges are uintptr_tnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16If high_pc uses DW_FORM_addr, it's not size but addressnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16check dwarf version and skip non Dwarf v4naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14Moved hexdump macro before usednobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14Make local functions staticnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14Read debug_info to show inline functions in backtracenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13addr2line.c: fix *printf type warnings on 32-bitnormal
Yup, back to using an ancient 32-bit system... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e