Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gleocadie committed Feb 4, 2025
1 parent 9192ea1 commit 5d0dbee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions crashtracker-ffi/src/crash_info/sig_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
// SPDX-License-Identifier: Apache-2.0

use datadog_crashtracker::{SiCodes, SignalNames};
use ddcommon_ffi::ToHexStr;
use ddcommon_ffi::{slice::AsBytes, CharSlice};

#[repr(C)]
pub struct SigInfo {
pub addr: usize,
pub struct SigInfo<'a> {
pub addr: CharSlice<'a>,
pub code: libc::c_int,
pub code_human_readable: SiCodes,
pub signo: libc::c_int,
pub signo_human_readable: SignalNames,
}

impl TryFrom<SigInfo> for datadog_crashtracker::SigInfo {
impl<'a> TryFrom<SigInfo<'a>> for datadog_crashtracker::SigInfo {
type Error = anyhow::Error;
fn try_from(value: SigInfo) -> anyhow::Result<Self> {
fn try_from(value: SigInfo<'a>) -> anyhow::Result<Self> {
Ok(Self {
si_addr: Some(value.addr.to_hex_str()),
si_addr: value.addr.try_to_string_option()?,
si_code: value.code,
si_code_human_readable: value.code_human_readable,
si_signo: value.signo,
Expand Down
1 change: 0 additions & 1 deletion crashtracker/src/crash_info/stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ impl StackFrame {
pub enum BuildIdType {
GNU,
GO,
PDB,
PE,
SHA1,
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ffi/crashinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void add_windows_style_frame(ddog_crasht_Handle_StackTrace* stacktrace) {
ddog_crasht_StackFrame_with_build_id(pbd_frame.get(), to_slice_c_char("abcdef12345")),
"failed to add build id");
check_result(
ddog_crasht_StackFrame_with_build_id_type(pbd_frame.get(), DDOG_CRASHT_BUILD_ID_TYPE_PDB),
ddog_crasht_StackFrame_with_build_id_type(pbd_frame.get(), DDOG_CRASHT_BUILD_ID_TYPE_PE),
"failed to add build id type");
check_result(ddog_crasht_StackFrame_with_file_type(pbd_frame.get(), DDOG_CRASHT_FILE_TYPE_PDB),
"failed to add file type");
Expand Down Expand Up @@ -242,7 +242,7 @@ int main(void) {
"Failed to set os_info");

auto sigInfo = ddog_crasht_SigInfo {
.addr = 0XBABEF00D,
.addr = "0xBABEF00D",
.code = 16,
.code_human_readable = DDOG_CRASHT_SI_CODES_UNKNOWN,
.signo = -1,
Expand Down

0 comments on commit 5d0dbee

Please sign in to comment.