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

175 Коммитов

Автор SHA1 Сообщение Дата
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
naruse 417fc484c3 check dwarf version and skip non Dwarf v4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-16 07:12:26 +00:00
nobu f572aeb71f Moved hexdump macro before used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14 23:45:33 +00:00
nobu bb9eea9065 Make local functions static
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14 23:40:27 +00:00
naruse 8bf4d89917 Read debug_info to show inline functions in backtrace
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-14 16:59:15 +00:00
svn 19f9d30249 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 05:36:51 +00:00
normal d3e1afacaa addr2line.c: fix *printf type warnings on 32-bit
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
2018-10-13 05:36:50 +00:00
svn eca36f9cd8 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:58:21 +00:00
naruse 0b81f7bfe7 Revert wrongly commit debug_info feature
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:58:20 +00:00
naruse d3853d7c10 Support FreeBSD
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:47 +00:00
naruse 628e85c7b3 Support compressed debug_info
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:47 +00:00
naruse 136d24ea1b free line info leaves
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:46 +00:00
naruse 336f86f2ee close dlopen-ed handle
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:45 +00:00
naruse 69f06e9e84 fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:45 +00:00
naruse 692a5f2164 Support additional forms
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:44 +00:00
naruse 37ea0f19a7 Show backtrace with .debug_info
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:44 +00:00
naruse 139f0bb44f Read .debug_info
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 23:55:43 +00:00
k0kubun af0e536d03 addr2line.c: fix -Wmaybe-uninitialized
../addr2line.c: In function ‘fill_lines’:
../addr2line.c:709:8: warning: ‘file’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (file != NULL) {
        ^
../addr2line.c:535:11: warning: ‘filesize’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     off_t filesize;
           ^~~~~~~~

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-16 13:22:00 +00:00
nobu 893949167b Fix issues detected by code analysis tool (mainly Coverity).
* Fix leaked storage in addr2line.c.
* Fix for "top_root" leaking the resource.

[Fix GH-1956]

From: Jun Aruga <jaruga@redhat.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-15 09:59:14 +00:00
naruse 4d2e0fffb0 FreeBSD 11.0 lacks ELFCOMPRESS_ZLIB
FreeBSD 11.0 unfortunately lacks ELF compression definitions in their
elf.h (sys/elf_common.h), and 11.1 introduced them.
b9167d33a1

Though we can add workaround, we simply drop support because
FreeBSD 11.0 is already EOL at November 30, 2017.
https://www.freebsd.org/security/unsupported.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 19:12:23 +00:00
naruse 0ca505347c Don't free allocated uncompressed_debug_line until backtrace is printed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 08:48:30 +00:00
naruse cc1c605912 Define parse_compressed_debug_line() only ifdef SUPPORT_COMPRESSED_DEBUG_LINE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 06:31:37 +00:00
naruse bcf8f79d6d support compressed debug_line
re-commit r64328
https://blogs.oracle.com/solaris/elf_section_compression-v2
https://gnu.wildebeest.org/blog/mjw/2016/01/13/elf-libelf-compressed-sections-and-elfutils/

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 06:20:12 +00:00
naruse 843589a726 Revert "support compressed debug_line"
This reverts commit r64328

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 06:05:39 +00:00
naruse a20a2b0044 support compressed debug_line
https://blogs.oracle.com/solaris/elf_section_compression-v2
https://gnu.wildebeest.org/blog/mjw/2016/01/13/elf-libelf-compressed-sections-and-elfutils/

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13 02:56:06 +00:00
kazu ae83c35b90 Add PRINTF_ARGS to kprintf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-31 15:20:54 +00:00
normal 63efc86bf7 addr2line.c (kprintf): static
This function is not used outside of addr2line.c

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09 03:07:59 +00:00
normal 0528838b37 addr2line.c: no need to keep fd around after mmap
POSIX mmap(3) manpage stipulates mmap bumps the reference
count of the file description.  Thus keeping a file descriptor
to maintain the reference is not necessary.

If this didn't work, every extension .so would require a
permanent FD, which is obviously not the case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-08 23:43:14 +00:00
ngoto b75828fdfa Support C89 if possible
* addr2line.c: Because stdbool.h is a C99 feature, compile error
  occurs with some old compilers without specifying C99 options.
  Fix compile error with Oracle Solaris Studio 12.4 on Solaris 10.
  [Bug #14200] [ruby-dev:50366]

* missing/stdbool.h: Alternative of stdbool.h for C89 compilers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 16:17:17 +00:00
normal 5a9907dcad addr2line.c: fix r60841 for glibc before 2.22
SHF_COMPRESSED was not defined until glibc 2.22, and there are
older distros (e.g. Debian 8.x jessie) which do not have this
defined.

Perhaps it is safe to define SHF_COMPRESSED to (1 << 11) ourselves,
too, since ELF should be a standardized format.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18 21:57:38 +00:00
naruse 8752634a97 explictly skip compressed debug line
To identify the line of backtrace with ease, show the offset address of library.
You can just find the source filename and the line with
`addr2line -e libruby.so.2.5.0 0xXXXX`

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18 18:05:39 +00:00
ko1 0de6da0ee5 make a func static.
* addr2line.c (main_exe_path): make it static.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 08:01:26 +00:00
nobu 79c50a77ff get rid of strcpy
* addr2line.c (follow_debuglink): insert global_debug_dir by using
  memmove instead of copying to temporary buffer.

* dln.c (dln_load): use memcpy with the known length instead of
  strcpy.

* gc.c (rb_gc_unprotect_logging): use strdup instead of malloc and
  strcpy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-26 09:28:46 +00:00
nobu 685a436a49 addr2line.c: boundary checks
* addr2line.c (parse_debug_line_cu): boundary checks for
  compressed debug sections.  [ruby-dev:49840] [Bug #12850]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-18 15:09:08 +00:00
hsbt 2bd2001d16 * addr2line.c: drop to support ATARI ST platform. It was discontinued
more than two decades ago. [fix GH-1350] Patch by @cremno
* include/ruby/ruby.h: ditto.
* io.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-28 01:46:27 +00:00
naruse 106be6694f * addr2line.c: define toupper for its use. fix r54391.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-29 10:34:54 +00:00
naruse b0188253dc * addr2line.c (fill_lines): get base addrs in fill_lines to use it
with dladdr_fbases introduced at r45563.
  it didn't get before if the executalbe is not pie.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14 10:08:04 +00:00
naruse c05940a403 * addr2line.c (main_exe_path): support FreeBSD.
At least sh, csh, tcsh, bash, and zsh sets realpath of the main
  executable for dladdr, but gdb doesn't.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14 10:08:02 +00:00
naruse c7ad29f58f * addr2line.c (rb_dump_backtrace_with_lines): set base address
which is retrived from dladdr to dladdr_fbases, to skip already
  parsed objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11 04:48:26 +00:00
naruse b8eb899785 * addr2line.c (append_obj): clear allocated memory.
* addr2line.c (rb_dump_backtrace_with_lines): free `base_addrs'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 07:19:53 +00:00
naruse 99d1f5f88b * addr2line.c (rb_dump_backtrace_with_lines): don't depend hard coded
symbol '_start'.

* addr2line.c (fill_lines): instead of above, get a dynamic symbol
  in the main executable and use it to know the base address.

* addr2line.c (follow_debuglink0): use obj_info_t instead of
  line_info_t to handle object related data.

* addr2line.c (main_exe_path): defined for Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-01 03:38:05 +00:00
naruse f265ce708d * addr2line.c (fill_lines): use dynsym, which is used for dynamic
linking and always exists, if there's no symtab.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-31 22:39:07 +00:00
naruse 209a310c47 revert r45417
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28 01:23:02 +00:00
naruse acc3cf5f30 * addr2line.c (fill_lines): check shdr[i].sh_type because even if
.symtab section exists, the section's type can be SHT_NOBITS and
  actual data doesn't exist in the file. [Bug #9654]
  revert r45441.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27 03:01:59 +00:00
naruse c6aa2c467b temporally change for powerpc64-linux fc18
fc18 powerpc64's libc6-dbg has symtab/strtab but it can't be
referenced. therefore add workaround not to see them.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 21:46:23 +00:00
naruse 2d8c3e7851 remove break because strtab/symtab is usually the last segment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 10:59:44 +00:00
naruse 623da1525a temporaly show sym->st_name and so on
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 07:40:51 +00:00
naruse 2bf56deded * addr2line.c (fill_lines): loop reverse order not to overwrite
the basis of base addresses comparison.

* addr2line.c: use uintptr_t instead of intptr_t for poinrters.

* addr2line.c (rb_dump_backtrace_with_lines): don't use syms.

* vm_dump.c (rb_print_backtrace): ditto.

* addr2line.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 04:30:43 +00:00
naruse f3867e2203 * addr2line.c (follow_debuglink): show message if it closes opened
(and maybe used) elf binary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 01:38:23 +00:00
naruse b8ba4016ac * addr2line.c (fill_line): pass and use offset instead of
curobj_baseaddr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 01:38:05 +00:00
naruse 537623e43d don't write _start as is; use dlsym
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 00:02:24 +00:00
naruse 3bd0fd118d temporaly change/add to debug on powerpc64-linux
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 23:55:58 +00:00
naruse 633b2fc9d7 * addr2line.c (fill_lines): don't run fill_lines multiple times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 23:55:39 +00:00
naruse 0fe34c4c3b main is not a pubic function, use _start instead
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 18:44:32 +00:00
naruse c1b81d3578 * addr2line.c (rb_dump_backtrace_with_lines): a function to get must
be a function in the main executable, whose absolute path is not
  available by dladdr, and ruby get it by /proc/self/exe on Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 16:58:45 +00:00
naruse cd2afc30fd * addr2line.c (fill_lines): skip if path is NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 16:58:42 +00:00
naruse 2e47a521e6 * addr2line.c (rb_dump_backtrace_with_lines): fetch path of the
executable from /proc/self/exe on Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-24 06:28:32 +00:00
naruse d2b1deda92 * addr2line.c (parse_debug_line_cu): explicitly specify signed char
because DWARF's line_Base is signed char and char maybe unsigned.
  patched by Rei Odaira. [ruby-dev:48068] [Bug #9654]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-24 04:18:28 +00:00
naruse 14c9cf885c * addr2line.c (fill_lines): compare the file names of object in which
symbols exist. [Bug #9654] [ruby-dev:48058]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-22 14:06:11 +00:00
naruse 356644685e * addr2line.c (fill_lines): return address is just after calling
address. Therefore noreturn function with tail call's return
  address may be in another function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-15 22:15:30 +00:00
naruse 6c08032d2f * addr2line.c (fill_lines): fetch symbol names from ELF binary's
symbol table if it is built with cc -g and not stripped.
  Now ruby can show static symbols on Linux though glibc's
  backtrace_symbols(3) don't show them.

* addr2line.c (rb_dump_backtrace_with_lines): use dladdr(3) to
  detect what object file declares the symbol because
  dl_iterate_phdr can't detect the main executable file
  and codes on the stack.
  NOTE: signal trampolines sometimes on the user stack. (FreeBSD)

* addr2line.c (rb_dump_backtrace_with_lines): stop showing
  backtrace if the function's name is main.
  NOTE: FreeBSD's backtrace (libexecinfo) shows _start and
  an additional address. Why it doesn't remove them on dladdr phase
  is, dladdr may fail to detect the main function but detect
  as _start function. Therefore it must be after scanning
  the symbol table and getting correct name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 06:29:39 +00:00
naruse be7cc58370 * configure.in: always check dladdr(1).
* addr2line.c (fill_lines): show the line number in C backtrace if
  ruby is built without --enable-shared (PIE) on Linux.
  patch is originally by Shinichiro Hamaji
  https://twitter.com/shinh/status/441957774264504321
  NOTE: ld doesn't insert __executable_start for PIE.
  dladdr(3)'s argument must be a function pointer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-10 03:20:53 +00:00
nobu 057098bfdc use strlcat
* addr2line.c (follow_debuglink): use strlcat instead of strncat.

* dln.c (aix_loaderror): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:13 +00:00
akr fdf7b4586f * addr2line.c: Include ELF header after system headers (especially
sys/types.h) to avoid compilation failure,
  "usr/include/sh3/elf_machdep.h:4:2: error: #error Define _BYTE_ORDER!",
  on NetBSD/sh3 (dreamcast, hpcsh, landisk, mmeye).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 03:04:27 +00:00
naruse c73c876d54 * addr2line.c: use more generic type:
* u_char -> unsigned char
  * u_short -> unsigned short
  * u_int -> unsigned int
  * u_long -> unsigned long
  * quad_t -> int64_t
  * u_quad_t -> uint64_t

* addr2line.c (imax): inline is defined by configure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 19:27:04 +00:00
ngoto 5427a5df05 * addr2line.c: quad_t and u_quad_t is not available on Solaris.
__inline is not available with old compilers on Solaris.
  [ruby-dev:47229] [Bug #8227]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 14:45:06 +00:00
akr 702250a412 * addr2line.c: include ruby/missing.h to fix compile error on Debian.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 11:23:36 +00:00
naruse 4fa7a0d8df Suppress -Werror=shorten-64-to-32
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 01:42:33 +00:00