109 Commits

Author SHA1 Message Date
François-Xavier Bourlet
29e4061494 clang-format 2020-05-04 15:01:55 -07:00
Martin Gerhardy
738e3c6c5a Fix invalid memset call
Also reformat another memset call, for consistency.

Closes #170
2020-05-04 14:59:51 -07:00
Michael Truog
74dd7d6733
Fix for C++ compilers without C++11 2020-04-14 13:28:11 -07:00
Michael Truog
6174c26f76
Fix for binutils 2.34
* For macro changes at https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fd3619828e94a24a92cddec42cbc0ab33352eeb4
2020-04-13 15:42:46 -07:00
Forrest Voight
f66f422fef Call std::getline with an lvalue std::ifstream rather than an rvalue. Older
libstdc++ versions (e.g. 4.8.2) don't have the rvalue overload of
std::getline. This fixes this error when compiled with libstdc++ 4.8.2:

ext/backward-cpp/backward.hpp: In static member function 'static std::string backward::TraceResolverLinuxBase::get_argv0()':
ext/backward-cpp/backward.hpp:1031:66: error: no matching function for call to 'getline(std::ifstream, std::string&, char)'
     std::getline(std::ifstream("/proc/self/cmdline"), argv0, '\0');
                                                                  ^
ext/backward-cpp/backward.hpp:1031:66: note: candidates are:
/usr/include/c++/4.8/bits/basic_string.h:2799:5: note: std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
     getline(basic_istream<char>& __in, basic_string<char>& __str,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2799:5: note:   no known conversion for argument 1 from 'std::ifstream {aka std::basic_ifstream<char>}' to 'std::basic_istream<char>&'
2020-04-13 02:50:29 -05:00
David P. Sicilia
c122f1f988 Put delimiter string into backward::details namespace. 2020-02-27 11:24:40 -05:00
David P. Sicilia
b30401a81f Use const char[] for delimiter string instead of macro. 2020-02-27 11:13:19 -05:00
David P. Sicilia
4053b2e2e3 Address some reviewer comments:
1. Make path splitting function less generic.
  2. Improve efficiency of emptiness test on C string.
  3. Cache result of splitting environment variable.
2020-02-26 17:23:52 -05:00
David P. Sicilia
257e5e57a0 Merge branch 'master' of https://github.com/bombela/backward-cpp 2020-02-26 16:58:21 -05:00
François-Xavier Bourlet
c51737a75c
Merge pull request #158 from eklitzke/dwarf_file_handle
fix bad pointer comparison in libdwarf backend
2020-02-10 12:40:54 -08:00
Evan Klitzke
10764bbffc
fix bad pointer comparison in libdwarf backend 2020-01-25 11:01:30 -08:00
Evan Klitzke
dd8af2505e
fix a memory leak when __cxa_demangle reallocs 2020-01-25 10:55:02 -08:00
David P. Sicilia
96007bd8e7 Allow specifying list of source file search paths in environment variable.
This is useful for binaries (using backward-cpp) that are built with
relative source file paths.  In such a situation, backward-cpp will
generally not be able to locate the source files.  This change allows
the user to specify a delimited list of search paths in the following
environment variable:

  BACKWARD_CXX_SOURCE_PREFIXES

The paths are separated by semicolons on Windows and colons otherwise.
When the environment variable is set, those search paths will be tried
first.  If they do not yield any valid files then backward-cpp will
fall back to current behavior.
2019-12-24 17:34:06 -05:00
Zsolt Parragi
7cbf4c25e9 Windows (Clang9, MSVC2017) implementation
Remaining issues:
* some warinings
2019-11-29 12:33:22 +01:00
Zsolt Parragi
4dfd5e6e24 Use a macro instead of direct noinline attributes.
This is a prerequisite of MSVC support, as it uses a different syntax.
2019-11-29 12:15:54 +01:00
Jiaxun Yang
3cec08149d Add mips support
MIPS didn't export regs at mcontext_t so we need to cast it as sigcontext.
All test passed on my mips64el machine.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
2019-11-23 21:34:56 +08:00
Forrest Voight
1ecbdc6491 Handle executable being deleted or replaced by directly opening
`/proc/self/exe` rather than file it links to. Fixes issue #146.
2019-09-25 12:52:52 -05:00
Forrest Voight
79e7738e1f Extracted duplicated code for get_argv0 and read_symlink 2019-09-23 14:17:45 -05:00
François-Xavier Bourlet
9fb93a08aa clang-format 2019-09-05 13:41:10 -07:00
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