Merge branch 'main' into dev

This commit is contained in:
Jeremy 2024-02-27 00:23:10 -06:00
commit d5b2646283
No known key found for this signature in database
GPG Key ID: BE03111EB7ED6E2E
17 changed files with 44 additions and 38 deletions

View File

@ -91,7 +91,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: dependencies
run: |
pip3 install colorama

View File

@ -195,7 +195,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: test
run: |
$tag=$(git rev-parse --abbrev-ref HEAD)
@ -216,7 +216,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: test
run: |
$tag=$(git rev-parse --abbrev-ref HEAD)
@ -242,7 +242,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: test
run: |
cd ..

View File

@ -48,7 +48,7 @@ jobs:
# steps:
# - uses: actions/checkout@v4
# - name: Enable Developer Command Prompt
# uses: ilammy/msvc-dev-cmd@v1.10.0
# uses: ilammy/msvc-dev-cmd@v1.13.0
# - name: build
# run: |
# mkdir -p build

View File

@ -107,7 +107,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: dependencies
run: |
pip3 install colorama

View File

@ -17,7 +17,7 @@ What's new:
Most notable improvements:
- Updated cpptrace exception objects to generate traces at the callsite for improved consistency with trace output. As
part fo this cpptrace exception objects have had their constructors updated.
part of this cpptrace exception objects have had their constructors updated.
- Improved dwarf back-end robustness
- Fallback to the compilation-unit cache or walking compilation-units if aranges lookup fails
- Eliminated reliance on a CMake-generated export header

View File

@ -279,7 +279,7 @@ target_compile_features(
PRIVATE cxx_std_11
)
if(APPLE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()

View File

@ -118,7 +118,7 @@ endif()
Be sure to configure with `-DCMAKE_BUILD_TYPE=Debug` or `-DDCMAKE_BUILD_TYPE=RelWithDebInfo` for symbols and line
information.
On macOS it is recommended to generate a .dSYM file, see [Platform Logistics](#platform-logistics) below.
On macOS it is recommended to generate a `.dSYM` file, see [Platform Logistics](#platform-logistics) below.
For other ways to use the library, such as through package managers, a system-wide installation, or on a platform
without internet access see [Usage](#usage) below.
@ -250,7 +250,7 @@ namespace cpptrace {
`cpptrace::demangle` provides a helper function for name demangling, since it has to implement that helper internally
anyways.
`cpptrace::isatty` and the fileno definitions are useful for deciding whether to use color when printing stack taces.
`cpptrace::isatty` and the fileno definitions are useful for deciding whether to use color when printing stack traces.
`cpptrace::register_terminate_handler()` is a helper function to set a custom `std::terminate` handler that prints a
stack trace from a cpptrace exception (more info below) and otherwise behaves like the normal terminate handler.
@ -455,7 +455,7 @@ non-signal-safe functions such as `malloc()`. To avoid this, call these routines
to "warm up" the library.
Because signal-safe tracing is an involved process, I have written up a comprehensive overview of
what is involved at [signal-safe-tracing.md](signal-safe-tracing.md).
what is involved at [signal-safe-tracing.md](docs/signal-safe-tracing.md).
## Utility Types
@ -730,9 +730,11 @@ target_link_libraries(main PRIVATE cpptrace::cpptrace)
# Platform Logistics
Windows and macos require a little extra work to get everything in the right place
Windows and macOS require a little extra work to get everything in the right place.
Copying the library .dll on windows:
## Windows
Copying the library `.dll` on Windows:
```cmake
# Copy the cpptrace.dll on windows to the same directory as the executable for your_target.
@ -747,18 +749,22 @@ if(WIN32)
endif()
```
On macOS it's recommended to generate a dSYM file containing debug information for your program:
## macOS
In xcode cmake this can be done with
On macOS, it is recommended to generate a `dSYM` file containing debug information for your program.
This is not required as cpptrace makes a good effort at finding and reading the debug information
without this, but having a `dSYM` file is the most robust method.
When using Xcode with CMake, this can be done with:
```cmake
set_target_properties(your_target PROPERTIES XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
```
And outside xcode this can be done with `dsymutil yourbinary`:
Outside of Xcode, this can be done with `dsymutil yourbinary`:
```cmake
# Create a .dSYM file on macos. Currently required, but hopefully not for long
# Create a .dSYM file on macOS
if(APPLE)
add_custom_command(
TARGET your_target

View File

@ -6,7 +6,7 @@ We take security seriously and I'm grateful for reports of security vulnerabilit
If the vulnerability can be reported without revealing exploitable specifics, please open an issue.
If the vulnerability can't be reported publically without leaving an obvious exploit in the public eye please email me
If the vulnerability can't be reported publicly without leaving an obvious exploit in the public eye please email me
at jeremy@rifkin.dev or reach out to me on [discord](https://discord.gg/7kv5AuCndG).
I will do my best to get back to you within a day.

View File

@ -60,7 +60,7 @@ def run_matrix(matrix, exclude, fn):
# results[config_tuple] = matrix_config["compiler"] != "g++-10"
#else:
# results[config_tuple] = not (matrix_config["compiler"] == "clang++-14" and matrix_config["symbols"] == "CPPTRACE_GET_SYMBOLS_WITH_ADDR2LINE")
# I had an idea for printing 2d slices of the n-dimentional matrix, but it didn't pan out as much as I'd hoped
# I had an idea for printing 2d slices of the n-dimensional matrix, but it didn't pan out as much as I'd hoped
dimensions = len(values)
# # Output diagnostic tables
# print("Results:", results)

View File

@ -138,7 +138,7 @@ void do_signal_safe_trace(cpptrace::frame_ptr* buffer, std::size_t size) {
pipe_t input_pipe;
pipe(input_pipe.data);
const pid_t pid = fork();
if(pid == -1) { return; /* Some error ocurred */ }
if(pid == -1) { return; /* Some error occurred */ }
if(pid == 0) { // child
dup2(input_pipe.read_end, STDIN_FILENO);
close(input_pipe.read_end);
@ -160,7 +160,7 @@ void do_signal_safe_trace(cpptrace::frame_ptr* buffer, std::size_t size) {
void handler(int signo, siginfo_t* info, void* context) {
// Print basic message
const char* message = "SIGSEGV ocurred:\n";
const char* message = "SIGSEGV occurred:\n";
write(STDERR_FILENO, message, strlen(message));
// Generate trace
constexpr std::size_t N = 100;

View File

@ -293,7 +293,7 @@ namespace cpptrace {
// Interface for a traced exception object
class CPPTRACE_EXPORT exception : public std::exception {
public:
virtual const char* what() const noexcept = 0;
const char* what() const noexcept override = 0;
virtual const char* message() const noexcept = 0;
virtual const stacktrace& trace() const noexcept = 0;
};
@ -413,7 +413,7 @@ namespace cpptrace {
mutable std::string message_value;
public:
explicit nested_exception(
std::exception_ptr exception_ptr,
const std::exception_ptr& exception_ptr,
raw_trace&& trace = detail::get_raw_trace_and_absorb()
) noexcept
: lazy_exception(std::move(trace)), ptr(exception_ptr) {}

View File

@ -372,7 +372,7 @@ namespace detail {
// produce information similar to dsymutil -dump-debug-map
static void print_debug_map(const debug_map& debug_map) {
for(const auto& entry : debug_map) {
std::cout<<entry.first<<": "<<std::endl;
std::cout<<entry.first<<": "<< '\n';
for(const auto& symbol : entry.second) {
std::cerr
<< " "
@ -383,7 +383,7 @@ namespace detail {
<< " "
<< symbol.size
<< std::dec
<< std::endl;
<< '\n';
}
}
}

View File

@ -174,10 +174,10 @@ namespace cpptrace {
) {
detail::enable_virtual_terminal_processing_if_needed();
}
stream<<(header ? header : "Stack trace (most recent call first):")<<std::endl;
stream<<(header ? header : "Stack trace (most recent call first):") << '\n';
std::size_t counter = 0;
if(frames.empty()) {
stream<<"<empty trace>"<<std::endl;
stream<<"<empty trace>" << '\n';
return;
}
const auto reset = color ? ESC "0m" : "";
@ -237,7 +237,7 @@ namespace cpptrace {
}
}
if(newline_at_end || &frame != &frames.back()) {
stream << std::endl;
stream << '\n';
}
counter++;
}
@ -455,7 +455,7 @@ namespace cpptrace {
// TODO: Append to message somehow
std::fprintf(
stderr,
"Cpptrace: Exception ocurred while resolving trace in cpptrace::exception object:\n%s\n",
"Cpptrace: Exception occurred while resolving trace in cpptrace::exception object:\n%s\n",
e.what()
);
}
@ -520,7 +520,7 @@ namespace cpptrace {
// TODO: Append to message somehow?
std::fprintf(
stderr,
"Exception ocurred while resolving trace in cpptrace::exception object:\n%s\n",
"Exception occurred while resolving trace in cpptrace::exception object:\n%s\n",
e.what()
);
}

View File

@ -188,7 +188,7 @@ namespace libdwarf {
}
CPPTRACE_FORCE_NO_INLINE_FOR_PROFILING
~dwarf_resolver() {
~dwarf_resolver() override {
// TODO: Maybe redundant since dwarf_finish(dbg); will clean up the line stuff anyway but may as well just
// for thoroughness
for(auto& entry : line_tables) {
@ -959,7 +959,7 @@ namespace libdwarf {
optional<std::unordered_map<std::string, uint64_t>> symbols;
std::unique_ptr<symbol_resolver> resolver;
target_object(std::string object_path) : object_path(object_path) {}
target_object(std::string object_path) : object_path(std::move(object_path)) {}
std::unique_ptr<symbol_resolver>& get_resolver() {
if(!resolver) {
@ -1034,7 +1034,7 @@ namespace libdwarf {
// get symbol entries from debug map, as well as the various object files used to make this binary
for(auto& entry : source_debug_map) {
// object it came from
target_objects.push_back({std::move(entry.first)});
target_objects.push_back({entry.first});
// push the symbols
auto& map_entry_symbols = entry.second;
symbols.reserve(symbols.size() + map_entry_symbols.size());

View File

@ -4,7 +4,7 @@
#include <string>
// libstdc++ and libc++
#if CPPTRACE_HAS_CXX_EXCEPTION_TYPE && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION)
#if defined(CPPTRACE_HAS_CXX_EXCEPTION_TYPE) && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION)
#include <cxxabi.h>
#endif
@ -13,7 +13,7 @@
namespace cpptrace {
namespace detail {
inline std::string exception_type_name() {
#if CPPTRACE_HAS_CXX_EXCEPTION_TYPE && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION)
#if defined(CPPTRACE_HAS_CXX_EXCEPTION_TYPE) && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION)
const std::type_info* t = abi::__cxa_current_exception_type();
return t ? detail::demangle(t->name()) : "<unknown>";
#else

View File

@ -280,7 +280,7 @@ namespace detail {
return *this;
}
void swap(optional& other) {
void swap(optional& other) noexcept {
if(holds_value && other.holds_value) {
std::swap(uvalue, other.uvalue);
} else if(holds_value && !other.holds_value) {
@ -409,7 +409,7 @@ namespace detail {
optional<D> deleter;
public:
raii_wrapper(T obj, D deleter) : obj(obj), deleter(deleter) {}
raii_wrapper(raii_wrapper&& other) noexcept : obj(std::move(other.obj)), deleter(other.deleter) {
raii_wrapper(raii_wrapper&& other) noexcept : obj(std::move(other.obj)), deleter(std::move(other.deleter)) {
other.deleter = nullopt;
}
raii_wrapper(const raii_wrapper&) = delete;

View File

@ -35,7 +35,7 @@ struct pipe_t {
static_assert(sizeof(pipe_t) == 2 * sizeof(int), "Unexpected struct packing");
void handler(int signo, siginfo_t* info, void* context) {
const char* message = "SIGSEGV ocurred:\n";
const char* message = "SIGSEGV occurred:\n";
write(STDERR_FILENO, message, strlen(message));
cpptrace::frame_ptr buffer[100];
std::size_t count = cpptrace::safe_generate_raw_trace(buffer, 100);