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

feat: Add Windows support to debug-images #366

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sentry-core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Session {
pub fn from_stack(stack: &StackLayer) -> Option<Self> {
let client = stack.client.as_ref()?;
let options = client.options();
let user = stack.scope.user.as_ref();
let user = stack.scope.user.as_deref();
let distinct_id = user
.and_then(|user| {
user.id
Expand Down
2 changes: 1 addition & 1 deletion sentry-debug-images/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ edition = "2018"
[dependencies]
sentry-core = { version = "0.23.0", path = "../sentry-core" }
lazy_static = "1.4.0"
findshlibs = "0.8.0"
findshlibs = "0.9.0"
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::env;

use sentry_core::protocol::debugid::DebugId;
use sentry_core::protocol::{DebugImage, SymbolicDebugImage};
use sentry_core::types::Uuid;
use sentry_core::types::{CodeId, DebugId, Uuid};

use findshlibs::{SharedLibrary, SharedLibraryId, TargetSharedLibrary, TARGET_SUPPORTED};

Expand Down Expand Up @@ -40,9 +39,11 @@ pub fn debug_images() -> Vec<DebugImage> {
}

TargetSharedLibrary::each(|shlib| {
let maybe_debug_id = shlib.id().and_then(|id| match id {
let maybe_debug_id = shlib.debug_id().and_then(|id| match id {
SharedLibraryId::Uuid(bytes) => Some(DebugId::from_uuid(Uuid::from_bytes(bytes))),
SharedLibraryId::GnuBuildId(ref id) => debug_id_from_build_id(id),
SharedLibraryId::PdbSignature(guid, age) => DebugId::from_guid_age(&guid, age).ok(),
_ => None,
});

let debug_id = match maybe_debug_id {
Expand All @@ -57,14 +58,19 @@ pub fn debug_images() -> Vec<DebugImage> {
.unwrap_or_else(|_| "<main>".to_string());
}

let code_id = shlib.id().map(|id| CodeId::new(format!("{}", id)));
let debug_name = shlib.debug_name().map(|n| n.to_string_lossy().to_string());

images.push(
SymbolicDebugImage {
id: debug_id,
name,
arch: None,
image_addr: shlib.actual_load_addr().0.into(),
image_size: shlib.len() as u64,
image_vmaddr: shlib.stated_load_addr().0.into(),
id: debug_id,
code_id,
debug_file: debug_name,
}
.into(),
);
Expand Down
13 changes: 2 additions & 11 deletions sentry-debug-images/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,8 @@
#![warn(missing_docs)]
#![deny(unsafe_code)]

#[cfg(unix)]
mod unix;

#[cfg(unix)]
use unix::debug_images;

#[cfg(not(unix))]
fn debug_images() -> Vec<sentry_core::protocol::DebugImage> {
vec![]
}

mod images;
mod integration;

use images::debug_images;
pub use integration::DebugImagesIntegration;
11 changes: 9 additions & 2 deletions sentry-types/src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::net::{AddrParseError, IpAddr};
use std::ops;
use std::str;

use ::debugid::DebugId;
use ::debugid::{CodeId, DebugId};
use chrono::{DateTime, Utc};
use serde::Serializer;
use serde::{Deserialize, Serialize};
Expand All @@ -40,7 +40,7 @@ pub mod map {

/// Represents a debug ID.
pub mod debugid {
pub use debugid::{BreakpadFormat, DebugId, ParseDebugIdError};
pub use debugid::{BreakpadFormat, CodeId, DebugId, ParseDebugIdError};
}

/// An arbitrary (JSON) value.
Expand Down Expand Up @@ -987,6 +987,13 @@ pub struct SymbolicDebugImage {
pub image_vmaddr: Addr,
/// The unique debug id of the image.
pub id: DebugId,

/// Identifier of the executable file.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code_id: Option<CodeId>,
/// Name / File of the debug file.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub debug_file: Option<String>,
}

/// Represents a proguard mapping file reference.
Expand Down
2 changes: 2 additions & 0 deletions sentry-types/tests/test_protocol_v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ mod test_debug_meta {
image_size: 4096,
image_vmaddr: 32768.into(),
id: "494f3aea-88fa-4296-9644-fa8ef5d139b6-1234".parse().unwrap(),
code_id: None,
debug_file: None,
}
.into(),
v7::ProguardDebugImage {
Expand Down