Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[crashtracker] Add builder class for CrashInfo #752

Merged
merged 38 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
175369a
[crashtracker] Add builder class for CrashInfo
danielsn Nov 20, 2024
8c2b85c
wrap macro
danielsn Nov 21, 2024
55d6bc8
use the wrap macro more
danielsn Nov 22, 2024
5c36e01
stacktrace
danielsn Nov 22, 2024
cdf4b49
stackframe
danielsn Nov 22, 2024
807e500
moved wrap function to common
danielsn Nov 25, 2024
6f11b73
more functions implemented
danielsn Nov 25, 2024
535f3a1
actually add the files
danielsn Nov 25, 2024
4cdc684
Merge branch 'main' into dsn/crashinfo-builder
danielsn Nov 27, 2024
7946573
Fixup after merge
danielsn Nov 27, 2024
08aaac5
more builder functions
danielsn Dec 3, 2024
5a61c46
with_thread
danielsn Dec 3, 2024
fb719dd
siginfo
danielsn Dec 3, 2024
924637a
all builder implemented
danielsn Dec 3, 2024
d5000dc
Add handle type, and use it
danielsn Dec 4, 2024
e5c7032
make handle.take() a little nicer
danielsn Dec 4, 2024
00ae5ea
sharpen the wrapper macros
danielsn Dec 4, 2024
5969cb0
add to_endpoint functions
danielsn Dec 4, 2024
c747f5f
normalizer
danielsn Dec 4, 2024
e1d6cd7
resolve names
danielsn Dec 5, 2024
525dbce
make the builder consistently return a result
danielsn Dec 5, 2024
5c0a8ad
make crashtracker.c compile
danielsn Dec 5, 2024
5ce5a12
example works, need to add a stack trace
danielsn Dec 6, 2024
f5517b5
extract result macro
danielsn Dec 6, 2024
31e9f84
nicer macros for extract result
danielsn Dec 6, 2024
8c5ae52
stacktrace in example
danielsn Dec 6, 2024
58e1e42
finished C++ example
danielsn Dec 6, 2024
53fb044
Merge branch 'main' into dsn/crashinfo-builder
danielsn Dec 6, 2024
dd8a7db
os_info
danielsn Dec 6, 2024
b36c3c0
licence
danielsn Dec 6, 2024
6cffa8c
headers
danielsn Dec 6, 2024
7786116
blazesym is only for unix
danielsn Dec 6, 2024
48c29be
more cfg unix
danielsn Dec 6, 2024
7e79d85
format
danielsn Dec 6, 2024
d83b284
even more cfg unix
danielsn Dec 6, 2024
954a577
unix
danielsn Dec 6, 2024
6bbefaf
hopefully the last unix move:
danielsn Dec 6, 2024
4c58d32
EXTRACT_RESULT that heap allocates
danielsn Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 36 additions & 1 deletion LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11238,6 +11238,41 @@ third_party_libraries:
DEALINGS IN THE SOFTWARE.
- license: Apache-2.0
text: " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\nEND OF TERMS AND CONDITIONS\n\nAPPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\nCopyright [yyyy] [name of copyright owner]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
- package_name: function_name
package_version: 0.3.0
repository: https://github.com/danielhenrymantilla/rust-function_name
license: MIT
licenses:
- license: MIT
text: |
MIT License

Copyright (c) 2019 Daniel Henry-Mantilla

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- package_name: function_name-proc-macro
package_version: 0.3.0
repository: https://github.com/danielhenrymantilla/rust-function_name
license: MIT
licenses:
- license: MIT
text: NOT FOUND
- package_name: futures
package_version: 0.3.31
repository: https://github.com/rust-lang/futures-rs
Expand Down Expand Up @@ -15890,7 +15925,7 @@ third_party_libraries:
- license: MIT
text: NOT FOUND
- package_name: libc
package_version: 0.2.161
package_version: 0.2.167
repository: https://github.com/rust-lang/libc
license: MIT OR Apache-2.0
licenses:
Expand Down
2 changes: 2 additions & 0 deletions crashtracker-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ ddcommon-ffi = { path = "../ddcommon-ffi", default-features = false }
hyper = {version = "0.14", features = ["backports", "deprecated"], default-features = false}
symbolic-demangle = { version = "12.8.0", default-features = false, features = ["rust", "cpp", "msvc"], optional = true }
symbolic-common = { version = "12.8.0", default-features = false, optional = true }
function_name = "0.3.0"
libc = "0.2.167"
1 change: 1 addition & 0 deletions crashtracker-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ renaming_overrides_prefixing = true
"Timespec" = "ddog_Timespec"
"Vec_Tag" = "ddog_Vec_Tag"
"Vec_U8" = "ddog_Vec_U8"
"VoidResult" = "ddog_VoidResult"

[export.mangle]
rename_types = "PascalCase"
Expand Down
8 changes: 4 additions & 4 deletions crashtracker-ffi/src/collector/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use super::datatypes::OpTypes;
use crate::Result;
use anyhow::Context;
use ddcommon_ffi::VoidResult;

/// Resets all counters to 0.
/// Expected to be used after a fork, to reset the counters on the child
Expand All @@ -15,7 +15,7 @@ use anyhow::Context;
/// No safety concerns.
#[no_mangle]
#[must_use]
pub unsafe extern "C" fn ddog_crasht_reset_counters() -> Result {
pub unsafe extern "C" fn ddog_crasht_reset_counters() -> VoidResult {
datadog_crashtracker::reset_counters()
.context("ddog_crasht_reset_counters failed")
.into()
Expand All @@ -28,7 +28,7 @@ pub unsafe extern "C" fn ddog_crasht_reset_counters() -> Result {
///
/// # Safety
/// No safety concerns.
pub unsafe extern "C" fn ddog_crasht_begin_op(op: OpTypes) -> Result {
pub unsafe extern "C" fn ddog_crasht_begin_op(op: OpTypes) -> VoidResult {
datadog_crashtracker::begin_op(op)
.context("ddog_crasht_begin_op failed")
.into()
Expand All @@ -41,7 +41,7 @@ pub unsafe extern "C" fn ddog_crasht_begin_op(op: OpTypes) -> Result {
///
/// # Safety
/// No safety concerns.
pub unsafe extern "C" fn ddog_crasht_end_op(op: OpTypes) -> Result {
pub unsafe extern "C" fn ddog_crasht_end_op(op: OpTypes) -> VoidResult {
datadog_crashtracker::end_op(op)
.context("ddog_crasht_end_op failed")
.into()
Expand Down
18 changes: 7 additions & 11 deletions crashtracker-ffi/src/collector/datatypes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use crate::option_from_char_slice;
pub use datadog_crashtracker::{OpTypes, StacktraceCollection};
use ddcommon::Endpoint;
use ddcommon_ffi::slice::{AsBytes, CharSlice};
Expand Down Expand Up @@ -30,23 +29,20 @@ impl<'a> TryFrom<ReceiverConfig<'a>> for datadog_crashtracker::CrashtrackerRecei
let args = {
let mut vec = Vec::with_capacity(value.args.len());
for x in value.args.iter() {
vec.push(x.try_to_utf8()?.to_string());
vec.push(x.try_to_string()?);
}
vec
};
let env = {
let mut vec = Vec::with_capacity(value.env.len());
for x in value.env.iter() {
vec.push((
x.key.try_to_utf8()?.to_string(),
x.val.try_to_utf8()?.to_string(),
));
vec.push((x.key.try_to_string()?, x.val.try_to_string()?));
}
vec
};
let path_to_receiver_binary = value.path_to_receiver_binary.try_to_utf8()?.to_string();
let stderr_filename = option_from_char_slice(value.optional_stderr_filename)?;
let stdout_filename = option_from_char_slice(value.optional_stdout_filename)?;
let path_to_receiver_binary = value.path_to_receiver_binary.try_to_string()?;
let stderr_filename = value.optional_stderr_filename.try_to_string_option()?;
let stdout_filename = value.optional_stdout_filename.try_to_string_option()?;
Self::new(
args,
env,
Expand Down Expand Up @@ -80,7 +76,7 @@ impl<'a> TryFrom<Config<'a>> for datadog_crashtracker::CrashtrackerConfiguration
let additional_files = {
let mut vec = Vec::with_capacity(value.additional_files.len());
for x in value.additional_files.iter() {
vec.push(x.try_to_utf8()?.to_string());
vec.push(x.try_to_string()?);
}
vec
};
Expand All @@ -89,7 +85,7 @@ impl<'a> TryFrom<Config<'a>> for datadog_crashtracker::CrashtrackerConfiguration
let endpoint = value.endpoint.cloned();
let resolve_frames = value.resolve_frames;
let timeout_ms = value.timeout_ms;
let unix_socket_path = option_from_char_slice(value.optional_unix_socket_filename)?;
let unix_socket_path = value.optional_unix_socket_filename.try_to_string_option()?;
Self::new(
additional_files,
create_alt_stack,
Expand Down
Loading
Loading