mirror of
https://github.com/QuasarApp/backward-cpp.git
synced 2025-05-02 12:59:34 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
218e43e6c2
@ -72,7 +72,7 @@ if (${STACK_DETAILS_AUTO_DETECT})
|
||||
LIBDL_INCLUDE_DIR LIBDL_LIBRARY)
|
||||
|
||||
# find libdwarf
|
||||
find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h")
|
||||
find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf)
|
||||
find_path(LIBELF_INCLUDE_DIR NAMES "libelf.h")
|
||||
find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h")
|
||||
find_library(LIBDWARF_LIBRARY dwarf)
|
||||
@ -133,7 +133,7 @@ else()
|
||||
endif()
|
||||
|
||||
if (STACK_DETAILS_DWARF)
|
||||
LIST(APPEND BACKWARD_LIBRARIES dwarf elf)
|
||||
LIST(APPEND _BACKWARD_LIBRARIES dwarf elf)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -169,10 +169,8 @@ list(APPEND _BACKWARD_INCLUDE_DIRS ${BACKWARD_INCLUDE_DIR})
|
||||
|
||||
macro(add_backward target)
|
||||
target_include_directories(${target} PRIVATE ${BACKWARD_INCLUDE_DIRS})
|
||||
set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${_BACKWARD_DEFINITIONS})
|
||||
if(BACKWARD_HAS_EXTERNAL_LIBRARIES)
|
||||
set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${_BACKWARD_LIBRARIES})
|
||||
endif()
|
||||
set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${BACKWARD_DEFINITIONS})
|
||||
set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${BACKWARD_LIBRARIES})
|
||||
endmacro()
|
||||
|
||||
set(BACKWARD_INCLUDE_DIRS ${_BACKWARD_INCLUDE_DIRS} CACHE INTERNAL "_BACKWARD_INCLUDE_DIRS")
|
||||
@ -180,6 +178,16 @@ set(BACKWARD_DEFINITIONS ${_BACKWARD_DEFINITIONS} CACHE INTERNAL "BACKWARD_DEFIN
|
||||
set(BACKWARD_LIBRARIES ${_BACKWARD_LIBRARIES} CACHE INTERNAL "BACKWARD_LIBRARIES")
|
||||
mark_as_advanced(BACKWARD_INCLUDE_DIRS BACKWARD_DEFINITIONS BACKWARD_LIBRARIES)
|
||||
|
||||
# Expand each definition in BACKWARD_DEFINITIONS to its own cmake var and export
|
||||
# to outer scope
|
||||
foreach(var ${BACKWARD_DEFINITIONS})
|
||||
string(REPLACE "=" ";" var_as_list ${var})
|
||||
list(GET var_as_list 0 var_name)
|
||||
list(GET var_as_list 1 var_value)
|
||||
set(${var_name} ${var_value})
|
||||
mark_as_advanced(${var_name})
|
||||
endforeach()
|
||||
|
||||
if (NOT TARGET Backward::Backward)
|
||||
add_library(Backward::Backward INTERFACE IMPORTED)
|
||||
set_target_properties(Backward::Backward PROPERTIES
|
||||
|
24
README.md
24
README.md
@ -149,7 +149,29 @@ Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the
|
||||
linkage details in your build system and even auto-detect which library is
|
||||
installed, it's up to you.
|
||||
|
||||
That'ss it, you are all set, you should be getting nice stack traces like the
|
||||
#### [libdwarf](https://sourceforge.net/projects/libdwarf/) and [libelf](http://www.mr511.de/software/english.html)
|
||||
|
||||
apt-get install libdwarf-dev (or equivalent)
|
||||
|
||||
And do not forget to link with the lib and inform Backward to use it:
|
||||
|
||||
#define BACKWARD_HAS_DWARF 1
|
||||
|
||||
There are several alternative implementations of libdwarf and libelf that
|
||||
are API compatible so it's possible, although it hasn't been tested, to
|
||||
replace the ones used when developing backward (in bold, below):
|
||||
|
||||
* **_libelf_** by [Michael "Tired" Riepe](http://www.mr511.de/software/english.html)
|
||||
* **_libdwarf_** by [David Anderson](https://www.prevanders.net/dwarf.html)
|
||||
* libelf from [elfutils](https://fedorahosted.org/elfutils/)
|
||||
* libelf and libdwarf from FreeBSD's [ELF Tool Chain](https://sourceforge.net/p/elftoolchain/wiki/Home/) project
|
||||
|
||||
|
||||
Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the
|
||||
linkage details in your build system and even auto-detect which library is
|
||||
installed, it's up to you.
|
||||
|
||||
That's it, you are all set, you should be getting nice stack traces like the
|
||||
one at the beginning of this document.
|
||||
|
||||
## API
|
||||
|
@ -719,7 +719,7 @@ private:
|
||||
} else {
|
||||
ip -= 1; // else just normally decrement it (no overflow/underflow will happen)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_index >= 0) { // ignore first frame.
|
||||
(*_f)(static_cast<size_t>(_index), reinterpret_cast<void*>(ip));
|
||||
|
Loading…
x
Reference in New Issue
Block a user