├── .cargo └── config.toml ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ └── rust-ci.yml ├── .gitignore ├── .gitmodules ├── .mergify.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── breakpad-handler ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── examples │ └── handle_crash.rs └── src │ ├── error.rs │ └── lib.rs ├── breakpad-sys ├── Cargo.toml ├── README.md ├── build.rs ├── examples │ └── handle_crash.rs └── src │ ├── impl.cpp │ └── lib.rs ├── deny.toml ├── release.toml └── src ├── breakpad_integration.rs ├── error.rs ├── lib.rs ├── shared.rs └── transport.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(all())'] 2 | rustflags = [ 3 | # BEGIN - Embark standard lints v6 for Rust 1.55+ 4 | # do not change or add/remove here, but one can add exceptions after this section 5 | # for more info see: 6 | "-Dunsafe_code", 7 | "-Wclippy::all", 8 | "-Wclippy::await_holding_lock", 9 | "-Wclippy::char_lit_as_u8", 10 | "-Wclippy::checked_conversions", 11 | "-Wclippy::dbg_macro", 12 | "-Wclippy::debug_assert_with_mut_call", 13 | "-Wclippy::doc_markdown", 14 | "-Wclippy::empty_enum", 15 | "-Wclippy::enum_glob_use", 16 | "-Wclippy::exit", 17 | "-Wclippy::expl_impl_clone_on_copy", 18 | "-Wclippy::explicit_deref_methods", 19 | "-Wclippy::explicit_into_iter_loop", 20 | "-Wclippy::fallible_impl_from", 21 | "-Wclippy::filter_map_next", 22 | "-Wclippy::flat_map_option", 23 | "-Wclippy::float_cmp_const", 24 | "-Wclippy::fn_params_excessive_bools", 25 | "-Wclippy::from_iter_instead_of_collect", 26 | "-Wclippy::if_let_mutex", 27 | "-Wclippy::implicit_clone", 28 | "-Wclippy::imprecise_flops", 29 | "-Wclippy::inefficient_to_string", 30 | "-Wclippy::invalid_upcast_comparisons", 31 | "-Wclippy::large_digit_groups", 32 | "-Wclippy::large_stack_arrays", 33 | "-Wclippy::large_types_passed_by_value", 34 | "-Wclippy::let_unit_value", 35 | "-Wclippy::linkedlist", 36 | "-Wclippy::lossy_float_literal", 37 | "-Wclippy::macro_use_imports", 38 | "-Wclippy::manual_ok_or", 39 | "-Wclippy::map_err_ignore", 40 | "-Wclippy::map_flatten", 41 | "-Wclippy::map_unwrap_or", 42 | "-Wclippy::match_on_vec_items", 43 | "-Wclippy::match_same_arms", 44 | "-Wclippy::match_wild_err_arm", 45 | "-Wclippy::match_wildcard_for_single_variants", 46 | "-Wclippy::mem_forget", 47 | "-Wclippy::mismatched_target_os", 48 | "-Wclippy::missing_enforced_import_renames", 49 | "-Wclippy::mut_mut", 50 | "-Wclippy::mutex_integer", 51 | "-Wclippy::needless_borrow", 52 | "-Wclippy::needless_continue", 53 | "-Wclippy::needless_for_each", 54 | "-Wclippy::option_option", 55 | "-Wclippy::path_buf_push_overwrite", 56 | "-Wclippy::ptr_as_ptr", 57 | "-Wclippy::rc_mutex", 58 | "-Wclippy::ref_option_ref", 59 | "-Wclippy::rest_pat_in_fully_bound_structs", 60 | "-Wclippy::same_functions_in_if_condition", 61 | "-Wclippy::semicolon_if_nothing_returned", 62 | "-Wclippy::single_match_else", 63 | "-Wclippy::string_add_assign", 64 | "-Wclippy::string_add", 65 | "-Wclippy::string_lit_as_bytes", 66 | "-Wclippy::string_to_string", 67 | "-Wclippy::todo", 68 | "-Wclippy::trait_duplication_in_bounds", 69 | "-Wclippy::unimplemented", 70 | "-Wclippy::unnested_or_patterns", 71 | "-Wclippy::unused_self", 72 | "-Wclippy::useless_transmute", 73 | "-Wclippy::verbose_file_reads", 74 | "-Wclippy::zero_sized_map_values", 75 | "-Wfuture_incompatible", 76 | "-Wnonstandard_style", 77 | "-Wrust_2018_idioms", 78 | # END - Embark standard lints v6 for Rust 1.55+ 79 | ] 80 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Jake-Shadle 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Device:** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Checklist 2 | 3 | * [ ] I have read the [Contributor Guide](../../CONTRIBUTING.md) 4 | * [ ] I have read and agree to the [Code of Conduct](../../CODE_OF_CONDUCT.md) 5 | * [ ] I have added a description of my changes and why I'd like them included in the section below 6 | 7 | ### Description of Changes 8 | 9 | Describe your changes here 10 | 11 | ### Related Issues 12 | 13 | List related issues here 14 | -------------------------------------------------------------------------------- /.github/workflows/rust-ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | tags: 6 | - "*" 7 | pull_request: 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 11 | cancel-in-progress: true 12 | 13 | name: CI 14 | jobs: 15 | lint: 16 | name: Lint 17 | runs-on: ubuntu-22.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | with: 21 | submodules: true 22 | - uses: dtolnay/rust-toolchain@stable 23 | with: 24 | components: "clippy, rustfmt" 25 | - uses: Swatinem/rust-cache@v2 26 | # make sure all code has been formatted with rustfmt 27 | - name: check rustfmt 28 | run: cargo fmt -- --check --color always 29 | 30 | # run clippy to verify we have no warnings 31 | - run: cargo fetch 32 | - name: cargo clippy 33 | run: cargo clippy --all-targets -- -D warnings 34 | 35 | test: 36 | name: Test 37 | strategy: 38 | matrix: 39 | os: [ubuntu-22.04, windows-latest, macOS-latest] 40 | runs-on: ${{ matrix.os }} 41 | steps: 42 | - uses: actions/checkout@v3 43 | with: 44 | submodules: true 45 | - uses: dtolnay/rust-toolchain@stable 46 | - uses: Swatinem/rust-cache@v2 47 | - run: cargo fetch 48 | - name: build 49 | run: cargo build --manifest-path breakpad-sys/Cargo.toml --example handle_crash 50 | 51 | deny-check: 52 | name: cargo-deny 53 | runs-on: ubuntu-22.04 54 | steps: 55 | - uses: actions/checkout@v3 56 | with: 57 | submodules: true 58 | - uses: EmbarkStudios/cargo-deny-action@v1 59 | with: 60 | command-arguments: "-D warnings" 61 | 62 | publish-check: 63 | name: Publish Check 64 | runs-on: ubuntu-22.04 65 | steps: 66 | - uses: actions/checkout@v3 67 | with: 68 | submodules: true 69 | - uses: dtolnay/rust-toolchain@stable 70 | - uses: Swatinem/rust-cache@v2 71 | - run: cargo fetch 72 | - name: cargo publish check breakpad-sys 73 | run: cargo publish --dry-run --manifest-path breakpad-sys/Cargo.toml 74 | - name: cargo publish check breakpad-handler 75 | run: cargo publish --dry-run --manifest-path breakpad-handler/Cargo.toml 76 | - name: cargo publish check sentry-contrib-breakpad 77 | run: cargo publish --dry-run --manifest-path Cargo.toml 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "breakpad-sys/breakpad"] 2 | path = breakpad-sys/breakpad 3 | url = https://github.com/EmbarkStudios/breakpad.git 4 | branch = main 5 | [submodule "breakpad-sys/lss/third_party/lss"] 6 | path = breakpad-sys/lss/third_party/lss 7 | url = https://chromium.googlesource.com/linux-syscall-support.git 8 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: automatic merge when CI passes and 1 reviews 3 | conditions: 4 | - "#approved-reviews-by>=1" 5 | - "#review-requested=0" 6 | - "#changes-requested-reviews-by=0" 7 | - base=main 8 | actions: 9 | merge: 10 | method: squash 11 | - name: delete head branch after merge 12 | conditions: 13 | - merged 14 | actions: 15 | delete_head_branch: {} 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Changelog 4 | All notable changes to this project will be documented in this file. 5 | 6 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 7 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 8 | 9 | 10 | ## [Unreleased] - ReleaseDate 11 | ## [0.9.0] - 2023-11-15 12 | ### Changed 13 | - [PR#27](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/27) changed the version requirements for `sentry-types` to fix the breaking change it introduced. 14 | 15 | ## [0.8.2] - 2023-11-15 16 | ### Fixed 17 | - Commit [7f48012] pinned `sentry-types` to =0.31.6 to avoid a breaking change in >=0.31.7. 18 | 19 | ## [0.8.1] - 2023-11-15 **yanked** 20 | ### Fixed 21 | - Commit [6adfcc4] pinned `sentry-types` to <=0.31.6 to avoid a breaking change in >=0.31.7. 22 | 23 | ## [0.8.0] - 2023-05-23 **yanked** 24 | ### Changed 25 | - [PR#24](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/24) updated the underlying breakpad C++ library to ~HEAD. Thanks [@MarijnS95](https://github.com/MarijnS95)! 26 | 27 | ## [0.7.0] - 2022-12-16 28 | ### Changed 29 | - [PR#22](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/22) bumped `sentry-core` to `>=0.29` which will hopefully mean we don't need to bump version numbers for new releases until there is an actual breaking change. 30 | 31 | ## [0.6.0] - 2022-11-04 32 | ### Changed 33 | - [PR#18](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/18) bumped `sentry-core` to `0.28`. 34 | 35 | ## [0.5.0] - 2022-06-29 36 | ### Changed 37 | - [PR#15](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/15) bumped `sentry-core` to `0.27`. 38 | 39 | ## [0.4.0] - 2022-05-26 40 | ### Changed 41 | - Nothing. Bumping semver minor version since [0.3.1] was not technically semver correct. 42 | 43 | ## [0.3.1] - 2022-05-20 44 | ### Changed 45 | - [PR#14](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/14) updated `sentry-core` to 0.26.0. Thanks [@poliorcetics](https://github.com/poliorcetics)! 46 | 47 | ## [0.3.0] - 2022-03-03 48 | ### Changed 49 | - [PR#13](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/13) updated `sentry-core` to 0.25.0. Thanks [@vthib](https://github.com/vthib)! 50 | 51 | ### Removed 52 | - [PR#11](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/11) removed some unused dependencies. Thanks [@vthib](https://github.com/vthib)! 53 | 54 | ## [0.2.0] - 2022-01-21 55 | ### Changed 56 | - [PR#10](https://github.com/EmbarkStudios/sentry-contrib-rust/pull/10) updated `sentry-core` to 0.24.1. Thanks [@MarijnS95](https://github.com/MarijnS95)! 57 | 58 | ## [0.1.0] - 2021-07-27 59 | ### Added 60 | - Initial implementation 61 | 62 | 63 | [Unreleased]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.9.0...HEAD 64 | [0.9.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.8.2...0.9.0 65 | [0.8.2]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.8.1...0.8.2 66 | [0.8.1]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.8.0...0.8.1 67 | [0.8.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.7.0...0.8.0 68 | [0.7.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.6.0...0.7.0 69 | [0.6.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.5.0...0.6.0 70 | [0.5.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.4.0...0.5.0 71 | [0.4.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.3.1...0.4.0 72 | [0.3.1]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.3.0...0.3.1 73 | [0.3.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.2.0...0.3.0 74 | [0.2.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/0.1.0...0.2.0 75 | [0.1.0]: https://github.com/EmbarkStudios/sentry-contrib-rust/releases/tag/0.1.0 76 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Embark Contributor Guidelines 2 | 3 | Welcome! This project is created by the team at [Embark Studios](https://embark.games). We're glad you're interested in contributing! We welcome contributions from people of all backgrounds who are interested in making great software with us. 4 | 5 | At Embark, we aspire to empower everyone to create interactive experiences. To do this, we're exploring and pushing the boundaries of new technologies, and sharing our learnings with the open source community. 6 | 7 | If you have ideas for collaboration, email us at opensource@embark-studios.com. 8 | 9 | We're also hiring full-time engineers to work with us in Stockholm! Check out our current job postings [here](https://www.embark-studios.com/jobs). 10 | 11 | ## Issues 12 | 13 | ### Feature Requests 14 | 15 | If you have ideas or how to improve our projects, you can suggest features by opening a GitHub issue. Make sure to include details about the feature or change, and describe any uses cases it would enable. 16 | 17 | Feature requests will be tagged as `enhancement` and their status will be updated in the comments of the issue. 18 | 19 | ### Bugs 20 | 21 | When reporting a bug or unexpected behaviour in a project, make sure your issue describes steps to reproduce the behaviour, including the platform you were using, what steps you took, and any error messages. 22 | 23 | Reproducible bugs will be tagged as `bug` and their status will be updated in the comments of the issue. 24 | 25 | ### Wontfix 26 | 27 | Issues will be closed and tagged as `wontfix` if we decide that we do not wish to implement it, usually due to being misaligned with the project vision or out of scope. We will comment on the issue with more detailed reasoning. 28 | 29 | ## Contribution Workflow 30 | 31 | ### Open Issues 32 | 33 | If you're ready to contribute, start by looking at our open issues tagged as [`help wanted`](../../issues?q=is%3Aopen+is%3Aissue+label%3A"help+wanted") or [`good first issue`](../../issues?q=is%3Aopen+is%3Aissue+label%3A"good+first+issue"). 34 | 35 | You can comment on the issue to let others know you're interested in working on it or to ask questions. 36 | 37 | ### Making Changes 38 | 39 | 1. Fork the repository. 40 | 41 | 2. Create a new feature branch. 42 | 43 | 3. Make your changes. Ensure that there are no build errors by running the project with your changes locally. 44 | 45 | 4. Open a pull request with a name and description of what you did. You can read more about working with pull requests on GitHub [here](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork). 46 | 47 | 5. A maintainer will review your pull request and may ask you to make changes. 48 | 49 | ## Code Guidelines 50 | 51 | ### Rust 52 | 53 | You can read about our standards and recommendations for working with Rust [here](https://github.com/EmbarkStudios/rust-ecosystem/blob/main/guidelines.md). 54 | 55 | ### Python 56 | 57 | We recommend following [PEP8 conventions](https://www.python.org/dev/peps/pep-0008/) when working with Python modules. 58 | 59 | ### JavaScript 60 | 61 | We follow the [AirBnB JavaScript style guide](https://github.com/airbnb/javascript). You can find the ESLint configuration in relevant repositories. 62 | 63 | ## Licensing 64 | 65 | Unless otherwise specified, all Embark open source projects are licensed under a dual MIT OR Apache-2.0 license, allowing licensees to chose either at their option. You can read more in each project's respective README. 66 | 67 | ## Code of Conduct 68 | 69 | Please note that our projects are released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that they are welcoming places for everyone to contribute. By participating in any Embark open source project, you agree to abide by these terms. 70 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sentry-contrib-breakpad" 3 | description = "Unopinionated crash collection for Sentry reporting purposes" 4 | repository = "https://github.com/EmbarkStudios/sentry-contrib-rust" 5 | version = "0.9.0" 6 | authors = ["Embark "] 7 | edition = "2018" 8 | license = "MIT OR Apache-2.0" 9 | readme = "README.md" 10 | documentation = "https://docs.rs/sentry-contrib-breakpad" 11 | homepage = "https://github.com/EmbarkStudios/sentry-contrib-rust" 12 | keywords = ["breakpad", "sentry", "minidump", "crash"] 13 | exclude = [".github", "release.toml", "breakpad-handler", "breakpad-sys"] 14 | 15 | [badges] 16 | # We don't use this crate ourselves any longer 17 | maintenance = { status = "passively-maintained" } 18 | 19 | [features] 20 | default = [] 21 | debug-logs = [] 22 | 23 | [dependencies] 24 | breakpad-handler = { version = "0.2.0", path = "./breakpad-handler" } 25 | sentry-core = { version = ">=0.31.7", features = ["client"] } 26 | sentry-types = ">=0.31.7" 27 | serde_json = "1.0" 28 | 29 | [workspace] 30 | members = ["breakpad-handler", "breakpad-sys"] 31 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Embark Studios 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | # `👁 sentry-contrib-breakpad` 4 | 5 | **Provides a small library to integrate native crash dump handling with Sentry, without relying on [sentry-native](https://github.com/getsentry/sentry-native).** 6 | 7 | [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) 8 | [![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS) 9 | [![Crates.io](https://img.shields.io/crates/v/sentry-contrib-breakpad.svg)](https://crates.io/crates/sentry-contrib-breakpad) 10 | [![Docs](https://docs.rs/sentry-contrib-breakpad/badge.svg)](https://docs.rs/sentry-contrib-breakpad) 11 | [![dependency status](https://deps.rs/repo/github/EmbarkStudios/sentry-contrib-breakpad/status.svg)](https://deps.rs/repo/github/EmbarkStudios/sentry-contrib-breakpad) 12 | [![Build status](https://github.com/EmbarkStudios/sentry-contrib-rust/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/sentry-contrib-rust/actions) 13 | 14 |
15 | 16 | ## Contributing 17 | 18 | [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](CODE_OF_CONDUCT.md) 19 | 20 | We welcome community contributions to this project. 21 | 22 | Please read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started. 23 | 24 | ## License 25 | 26 | Licensed under either of 27 | 28 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) 29 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or ) 30 | 31 | at your option. 32 | 33 | ### Contribution 34 | 35 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 36 | -------------------------------------------------------------------------------- /breakpad-handler/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "breakpad-handler" 3 | description = "Allows writing of a minidump when a crash occurs" 4 | repository = "https://github.com/EmbarkStudios/sentry-contrib-rust" 5 | version = "0.2.0" 6 | authors = ["Embark "] 7 | edition = "2021" 8 | license = "MIT OR Apache-2.0" 9 | documentation = "https://docs.rs/breakpad-handler" 10 | homepage = "https://github.com/EmbarkStudios/sentry-contrib-rust/tree/main/breakpad-handler" 11 | keywords = ["breakpad", "minidump", "crash"] 12 | readme = "README.md" 13 | 14 | [dependencies] 15 | breakpad-sys = { version = "0.2.0", path = "../breakpad-sys" } 16 | -------------------------------------------------------------------------------- /breakpad-handler/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /breakpad-handler/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Embark Studios 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /breakpad-handler/README.md: -------------------------------------------------------------------------------- 1 | # 👁 breakpad-handler 2 | 3 | [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) 4 | [![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS) 5 | [![Crates.io](https://img.shields.io/crates/v/breakpad-handler.svg)](https://crates.io/crates/breakpad-handler) 6 | [![Docs](https://docs.rs/breakpad-handler/badge.svg)](https://docs.rs/breakpad-handler) 7 | [![Build status](https://github.com/EmbarkStudios/sentry-contrib-rust/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/sentry-contrib-rust/actions) 8 | 9 | Rust wrapper around the [breakpad-sys](https://crates.io/crates/breakpad-sys) crate. 10 | 11 | ## Contributing 12 | 13 | [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](../CODE_OF_CONDUCT.md) 14 | 15 | We welcome community contributions to this project. 16 | 17 | Please read our [Contributor Guide](../CONTRIBUTING.md) for more information on how to get started. 18 | 19 | ## License 20 | 21 | Licensed under either of 22 | 23 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 24 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 25 | 26 | at your option. 27 | 28 | ### Contribution 29 | 30 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 31 | -------------------------------------------------------------------------------- /breakpad-handler/examples/handle_crash.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let cur_dir = std::env::current_dir().unwrap(); 3 | 4 | let _handler = breakpad_handler::BreakpadHandler::attach( 5 | cur_dir, 6 | breakpad_handler::InstallOptions::BothHandlers, 7 | Box::new(|minidump_path: std::path::PathBuf| { 8 | println!("Minidump written to {}", minidump_path.display()); 9 | 10 | match std::fs::remove_file(&minidump_path) { 11 | Ok(_) => { 12 | println!("Removed {}", minidump_path.display()); 13 | } 14 | Err(e) => { 15 | println!("Failed to remove {}: {}", minidump_path.display(), e); 16 | } 17 | } 18 | }), 19 | ) 20 | .unwrap(); 21 | 22 | #[allow(unsafe_code)] 23 | unsafe { 24 | if std::env::args().any(|a| a == "--crash") { 25 | let ptr: *mut u8 = std::ptr::null_mut(); 26 | *ptr = 42; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /breakpad-handler/src/error.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | #[derive(Debug)] 4 | pub enum Error { 5 | HandlerAlreadyRegistered, 6 | } 7 | 8 | impl std::error::Error for Error {} 9 | 10 | impl fmt::Display for Error { 11 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 12 | match self { 13 | Self::HandlerAlreadyRegistered => { 14 | f.write_str("Unable to register crash handler, only one is allowed at a time") 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /breakpad-handler/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod error; 2 | pub use error::Error; 3 | 4 | use std::sync::atomic; 5 | 6 | /// Trait used by the crash handler to notify the implementor that a crash was 7 | /// captured, providing the full path on disk to that minidump. 8 | pub trait CrashEvent: Sync + Send { 9 | fn on_crash(&self, minidump_path: std::path::PathBuf); 10 | } 11 | 12 | impl CrashEvent for F 13 | where 14 | F: Fn(std::path::PathBuf) + Send + Sync, 15 | { 16 | fn on_crash(&self, minidump_path: std::path::PathBuf) { 17 | self(minidump_path); 18 | } 19 | } 20 | 21 | static HANDLER_ATTACHED: atomic::AtomicBool = atomic::AtomicBool::new(false); 22 | 23 | /// Determines which handlers are installed to catch errors. These options are 24 | /// only used when targetting MacOS/iOS, all other platforms use the only 25 | /// error handler they support 26 | pub enum InstallOptions { 27 | /// No handlers are registered. This means you won't actually catch any 28 | /// errors at all. 29 | NoHandlers, 30 | /// Registers the exception handler. On Mac, this means that traditional 31 | /// Unix signals will **NOT** be sent, which can interfere with normal 32 | /// operations of your program if it is indeed trying to hook into signal 33 | /// handlers, eg wasmtime. 34 | ExceptionHandler, 35 | /// Registers the signal handler. If the exception handler is not installed 36 | /// this means that exceptions will be turned into normal Unix signals 37 | /// instead, which allows other signal handlers to interoperate with the 38 | /// Breakpad signal handler by just installing themselves **AFTER** 39 | /// the Breakpad signal handler is installed and restoring it when they are 40 | /// finished with their signal handling, allowing Breakpad to continue to 41 | /// catch crash signals when other application signal handlers are not active 42 | SignalHandler, 43 | /// Installs both the ExceptionHandler and SignalHandler, but this has all 44 | /// of the caveats of the ExceptionHandler. 45 | BothHandlers, 46 | } 47 | 48 | pub struct BreakpadHandler { 49 | handler: *mut breakpad_sys::ExceptionHandler, 50 | on_crash: *mut std::ffi::c_void, 51 | } 52 | 53 | #[allow(unsafe_code)] 54 | unsafe impl Send for BreakpadHandler {} 55 | #[allow(unsafe_code)] 56 | unsafe impl Sync for BreakpadHandler {} 57 | 58 | impl BreakpadHandler { 59 | /// Sets up a breakpad handler to catch exceptions/signals, writing out 60 | /// a minidump to the designated directory if a crash occurs. Only one 61 | /// handler can be attached at a time 62 | pub fn attach>( 63 | crash_dir: P, 64 | install_opts: InstallOptions, 65 | on_crash: Box, 66 | ) -> Result { 67 | match HANDLER_ATTACHED.compare_exchange( 68 | false, 69 | true, 70 | atomic::Ordering::Relaxed, 71 | atomic::Ordering::Relaxed, 72 | ) { 73 | Ok(true) | Err(true) => return Err(Error::HandlerAlreadyRegistered), 74 | _ => {} 75 | } 76 | 77 | let on_crash = Box::into_raw(Box::new(on_crash)).cast(); 78 | 79 | #[allow(unsafe_code)] 80 | // SAFETY: Calling into C code :shrug: 81 | unsafe { 82 | let os_str = crash_dir.as_ref().as_os_str(); 83 | 84 | let path: Vec = { 85 | #[cfg(windows)] 86 | { 87 | use std::os::windows::ffi::OsStrExt; 88 | os_str.encode_wide().collect() 89 | } 90 | #[cfg(unix)] 91 | { 92 | use std::os::unix::ffi::OsStrExt; 93 | Vec::from(os_str.as_bytes()) 94 | } 95 | }; 96 | 97 | extern "C" fn crash_callback( 98 | path: *const breakpad_sys::PathChar, 99 | path_len: usize, 100 | ctx: *mut std::ffi::c_void, 101 | ) { 102 | let path_slice = unsafe { std::slice::from_raw_parts(path, path_len) }; 103 | 104 | let path = { 105 | #[cfg(windows)] 106 | { 107 | use std::os::windows::ffi::OsStringExt; 108 | std::path::PathBuf::from(std::ffi::OsString::from_wide(path_slice)) 109 | } 110 | #[cfg(unix)] 111 | { 112 | use std::os::unix::ffi::OsStrExt; 113 | std::path::PathBuf::from(std::ffi::OsStr::from_bytes(path_slice).to_owned()) 114 | } 115 | }; 116 | 117 | let context: Box> = unsafe { Box::from_raw(ctx.cast()) }; 118 | context.on_crash(path); 119 | Box::leak(context); 120 | } 121 | 122 | let install_opts = match install_opts { 123 | InstallOptions::NoHandlers => breakpad_sys::INSTALL_NO_HANDLER, 124 | InstallOptions::ExceptionHandler => breakpad_sys::INSTALL_EXCEPTION_HANDLER, 125 | InstallOptions::SignalHandler => breakpad_sys::INSTALL_SIGNAL_HANDLER, 126 | InstallOptions::BothHandlers => breakpad_sys::INSTALL_BOTH_HANDLERS, 127 | }; 128 | 129 | let handler = breakpad_sys::attach_exception_handler( 130 | path.as_ptr(), 131 | path.len(), 132 | crash_callback, 133 | on_crash, 134 | install_opts, 135 | ); 136 | 137 | Ok(Self { handler, on_crash }) 138 | } 139 | } 140 | } 141 | 142 | impl Drop for BreakpadHandler { 143 | fn drop(&mut self) { 144 | #[allow(unsafe_code)] 145 | // SAFETY: Calling into C code 146 | unsafe { 147 | breakpad_sys::detach_exception_handler(self.handler); 148 | let _: Box> = Box::from_raw(self.on_crash.cast()); 149 | HANDLER_ATTACHED.swap(false, atomic::Ordering::Relaxed); 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /breakpad-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "breakpad-sys" 3 | description = "Wrapper around breakpad's crash detection and minidump writing facilities" 4 | repository = "https://github.com/EmbarkStudios/tame-sentry" 5 | version = "0.2.0" 6 | authors = ["Embark "] 7 | edition = "2021" 8 | # This is the license for a majority of the C++ code, though there are a ton of 9 | # "other" licenses floating around, but it's clear that BSD-3-Clause covers a 10 | # majority of the code that is actually compiled and used 11 | # https://clearlydefined.io/definitions/git/github/google/breakpad/5bba75bfd6ec386b8e3af0b91332388a378135bf 12 | license = "BSD-3-Clause" 13 | documentation = "https://docs.rs/breakpad-sys" 14 | homepage = "https://github.com/EmbarkStudios/sentry-contrib-rust/tree/main/breakpad-sys" 15 | keywords = ["breakpad", "minidump", "crash"] 16 | readme = "README.md" 17 | exclude = [ 18 | "breakpad/.github", 19 | "breakpad/android", 20 | "breakpad/autotools", 21 | "breakpad/docs", 22 | "breakpad/m4", 23 | "breakpad/scripts", 24 | "breakpad/src/build", 25 | "breakpad/src/client/solaris", 26 | "breakpad/src/common/solaris", 27 | "breakpad/src/common/testdata", 28 | "breakpad/src/common/tests", 29 | "breakpad/src/processor", 30 | "breakpad/src/tools", 31 | ] 32 | 33 | [build-dependencies] 34 | cc = { version = "1.0", features = ["parallel"] } 35 | -------------------------------------------------------------------------------- /breakpad-sys/README.md: -------------------------------------------------------------------------------- 1 | # 👁 breakpad-sys 2 | 3 | [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) 4 | [![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS) 5 | [![Crates.io](https://img.shields.io/crates/v/breakpad-sys.svg)](https://crates.io/crates/breakpad-sys) 6 | [![Docs](https://docs.rs/breakpad-sys/badge.svg)](https://docs.rs/breakpad-sys) 7 | [![Build status](https://github.com/EmbarkStudios/sentry-contrib-rust/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/sentry-contrib-rust/actions) 8 | 9 | Rust crate wrapping the crash handling and minidump creation aspects of [Breakpad](https://chromium.googlesource.com/breakpad/breakpad/). This is intended to be a stopgap crate until a [Rust](https://github.com/getsentry/symbolic/issues/375) solution is available. 10 | 11 | ## Contributing 12 | 13 | [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](../CODE_OF_CONDUCT.md) 14 | 15 | We welcome community contributions to this project. 16 | 17 | Please read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started. 18 | 19 | ## License 20 | 21 | Licensed [BSD-3-Clause](breakpad/LICENSE), the same license as the C++ breakpad code itself. 22 | -------------------------------------------------------------------------------- /breakpad-sys/build.rs: -------------------------------------------------------------------------------- 1 | fn add_sources(build: &mut cc::Build, root: &str, files: &[&str]) { 2 | let root = std::path::Path::new(root); 3 | build.files(files.iter().map(|src| { 4 | let mut p = root.join(src); 5 | p.set_extension("cc"); 6 | p 7 | })); 8 | 9 | build.include(root); 10 | } 11 | 12 | fn main() { 13 | let mut build = cc::Build::new(); 14 | 15 | build 16 | .cpp(true) 17 | .warnings(false) 18 | .include(".") 19 | .include("breakpad/src") 20 | .define("BPLOG_MINIMUM_SEVERITY", "SEVERITY_ERROR") 21 | .define( 22 | "BPLOG(severity)", 23 | "1 ? (void)0 : google_breakpad::LogMessageVoidify() & (BPLOG_ERROR)", 24 | ); 25 | 26 | if !build.get_compiler().is_like_msvc() { 27 | build.flag("-std=c++17").flag("-fpermissive"); 28 | } 29 | 30 | // Our file that implements a small C API that we can easily bind to 31 | build.file("src/impl.cpp"); 32 | 33 | add_sources( 34 | &mut build, 35 | "breakpad/src/common", 36 | &["convert_UTF", "string_conversion"], 37 | ); 38 | 39 | build.define("TARGET_OS_WINDOWS", "0"); 40 | 41 | match std::env::var("CARGO_CFG_TARGET_OS") 42 | .expect("TARGET_OS not specified") 43 | .as_str() 44 | { 45 | "linux" | "android" => { 46 | build.define("TARGET_OS_LINUX", None).include("lss"); 47 | 48 | add_sources(&mut build, "breakpad/src/client", &["minidump_file_writer"]); 49 | 50 | add_sources( 51 | &mut build, 52 | "breakpad/src/common/linux", 53 | &[ 54 | "elfutils", 55 | "file_id", 56 | "guid_creator", 57 | "linux_libc_support", 58 | "memory_mapped_file", 59 | "safe_readlink", 60 | ], 61 | ); 62 | 63 | add_sources(&mut build, "breakpad/src/client/linux/log", &["log"]); 64 | 65 | add_sources( 66 | &mut build, 67 | "breakpad/src/client/linux/handler", 68 | &["exception_handler", "minidump_descriptor"], 69 | ); 70 | 71 | add_sources( 72 | &mut build, 73 | "breakpad/src/client/linux/crash_generation", 74 | &["crash_generation_client"], 75 | ); 76 | 77 | add_sources( 78 | &mut build, 79 | "breakpad/src/client/linux/microdump_writer", 80 | &["microdump_writer"], 81 | ); 82 | 83 | add_sources( 84 | &mut build, 85 | "breakpad/src/client/linux/minidump_writer", 86 | &[ 87 | "linux_dumper", 88 | "linux_ptrace_dumper", 89 | "minidump_writer", 90 | "pe_file", 91 | ], 92 | ); 93 | 94 | add_sources( 95 | &mut build, 96 | "breakpad/src/client/linux/dump_writer_common", 97 | &["thread_info", "ucontext_reader"], 98 | ); 99 | } 100 | "windows" => { 101 | build 102 | .define("TARGET_OS_WINDOWS", "1") 103 | .define("UNICODE", None); 104 | 105 | add_sources(&mut build, "breakpad/src/common/windows", &["guid_string"]); 106 | 107 | add_sources( 108 | &mut build, 109 | "breakpad/src/client/windows/crash_generation", 110 | &["crash_generation_client"], 111 | ); 112 | 113 | add_sources( 114 | &mut build, 115 | "breakpad/src/client/windows/handler", 116 | &["exception_handler"], 117 | ); 118 | } 119 | "macos" => { 120 | build.define("TARGET_OS_MAC", None); 121 | 122 | add_sources(&mut build, "breakpad/src/client", &["minidump_file_writer"]); 123 | 124 | add_sources(&mut build, "breakpad/src/common", &["md5"]); 125 | 126 | add_sources( 127 | &mut build, 128 | "breakpad/src/common/mac", 129 | &[ 130 | "arch_utilities", 131 | "file_id", 132 | "macho_id", 133 | "macho_utilities", 134 | "macho_walker", 135 | "string_utilities", 136 | ], 137 | ); 138 | 139 | build.file("breakpad/src/common/mac/MachIPC.mm"); 140 | 141 | add_sources( 142 | &mut build, 143 | "breakpad/src/client/mac/crash_generation", 144 | &["crash_generation_client"], 145 | ); 146 | 147 | add_sources( 148 | &mut build, 149 | "breakpad/src/client/mac/handler", 150 | &[ 151 | "breakpad_nlist_64", 152 | "dynamic_images", 153 | "exception_handler", 154 | "minidump_generator", 155 | "protected_memory_allocator", 156 | ], 157 | ); 158 | 159 | println!("cargo:rustc-link-lib=framework=Foundation"); 160 | } 161 | unsupported => panic!("'{unsupported}' is not a supported target"), 162 | } 163 | 164 | build.compile("breakpad"); 165 | } 166 | -------------------------------------------------------------------------------- /breakpad-sys/examples/handle_crash.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let cur_dir = std::env::current_dir().unwrap(); 3 | let os_str = cur_dir.as_os_str(); 4 | 5 | let path: Vec = { 6 | #[cfg(windows)] 7 | { 8 | use std::os::windows::ffi::OsStrExt; 9 | os_str.encode_wide().collect() 10 | } 11 | #[cfg(unix)] 12 | { 13 | use std::os::unix::ffi::OsStrExt; 14 | Vec::from(os_str.as_bytes()) 15 | } 16 | }; 17 | 18 | #[allow(unsafe_code)] 19 | unsafe { 20 | extern "C" fn callback( 21 | path: *const breakpad_sys::PathChar, 22 | path_len: usize, 23 | _ctx: *mut std::ffi::c_void, 24 | ) { 25 | let path_slice = unsafe { std::slice::from_raw_parts(path, path_len) }; 26 | 27 | let path = { 28 | #[cfg(windows)] 29 | { 30 | use std::os::windows::ffi::OsStringExt; 31 | std::path::PathBuf::from(std::ffi::OsString::from_wide(path_slice)) 32 | } 33 | #[cfg(unix)] 34 | { 35 | use std::os::unix::ffi::OsStrExt; 36 | std::path::PathBuf::from(std::ffi::OsStr::from_bytes(path_slice).to_owned()) 37 | } 38 | }; 39 | 40 | println!("Crashdump written to {}", path.display()); 41 | match std::fs::remove_file(&path) { 42 | Ok(_) => { 43 | println!("Removed {}", path.display()); 44 | } 45 | Err(e) => { 46 | println!("Failed to remove {}: {}", path.display(), e); 47 | } 48 | } 49 | } 50 | 51 | let exc_handler = breakpad_sys::attach_exception_handler( 52 | path.as_ptr(), 53 | path.len(), 54 | callback, 55 | std::ptr::null_mut(), 56 | breakpad_sys::INSTALL_BOTH_HANDLERS, 57 | ); 58 | 59 | if std::env::args().any(|a| a == "--crash") { 60 | let ptr: *mut u8 = std::ptr::null_mut(); 61 | *ptr = 42; 62 | } 63 | 64 | breakpad_sys::detach_exception_handler(exc_handler); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /breakpad-sys/src/impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "exception_handler.h" 5 | 6 | #if TARGET_OS_WINDOWS 7 | #define CHAR_TYPE uint16_t 8 | #else 9 | #define CHAR_TYPE uint8_t 10 | #endif 11 | 12 | // Callback invoked when a minidump occurs. Returns the path + length of the 13 | // minidump file, along with the callback context. 14 | typedef void (*dump_callback)(const CHAR_TYPE*, size_t, void*); 15 | 16 | struct BreakpadContext { 17 | dump_callback callback; 18 | void* callback_ctx; 19 | }; 20 | 21 | struct ExcHandler { 22 | BreakpadContext* bp_ctx; 23 | google_breakpad::ExceptionHandler* handler; 24 | }; 25 | 26 | extern "C" { 27 | ExcHandler* attach_exception_handler( 28 | const CHAR_TYPE* path, 29 | size_t path_len, 30 | dump_callback crash_cb, 31 | void* callback_ctx, 32 | uint32_t install_options 33 | ) { 34 | auto* bp_ctx = new BreakpadContext; 35 | bp_ctx->callback = crash_cb; 36 | bp_ctx->callback_ctx = callback_ctx; 37 | 38 | #if TARGET_OS_WINDOWS 39 | std::wstring dump_path(reinterpret_cast(path), path_len); 40 | 41 | auto crash_callback = []( 42 | const wchar_t* breakpad_dump_path, 43 | const wchar_t* minidump_id, 44 | void* context, 45 | EXCEPTION_POINTERS*, 46 | MDRawAssertionInfo*, 47 | bool succeeded 48 | ) -> bool { 49 | auto* ctx = (BreakpadContext*)context; 50 | 51 | // We have to construct the full path to the minidump file ourselves 52 | google_breakpad::wstring dump_path(breakpad_dump_path); 53 | dump_path.push_back('/'); 54 | dump_path.append(minidump_id); 55 | dump_path.append(L".dmp"); 56 | 57 | ctx->callback( 58 | reinterpret_cast(dump_path.data()), 59 | dump_path.size(), 60 | ctx->callback_ctx 61 | ); 62 | 63 | return succeeded; 64 | }; 65 | 66 | auto* handler = new google_breakpad::ExceptionHandler( 67 | dump_path, // Directory to store the minidump in 68 | nullptr, // Minidump write filter, might be used later 69 | crash_callback, // Callback invoked after the minidump has been written 70 | bp_ctx, // Callback context 71 | google_breakpad::ExceptionHandler::HANDLER_EXCEPTION // Write minidumps when a structured exception occurs 72 | ); 73 | #elif defined(TARGET_OS_MAC) 74 | std::string dump_path(reinterpret_cast(path), path_len); 75 | 76 | auto crash_callback = []( 77 | const char* dump_dir, 78 | const char* minidump_id, 79 | void* context, 80 | bool succeeded 81 | ) -> bool { 82 | auto* ctx = (BreakpadContext*)context; 83 | 84 | std::string dump_path(dump_dir); 85 | dump_path.push_back('/'); 86 | dump_path.append(minidump_id); 87 | dump_path.append(".dmp"); 88 | 89 | ctx->callback( 90 | reinterpret_cast(dump_path.data()), 91 | dump_path.size(), 92 | ctx->callback_ctx 93 | ); 94 | 95 | return succeeded; 96 | }; 97 | 98 | auto* handler = new google_breakpad::ExceptionHandler( 99 | dump_path, // Directory to store the minidump in 100 | nullptr, // Minidump write filter, might be used later 101 | crash_callback, // Callback invoked after the minidump has been written 102 | bp_ctx, // Callback context 103 | static_cast(install_options), // Which handlers to install, ignored on other platforms 104 | nullptr // Don't start a separate process, handle crashes in the same process 105 | ); 106 | #elif defined(TARGET_OS_LINUX) 107 | std::string dump_path(reinterpret_cast(path), path_len); 108 | google_breakpad::MinidumpDescriptor descriptor(dump_path); 109 | 110 | auto crash_callback = []( 111 | const google_breakpad::MinidumpDescriptor& descriptor, 112 | void* context, 113 | bool succeeded 114 | ) -> bool { 115 | auto* ctx = (BreakpadContext*)context; 116 | 117 | auto* dump_path = descriptor.path(); 118 | 119 | ctx->callback( 120 | reinterpret_cast(dump_path), 121 | strlen(dump_path), 122 | ctx->callback_ctx 123 | ); 124 | 125 | return succeeded; 126 | }; 127 | 128 | auto* handler = new google_breakpad::ExceptionHandler( 129 | descriptor, // Decides where to place the minidump file 130 | nullptr, // Minidump write filter, might be used later 131 | crash_callback, // Callback invoked after the minidump has been written 132 | bp_ctx, // Callback context 133 | true, // Actually write minidumps when unhandled signals occur 134 | -1 // Don't start a separate process, handle crashes in the same process 135 | ); 136 | #else 137 | #error "Unknown target platform" 138 | #endif 139 | 140 | auto* exc_handler = new ExcHandler; 141 | exc_handler->bp_ctx = bp_ctx; 142 | exc_handler->handler = handler; 143 | 144 | return exc_handler; 145 | } 146 | 147 | void detach_exception_handler(ExcHandler* handler) { 148 | delete handler->bp_ctx; 149 | delete handler->handler; 150 | delete handler; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /breakpad-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[repr(C)] 2 | pub struct ExceptionHandler { 3 | _unused: [u8; 0], 4 | } 5 | 6 | #[cfg(not(windows))] 7 | pub type PathChar = u8; 8 | #[cfg(windows)] 9 | pub type PathChar = u16; 10 | 11 | pub type CrashCallback = extern "C" fn( 12 | minidump_path: *const PathChar, 13 | minidump_path_len: usize, 14 | ctx: *mut std::ffi::c_void, 15 | ); 16 | 17 | pub const INSTALL_NO_HANDLER: u32 = 0x0; 18 | pub const INSTALL_EXCEPTION_HANDLER: u32 = 0x1; 19 | pub const INSTALL_SIGNAL_HANDLER: u32 = 0x2; 20 | pub const INSTALL_BOTH_HANDLERS: u32 = INSTALL_EXCEPTION_HANDLER | INSTALL_SIGNAL_HANDLER; 21 | 22 | extern "C" { 23 | /// Creates and attaches an exception handler that will monitor this process 24 | /// for crashes 25 | /// 26 | /// Note: The `install_options` only applies on MacOS/iOS, it is ignored 27 | /// for all other platforms. 28 | pub fn attach_exception_handler( 29 | path: *const PathChar, 30 | path_len: usize, 31 | crash_callback: CrashCallback, 32 | crash_callback_ctx: *mut std::ffi::c_void, 33 | install_options: u32, 34 | ) -> *mut ExceptionHandler; 35 | 36 | /// Detaches and frees the exception handler 37 | pub fn detach_exception_handler(handler: *mut ExceptionHandler); 38 | } 39 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | [advisories] 2 | vulnerability = "deny" 3 | unmaintained = "deny" 4 | yanked = "deny" 5 | notice = "deny" 6 | ignore = [] 7 | 8 | [licenses] 9 | allow = ["MIT", "Apache-2.0", "BSD-3-Clause", "Unicode-DFS-2016"] 10 | unlicensed = "deny" 11 | copyleft = "deny" 12 | allow-osi-fsf-free = "neither" 13 | default = "deny" 14 | exceptions = [] 15 | 16 | [bans] 17 | multiple-versions = "deny" 18 | wildcards = "deny" 19 | skip = [] 20 | skip-tree = [] 21 | 22 | [sources] 23 | unknown-registry = "deny" 24 | unknown-git = "deny" 25 | allow-git = [] 26 | 27 | [sources.allow-org] 28 | github = [] 29 | -------------------------------------------------------------------------------- /release.toml: -------------------------------------------------------------------------------- 1 | pre-release-commit-message = "Release {{version}}" 2 | tag-message = "Release {{version}}" 3 | tag-name = "{{version}}" 4 | pre-release-replacements = [ 5 | { file = "CHANGELOG.md", search = "Unreleased", replace = "{{version}}" }, 6 | { file = "CHANGELOG.md", search = "\\.\\.\\.HEAD", replace = "...{{tag_name}}" }, 7 | { file = "CHANGELOG.md", search = "ReleaseDate", replace = "{{date}}" }, 8 | { file = "CHANGELOG.md", search = "", replace = "\n## [Unreleased] - ReleaseDate" }, 9 | { file = "CHANGELOG.md", search = "", replace = "\n[Unreleased]: https://github.com/EmbarkStudios/sentry-contrib-rust/compare/{{tag_name}}...HEAD" }, 10 | ] 11 | 12 | # cargo-release only allows using {{version}} in the commit title when creating one 13 | # commit across all released packages in this workspace (we only release one package 14 | # though), or by using the same version for all packages. 15 | # https://github.com/crate-ci/cargo-release/issues/540#issuecomment-1328769105 16 | # https://github.com/crate-ci/cargo-release/commit/3af94caa4b9bbee010a5cf3f196cc4afffbaf192 17 | consolidate-commits = false 18 | shared-version = true 19 | -------------------------------------------------------------------------------- /src/breakpad_integration.rs: -------------------------------------------------------------------------------- 1 | use sentry_core::protocol as proto; 2 | use std::{path::Path, time::SystemTime}; 3 | 4 | pub use breakpad_handler::InstallOptions; 5 | 6 | /// Monitors the current process for crashes, writing them to disk as minidumps 7 | /// and reporting the crash event to Sentry. 8 | pub struct BreakpadIntegration { 9 | crash_handler: Option, 10 | } 11 | 12 | impl BreakpadIntegration { 13 | /// Creates a new Breakpad Integration, note that only *one* can exist 14 | /// in the application at a time! 15 | pub fn new( 16 | crash_dir: impl AsRef, 17 | install_options: InstallOptions, 18 | hub: std::sync::Arc, 19 | ) -> Result { 20 | // The paths generated by breakpad are just guids with an extension so they 21 | // are utf-8 safe, however, due to how we pass the path via metadata 22 | // to the transport, we require that the root crash path is also utf-8 23 | if crash_dir.as_ref().to_str().is_none() { 24 | return Err(crate::Error::NonUtf8Path(crash_dir.as_ref().to_owned())); 25 | } 26 | 27 | // Ensure the directory exists, breakpad should do this when writing crashdumps 28 | // anyway, but then again, it's C++ code, so I have low trust 29 | std::fs::create_dir_all(&crash_dir)?; 30 | 31 | let crash_hub = std::sync::Arc::downgrade(&hub); 32 | let crash_handler = breakpad_handler::BreakpadHandler::attach( 33 | &crash_dir, 34 | install_options, 35 | Box::new(move |minidump_path: std::path::PathBuf| { 36 | if let Some(crash_hub) = crash_hub.upgrade() { 37 | // We **don't** do end_session_with_status as it just 38 | // immediately takes the session from the scope and sends it, 39 | // but we want to send the event, session update, and minidump 40 | // all in the same event 41 | // crash_hub.end_session_with_status(protocol::SessionStatus::Crashed); 42 | 43 | let mut extra = std::collections::BTreeMap::new(); 44 | // We should never get here unless the path is valid utf-8, so this is fine 45 | extra.insert( 46 | "__breakpad_minidump_path".to_owned(), 47 | minidump_path 48 | .to_str() 49 | .expect("utf-8 path") 50 | .to_owned() 51 | .into(), 52 | ); 53 | 54 | // Create an event for crash so that we can add all of the context 55 | // we can to it, the important information like stack traces/threads 56 | // modules/etc is contained in the minidump recorded by breakpad 57 | let event = proto::Event { 58 | level: proto::Level::Fatal, 59 | // We want to set the timestamp here since we aren't actually 60 | // going to send the crash directly, but rather the next time 61 | // this integration is initialized 62 | timestamp: SystemTime::now(), 63 | // This is the easiest way to indicate a session crash update 64 | // in the same envelope with the crash itself. :p 65 | exception: vec![proto::Exception { 66 | mechanism: Some(proto::Mechanism { 67 | handled: Some(false), 68 | ..Default::default() 69 | }), 70 | ..Default::default() 71 | }] 72 | .into(), 73 | extra, 74 | ..Default::default() 75 | }; 76 | 77 | crash_hub.capture_event(event); 78 | 79 | if let Some(client) = crash_hub.client() { 80 | client.close(None); 81 | } 82 | } 83 | }), 84 | )?; 85 | 86 | let crash_dir = crash_dir.as_ref().to_owned(); 87 | 88 | Self::upload_minidumps(&crash_dir, &hub); 89 | 90 | Ok(Self { 91 | crash_handler: Some(crash_handler), 92 | }) 93 | } 94 | 95 | /// Called during startup to send any minidumps + metadata that have been 96 | /// captured in previous sessions but (seem to) have not been sent yet 97 | fn upload_minidumps(crash_dir: &Path, hub: &sentry_core::Hub) { 98 | // Scan the directory the integration was initialized with to find any 99 | // envelopes that have been serialized to disk and send + delete them 100 | let rd = match std::fs::read_dir(crash_dir) { 101 | Ok(rd) => rd, 102 | Err(e) => { 103 | debug_print!( 104 | "Unable to read crash directory '{}': {}", 105 | crash_dir.display(), 106 | e 107 | ); 108 | return; 109 | } 110 | }; 111 | 112 | let client = match hub.client() { 113 | Some(c) => c, 114 | None => return, 115 | }; 116 | 117 | // The minidumps are what we care about the most, but of course, the 118 | // metadata that we (hopefully) were able to capture along with the crash 119 | for entry in rd.filter_map(|e| e.ok()) { 120 | if entry 121 | .file_name() 122 | .to_str() 123 | .map_or(true, |s| !s.ends_with(".dmp")) 124 | { 125 | continue; 126 | } 127 | 128 | let mut minidump_path = entry.path(); 129 | minidump_path.set_extension("metadata"); 130 | 131 | let md = crate::shared::CrashMetadata::deserialize(&minidump_path); 132 | if let Err(e) = std::fs::remove_file(&minidump_path) { 133 | debug_print!("failed to remove {}: {}", minidump_path.display(), e); 134 | } 135 | 136 | minidump_path.set_extension("dmp"); 137 | 138 | let envelope = crate::shared::assemble_envelope(md, &minidump_path); 139 | if let Err(e) = std::fs::remove_file(&minidump_path) { 140 | debug_print!("failed to remove {}: {}", minidump_path.display(), e); 141 | } 142 | 143 | client.send_envelope(envelope); 144 | } 145 | } 146 | 147 | #[inline] 148 | pub fn inner_handler(&self) -> &Option { 149 | &self.crash_handler 150 | } 151 | } 152 | 153 | impl Drop for BreakpadIntegration { 154 | fn drop(&mut self) { 155 | let _ = self.crash_handler.take(); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | #[derive(Debug)] 4 | pub enum Error { 5 | Handler(breakpad_handler::Error), 6 | Io(std::io::Error), 7 | /// Paths in some cases are required to be utf-8 compatible 8 | NonUtf8Path(std::path::PathBuf), 9 | } 10 | 11 | impl std::error::Error for Error { 12 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { 13 | match self { 14 | Self::Handler(e) => Some(e), 15 | Self::Io(e) => Some(e), 16 | Self::NonUtf8Path(_) => None, 17 | } 18 | } 19 | } 20 | 21 | impl fmt::Display for Error { 22 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 23 | match self { 24 | Self::Handler(e) => write!(f, "handler error: {}", e), 25 | Self::Io(e) => write!(f, "io error: {}", e), 26 | Self::NonUtf8Path(p) => write!(f, "{} is not a utf-8 path", p.display()), 27 | } 28 | } 29 | } 30 | 31 | impl From for Error { 32 | fn from(e: breakpad_handler::Error) -> Self { 33 | Self::Handler(e) 34 | } 35 | } 36 | 37 | impl From for Error { 38 | fn from(e: std::io::Error) -> Self { 39 | Self::Io(e) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Capture and report minidumps to [Sentry](https://sentry.io/about/) 2 | //! 3 | //! 1. Create a [`BreakpadTransportFactory`] for [`ClientOptions::transport`](https://docs.rs/sentry-core/0.23.0/sentry_core/struct.ClientOptions.html#structfield.transport) 4 | //! , providing it with the [`TransportFactory`](https://docs.rs/sentry-core/0.23.0/sentry_core/trait.TransportFactory.html) 5 | //! you were previously using. 6 | //! 2. Initialize a Sentry [`Hub`](https://docs.rs/sentry-core/0.23.0/sentry_core/struct.Hub.html). 7 | //! 3. Create the [`BreakpadIntegration`] which will attach a crash handler and 8 | //! send any previous crashes that are in the crash directoy specified. 9 | 10 | macro_rules! debug_print { 11 | ($($arg:tt)*) => { 12 | #[cfg(feature = "debug-logs")] 13 | { 14 | eprintln!("[bp] {}", format_args!($($arg)*)); 15 | } 16 | #[cfg(not(feature = "debug-logs"))] 17 | { 18 | let _ = format_args!($($arg)*); 19 | } 20 | } 21 | } 22 | 23 | mod breakpad_integration; 24 | mod error; 25 | mod shared; 26 | mod transport; 27 | 28 | pub use breakpad_integration::{BreakpadIntegration, InstallOptions}; 29 | pub use error::Error; 30 | pub use transport::{BreakpadTransportFactory, CrashSendStyle}; 31 | -------------------------------------------------------------------------------- /src/shared.rs: -------------------------------------------------------------------------------- 1 | use sentry_core::{protocol as proto, types}; 2 | use std::{path::Path, time::SystemTime}; 3 | 4 | pub(crate) fn assemble_envelope(md: CrashMetadata, minidump_path: &Path) -> proto::Envelope { 5 | let mut envelope = proto::Envelope::new(); 6 | 7 | let timestamp = md 8 | .event 9 | .as_ref() 10 | .map(|eve| eve.timestamp) 11 | .or_else(|| { 12 | minidump_path 13 | .metadata() 14 | .ok() 15 | .and_then(|md| md.created().ok()) 16 | }) 17 | .unwrap_or_else(SystemTime::now); 18 | 19 | // An event_id is required, so if we were unable to get one from the .metadata 20 | // we just use the guid in the filename of the minidump 21 | envelope.add_item(md.event.unwrap_or_else(|| { 22 | proto::Event { 23 | event_id: minidump_path 24 | .file_stem() 25 | .and_then(|fname| fname.to_str().and_then(|fs| fs.parse::().ok())) 26 | .unwrap_or_else(types::random_uuid), 27 | level: proto::Level::Fatal, 28 | timestamp, 29 | ..Default::default() 30 | } 31 | })); 32 | 33 | // Unfortunately we can't really synthesize this with the current API as, 34 | // among other things, the session id is not exposed anywhere :-/ 35 | if let Some(su) = md.session_update { 36 | envelope.add_item(su); 37 | } 38 | 39 | match std::fs::read(minidump_path) { 40 | Err(e) => { 41 | debug_print!( 42 | "unable to read minidump from '{}': {}", 43 | minidump_path.display(), 44 | e 45 | ); 46 | } 47 | Ok(minidump) => { 48 | envelope.add_item(proto::EnvelopeItem::Attachment(proto::Attachment { 49 | buffer: minidump, 50 | filename: minidump_path.file_name().unwrap().to_string_lossy().into(), 51 | content_type: Some("application/octet-stream".to_owned()), 52 | ty: Some(proto::AttachmentType::Minidump), 53 | })); 54 | } 55 | } 56 | 57 | envelope 58 | } 59 | 60 | pub(crate) struct CrashMetadata { 61 | pub(crate) event: Option>, 62 | pub(crate) session_update: Option>, 63 | } 64 | 65 | impl CrashMetadata { 66 | pub(crate) fn deserialize(path: &Path) -> Self { 67 | if !path.exists() { 68 | return Self { 69 | event: None, 70 | session_update: None, 71 | }; 72 | } 73 | 74 | let contents = match std::fs::read_to_string(path) { 75 | Ok(contents) => { 76 | // Immediately remove the file so we don't try to do this again 77 | let _ = std::fs::remove_file(path); 78 | contents 79 | } 80 | Err(e) => { 81 | debug_print!( 82 | "unable to read crash metadata from '{}': {}", 83 | path.display(), 84 | e 85 | ); 86 | return Self { 87 | event: None, 88 | session_update: None, 89 | }; 90 | } 91 | }; 92 | 93 | let mut lines = contents.lines(); 94 | 95 | let event = lines.next().and_then(|eve| { 96 | if !eve.is_empty() { 97 | match serde_json::from_str::>(eve) { 98 | Ok(event) => Some(event), 99 | Err(e) => { 100 | debug_print!("unable to deserialize Event: {}", e); 101 | None 102 | } 103 | } 104 | } else { 105 | None 106 | } 107 | }); 108 | 109 | let session_update = lines.next().and_then(|su| { 110 | if !su.is_empty() { 111 | match serde_json::from_str::>(su) { 112 | Ok(sess) => Some(sess), 113 | Err(e) => { 114 | debug_print!("unable to deserialize SessionUpdate: {}", e); 115 | None 116 | } 117 | } 118 | } else { 119 | None 120 | } 121 | }); 122 | 123 | Self { 124 | event, 125 | session_update, 126 | } 127 | } 128 | 129 | pub(crate) fn serialize(self) -> Vec { 130 | use std::io::Write; 131 | 132 | let mut md = Vec::with_capacity(2048); 133 | 134 | // Serialize the envelope then the session update to their own JSON line 135 | if let Some(eve) = self.event { 136 | debug_print!("serializing event to metadata"); 137 | if let Err(e) = serde_json::to_writer(&mut md, &eve) { 138 | debug_print!("failed to serialize event to crash metadata: {}", e); 139 | } 140 | } 141 | 142 | let _ = writeln!(&mut md); 143 | 144 | if let Some(su) = self.session_update { 145 | debug_print!("serializing session update to metadata"); 146 | if let Err(e) = serde_json::to_writer(&mut md, &su) { 147 | debug_print!( 148 | "failed to serialize session update to crash metadata: {}", 149 | e 150 | ); 151 | } 152 | } 153 | 154 | let _ = writeln!(&mut md); 155 | md 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/transport.rs: -------------------------------------------------------------------------------- 1 | use sentry_core::{ClientOptions, Envelope, Transport, TransportFactory}; 2 | use std::{sync::Arc, time::Duration}; 3 | 4 | /// Determines how crashes are sent to Sentry after they have been captured. 5 | #[derive(Copy, Clone)] 6 | pub enum CrashSendStyle { 7 | /// Attempts to send crash envelopes immediately, in the same session that 8 | /// crashed, which may be unreliable depending on the overall state of the 9 | /// session. Use with care. 10 | SendImmediately, 11 | /// Serializes the envelope to disk instead of forwarding it to the final 12 | /// [`Transport`], initializing the BreakpadIntegration with the same path 13 | /// for crashes will send any existing crashes from previous sessions. 14 | SendNextSession, 15 | } 16 | 17 | /// The [`TransportFactory`](https://docs.rs/sentry-core/0.23.0/sentry_core/trait.TransportFactory.html) implementation that must be used in concert with 18 | /// [`BreakpadIntegration`](crate::BreakpadIntegration) to report crash events to 19 | /// Sentry 20 | pub struct BreakpadTransportFactory { 21 | inner: Arc, 22 | style: CrashSendStyle, 23 | } 24 | 25 | impl BreakpadTransportFactory { 26 | pub fn new(style: CrashSendStyle, transport: Arc) -> Self { 27 | Self { 28 | style, 29 | inner: transport, 30 | } 31 | } 32 | } 33 | 34 | impl TransportFactory for BreakpadTransportFactory { 35 | fn create_transport(&self, options: &ClientOptions) -> Arc { 36 | Arc::new(BreakpadTransport { 37 | inner: self.inner.create_transport(options), 38 | style: self.style, 39 | }) 40 | } 41 | } 42 | 43 | struct BreakpadTransport { 44 | inner: Arc, 45 | style: CrashSendStyle, 46 | } 47 | 48 | impl BreakpadTransport { 49 | fn process(&self, envelope: Envelope) -> Option { 50 | use sentry_core::protocol as proto; 51 | 52 | match envelope.event() { 53 | // Check if this is actually a crash event 54 | Some(eve) if !eve.extra.contains_key("__breakpad_minidump_path") => Some(envelope), 55 | None => Some(envelope), 56 | Some(eve) => { 57 | let mut event = eve.clone(); 58 | 59 | // Clear the exceptions array, Sentry will automatically fill this 60 | // in for the event due to it having a minidump attachment 61 | event.exception.values.clear(); 62 | 63 | let mut minidump_path = match event.extra.remove("__breakpad_minidump_path") { 64 | Some(sentry_core::protocol::Value::String(s)) => std::path::PathBuf::from(s), 65 | other => unreachable!( 66 | "__breakpad_minidump_path should be a String, but was {:?}", 67 | other 68 | ), 69 | }; 70 | 71 | let session_update = envelope.items().find_map(|ei| match ei { 72 | proto::EnvelopeItem::SessionUpdate(su) => { 73 | let mut su = su.clone(); 74 | su.status = proto::SessionStatus::Crashed; 75 | 76 | Some(su) 77 | } 78 | _ => None, 79 | }); 80 | 81 | let md = crate::shared::CrashMetadata { 82 | event: Some(event), 83 | session_update, 84 | }; 85 | 86 | match self.style { 87 | CrashSendStyle::SendImmediately => { 88 | let envelope = crate::shared::assemble_envelope(md, &minidump_path); 89 | 90 | if let Err(e) = std::fs::remove_file(&minidump_path) { 91 | debug_print!( 92 | "failed to remove crashdump {}: {}", 93 | minidump_path.display(), 94 | e 95 | ); 96 | } 97 | 98 | Some(envelope) 99 | } 100 | CrashSendStyle::SendNextSession => { 101 | let serialized = md.serialize(); 102 | 103 | minidump_path.set_extension("metadata"); 104 | if let Err(e) = std::fs::write(&minidump_path, serialized) { 105 | debug_print!( 106 | "failed to write crash metadata {}: {}", 107 | minidump_path.display(), 108 | e 109 | ); 110 | } 111 | 112 | None 113 | } 114 | } 115 | } 116 | } 117 | } 118 | } 119 | 120 | impl Transport for BreakpadTransport { 121 | fn send_envelope(&self, envelope: Envelope) { 122 | if let Some(envelope) = self.process(envelope) { 123 | self.inner.send_envelope(envelope); 124 | } 125 | } 126 | 127 | fn flush(&self, timeout: Duration) -> bool { 128 | self.inner.flush(timeout) 129 | } 130 | 131 | fn shutdown(&self, timeout: Duration) -> bool { 132 | self.inner.shutdown(timeout) 133 | } 134 | } 135 | --------------------------------------------------------------------------------