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 support for Portable PDB debug files #1345

Merged
merged 4 commits into from
Oct 19, 2022
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
59 changes: 45 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.81"
sha1_smol = { version = "1.0.0", features = ["serde"] }
sourcemap = { version = "6.0.2", features = ["ram_bundle"] }
symbolic = { version = "9.1.4", features = ["debuginfo-serde", "il2cpp"] }
symbolic = { version = "10.0.0", features = ["debuginfo-serde", "il2cpp"] }
thiserror = "1.0.31"
url = "2.2.2"
username = "0.2.0"
Expand Down
4 changes: 4 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,9 @@ pub enum ChunkUploadCapability {
/// Upload of PDBs and debug id overrides
Pdbs,

/// Upload of Portable PDBs
PortablePdbs,

/// Uploads of source archives
Sources,

Expand All @@ -2538,6 +2541,7 @@ impl<'de> Deserialize<'de> for ChunkUploadCapability {
"debug_files" => ChunkUploadCapability::DebugFiles,
"release_files" => ChunkUploadCapability::ReleaseFiles,
"pdbs" => ChunkUploadCapability::Pdbs,
"portablepdbs" => ChunkUploadCapability::PortablePdbs,
"sources" => ChunkUploadCapability::Sources,
"bcsymbolmaps" => ChunkUploadCapability::BcSymbolmap,
"il2cpp" => ChunkUploadCapability::Il2Cpp,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/debug_files/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Result;
use clap::{Arg, ArgMatches, Command};
use console::style;

use crate::utils::dif::DifFile;
use crate::utils::dif::{DifFile, DifType};
use crate::utils::logging::is_quiet_mode;
use crate::utils::system::QuietExit;

Expand All @@ -26,7 +26,7 @@ pub fn make_command(command: Command) -> Command {
.long("type")
.short('t')
.value_name("TYPE")
.possible_values(&["dsym", "elf", "proguard", "breakpad"])
.possible_values(DifType::all_names())
.help(
"Explicitly set the type of the debug info file. \
This should not be needed as files are auto detected.",
Expand Down
32 changes: 17 additions & 15 deletions src/commands/debug_files/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ pub fn make_command(command: Command) -> Command {
.short('t')
.value_name("TYPE")
.multiple_occurrences(true)
.possible_values(&[
"dsym",
"elf",
"pe",
"pdb",
"proguard",
"breakpad",
"sourcebundle",
])
.possible_values(DifType::all_names())
.help(
"Only consider debug information files of the given \
type. By default all types are considered.",
Expand Down Expand Up @@ -147,6 +139,7 @@ fn find_ids(
DifType::Elf => find_ids_for_elf(&dirent, &remaining),
DifType::Pe => find_ids_for_pe(&dirent, &remaining),
DifType::Pdb => find_ids_for_pdb(&dirent, &remaining),
DifType::PortablePdb => find_ids_for_portablepdb(&dirent, &remaining),
DifType::SourceBundle => find_ids_for_sourcebundle(&dirent, &remaining),
DifType::Breakpad => find_ids_for_breakpad(&dirent, &remaining),
DifType::Proguard => find_ids_for_proguard(&dirent, &proguard_uuids),
Expand Down Expand Up @@ -272,6 +265,20 @@ fn find_ids_for_pdb(
None
}

fn find_ids_for_portablepdb(
dirent: &DirEntry,
remaining: &HashSet<DebugId>,
) -> Option<Vec<(DebugId, DifType)>> {
if_chain! {
if dirent.path().extension() == Some(OsStr::new("pdb"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::PortablePdb));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::PortablePdb))
}
}
None
}

fn find_ids_for_sourcebundle(
dirent: &DirEntry,
remaining: &HashSet<DebugId>,
Expand Down Expand Up @@ -326,12 +333,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
types.insert(ty.parse().unwrap());
}
} else {
types.insert(DifType::Dsym);
types.insert(DifType::Pdb);
types.insert(DifType::Pe);
types.insert(DifType::Proguard);
types.insert(DifType::SourceBundle);
types.insert(DifType::Breakpad);
types.extend(DifType::all());
}

let with_well_known = !matches.is_present("no_well_known");
Expand Down
16 changes: 6 additions & 10 deletions src/commands/debug_files/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use symbolic::debuginfo::FileFormat;
use crate::api::Api;
use crate::config::Config;
use crate::utils::args::{validate_id, ArgExt};
use crate::utils::dif::ObjectDifFeatures;
use crate::utils::dif::{DifType, ObjectDifFeatures};
use crate::utils::dif_upload::{DifFormat, DifUpload};
use crate::utils::progress::{ProgressBar, ProgressStyle};
use crate::utils::system::QuietExit;
Expand All @@ -20,6 +20,9 @@ use crate::utils::xcode::{InfoPlist, MayDetach};
static DERIVED_DATA_FOLDER: &str = "Library/Developer/Xcode/DerivedData";

pub fn make_command(command: Command) -> Command {
let mut types = vec!["bcsymbolmap"];
types.extend(DifType::all_names());

command
.about("Upload debugging information files.")
.org_arg()
Expand All @@ -36,15 +39,7 @@ pub fn make_command(command: Command) -> Command {
.short('t')
.value_name("TYPE")
.multiple_occurrences(true)
.possible_values(&[
"dsym",
"elf",
"breakpad",
"pdb",
"pe",
"sourcebundle",
"bcsymbolmap",
])
.possible_values(types)
.help(
"Only consider debug information files of the given \
type. By default, all types are considered.",
Expand Down Expand Up @@ -200,6 +195,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
"pdb" => upload.filter_format(DifFormat::Object(FileFormat::Pdb)),
"pe" => upload.filter_format(DifFormat::Object(FileFormat::Pe)),
"sourcebundle" => upload.filter_format(DifFormat::Object(FileFormat::SourceBundle)),
"portablepdb" => upload.filter_format(DifFormat::Object(FileFormat::PortablePdb)),
"bcsymbolmap" => {
upload.filter_format(DifFormat::BcSymbolMap);
upload.filter_format(DifFormat::PList)
Expand Down
34 changes: 34 additions & 0 deletions src/utils/dif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum DifType {
SourceBundle,
Pe,
Pdb,
PortablePdb,
Wasm,
}

Expand All @@ -29,12 +30,41 @@ impl DifType {
DifType::Elf => "elf",
DifType::Pe => "pe",
DifType::Pdb => "pdb",
DifType::PortablePdb => "portablepdb",
DifType::SourceBundle => "sourcebundle",
DifType::Breakpad => "breakpad",
DifType::Proguard => "proguard",
DifType::Wasm => "wasm",
}
}

pub fn all() -> &'static [DifType] {
&[
DifType::Dsym,
DifType::Elf,
DifType::Pe,
DifType::Pdb,
DifType::PortablePdb,
DifType::SourceBundle,
DifType::Breakpad,
DifType::Proguard,
DifType::Wasm,
]
}

pub fn all_names() -> &'static [&'static str] {
&[
"dsym",
"elf",
"pe",
"pdb",
"portablepdb",
"sourcebundle",
"breakpad",
"proguard",
"wasm",
]
}
}

impl fmt::Display for DifType {
Expand All @@ -52,6 +82,7 @@ impl str::FromStr for DifType {
"elf" => Ok(DifType::Elf),
"pe" => Ok(DifType::Pe),
"pdb" => Ok(DifType::Pdb),
"portablepdb" => Ok(DifType::PortablePdb),
"sourcebundle" => Ok(DifType::SourceBundle),
"breakpad" => Ok(DifType::Breakpad),
"proguard" => Ok(DifType::Proguard),
Expand Down Expand Up @@ -191,6 +222,7 @@ impl DifFile<'static> {
| FileFormat::Elf
| FileFormat::Pe
| FileFormat::Pdb
| FileFormat::PortablePdb
| FileFormat::Breakpad
| FileFormat::Wasm
| FileFormat::SourceBundle => return DifFile::from_archive(archive),
Expand All @@ -214,6 +246,7 @@ impl DifFile<'static> {
Some(DifType::Elf) => DifFile::open_object(path, FileFormat::Elf),
Some(DifType::Pe) => DifFile::open_object(path, FileFormat::Pe),
Some(DifType::Pdb) => DifFile::open_object(path, FileFormat::Pdb),
Some(DifType::PortablePdb) => DifFile::open_object(path, FileFormat::PortablePdb),
Some(DifType::SourceBundle) => DifFile::open_object(path, FileFormat::SourceBundle),
Some(DifType::Wasm) => DifFile::open_object(path, FileFormat::Wasm),
Some(DifType::Breakpad) => DifFile::open_object(path, FileFormat::Breakpad),
Expand Down Expand Up @@ -246,6 +279,7 @@ impl<'a> DifFile<'a> {
FileFormat::Breakpad => DifType::Breakpad,
FileFormat::Elf => DifType::Elf,
FileFormat::Pdb => DifType::Pdb,
FileFormat::PortablePdb => DifType::PortablePdb,
FileFormat::Pe => DifType::Pe,
FileFormat::Wasm => DifType::Wasm,
FileFormat::SourceBundle => DifType::SourceBundle,
Expand Down
Loading