90 Commits

Author SHA1 Message Date
John Salmon
af2debf91e StackTraceImpl::operator[] is const
This is only matters when compiling with -DBACWARD_SYSTEM_UNKNOWN.
2019-08-25 20:56:27 -04:00
John Salmon
80af93580f Improve portability to non-glibc Linux systems
Linux is not synonymous with glibc.  Alpine linux (among others) uses
libmusl as the standard C library.  Alpine/libmusl doesn't have
backtrace, dladdr1, execinfo.h or error.h.  It does have libunwind
and program_invocation_name and libdwarf and libelf are available as
packages.

This patch makes backward-cpp work on Alpine linux (and hopefully
others that rely on libmusl).

This patch makes dladdr1 dependent on the __GLIBC__ pp-symbol
(rather than __ANDROID__).

It uses __has_include (protected by a defined()) rather than __APPLE__
to decide whether to include <error.h> in _test_main.cpp.
2019-08-25 20:34:28 -04:00
Marco Magdy
9c4c163583 squash! Add missing ref qualifier to the other overload 2019-06-03 15:29:56 +00:00
Marco Magdy
fb4a00d1f8
Add missing ref qualifier
returning a `const T` as opposed to `const T&` serves little purpose and is most likely not what the writer intended.
This change was called out by clang-tidy.
2019-06-01 10:26:18 -07:00
Nikos Skalkotos
b7ffd640ec Fix unknown pragma warning in gcc
Check if the compiler is clang before using clang only pragma statements.
2018-11-06 14:05:47 +02:00
Michael Truog
7539d53b54
Fix compilation for GCC (tested with 5.4.0) 2018-09-22 19:10:56 -07:00
François-Xavier Bourlet
84ae4f5e80
Merge pull request #118 from pedronavf/optimizations
Code optimizations
2018-06-28 11:41:29 -07:00
François-Xavier Bourlet
218e43e6c2
Merge branch 'master' into master 2018-06-28 11:29:07 -07:00
Alexei Drake
e304e655f6 Fix -Wold-style-cast compilation warnings by using static_cast and reinterpret_cast 2018-06-28 12:41:53 +02:00
Pedro Navarro
9524b15ea7 DIE iteration optimizations
When iterating through all the CU DIEs, only inspect those that have the
DW_TAG_compile_unit tag. When finishing the iteration, only keep going
to reset libdwarf's internal CU iterator if we found a DIE.
2018-05-25 17:33:58 -07:00
Pedro Navarro
d6bd44914c Fix some source code formatting issues 2018-05-25 17:33:38 -07:00
Pedro Navarro
06f4e1adb7 Do not process a .debug_range entry if its start address is 0 2018-05-25 17:33:18 -07:00
Pedro Navarro
ae396dae74 Pass the filename string as a reference 2018-05-25 17:33:05 -07:00
Arkadiusz Piekarz
260c82ad08 Silence -Wdisabled-macro-expansion on Clang 2018-05-06 00:15:07 +02:00
Arkadiusz Piekarz
30fc52e002 Silence -Wzero-as-null-pointer-constant with libbfd on Clang 2018-05-06 00:11:08 +02:00
Arkadiusz Piekarz
9e58734de9 Fix compilation on GCC with -Wzero-as-null-pointer-constant by using nullptr 2018-05-05 22:50:59 +02:00
Arkadiusz Piekarz
f8b6d76dd2 Fix compilation on GCC with -Wsign-conversion by using static_cast 2018-05-05 18:53:52 +02:00
Arkadiusz Piekarz
127243ca9f Fix compilation on GCC with -Wold-style-cast by using static_cast and reinterpret_cast 2018-05-05 18:53:52 +02:00
François-Xavier Bourlet
8f76407505
Merge pull request #102 from pedronavf/patch-2
Added instruction pointer for 32 bit OS X
2018-05-05 08:00:16 -07:00
François-Xavier Bourlet
5319fb3cc6
Merge pull request #103 from pedronavf/patch-3
Remove warning about unused variable 'info"
2018-05-05 07:55:54 -07:00
François-Xavier Bourlet
b75f050edd
Merge pull request #104 from clnperez/linux_defines
add check for __linux__
2018-05-05 07:54:51 -07:00
Pedro Navarro
2ba1296b5f libdwarf/libelf implementation 2018-05-01 12:02:59 -07:00
Christy Norman
98528c1405 add check for __linux__
Some compiler flags and/or compilers will set this instead. There are
undoubtedly others but I know this fixes my problem.

The flag that I'm currently seeing alter this is `-std=c++0x`.

Signed-off-by: Christy Norman <christy@linux.vnet.ibm.com>
2018-04-02 15:56:08 -04:00
Pedro Navarro
a18aa777bc
Remove warning about unused variable 'info"
On some platforms we got a warning about 'info' not being used because the #if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L was not true. Can't remember which platform right now but this patch addressed it.
2018-03-30 11:56:15 -07:00
Pedro Navarro
91c92d94b6
Added instruction pointer for 32 bit OS X 2018-03-30 11:51:10 -07:00
Pedro Navarro
c25d2e0f8e Remove override warnings in C++11 builds (#100)
GCC shows warnings (like:

warning: 'virtual std::streamsize backward::cfile_streambuf::xsputn(const char_type*, std::streamsize)' can be marked override [-Wsuggest-override] 

In the cfile_streambuf class. This patch #defines override to be nothingness in C++98 and adds the override keyword to the functions with the warnings.
2018-03-27 20:38:50 -07:00
Stephan Zuercher
44ae9609e8 functional mac port (#70)
* functional mac port

* combine common parts of Linux and Darwin implementations

* add unwind support for apple

* insure BACKWARD_HAS_BACKTRACE_SYMBOL is set for BACKWARD_SYSTEM_DARWIN

* fix indentation

* use pthread_self and pthread_main_np
2018-02-06 22:43:16 -08:00
preetikhorjuvenkar
4ebf74018e Added s390x support code. 2018-01-30 05:09:30 +00:00
tdowns
2221a39225 one more more const correction addition, review changes 2017-12-01 13:12:38 -06:00
tdowns
3f45d70f42 make operator[](size_t) for StackTrace const 2017-11-17 23:42:59 -06:00
Forrest Voight
7a9229f57c Handle dladdr not returning the true location of the executable, but merely argv[0]. see issue #80
If an executable is run by e.g. being on the PATH (anything that results in argv[0] not being a valid
path to the executable), problems ensue when backward-cpp tries to print a stack trace.

dladdr returns argv[0] in dli_fname for symbols contained in the main executable, which is not a valid
path if the executable was found by a search of the PATH environment variable. Then, load_object_with_bfd
is called on that non-existent filename and fails.

The implemented solution is to detect `dladdr` returning `argv[0]` and replace it with the executable's
path, read from the /proc/self/exe symlink.
2017-11-08 22:20:42 -05:00
Forrest Voight
bd862932e5 Fixed memory leak in demangle()
abi::__cxa_demangle returns null and does nothing with output_buffer on failure, resulting in previous value of _demangle_buffer being leaked
2017-11-08 22:13:48 -05:00
Forrest Voight
d62c9fefd9 Fixed bfd_close being called on null pointer if bfd_fdopenr returns null 2017-11-08 22:13:48 -05:00
Georgios Bitzes
d29afac746 Allow running sighandler logic as part of a cleanup chain
In our code, we need to take certain cleanup actions
after receiving a SIGSEGV. This makes it difficult to
integrate with backward, as our custom sighandler is overriden.

A simple solution is to have backward-cpp expose the
core sighandling logic as a public function, which
we can simply call from within our code. This is not
currently possible since sig_handler is private, and
additionally raises the signal again at the end.

This pull request makes the above possible. The alternative
is to copy handleSignal into our own code, which is just ugly.
2017-10-31 11:25:15 +01:00
Dāvis Mosāns
884a7c39a3 Fix data type conversion warnings 2017-09-13 15:06:38 +03:00
Dāvis Mosāns
cd155ec977 Remove SIGUNUSED, it doesn't exist anymore
This fixes #71
2017-09-13 15:06:24 +03:00
François-Xavier Bourlet
857bc8fc31 Merge pull request #67 from chsterz/feature/aarch64-support
Add aarch64 support
2017-07-03 15:11:25 -07:00
Rafal Crypto Tigusoft
89b77f96b9
Fix the ip==0 workaround to skip opening-parentheses 2017-06-29 14:33:54 +00:00
Christoph Sterz
61876549f1 Add aarch64 support
*Read the pc as specified for aarch64 processors.
*Disable division by zero tests, since aarch64 does not trap these and
 therefore does not generate SIGFPEs there.
*All other tests succeed.
2017-06-29 15:12:18 +02:00
Rafal Crypto Tigusoft
e1bf45fd0c
After review pr#66 2017-06-29 10:57:04 +00:00
Rafal Crypto Tigusoft
dd552a10c8
fix off-by-one when resolve goes up to ip==0 frame 2017-06-29 10:57:04 +00:00
François-Xavier Bourlet
f9f732ddeb Merge pull request #63 from rfree-d/fix_warning_ip_minus1
To pass sanitization, do not rely on underflow 0-1
2017-06-28 11:40:58 -07:00
Govind Sahai
9ecb5c6bf3 Added _ to remove warning 2017-06-25 00:21:05 +05:30
Rafal Crypto Tigusoft
7430bea233
Fixed problem with decltype (on older compiler/travis) 2017-06-22 17:08:30 +00:00
Rafal Crypto Tigusoft
4fc30f7ce6
To pass sanitization, do not rely on underflow 0-1
for ip==0, we sometimes calculate ip-=1.
ip is unsigned, so this is an underflow.

This is not strictly an UB, but more pedantic sanitizers
do catch this and report as possible error.

So why not instead just explicitly set value 0xffff...
(result of 0-1) and avoid this warnings.
2017-06-22 16:35:40 +00:00
François-Xavier Bourlet
8eb8fad38f Add color mode.
This is a breaking change.

The printer now offers a color_mode setting: automatic, always, never.

When given a FILE* stream on linux, the automatic mode will retrieve
file descriptor behind it and call isatty().
2017-05-28 17:03:29 -07:00
François-Xavier Bourlet
c432e7ef8d Merge branch 'print-to-streams' of https://github.com/ogdf/backward-cpp into ogdf-print-to-streams 2017-05-28 15:16:29 -07:00
François-Xavier Bourlet
71dafcb203 Merge pull request #60 from ogdf/g++7-warnings
Fix g++ 7.0.1 warnings
2017-03-29 14:36:47 -07:00
François-Xavier Bourlet
6ae8564fbd enable tests that somebody thought it was a good idea to permanently disable. 2017-03-15 17:32:15 -07:00
François-Xavier Bourlet
5557e53f23 Only catch signals with a default action of "Core"
Close #59
2017-03-15 17:01:35 -07:00