diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 717175e..4ce8221 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/cmake-integration.yml b/.github/workflows/cmake-integration.yml index cb236ca..fb60aa7 100644 --- a/.github/workflows/cmake-integration.yml +++ b/.github/workflows/cmake-integration.yml @@ -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 .. diff --git a/.github/workflows/performance-tests.yml b/.github/workflows/performance-tests.yml index 0ca7884..6448f04 100644 --- a/.github/workflows/performance-tests.yml +++ b/.github/workflows/performance-tests.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5090241..202e168 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d63f14..1165ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f3ec74..9d56d6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 " -no_warning_for_no_symbols -c ") SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") endif() diff --git a/README.md b/README.md index f814d93..d21b174 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/SECURITY.md b/SECURITY.md index c33bbd5..7f20442 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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. diff --git a/ci/util.py b/ci/util.py index 45fdd3c..4933e6e 100644 --- a/ci/util.py +++ b/ci/util.py @@ -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) diff --git a/docs/signal-safe-tracing.md b/docs/signal-safe-tracing.md index 362166c..3dbebdb 100644 --- a/docs/signal-safe-tracing.md +++ b/docs/signal-safe-tracing.md @@ -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; diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index 2a03162..b4bb01f 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -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) {} diff --git a/src/binary/mach-o.hpp b/src/binary/mach-o.hpp index b0260a3..7769089 100644 --- a/src/binary/mach-o.hpp +++ b/src/binary/mach-o.hpp @@ -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<"<" << '\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() ); } diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index 53b84bc..1c8151a 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -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> symbols; std::unique_ptr 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& 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()); diff --git a/src/utils/exception_type.hpp b/src/utils/exception_type.hpp index 25d44b6..0d9047e 100644 --- a/src/utils/exception_type.hpp +++ b/src/utils/exception_type.hpp @@ -4,7 +4,7 @@ #include // 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 #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()) : ""; #else diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index c51a2a2..c61db30 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -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 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; diff --git a/test/signal_demo.cpp b/test/signal_demo.cpp index dc7decc..1d7b9a4 100644 --- a/test/signal_demo.cpp +++ b/test/signal_demo.cpp @@ -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);