Skip to content

Commit

Permalink
Merge pull request #387 from mstange/symbol-download-improvements
Browse files Browse the repository at this point in the history
Symbol download improvements
  • Loading branch information
mstange authored Oct 15, 2024
2 parents 14614b7 + c28f499 commit 8c486e0
Show file tree
Hide file tree
Showing 22 changed files with 1,160 additions and 712 deletions.
3 changes: 1 addition & 2 deletions fxprof-processed-profile/src/markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use serde::ser::{SerializeMap, SerializeSeq};
use serde::Serialize;
use serde_derive::Serialize;

use crate::{CategoryHandle, Profile};

use super::profile::StringHandle;
use super::timestamp::Timestamp;
use crate::{CategoryHandle, Profile};

/// The handle for a marker. Returned from [`Profile::add_marker`].
///
Expand Down
4 changes: 2 additions & 2 deletions samply/src/linux_shared/kernel_symbols.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;
use std::fmt::Debug;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::{fmt::Debug, path::PathBuf};

use fxprof_processed_profile::{Symbol, SymbolTable};
use object::{elf, read, NativeEndian, Object};
Expand Down
3 changes: 2 additions & 1 deletion samply/src/mac/codesign_setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{env, io::Write};
use std::env;
use std::io::Write;

const ENTITLEMENTS_XML: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down
3 changes: 1 addition & 2 deletions samply/src/mac/process_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ use mach::task::{task_resume, task_suspend};
use mach::traps::task_for_pid;
use tempfile::tempdir;

use crate::shared::ctrl_c::CtrlC;

pub use super::mach_ipc::{mach_port_t, MachError, OsIpcSender};
use super::mach_ipc::{mach_task_self, BlockingMode, OsIpcMultiShotServer, MACH_PORT_NULL};
use crate::shared::ctrl_c::CtrlC;

pub trait RootTaskRunner {
fn run_root_task(&mut self) -> Result<ExitStatus, MachError>;
Expand Down
10 changes: 6 additions & 4 deletions samply/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rand::RngCore;
use tokio::net::TcpListener;
use tokio_util::io::ReaderStream;
use wholesym::debugid::DebugId;
use wholesym::{LibraryInfo, SymbolManager, SymbolManagerConfig};
use wholesym::{LibraryInfo, SymbolManager, SymbolManagerConfig, VerboseSymbolManagerObserver};

use crate::name::SAMPLY_NAME;
use crate::shared;
Expand Down Expand Up @@ -65,13 +65,12 @@ impl PortSelection {
}
}

fn create_symbol_manager_config(symbol_props: SymbolProps, verbose: bool) -> SymbolManagerConfig {
fn create_symbol_manager_config(symbol_props: SymbolProps) -> SymbolManagerConfig {
let _config_dir = AppDirs::new(Some(SAMPLY_NAME), true).map(|dirs| dirs.config_dir);
let cache_base_dir = AppDirs::new(Some(SAMPLY_NAME), false).map(|dirs| dirs.cache_dir);
let cache_base_dir = cache_base_dir.as_deref();

let mut config = SymbolManagerConfig::new()
.verbose(verbose)
.respect_nt_symbol_path(true)
.use_debuginfod(std::env::var("SAMPLY_USE_DEBUGINFOD").is_ok())
.use_spotlight(true);
Expand Down Expand Up @@ -164,8 +163,11 @@ async fn start_server(

let template_values = Arc::new(template_values);

let config = create_symbol_manager_config(symbol_props, server_props.verbose);
let config = create_symbol_manager_config(symbol_props);
let mut symbol_manager = SymbolManager::with_config(config);
if server_props.verbose {
symbol_manager.set_observer(Some(Arc::new(VerboseSymbolManagerObserver::new())));
}
for lib_info in libinfo_map.into_values() {
symbol_manager.add_known_library(lib_info);
}
Expand Down
8 changes: 4 additions & 4 deletions samply/src/shared/symbol_precog.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::HashMap;
use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use std::str::FromStr;
use std::sync::Arc;
use std::{collections::HashMap, path::Path};

use debugid::DebugId;
use serde::{
ser::SerializeMap, ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer,
};
use serde::ser::{SerializeMap, SerializeSeq};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};
use serde_json::to_writer;
use wholesym::SourceFilePath;
Expand Down
16 changes: 7 additions & 9 deletions samply/src/windows/coreclr.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
use std::{collections::HashMap, convert::TryInto, fmt::Display};
use std::collections::HashMap;
use std::convert::TryInto;
use std::fmt::Display;

use bitflags::bitflags;
use etw_reader::parser::{Parser, TryParse};
use etw_reader::schema::TypedEvent;
use etw_reader::{self, event_properties_to_string};
use fxprof_processed_profile::*;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;

use etw_reader::{self, schema::TypedEvent};
use etw_reader::{
event_properties_to_string,
parser::{Parser, TryParse},
};

use super::elevated_helper::ElevatedRecordingProps;
use crate::shared::recording_props::{CoreClrProfileProps, ProfileCreationProps};
use crate::windows::profile_context::{KnownCategory, ProfileContext};

use super::elevated_helper::ElevatedRecordingProps;

struct SavedMarkerInfo {
start_timestamp_raw: u64,
name: String,
Expand Down
7 changes: 3 additions & 4 deletions samply/src/windows/elevated_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ use std::path::{Path, PathBuf};

use serde_derive::{Deserialize, Serialize};

use crate::shared::recording_props::{
CoreClrProfileProps, ProfileCreationProps, RecordingMode, RecordingProps,
};

use super::utility_process::{
run_child, UtilityProcess, UtilityProcessChild, UtilityProcessParent, UtilityProcessSession,
};
use super::xperf::Xperf;
use crate::shared::recording_props::{
CoreClrProfileProps, ProfileCreationProps, RecordingMode, RecordingProps,
};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "t", content = "c")]
Expand Down
7 changes: 4 additions & 3 deletions wholesym-addr2line/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::borrow::Cow;
use std::io::{BufRead, Lines, StdinLock, Write};
use std::path::{Path, PathBuf};
use std::sync::Arc;

use clap::parser::ValuesRef;
use clap::{value_parser, Arg, ArgAction, Command};
use wholesym::LookupAddress;
use wholesym::{LookupAddress, VerboseSymbolManagerObserver};

fn parse_uint_from_hex_string(string: &str) -> u64 {
if string.len() > 2 && string.starts_with("0x") {
Expand Down Expand Up @@ -153,9 +154,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let config = wholesym::SymbolManagerConfig::new()
.use_spotlight(true)
.verbose(true)
.respect_nt_symbol_path(true);
let symbol_manager = wholesym::SymbolManager::with_config(config);
let mut symbol_manager = wholesym::SymbolManager::with_config(config);
symbol_manager.set_observer(Some(Arc::new(VerboseSymbolManagerObserver::new())));
let symbol_map = symbol_manager
.load_symbol_map_for_binary_at_path(path, None)
.await?;
Expand Down
Loading

0 comments on commit 8c486e0

Please sign in to comment.