From 6571f5dea72df5bc425caabc09cd9850367b8f55 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 21 Aug 2020 13:44:14 +0200 Subject: [PATCH 01/22] feat(unreal): Add unreal data bags (#257) --- unreal/src/context.rs | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/unreal/src/context.rs b/unreal/src/context.rs index 4fc96301a..684f0e046 100644 --- a/unreal/src/context.rs +++ b/unreal/src/context.rs @@ -326,6 +326,27 @@ pub struct Unreal4Context { /// Platform specific properties. #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] pub platform_properties: Option, + + /// Engine data. + #[cfg_attr( + feature = "with-serde", + serde(default, skip_serializing_if = "BTreeMap::is_empty") + )] + pub engine_data: BTreeMap, + + /// Game data. + #[cfg_attr( + feature = "with-serde", + serde(default, skip_serializing_if = "BTreeMap::is_empty") + )] + pub game_data: BTreeMap, +} + +fn load_data_bag(element: &Element) -> BTreeMap { + element + .children() + .map(|child| (child.tag().name().to_string(), child.text().to_string())) + .collect() } impl Unreal4Context { @@ -336,6 +357,12 @@ impl Unreal4Context { Ok(Unreal4Context { runtime_properties: Unreal4ContextRuntimeProperties::from_xml(&root), platform_properties: Unreal4ContextPlatformProperties::from_xml(&root), + engine_data: root + .find("EngineData") + .map_or_else(Default::default, load_data_bag), + game_data: root + .find("GameData") + .map_or_else(Default::default, load_data_bag), }) } } @@ -356,6 +383,22 @@ const ONLY_ROOT_AND_CHILD_NODES: &str = r#" "#; +#[allow(dead_code)] +const ROOT_WITH_GAME_AND_ENGINE_DATA: &str = r#" + + + + + + + false + + + {"release":"foo.bar.baz@1.0.0"} + + +"#; + #[test] fn test_get_runtime_properties_missing_element() { let root = Element::from_reader(ONLY_ROOT_NODE.as_bytes()).unwrap(); @@ -375,6 +418,23 @@ fn test_get_runtime_properties_no_children() { assert_eq!(Unreal4ContextRuntimeProperties::default(), actual) } +#[test] +fn test_get_game_and_engine_data() { + let actual = + Unreal4Context::parse(&ROOT_WITH_GAME_AND_ENGINE_DATA.as_bytes()).expect("default struct"); + assert_eq!( + actual + .engine_data + .get("RHI.IsGPUOverclocked") + .map(|x| x.as_str()), + Some("false") + ); + assert_eq!( + actual.game_data.get("sentry").map(|x| x.as_str()), + Some(r#"{"release":"foo.bar.baz@1.0.0"}"#) + ); +} + #[test] fn test_get_platform_properties_no_children() { let root = Element::from_reader(ONLY_ROOT_AND_CHILD_NODES.as_bytes()).unwrap(); From 812ef4b6d7afac1d6d253224d11767e5ae785a0f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 21 Aug 2020 13:59:08 +0200 Subject: [PATCH 02/22] doc: Update changelog for 7.5.0 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13430c417..99d92ff8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 7.5.0 + +**Changes**: + +- Add missing unreal data bags (`EngineData` and `GameData`). ([#257](https://github.com/getsentry/symbolic/pull/257)) +- Expose binary names for ELF and MachO ([#252](https://github.com/getsentry/symbolic/pull/252)) +- Mark enums as `non_exhaustive` ([#256](https://github.com/getsentry/symbolic/pull/256)) +- Add method to create Archive from bytes ([#250](https://github.com/getsentry/symbolic/pull/250)) + ## 7.4.0 **Deprecations**: From f56d3f4670bafb85b3b2cfece25fdc20d80416d9 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Fri, 21 Aug 2020 15:17:25 +0200 Subject: [PATCH 03/22] feat: Unsafe transmute for PDB symbols (#258) This works around compilation errors on nightly when casting to the generic `DynIterator` type. This is caused by invariant lifetimes on PDB's stream type. The transmute is actually safe since the lifetime of the data is proved to be larger than the lifetime of the derived object. --- debuginfo/src/object.rs | 2 +- debuginfo/src/pdb.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/debuginfo/src/object.rs b/debuginfo/src/object.rs index ac194ae4a..7de19d1d1 100644 --- a/debuginfo/src/object.rs +++ b/debuginfo/src/object.rs @@ -346,7 +346,7 @@ impl<'d> ObjectLike for Object<'d> { } fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + unsafe { std::mem::transmute(Box::new(self.symbols()) as DynIterator<'_, _>) } } fn has_debug_info(&self) -> bool { diff --git a/debuginfo/src/pdb.rs b/debuginfo/src/pdb.rs index 4316d291b..2b57cd4e9 100644 --- a/debuginfo/src/pdb.rs +++ b/debuginfo/src/pdb.rs @@ -292,7 +292,8 @@ impl<'d> ObjectLike for PdbObject<'d> { } fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + // TODO: Avoid this transmute by introducing explicit lifetimes on the trait. + unsafe { std::mem::transmute(Box::new(self.symbols()) as DynIterator<'_, _>) } } fn symbol_map(&self) -> SymbolMap<'_> { From 18f174f4fdf39c30bf5f956fb322256edd1b5a2e Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Fri, 21 Aug 2020 15:21:00 +0200 Subject: [PATCH 04/22] meta: Update changelog for 7.5.0 --- CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d92ff8d..11bee229d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,14 @@ **Changes**: -- Add missing unreal data bags (`EngineData` and `GameData`). ([#257](https://github.com/getsentry/symbolic/pull/257)) +- Add missing unreal data attributes (`EngineData` and `GameData`). ([#257](https://github.com/getsentry/symbolic/pull/257)) - Expose binary names for ELF and MachO ([#252](https://github.com/getsentry/symbolic/pull/252)) -- Mark enums as `non_exhaustive` ([#256](https://github.com/getsentry/symbolic/pull/256)) -- Add method to create Archive from bytes ([#250](https://github.com/getsentry/symbolic/pull/250)) +- Mark enums as `non_exhaustive`. ([#256](https://github.com/getsentry/symbolic/pull/256)) +- Add method to create Archive from bytes. ([#250](https://github.com/getsentry/symbolic/pull/250)) + +**Bug Fixes**: + +- Fix compilation errors on nightly Rust due to a lifetime mismatch. This is temporarily solved with a statically verified unsafe transmute, which will be replaced in an upcoming breaking change. ([#258](https://github.com/getsentry/symbolic/pull/258)) ## 7.4.0 From 8d382fe05b6b3ebef814b0bb496a590178c8b348 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Fri, 21 Aug 2020 15:22:17 +0200 Subject: [PATCH 05/22] release: 7.5.0 --- Cargo.toml | 18 +++++++++--------- cabi/Cargo.lock | 20 ++++++++++---------- cabi/Cargo.toml | 4 ++-- common/Cargo.toml | 2 +- debuginfo/Cargo.toml | 4 ++-- demangle/Cargo.toml | 4 ++-- minidump/Cargo.toml | 6 +++--- proguard/Cargo.toml | 4 ++-- sourcemap/Cargo.toml | 2 +- symcache/Cargo.toml | 6 +++--- testutils/Cargo.toml | 2 +- unreal/Cargo.toml | 2 +- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc83459dc..3b8d05865 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -45,14 +45,14 @@ unreal = ["symbolic-unreal"] unreal-serde = ["unreal", "common-serde", "symbolic-unreal/with-serde"] [dependencies] -symbolic-common = { version = "7.4.0", path = "common" } -symbolic-debuginfo = { version = "7.4.0", path = "debuginfo", optional = true } -symbolic-demangle = { version = "7.4.0", path = "demangle", optional = true } -symbolic-minidump = { version = "7.4.0", path = "minidump", optional = true } -symbolic-proguard = { version = "7.4.0", path = "proguard", optional = true } -symbolic-sourcemap = { version = "7.4.0", path = "sourcemap", optional = true } -symbolic-symcache = { version = "7.4.0", path = "symcache", optional = true } -symbolic-unreal = { version = "7.4.0", path = "unreal", optional = true } +symbolic-common = { version = "7.5.0", path = "common" } +symbolic-debuginfo = { version = "7.5.0", path = "debuginfo", optional = true } +symbolic-demangle = { version = "7.5.0", path = "demangle", optional = true } +symbolic-minidump = { version = "7.5.0", path = "minidump", optional = true } +symbolic-proguard = { version = "7.5.0", path = "proguard", optional = true } +symbolic-sourcemap = { version = "7.5.0", path = "sourcemap", optional = true } +symbolic-symcache = { version = "7.5.0", path = "symcache", optional = true } +symbolic-unreal = { version = "7.5.0", path = "unreal", optional = true } [dev-dependencies] clap = "2.33.0" diff --git a/cabi/Cargo.lock b/cabi/Cargo.lock index 667c85746..55a5fdddb 100644 --- a/cabi/Cargo.lock +++ b/cabi/Cargo.lock @@ -866,7 +866,7 @@ dependencies = [ [[package]] name = "symbolic" -version = "7.4.0" +version = "7.5.0" dependencies = [ "symbolic-common", "symbolic-debuginfo", @@ -880,7 +880,7 @@ dependencies = [ [[package]] name = "symbolic-cabi" -version = "7.4.0" +version = "7.5.0" dependencies = [ "apple-crash-report-parser", "failure", @@ -891,7 +891,7 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "7.4.0" +version = "7.5.0" dependencies = [ "debugid", "failure", @@ -903,7 +903,7 @@ dependencies = [ [[package]] name = "symbolic-debuginfo" -version = "7.4.0" +version = "7.5.0" dependencies = [ "dmsort", "failure", @@ -927,7 +927,7 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "7.4.0" +version = "7.5.0" dependencies = [ "cc", "cpp_demangle", @@ -938,7 +938,7 @@ dependencies = [ [[package]] name = "symbolic-minidump" -version = "7.4.0" +version = "7.5.0" dependencies = [ "cc", "failure", @@ -950,7 +950,7 @@ dependencies = [ [[package]] name = "symbolic-proguard" -version = "7.4.0" +version = "7.5.0" dependencies = [ "proguard", "symbolic-common", @@ -958,7 +958,7 @@ dependencies = [ [[package]] name = "symbolic-sourcemap" -version = "7.4.0" +version = "7.5.0" dependencies = [ "failure", "sourcemap", @@ -966,7 +966,7 @@ dependencies = [ [[package]] name = "symbolic-symcache" -version = "7.4.0" +version = "7.5.0" dependencies = [ "dmsort", "failure", @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "symbolic-unreal" -version = "7.4.0" +version = "7.5.0" dependencies = [ "anylog", "bytes", diff --git a/cabi/Cargo.toml b/cabi/Cargo.toml index 86b470532..3771e95c0 100644 --- a/cabi/Cargo.toml +++ b/cabi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-cabi" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -29,5 +29,5 @@ lto = true serde_json = "1.0.40" failure = "0.1.5" apple-crash-report-parser = { version = "0.4.0", features = ["with_serde"] } -symbolic = { version = "7.4.0", path = "..", features = ["debuginfo", "demangle", "minidump", "proguard", "sourcemap", "symcache", "unreal-serde"] } +symbolic = { version = "7.5.0", path = "..", features = ["debuginfo", "demangle", "minidump", "proguard", "sourcemap", "symcache", "unreal-serde"] } proguard = { version = "4.0.1", features = ["uuid"] } diff --git a/common/Cargo.toml b/common/Cargo.toml index 03b5e47db..bec72a1a1 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-common" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", diff --git a/debuginfo/Cargo.toml b/debuginfo/Cargo.toml index 72358dc5e..a8d79c3b5 100644 --- a/debuginfo/Cargo.toml +++ b/debuginfo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-debuginfo" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -36,7 +36,7 @@ regex = "1.3.5" serde = { version = "1.0.94", features = ["derive"] } serde_json = "1.0.40" smallvec = "1.2.0" -symbolic-common = { version = "7.4.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../common" } zip = "0.5.2" [dev-dependencies] diff --git a/demangle/Cargo.toml b/demangle/Cargo.toml index e3c19896a..269e92cd7 100644 --- a/demangle/Cargo.toml +++ b/demangle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-demangle" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -24,7 +24,7 @@ exclude = [ cpp_demangle = "0.3.0" msvc-demangler = "0.8.0" rustc-demangle = "0.1.16" -symbolic-common = { version = "7.4.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../common" } [build-dependencies] cc = "1.0.50" diff --git a/minidump/Cargo.toml b/minidump/Cargo.toml index 073fa074b..2a7706b70 100644 --- a/minidump/Cargo.toml +++ b/minidump/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-minidump" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -31,8 +31,8 @@ failure = "0.1.5" lazy_static = "1.4.0" regex = "1.3.5" serde = { version = "1.0.94", optional = true } -symbolic-common = { version = "7.4.0", path = "../common" } -symbolic-debuginfo = { version = "7.4.0", path = "../debuginfo" } +symbolic-common = { version = "7.5.0", path = "../common" } +symbolic-debuginfo = { version = "7.5.0", path = "../debuginfo" } [build-dependencies] cc = { version = "1.0.50", features = ["parallel"] } diff --git a/proguard/Cargo.toml b/proguard/Cargo.toml index bb2462b26..1d6653b6b 100644 --- a/proguard/Cargo.toml +++ b/proguard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-proguard" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -18,4 +18,4 @@ edition = "2018" [dependencies] proguard = { version = "4.0.1", features = ["uuid"] } -symbolic-common = { version = "7.4.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../common" } diff --git a/sourcemap/Cargo.toml b/sourcemap/Cargo.toml index bda6a2c13..7f7812720 100644 --- a/sourcemap/Cargo.toml +++ b/sourcemap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-sourcemap" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", diff --git a/symcache/Cargo.toml b/symcache/Cargo.toml index 3d3ed3155..c879eb774 100644 --- a/symcache/Cargo.toml +++ b/symcache/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-symcache" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", @@ -24,8 +24,8 @@ dmsort = "1.0.0" failure = "0.1.5" fnv = "1.0.6" num = "0.2.1" -symbolic-common = { version = "7.4.0", path = "../common" } -symbolic-debuginfo = { version = "7.4.0", path = "../debuginfo" } +symbolic-common = { version = "7.5.0", path = "../common" } +symbolic-debuginfo = { version = "7.5.0", path = "../debuginfo" } [dev-dependencies] insta = "0.15.0" diff --git a/testutils/Cargo.toml b/testutils/Cargo.toml index 36f10b270..c5bcad865 100644 --- a/testutils/Cargo.toml +++ b/testutils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-testutils" -version = "7.4.0" +version = "7.5.0" license = "MIT" edition = "2018" publish = false diff --git a/unreal/Cargo.toml b/unreal/Cargo.toml index 5878ba322..392906e34 100644 --- a/unreal/Cargo.toml +++ b/unreal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "symbolic-unreal" -version = "7.4.0" +version = "7.5.0" license = "MIT" authors = [ "Armin Ronacher ", From 16b2b58a92c498dc49334a0389e6eb84deb0ae40 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Thu, 10 Sep 2020 16:16:48 +0200 Subject: [PATCH 06/22] fix(debuginfo): Detect mangled anonymous namespaces in PDB inlinees (#261) ID records specify the mangled format for anonymous namespaces: `?A0x`, where `id` is a hex identifier of the namespace. Demanglers usually resolve this as "anonymous namespace". This also fixes an issue with demangling: If the anonymous namespace is in the beginning of the composed name, it leads the demangler to believe that this is a mangled MSVC name. However, since this is a composed demangled name, this leads to a demangle error. --- debuginfo/src/pdb.rs | 17 ++++++++++++++++- debuginfo/tests/test_objects.rs | 26 ++++++++++++++++++++++++++ py/symbolic/debuginfo.py | 10 ++++++++-- py/symbolic/sourcemap.py | 5 ++++- py/symbolic/symcache.py | 6 +++++- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/debuginfo/src/pdb.rs b/debuginfo/src/pdb.rs index 2b57cd4e9..282f7b8dc 100644 --- a/debuginfo/src/pdb.rs +++ b/debuginfo/src/pdb.rs @@ -634,6 +634,15 @@ impl DebugSession for PdbDebugSession<'_> { } } +/// Checks whether the given name declares an anonymous namespace. +/// +/// ID records specify the mangled format for anonymous namespaces: `?A0x`, where `id` is a hex +/// identifier of the namespace. Demanglers usually resolve this as "anonymous namespace". +fn is_anonymous_namespace(name: &str) -> bool { + name.strip_prefix("?A0x") + .map_or(false, |rest| u32::from_str_radix(rest, 16).is_ok()) +} + /// Formatter for function types. /// /// This formatter currently only contains the minimum implementation requried to format inline @@ -693,7 +702,13 @@ impl<'u, 'd> TypeFormatter<'u, 'd> { write!(target, "\"")?; } Ok(pdb::IdData::String(data)) => { - write!(target, "{}", data.name.to_string())?; + let mut string = data.name.to_string(); + + if is_anonymous_namespace(&string) { + string = Cow::Borrowed("`anonymous namespace'"); + } + + write!(target, "{}", string)?; } Ok(pdb::IdData::UserDefinedTypeSource(_)) => { // nothing to do. diff --git a/debuginfo/tests/test_objects.rs b/debuginfo/tests/test_objects.rs index 1d40338f1..8df844fc8 100644 --- a/debuginfo/tests/test_objects.rs +++ b/debuginfo/tests/test_objects.rs @@ -445,3 +445,29 @@ fn test_pdb_functions() -> Result<(), Error> { Ok(()) } + +#[test] +fn test_pdb_anonymous_namespace() -> Result<(), Error> { + // Regression test for ?A0x namespaces + + let view = ByteView::open(fixture("windows/crash.pdb"))?; + let object = Object::parse(&view)?; + + let session = object.debug_session()?; + let main_function = session + .functions() + .filter_map(|f| f.ok()) + .find(|f| f.address == 0x2910) + .expect("main function at 0x2910"); + + let start_function = main_function + .inlinees + .iter() + .find(|f| f.address == 0x2a3d) + .expect("start function at 0x2a3d"); + + // was: "?A0xc3a0617d::start" + assert_eq!(start_function.name, "`anonymous namespace'::start"); + + Ok(()) +} diff --git a/py/symbolic/debuginfo.py b/py/symbolic/debuginfo.py index 11a1a06f6..322e7aa2e 100644 --- a/py/symbolic/debuginfo.py +++ b/py/symbolic/debuginfo.py @@ -138,7 +138,10 @@ def make_cficache(self): ) def __repr__(self): - return "" % (self.debug_id, self.arch,) + return "" % ( + self.debug_id, + self.arch, + ) class ObjectRef(object): @@ -165,7 +168,10 @@ def __init__(self, data): self.name = self.code_file def __repr__(self): - return "" % (self.debug_id, self.arch,) + return "" % ( + self.debug_id, + self.arch, + ) class ObjectLookup(object): diff --git a/py/symbolic/sourcemap.py b/py/symbolic/sourcemap.py index 4524125ed..69a0205d6 100644 --- a/py/symbolic/sourcemap.py +++ b/py/symbolic/sourcemap.py @@ -51,7 +51,10 @@ def __ne__(self, other): return not self.__eq__(other) def __repr__(self): - return "" % (self.src, self.src_line,) + return "" % ( + self.src, + self.src_line, + ) class SourceView(RustObject): diff --git a/py/symbolic/symcache.py b/py/symbolic/symcache.py index cf4416e49..35231a106 100644 --- a/py/symbolic/symcache.py +++ b/py/symbolic/symcache.py @@ -73,7 +73,11 @@ def rel_path(self): return strip_common_path_prefix(self.abs_path, self.comp_dir) def __str__(self): - return "%s:%s (%s)" % (self.function_name, self.line, self.rel_path,) + return "%s:%s (%s)" % ( + self.function_name, + self.line, + self.rel_path, + ) def __repr__(self): return "LineInfo(%s)" % ( From 7efcc026b3b6528e05102482f263dd412e903e63 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Thu, 17 Sep 2020 13:56:17 +0200 Subject: [PATCH 07/22] build(unreal): Rename with-serde to serde (#265) Streamlines the feature name for serde in symbolic-unreal with other crates. --- Cargo.toml | 2 +- unreal/Cargo.toml | 4 +- unreal/src/context.rs | 114 ++++++++++++------------ unreal/src/logs.rs | 10 +-- unreal/tests/test_unreal_crash_parse.rs | 1 + 5 files changed, 65 insertions(+), 66 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b8d05865..799bf20ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ proguard = ["symbolic-proguard"] sourcemap = ["symbolic-sourcemap"] symcache = ["symbolic-symcache", "debuginfo"] unreal = ["symbolic-unreal"] -unreal-serde = ["unreal", "common-serde", "symbolic-unreal/with-serde"] +unreal-serde = ["unreal", "common-serde", "symbolic-unreal/serde"] [dependencies] symbolic-common = { version = "7.5.0", path = "common" } diff --git a/unreal/Cargo.toml b/unreal/Cargo.toml index 392906e34..4212f6fde 100644 --- a/unreal/Cargo.toml +++ b/unreal/Cargo.toml @@ -20,7 +20,7 @@ exclude = [ ] [features] -with-serde = ["serde", "chrono/serde"] +serde = ["serde_", "chrono/serde"] [dependencies] anylog = "0.5.0" @@ -32,7 +32,7 @@ lazy_static = "1.4.0" flate2 = { version = "1.0.13", features = ["rust_backend"], default-features = false } regex = "1.3.5" scroll = { version = "0.10.1", features = ["derive"] } -serde = { version = "1.0.94", optional = true, features = ["derive"] } +serde_ = { package = "serde", version = "1.0.94", optional = true, features = ["derive"] } [dev-dependencies] insta = "0.15.0" diff --git a/unreal/src/context.rs b/unreal/src/context.rs index 684f0e046..f8817cdd9 100644 --- a/unreal/src/context.rs +++ b/unreal/src/context.rs @@ -5,160 +5,158 @@ use elementtree::{Element, QName}; use std::collections::BTreeMap; -#[cfg(feature = "with-serde")] -use serde::Serialize; - use crate::error::Unreal4Error; /// RuntimeProperties context element. /// /// [Source](https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformCrashContext.cpp#L274) #[derive(Clone, Debug, Default, PartialEq)] -#[cfg_attr(feature = "with-serde", derive(Serialize))] +#[cfg_attr(feature = "serde", derive(serde_::Serialize))] +#[cfg_attr(feature = "serde", serde(crate = "serde_"))] pub struct Unreal4ContextRuntimeProperties { /// CrashGUID - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub crash_guid: Option, /// ProcessId - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub process_id: Option, /// IsInternalBuild - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub is_internal_build: Option, /// IsSourceDistribution - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub is_source_distribution: Option, /// IsAssert - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub is_assert: Option, /// IsEnsure - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub is_ensure: Option, /// CrashType - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub crash_type: Option, /// SecondsSinceStart - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub seconds_since_start: Option, /// GameName - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub game_name: Option, /// ExecutableName - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub executable_name: Option, /// BuildConfiguration - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub build_configuration: Option, /// PlatformName - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub platform_name: Option, /// EngineMode - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub engine_mode: Option, /// EngineVersion - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub engine_version: Option, /// LanguageLCID - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub language_lcid: Option, /// AppDefaultLocale - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub app_default_locate: Option, /// BuildVersion - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub build_version: Option, /// IsUE4Release - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub is_ue4_release: Option, /// UserName - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub username: Option, /// BaseDir - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub base_dir: Option, /// RootDir - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub root_dir: Option, /// MachineId - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub machine_id: Option, /// LoginId - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub login_id: Option, /// EpicAccountId - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub epic_account_id: Option, /// CallStack /// [Source](https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformCrashContext.cpp#L326-L327) - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub legacy_call_stack: Option, /// PCallStack // [Sopurce](https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformCrashContext.cpp#L329-L330) - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub portable_call_stack: Option, /// UserDescription - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub user_description: Option, /// ErrorMessage - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub error_message: Option, /// CrashReporterMessage - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub crash_reporter_message: Option, /// Misc.NumberOfCores - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_number_of_cores: Option, /// Misc.NumberOfCoresIncludingHyperthreads - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_number_of_cores_inc_hyperthread: Option, /// Misc.Is64bitOperatingSystem - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_is_64bit: Option, /// Misc.CPUVendor - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_cpu_vendor: Option, /// Misc.CPUBrand - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_cpu_brand: Option, #[doc(hidden)] #[deprecated(note = "use misc_primary_gpu_brand instead")] - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_primary_cpu_brand: Option, /// Misc.PrimaryGPUBrand - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_primary_gpu_brand: Option, /// Misc.OSVersionMajor - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_os_version_major: Option, /// Misc.OSVersionMinor - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_os_version_minor: Option, /// GameStateName - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub game_state_name: Option, /// MemoryStats.TotalPhysical - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub memory_stats_total_physical: Option, /// MemoryStats.TotalVirtual - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub memory_stats_total_virtual: Option, /// MemoryStats.PageSize - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub memory_stats_page_size: Option, /// MemoryStats.TotalPhysicalGB - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub memory_stats_total_phsysical_gb: Option, /// TimeOfCrash - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub time_of_crash: Option, /// bAllowToBeContacted - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub allowed_to_be_contacted: Option, /// CrashReportClientVersion - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub crash_reporter_client_version: Option, /// Modules - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub modules: Option, /// Custom attributes pub custom: BTreeMap, @@ -277,7 +275,8 @@ impl Unreal4ContextRuntimeProperties { /// [Source[(https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformCrashContext.cpp#L451-L455) /// [Windows](https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/Windows/WindowsPlatformCrashContext.cpp#L39-L44) #[derive(Clone, Debug, Default, PartialEq)] -#[cfg_attr(feature = "with-serde", derive(Serialize))] +#[cfg_attr(feature = "serde", derive(serde_::Serialize))] +#[cfg_attr(feature = "serde", serde(crate = "serde_"))] pub struct Unreal4ContextPlatformProperties { /// Whether the crash happened on a Windows device. pub is_windows: Option, @@ -317,26 +316,27 @@ impl Unreal4ContextPlatformProperties { /// /// [Source](https://github.com/EpicGames/UnrealEngine/blob/b70f31f6645d764bcb55829228918a6e3b571e0b/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformCrashContext.cpp) #[derive(Clone, Debug, Default, PartialEq)] -#[cfg_attr(feature = "with-serde", derive(Serialize))] +#[cfg_attr(feature = "serde", derive(serde_::Serialize))] +#[cfg_attr(feature = "serde", serde(crate = "serde_"))] pub struct Unreal4Context { /// RuntimeProperties context element. - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub runtime_properties: Option, /// Platform specific properties. - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub platform_properties: Option, /// Engine data. #[cfg_attr( - feature = "with-serde", + feature = "serde", serde(default, skip_serializing_if = "BTreeMap::is_empty") )] pub engine_data: BTreeMap, /// Game data. #[cfg_attr( - feature = "with-serde", + feature = "serde", serde(default, skip_serializing_if = "BTreeMap::is_empty") )] pub game_data: BTreeMap, diff --git a/unreal/src/logs.rs b/unreal/src/logs.rs index 33ac65451..1c5db1729 100644 --- a/unreal/src/logs.rs +++ b/unreal/src/logs.rs @@ -3,9 +3,6 @@ use chrono::{DateTime, TimeZone, Utc}; use lazy_static::lazy_static; use regex::Regex; -#[cfg(feature = "with-serde")] -use serde::Serialize; - use crate::error::Unreal4Error; lazy_static! { @@ -16,14 +13,15 @@ lazy_static! { } /// A log entry from an Unreal Engine 4 crash. -#[cfg_attr(feature = "with-serde", derive(Serialize))] +#[cfg_attr(feature = "serde", derive(serde_::Serialize))] +#[cfg_attr(feature = "serde", serde(crate = "serde_"))] pub struct Unreal4LogEntry { /// The timestamp of the message, when available. - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub timestamp: Option>, /// The component that issued the log, when available. - #[cfg_attr(feature = "with-serde", serde(skip_serializing_if = "Option::is_none"))] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub component: Option, /// The log message. diff --git a/unreal/tests/test_unreal_crash_parse.rs b/unreal/tests/test_unreal_crash_parse.rs index 5e6babad7..b726441c9 100644 --- a/unreal/tests/test_unreal_crash_parse.rs +++ b/unreal/tests/test_unreal_crash_parse.rs @@ -64,6 +64,7 @@ fn test_get_apple_crash_report() { } #[test] +#[cfg(feature = "serde")] fn test_contexts_runtime_properties() { let ue4_crash = get_unreal_crash().expect("test crash file loads"); From 7294a852dec94e70918ff60b1cf9804dcaa6df96 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Fri, 18 Sep 2020 10:57:54 +0200 Subject: [PATCH 08/22] build: Reorganize the workspace (#266) Moves the main `symbolic` library into a workspace member and reorganizes all examples as workspace members. The main readme is temporarily duplicated until the new version is published. --- .gitignore | 3 +- .gitmodules | 4 +- Cargo.toml | 85 +- Makefile | 11 +- README.md | 26 +- cabi/Cargo.lock | 1134 ----------------- examples/addr2line/Cargo.toml | 12 + .../{addr2line.rs => addr2line/src/main.rs} | 0 examples/dump_cfi/Cargo.toml | 12 + .../{dump_cfi.rs => dump_cfi/src/main.rs} | 0 examples/dump_sources/Cargo.toml | 12 + .../src/main.rs} | 0 examples/minidump_stackwalk/Cargo.toml | 13 + .../src/main.rs} | 0 examples/object_debug/Cargo.toml | 12 + .../src/main.rs} | 0 examples/symcache_debug/Cargo.toml | 12 + .../src/main.rs} | 0 examples/unreal_engine_crash/Cargo.toml | 12 + .../src/main.rs} | 0 py/setup.py | 18 +- py/tests/test_debug.py | 2 +- run | 2 +- scripts/bump-version | 3 - scripts/cargo-publish-all | 41 - src/lib.rs | 32 - {cabi => symbolic-cabi}/Cargo.toml | 10 +- {cabi => symbolic-cabi}/Makefile | 2 +- {cabi => symbolic-cabi}/README.md | 4 +- {cabi => symbolic-cabi}/c-tests/common.c | 0 {cabi => symbolic-cabi}/c-tests/demangle | Bin {cabi => symbolic-cabi}/c-tests/demangle.c | 0 {cabi => symbolic-cabi}/c-tests/object.c | 0 {cabi => symbolic-cabi}/cbindgen.toml | 0 {cabi => symbolic-cabi}/include/symbolic.h | 1 + {cabi => symbolic-cabi}/src/common.rs | 0 {cabi => symbolic-cabi}/src/core.rs | 6 +- {cabi => symbolic-cabi}/src/debuginfo.rs | 0 {cabi => symbolic-cabi}/src/demangle.rs | 0 {cabi => symbolic-cabi}/src/lib.rs | 5 +- {cabi => symbolic-cabi}/src/minidump.rs | 0 {cabi => symbolic-cabi}/src/proguard.rs | 0 {cabi => symbolic-cabi}/src/sourcemap.rs | 0 {cabi => symbolic-cabi}/src/symcache.rs | 0 {cabi => symbolic-cabi}/src/unreal.rs | 0 {cabi => symbolic-cabi}/src/utils.rs | 0 {common => symbolic-common}/Cargo.toml | 5 +- {common => symbolic-common}/README.md | 0 {common => symbolic-common}/src/byteview.rs | 0 {common => symbolic-common}/src/cell.rs | 0 {common => symbolic-common}/src/fail.rs | 0 {common => symbolic-common}/src/heuristics.rs | 0 {common => symbolic-common}/src/lib.rs | 0 {common => symbolic-common}/src/path.rs | 0 {common => symbolic-common}/src/types.rs | 0 {debuginfo => symbolic-debuginfo}/Cargo.toml | 7 +- {debuginfo => symbolic-debuginfo}/src/base.rs | 0 .../src/breakpad.pest | 0 .../src/breakpad.rs | 0 .../src/dwarf.rs | 0 {debuginfo => symbolic-debuginfo}/src/elf.rs | 0 {debuginfo => symbolic-debuginfo}/src/lib.rs | 0 .../src/macho.rs | 0 .../src/object.rs | 0 {debuginfo => symbolic-debuginfo}/src/pdb.rs | 0 {debuginfo => symbolic-debuginfo}/src/pe.rs | 0 .../src/private.rs | 0 .../src/sourcebundle.rs | 0 .../tests/fixtures/CppConsoleApp.exe | Bin .../tests/fixtures/CppConsoleApp.pdb | Bin .../tests/fixtures/CppConsoleApp.pdb.sym | 0 .../tests/fixtures/crash.exe | Bin .../tests/fixtures/crash.pdb | Bin .../tests/fixtures/crash.sym | 0 .../tests/fixtures/msvcrt.dll | Bin .../test_objects__breakpad_files.snap | 0 .../test_objects__breakpad_functions.snap | 0 .../test_objects__breakpad_symbols.snap | 0 .../snapshots/test_objects__elf_files.snap | 0 .../test_objects__elf_functions.snap | 0 .../snapshots/test_objects__elf_symbols.snap | 0 .../snapshots/test_objects__mach_files.snap | 0 .../test_objects__mach_functions.snap | 0 .../snapshots/test_objects__mach_symbols.snap | 0 .../snapshots/test_objects__pdb_files.snap | 0 .../test_objects__pdb_functions.snap | 0 .../snapshots/test_objects__pdb_symbols.snap | 0 .../tests/test_objects.rs | 0 {demangle => symbolic-demangle}/Cargo.toml | 5 +- {demangle => symbolic-demangle}/README.md | 0 {demangle => symbolic-demangle}/build.rs | 0 {demangle => symbolic-demangle}/src/lib.rs | 0 .../src/swiftdemangle.cpp | 0 .../tests/test_cpp.rs | 0 .../tests/test_detection.rs | 0 .../tests/test_msvc.rs | 0 .../tests/test_objcpp.rs | 0 .../tests/test_swift.rs | 0 .../tests/utils/mod.rs | 0 .../vendor/swift/1-arguments.patch | 0 .../vendor/swift/LICENSE.txt | 0 .../vendor/swift/LICENSE_LLVM.txt | 0 .../vendor/swift/README.md | 0 .../vendor/swift/include/llvm-c/DataTypes.h | 0 .../vendor/swift/include/llvm/ADT/None.h | 0 .../vendor/swift/include/llvm/ADT/Optional.h | 0 .../vendor/swift/include/llvm/ADT/STLExtras.h | 0 .../swift/include/llvm/ADT/SmallVector.h | 0 .../vendor/swift/include/llvm/ADT/StringRef.h | 0 .../swift/include/llvm/ADT/StringSwitch.h | 0 .../vendor/swift/include/llvm/ADT/iterator.h | 0 .../swift/include/llvm/ADT/iterator_range.h | 0 .../swift/include/llvm/Config/abi-breaking.h | 0 .../swift/include/llvm/Config/llvm-config.h | 0 .../swift/include/llvm/Support/AlignOf.h | 0 .../swift/include/llvm/Support/Casting.h | 0 .../swift/include/llvm/Support/Compiler.h | 0 .../swift/include/llvm/Support/DataTypes.h | 0 .../include/llvm/Support/ErrorHandling.h | 0 .../swift/include/llvm/Support/MathExtras.h | 0 .../swift/include/llvm/Support/MemAlloc.h | 0 .../include/llvm/Support/SwapByteOrder.h | 0 .../swift/include/llvm/Support/raw_ostream.h | 0 .../swift/include/llvm/Support/type_traits.h | 0 .../swift/include/swift/AST/Ownership.h | 0 .../include/swift/AST/ReferenceStorage.def | 0 .../include/swift/Basic/InlineBitfield.h | 0 .../vendor/swift/include/swift/Basic/LLVM.h | 0 .../swift/include/swift/Basic/STLExtras.h | 0 .../swift/include/swift/Demangling/Demangle.h | 0 .../swift/Demangling/DemangleNodes.def | 0 .../include/swift/Demangling/Demangler.h | 0 .../include/swift/Demangling/ManglingMacros.h | 0 .../include/swift/Demangling/ManglingUtils.h | 0 .../swift/include/swift/Demangling/Punycode.h | 0 .../Demangling/StandardTypesMangling.def | 0 .../swift/Demangling/ValueWitnessMangling.def | 0 .../include/swift/Runtime/BackDeployment.h | 0 .../swift/include/swift/Runtime/CMakeConfig.h | 0 .../swift/include/swift/Runtime/Config.h | 0 .../vendor/swift/include/swift/Strings.h | 0 .../swift/lib/Demangling/CMakeLists.txt | 0 .../vendor/swift/lib/Demangling/Context.cpp | 0 .../vendor/swift/lib/Demangling/Demangler.cpp | 0 .../swift/lib/Demangling/ManglingUtils.cpp | 0 .../swift/lib/Demangling/NodeDumper.cpp | 0 .../swift/lib/Demangling/NodePrinter.cpp | 0 .../swift/lib/Demangling/OldDemangler.cpp | 0 .../swift/lib/Demangling/OldRemangler.cpp | 0 .../vendor/swift/lib/Demangling/Punycode.cpp | 0 .../vendor/swift/lib/Demangling/Remangler.cpp | 0 .../swift/lib/Demangling/RemanglerBase.h | 0 .../stdlib/public/SwiftShims/Visibility.h | 0 .../vendor/swift/update.py | 0 {minidump => symbolic-minidump}/Cargo.toml | 9 +- {minidump => symbolic-minidump}/build.rs | 0 .../cpp/c_mapping.h | 0 .../cpp/c_string.cpp | 0 .../cpp/c_string.h | 0 .../cpp/data_definitions.h | 0 .../cpp/data_structures.cpp | 0 .../cpp/data_structures.h | 0 .../cpp/memstream.h | 0 .../cpp/mmap_symbol_supplier.cpp | 0 .../cpp/mmap_symbol_supplier.h | 0 .../cpp/processor.cpp | 0 .../cpp/processor.h | 0 {minidump => symbolic-minidump}/src/cfi.rs | 0 {minidump => symbolic-minidump}/src/lib.rs | 0 .../src/processor.rs | 0 {minidump => symbolic-minidump}/src/utils.rs | 0 .../tests/snapshots/test_cfi__cfi_elf.snap | 0 .../tests/snapshots/test_cfi__cfi_macho.snap | 0 .../snapshots/test_cfi__cfi_pdb_windows.snap | 0 .../snapshots/test_cfi__cfi_pe_windows.snap | 0 .../snapshots/test_cfi__cfi_sym_linux.snap | 0 .../snapshots/test_cfi__cfi_sym_macos.snap | 0 .../snapshots/test_cfi__cfi_sym_windows.snap | 0 .../test_processor__process_state_linux.snap | 0 .../test_processor__process_state_macos.snap | 0 ...test_processor__process_state_windows.snap | 0 ...t_processor__referenced_modules_linux.snap | 0 ...t_processor__referenced_modules_macos.snap | 0 ...processor__referenced_modules_windows.snap | 0 .../tests/test_cfi.rs | 0 .../tests/test_processor.rs | 0 .../third_party/breakpad | 0 .../third_party/lss | 0 {proguard => symbolic-proguard}/Cargo.toml | 5 +- {proguard => symbolic-proguard}/src/lib.rs | 0 {sourcemap => symbolic-sourcemap}/Cargo.toml | 3 + {sourcemap => symbolic-sourcemap}/src/lib.rs | 0 .../tests/fixtures/README.md | 0 .../tests/fixtures/react-native-hermes.map | 0 .../tests/fixtures/react-native-metro.js | 0 .../tests/fixtures/react-native-metro.js.map | 0 {symcache => symbolic-symcache}/Cargo.toml | 9 +- .../benches/bench_writer.rs | 0 {symcache => symbolic-symcache}/src/cache.rs | 0 {symcache => symbolic-symcache}/src/error.rs | 0 {symcache => symbolic-symcache}/src/format.rs | 0 {symcache => symbolic-symcache}/src/lib.rs | 0 {symcache => symbolic-symcache}/src/writer.rs | 0 .../test_cache__functions_linux.snap | 0 .../test_cache__functions_macos.snap | 0 .../tests/snapshots/test_cache__lookup.snap | 0 .../test_writer__functions_linux.snap | 0 .../test_writer__functions_macos.snap | 0 .../tests/test_cache.rs | 0 .../tests/test_compat.rs | 0 .../tests/test_writer.rs | 0 {testutils => symbolic-testutils}/Cargo.toml | 3 + .../fixtures/linux/crash | Bin .../fixtures/linux/crash.debug | Bin .../fixtures/linux/crash.sym | 0 .../fixtures/linux/mini.dmp | Bin .../fixtures/macos/crash | Bin .../macos/crash.dSYM/Contents/Info.plist | 0 .../crash.dSYM/Contents/Resources/DWARF/crash | Bin .../Contents/Resources/DWARF/invalid | 0 .../fixtures/macos/crash.sym | 0 .../fixtures/macos/mini.dmp | Bin .../Contents/Resources/DWARF/invalid | 0 .../fixtures/regression/large_symbol.sym | 0 .../fixtures/symcache/compat/v1.symc | Bin .../fixtures/symcache/current/linux.symc | Bin .../fixtures/symcache/current/macos.symc | Bin .../fixtures/unreal/unreal_crash | Bin .../fixtures/unreal/unreal_crash_apple | Bin .../fixtures/windows/CrashWithException.exe | Bin .../fixtures/windows/CrashWithException.pdb | Bin .../windows/CrashWithException.pdb.sym | 0 .../fixtures/windows/crash.exe | Bin .../fixtures/windows/crash.pdb | Bin .../fixtures/windows/crash.sym | 0 .../fixtures/windows/mini.dmp | Bin {testutils => symbolic-testutils}/src/lib.rs | 0 {unreal => symbolic-unreal}/Cargo.toml | 5 +- {unreal => symbolic-unreal}/src/container.rs | 0 {unreal => symbolic-unreal}/src/context.rs | 0 {unreal => symbolic-unreal}/src/error.rs | 0 {unreal => symbolic-unreal}/src/lib.rs | 0 {unreal => symbolic-unreal}/src/logs.rs | 0 ...sh_parse__contexts_runtime_properties.snap | 0 .../tests/test_unreal_crash_parse.rs | 0 symbolic/Cargo.toml | 47 + symbolic/README.md | 67 + symbolic/src/lib.rs | 88 ++ 248 files changed, 367 insertions(+), 1360 deletions(-) delete mode 100644 cabi/Cargo.lock create mode 100644 examples/addr2line/Cargo.toml rename examples/{addr2line.rs => addr2line/src/main.rs} (100%) create mode 100644 examples/dump_cfi/Cargo.toml rename examples/{dump_cfi.rs => dump_cfi/src/main.rs} (100%) create mode 100644 examples/dump_sources/Cargo.toml rename examples/{dump_sources.rs => dump_sources/src/main.rs} (100%) create mode 100644 examples/minidump_stackwalk/Cargo.toml rename examples/{minidump_stackwalk.rs => minidump_stackwalk/src/main.rs} (100%) create mode 100644 examples/object_debug/Cargo.toml rename examples/{object_debug.rs => object_debug/src/main.rs} (100%) create mode 100644 examples/symcache_debug/Cargo.toml rename examples/{symcache_debug.rs => symcache_debug/src/main.rs} (100%) create mode 100644 examples/unreal_engine_crash/Cargo.toml rename examples/{unreal_engine_crash.rs => unreal_engine_crash/src/main.rs} (100%) delete mode 100755 scripts/cargo-publish-all delete mode 100644 src/lib.rs rename {cabi => symbolic-cabi}/Cargo.toml (76%) rename {cabi => symbolic-cabi}/Makefile (91%) rename {cabi => symbolic-cabi}/README.md (96%) rename {cabi => symbolic-cabi}/c-tests/common.c (100%) rename {cabi => symbolic-cabi}/c-tests/demangle (100%) rename {cabi => symbolic-cabi}/c-tests/demangle.c (100%) rename {cabi => symbolic-cabi}/c-tests/object.c (100%) rename {cabi => symbolic-cabi}/cbindgen.toml (100%) rename {cabi => symbolic-cabi}/include/symbolic.h (99%) rename {cabi => symbolic-cabi}/src/common.rs (100%) rename {cabi => symbolic-cabi}/src/core.rs (98%) rename {cabi => symbolic-cabi}/src/debuginfo.rs (100%) rename {cabi => symbolic-cabi}/src/demangle.rs (100%) rename {cabi => symbolic-cabi}/src/lib.rs (79%) rename {cabi => symbolic-cabi}/src/minidump.rs (100%) rename {cabi => symbolic-cabi}/src/proguard.rs (100%) rename {cabi => symbolic-cabi}/src/sourcemap.rs (100%) rename {cabi => symbolic-cabi}/src/symcache.rs (100%) rename {cabi => symbolic-cabi}/src/unreal.rs (100%) rename {cabi => symbolic-cabi}/src/utils.rs (100%) rename {common => symbolic-common}/Cargo.toml (90%) rename {common => symbolic-common}/README.md (100%) rename {common => symbolic-common}/src/byteview.rs (100%) rename {common => symbolic-common}/src/cell.rs (100%) rename {common => symbolic-common}/src/fail.rs (100%) rename {common => symbolic-common}/src/heuristics.rs (100%) rename {common => symbolic-common}/src/lib.rs (100%) rename {common => symbolic-common}/src/path.rs (100%) rename {common => symbolic-common}/src/types.rs (100%) rename {debuginfo => symbolic-debuginfo}/Cargo.toml (85%) rename {debuginfo => symbolic-debuginfo}/src/base.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/breakpad.pest (100%) rename {debuginfo => symbolic-debuginfo}/src/breakpad.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/dwarf.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/elf.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/lib.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/macho.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/object.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/pdb.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/pe.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/private.rs (100%) rename {debuginfo => symbolic-debuginfo}/src/sourcebundle.rs (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/CppConsoleApp.exe (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/CppConsoleApp.pdb (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/CppConsoleApp.pdb.sym (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/crash.exe (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/crash.pdb (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/crash.sym (100%) rename {debuginfo => symbolic-debuginfo}/tests/fixtures/msvcrt.dll (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__breakpad_files.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__breakpad_functions.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__breakpad_symbols.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__elf_files.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__elf_functions.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__elf_symbols.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__mach_files.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__mach_functions.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__mach_symbols.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__pdb_files.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__pdb_functions.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/snapshots/test_objects__pdb_symbols.snap (100%) rename {debuginfo => symbolic-debuginfo}/tests/test_objects.rs (100%) rename {demangle => symbolic-demangle}/Cargo.toml (86%) rename {demangle => symbolic-demangle}/README.md (100%) rename {demangle => symbolic-demangle}/build.rs (100%) rename {demangle => symbolic-demangle}/src/lib.rs (100%) rename {demangle => symbolic-demangle}/src/swiftdemangle.cpp (100%) rename {demangle => symbolic-demangle}/tests/test_cpp.rs (100%) rename {demangle => symbolic-demangle}/tests/test_detection.rs (100%) rename {demangle => symbolic-demangle}/tests/test_msvc.rs (100%) rename {demangle => symbolic-demangle}/tests/test_objcpp.rs (100%) rename {demangle => symbolic-demangle}/tests/test_swift.rs (100%) rename {demangle => symbolic-demangle}/tests/utils/mod.rs (100%) rename {demangle => symbolic-demangle}/vendor/swift/1-arguments.patch (100%) rename {demangle => symbolic-demangle}/vendor/swift/LICENSE.txt (100%) rename {demangle => symbolic-demangle}/vendor/swift/LICENSE_LLVM.txt (100%) rename {demangle => symbolic-demangle}/vendor/swift/README.md (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm-c/DataTypes.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/None.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/Optional.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/STLExtras.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/SmallVector.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/StringRef.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/StringSwitch.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/iterator.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/ADT/iterator_range.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Config/abi-breaking.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Config/llvm-config.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/AlignOf.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/Casting.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/Compiler.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/DataTypes.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/ErrorHandling.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/MathExtras.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/MemAlloc.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/SwapByteOrder.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/raw_ostream.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/llvm/Support/type_traits.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/AST/Ownership.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/AST/ReferenceStorage.def (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Basic/InlineBitfield.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Basic/LLVM.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Basic/STLExtras.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/Demangle.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/DemangleNodes.def (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/Demangler.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/ManglingMacros.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/ManglingUtils.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/Punycode.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/StandardTypesMangling.def (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Demangling/ValueWitnessMangling.def (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Runtime/BackDeployment.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Runtime/CMakeConfig.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Runtime/Config.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/include/swift/Strings.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/CMakeLists.txt (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/Context.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/Demangler.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/ManglingUtils.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/NodeDumper.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/NodePrinter.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/OldDemangler.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/OldRemangler.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/Punycode.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/Remangler.cpp (100%) rename {demangle => symbolic-demangle}/vendor/swift/lib/Demangling/RemanglerBase.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/stdlib/public/SwiftShims/Visibility.h (100%) rename {demangle => symbolic-demangle}/vendor/swift/update.py (100%) rename {minidump => symbolic-minidump}/Cargo.toml (78%) rename {minidump => symbolic-minidump}/build.rs (100%) rename {minidump => symbolic-minidump}/cpp/c_mapping.h (100%) rename {minidump => symbolic-minidump}/cpp/c_string.cpp (100%) rename {minidump => symbolic-minidump}/cpp/c_string.h (100%) rename {minidump => symbolic-minidump}/cpp/data_definitions.h (100%) rename {minidump => symbolic-minidump}/cpp/data_structures.cpp (100%) rename {minidump => symbolic-minidump}/cpp/data_structures.h (100%) rename {minidump => symbolic-minidump}/cpp/memstream.h (100%) rename {minidump => symbolic-minidump}/cpp/mmap_symbol_supplier.cpp (100%) rename {minidump => symbolic-minidump}/cpp/mmap_symbol_supplier.h (100%) rename {minidump => symbolic-minidump}/cpp/processor.cpp (100%) rename {minidump => symbolic-minidump}/cpp/processor.h (100%) rename {minidump => symbolic-minidump}/src/cfi.rs (100%) rename {minidump => symbolic-minidump}/src/lib.rs (100%) rename {minidump => symbolic-minidump}/src/processor.rs (100%) rename {minidump => symbolic-minidump}/src/utils.rs (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_elf.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_macho.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_pdb_windows.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_pe_windows.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_sym_linux.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_sym_macos.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_cfi__cfi_sym_windows.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__process_state_linux.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__process_state_macos.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__process_state_windows.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__referenced_modules_linux.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__referenced_modules_macos.snap (100%) rename {minidump => symbolic-minidump}/tests/snapshots/test_processor__referenced_modules_windows.snap (100%) rename {minidump => symbolic-minidump}/tests/test_cfi.rs (100%) rename {minidump => symbolic-minidump}/tests/test_processor.rs (100%) rename {minidump => symbolic-minidump}/third_party/breakpad (100%) rename {minidump => symbolic-minidump}/third_party/lss (100%) rename {proguard => symbolic-proguard}/Cargo.toml (83%) rename {proguard => symbolic-proguard}/src/lib.rs (100%) rename {sourcemap => symbolic-sourcemap}/Cargo.toml (91%) rename {sourcemap => symbolic-sourcemap}/src/lib.rs (100%) rename {sourcemap => symbolic-sourcemap}/tests/fixtures/README.md (100%) rename {sourcemap => symbolic-sourcemap}/tests/fixtures/react-native-hermes.map (100%) rename {sourcemap => symbolic-sourcemap}/tests/fixtures/react-native-metro.js (100%) rename {sourcemap => symbolic-sourcemap}/tests/fixtures/react-native-metro.js.map (100%) rename {symcache => symbolic-symcache}/Cargo.toml (74%) rename {symcache => symbolic-symcache}/benches/bench_writer.rs (100%) rename {symcache => symbolic-symcache}/src/cache.rs (100%) rename {symcache => symbolic-symcache}/src/error.rs (100%) rename {symcache => symbolic-symcache}/src/format.rs (100%) rename {symcache => symbolic-symcache}/src/lib.rs (100%) rename {symcache => symbolic-symcache}/src/writer.rs (100%) rename {symcache => symbolic-symcache}/tests/snapshots/test_cache__functions_linux.snap (100%) rename {symcache => symbolic-symcache}/tests/snapshots/test_cache__functions_macos.snap (100%) rename {symcache => symbolic-symcache}/tests/snapshots/test_cache__lookup.snap (100%) rename {symcache => symbolic-symcache}/tests/snapshots/test_writer__functions_linux.snap (100%) rename {symcache => symbolic-symcache}/tests/snapshots/test_writer__functions_macos.snap (100%) rename {symcache => symbolic-symcache}/tests/test_cache.rs (100%) rename {symcache => symbolic-symcache}/tests/test_compat.rs (100%) rename {symcache => symbolic-symcache}/tests/test_writer.rs (100%) rename {testutils => symbolic-testutils}/Cargo.toml (71%) rename {testutils => symbolic-testutils}/fixtures/linux/crash (100%) rename {testutils => symbolic-testutils}/fixtures/linux/crash.debug (100%) rename {testutils => symbolic-testutils}/fixtures/linux/crash.sym (100%) rename {testutils => symbolic-testutils}/fixtures/linux/mini.dmp (100%) rename {testutils => symbolic-testutils}/fixtures/macos/crash (100%) rename {testutils => symbolic-testutils}/fixtures/macos/crash.dSYM/Contents/Info.plist (100%) rename {testutils => symbolic-testutils}/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/crash (100%) rename {testutils => symbolic-testutils}/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/invalid (100%) rename {testutils => symbolic-testutils}/fixtures/macos/crash.sym (100%) rename {testutils => symbolic-testutils}/fixtures/macos/mini.dmp (100%) rename {testutils => symbolic-testutils}/fixtures/macos/other.dSYM/Contents/Resources/DWARF/invalid (100%) rename {testutils => symbolic-testutils}/fixtures/regression/large_symbol.sym (100%) rename {testutils => symbolic-testutils}/fixtures/symcache/compat/v1.symc (100%) rename {testutils => symbolic-testutils}/fixtures/symcache/current/linux.symc (100%) rename {testutils => symbolic-testutils}/fixtures/symcache/current/macos.symc (100%) rename {testutils => symbolic-testutils}/fixtures/unreal/unreal_crash (100%) rename {testutils => symbolic-testutils}/fixtures/unreal/unreal_crash_apple (100%) rename {testutils => symbolic-testutils}/fixtures/windows/CrashWithException.exe (100%) rename {testutils => symbolic-testutils}/fixtures/windows/CrashWithException.pdb (100%) rename {testutils => symbolic-testutils}/fixtures/windows/CrashWithException.pdb.sym (100%) rename {testutils => symbolic-testutils}/fixtures/windows/crash.exe (100%) rename {testutils => symbolic-testutils}/fixtures/windows/crash.pdb (100%) rename {testutils => symbolic-testutils}/fixtures/windows/crash.sym (100%) rename {testutils => symbolic-testutils}/fixtures/windows/mini.dmp (100%) rename {testutils => symbolic-testutils}/src/lib.rs (100%) rename {unreal => symbolic-unreal}/Cargo.toml (90%) rename {unreal => symbolic-unreal}/src/container.rs (100%) rename {unreal => symbolic-unreal}/src/context.rs (100%) rename {unreal => symbolic-unreal}/src/error.rs (100%) rename {unreal => symbolic-unreal}/src/lib.rs (100%) rename {unreal => symbolic-unreal}/src/logs.rs (100%) rename {unreal => symbolic-unreal}/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap (100%) rename {unreal => symbolic-unreal}/tests/test_unreal_crash_parse.rs (100%) create mode 100644 symbolic/Cargo.toml create mode 100644 symbolic/README.md create mode 100644 symbolic/src/lib.rs diff --git a/.gitignore b/.gitignore index 9e81fbcfd..16f1f6254 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,7 @@ # Rust target/ **/*.rs.bk -# Only ignore the library's lockfile, not for the CABI -/Cargo.lock +Cargo.lock # Python *.pyc diff --git a/.gitmodules b/.gitmodules index 57ae5d73e..4738c99d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "minidump/third_party/breakpad"] - path = minidump/third_party/breakpad + path = symbolic-minidump/third_party/breakpad url = https://github.com/getsentry/breakpad shallow = true [submodule "minidump/third_party/lss"] - path = minidump/third_party/lss + path = symbolic-minidump/third_party/lss url = https://github.com/getsentry/linux-syscall-support diff --git a/Cargo.toml b/Cargo.toml index 799bf20ce..4a8b5af50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,80 +1,9 @@ -[package] -name = "symbolic" -version = "7.5.0" -license = "MIT" -authors = [ - "Armin Ronacher ", - "Jan Michael Auer ", -] -documentation = "https://docs.rs/symbolic" -homepage = "https://github.com/getsentry/symbolic" -repository = "https://github.com/getsentry/symbolic" -readme = "README.md" -description = """ -A library to symbolicate and process stack traces from native applications, -minidumps, Unreal Engine 4, minified JavaScripts or ProGuard optimized Android apps. -""" -edition = "2018" -autoexamples = true - -include = [ - "/src/**/*.rs", - "/*.toml", - "/.gitmodules", - "/LICENSE", - "/README.md", -] - -[package.metadata.docs.rs] -all-features = true - [workspace] +members = [ + "symbolic*", + "examples/*", +] -[features] -default = ["debuginfo"] -common-serde = ["symbolic-common/serde"] -debuginfo = ["symbolic-debuginfo"] -debuginfo-serde = ["debuginfo", "common-serde"] -demangle = ["symbolic-demangle"] -minidump = ["symbolic-minidump", "debuginfo"] -minidump-serde = ["minidump", "debuginfo-serde", "symbolic-minidump/serde"] -proguard = ["symbolic-proguard"] -sourcemap = ["symbolic-sourcemap"] -symcache = ["symbolic-symcache", "debuginfo"] -unreal = ["symbolic-unreal"] -unreal-serde = ["unreal", "common-serde", "symbolic-unreal/serde"] - -[dependencies] -symbolic-common = { version = "7.5.0", path = "common" } -symbolic-debuginfo = { version = "7.5.0", path = "debuginfo", optional = true } -symbolic-demangle = { version = "7.5.0", path = "demangle", optional = true } -symbolic-minidump = { version = "7.5.0", path = "minidump", optional = true } -symbolic-proguard = { version = "7.5.0", path = "proguard", optional = true } -symbolic-sourcemap = { version = "7.5.0", path = "sourcemap", optional = true } -symbolic-symcache = { version = "7.5.0", path = "symcache", optional = true } -symbolic-unreal = { version = "7.5.0", path = "unreal", optional = true } - -[dev-dependencies] -clap = "2.33.0" -failure = "0.1.7" -walkdir = "2.3.1" - -[[example]] -name = "addr2line" -required-features = ["demangle"] - -[[example]] -name = "dump_cfi" -required-features = ["minidump"] - -[[example]] -name = "minidump_stackwalk" -required-features = ["minidump", "symcache", "demangle"] - -[[example]] -name = "symcache_debug" -required-features = ["symcache", "demangle"] - -[[example]] -name = "unreal_engine_crash" -required-features = ["unreal"] +[profile.release] +debug = true +lto = true diff --git a/Makefile b/Makefile index deb07f278..e68d48876 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ check: style lint clean: cargo clean - cargo clean --manifest-path cabi/Cargo.toml rm -rf .venv .PHONY: clean @@ -36,7 +35,7 @@ test: test-rust test-python .PHONY: test test-rust: - cargo test --all --all-features + cargo test --workspace --all-features .PHONY: test-rust test-python: .venv/bin/python @@ -52,8 +51,7 @@ style: style-rust style-python style-rust: @rustup component add rustfmt --toolchain stable 2> /dev/null - cargo +stable fmt -- --check - cd cabi && cargo +stable fmt -- --check + cargo +stable fmt --all -- --check .PHONY: style-rust style-python: .venv/bin/python @@ -67,7 +65,7 @@ lint: lint-rust lint-python lint-rust: @rustup component add clippy --toolchain stable 2> /dev/null - cargo +stable clippy --all-features --all --tests --examples -- -D clippy::all + cargo +stable clippy --all-features --workspace --tests --examples -- -D clippy::all .PHONY: lint-rust lint-python: .venv/bin/python @@ -82,8 +80,7 @@ format: format-rust format-python format-rust: @rustup component add rustfmt --toolchain stable 2> /dev/null - cargo +stable fmt - cd cabi && cargo +stable fmt + cargo +stable fmt --all .PHONY: format-rust format-python: .venv/bin/python diff --git a/README.md b/README.md index 82b48e430..8e8c7b625 100644 --- a/README.md +++ b/README.md @@ -40,31 +40,7 @@ Symbolic provides the following functionality: ## Rust Usage -Add `symbolic` as a dependency to your `Cargo.toml`. You will most likely want to activate some of -the features: - -- **`debuginfo`** (default): Contains support for various object file formats and debugging - information. Currently, this comprises MachO and ELF (with DWARF debugging), PE and PDB, as well - as Breakpad symbols. -- **`demangle`**: Demangling for Rust, C++, Swift and Objective C symbols. This feature requires a - C++14 compiler on the PATH. -- **`minidump`**: Rust bindings for the Breakpad Minidump processor. Additionally, this includes - facilities to extract stack unwinding information (sometimes called CFI) from object files. This - feature requires a C++11 compiler on the PATH. -- **`proguard`**: Processing of Proguard mapping files to look up mangled Java function paths. -- **`sourcemap`**: Processing and expansion of JavaScript source maps, as well as lookups for - minified function names. -- **`symcache`**: An optimized, platform-independent storage for common debugging information. This - allows blazing fast symbolication of instruction addresses to function names and file locations. -- **`unreal`**: Processing of Unreal Engine 4 crash reports. - -There are also alternate versions for some of the above features that additionally add -implementations for `serde::{Deserialize, Serialize}` on suitable types: - -- **`common-serde`** -- **`debuginfo-serde`** -- **`minidump-serde`** -- **`unreal-serde`** +The Rust crates are published to [Crates.io](https://crates.io/crates/symbolic) and documentation is available on [docs.rs](https://docs.rs/symbolic/latest/symbolic/). ## Python Usage diff --git a/cabi/Cargo.lock b/cabi/Cargo.lock deleted file mode 100644 index 55a5fdddb..000000000 --- a/cabi/Cargo.lock +++ /dev/null @@ -1,1134 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456d75cbb82da1ad150c8a9d97285ffcd21c9931dcb11e995903e7d75141b38b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" - -[[package]] -name = "aho-corasick" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" -dependencies = [ - "memchr", -] - -[[package]] -name = "anylog" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3677680d7f74e87066850ba07976ad03296b6ec4e17bddef05564438ffb86e" -dependencies = [ - "chrono", - "lazy_static", - "regex", -] - -[[package]] -name = "apple-crash-report-parser" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4a2dcbf6f97f12fb3b01b2b46e7d110b0e5bb3da741a36182bc939be365b8e" -dependencies = [ - "chrono", - "lazy_static", - "regex", - "serde", - "uuid", -] - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "bzip2" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.8+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05305b41c5034ff0e93937ac64133d109b5a2660114ec45e9760bc6816d83038" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "cc" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "chrono" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" -dependencies = [ - "num-integer", - "num-traits", - "serde", - "time", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cpp_demangle" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad49cad3673b9d586bc50cd92fdc0e9205ecd162d4206073d9774c4fe13a8fde" -dependencies = [ - "cfg-if", - "glob", -] - -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "debugid" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36294832663d7747e17832f32492daedb65ae665d5ae1b369edabf52a2a92afc" -dependencies = [ - "lazy_static", - "regex", - "serde", - "uuid", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dmsort" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc94b97c995cfd2f02fc3972ae0f385cd441b50bb7610b59c7c779d5aec7444" - -[[package]] -name = "elementtree" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c5d32d0ab83734d2d7452047ef901c105991044b7b07da30fe82371a149a25" -dependencies = [ - "string_cache", - "xml-rs", -] - -[[package]] -name = "failure" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "flate2" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" -dependencies = [ - "cfg-if", - "crc32fast", - "libc", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "gimli" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" -dependencies = [ - "fallible-iterator", - "stable_deref_trait", -] - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "goblin" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884" -dependencies = [ - "log", - "plain", - "scroll", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "if_chain" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" - -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" - -[[package]] -name = "libc" -version = "0.2.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -dependencies = [ - "adler32", -] - -[[package]] -name = "msvc-demangler" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6584cf122f02fc0396420a116cd395a9a776ec4347dffe1c5119c3fcc917c060" -dependencies = [ - "bitflags", -] - -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "parking_lot" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "pdb" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66be5fcea88b52962d3d6fcc5194f1d77666f5aca256926688743a8de1152e4" -dependencies = [ - "fallible-iterator", - "scroll", - "uuid", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pest_meta" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" -dependencies = [ - "maplit", - "pest", - "sha-1", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher", -] - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "podio" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" - -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - -[[package]] -name = "proc-macro2" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "proguard" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0d8a8e23b9f03fb2d05f7f00431cb671514ab40384a310e41059b0d29e650f" -dependencies = [ - "lazy_static", - "uuid", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "regex" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8900ebc1363efa7ea1c399ccc32daed870b4002651e0bed86e72d501ebbe0048" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "scroll" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - -[[package]] -name = "siphasher" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83da420ee8d1a89e640d0948c646c1c088758d3a3c538f943bfa97bdac17929d" - -[[package]] -name = "smallvec" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" - -[[package]] -name = "sourcemap" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd57aa9e5cea41b4a3c26a61039fad5585e2154ffe057a2656540a21b03a2d2" -dependencies = [ - "base64", - "if_chain", - "lazy_static", - "regex", - "rustc_version", - "serde", - "serde_json", - "url", -] - -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" - -[[package]] -name = "string_cache" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a" -dependencies = [ - "lazy_static", - "new_debug_unreachable", - "phf_shared", - "precomputed-hash", - "serde", -] - -[[package]] -name = "symbolic" -version = "7.5.0" -dependencies = [ - "symbolic-common", - "symbolic-debuginfo", - "symbolic-demangle", - "symbolic-minidump", - "symbolic-proguard", - "symbolic-sourcemap", - "symbolic-symcache", - "symbolic-unreal", -] - -[[package]] -name = "symbolic-cabi" -version = "7.5.0" -dependencies = [ - "apple-crash-report-parser", - "failure", - "proguard", - "serde_json", - "symbolic", -] - -[[package]] -name = "symbolic-common" -version = "7.5.0" -dependencies = [ - "debugid", - "failure", - "memmap", - "serde", - "stable_deref_trait", - "uuid", -] - -[[package]] -name = "symbolic-debuginfo" -version = "7.5.0" -dependencies = [ - "dmsort", - "failure", - "fallible-iterator", - "flate2", - "gimli", - "goblin", - "lazy_static", - "lazycell", - "parking_lot", - "pdb", - "pest", - "pest_derive", - "regex", - "serde", - "serde_json", - "smallvec", - "symbolic-common", - "zip", -] - -[[package]] -name = "symbolic-demangle" -version = "7.5.0" -dependencies = [ - "cc", - "cpp_demangle", - "msvc-demangler", - "rustc-demangle", - "symbolic-common", -] - -[[package]] -name = "symbolic-minidump" -version = "7.5.0" -dependencies = [ - "cc", - "failure", - "lazy_static", - "regex", - "symbolic-common", - "symbolic-debuginfo", -] - -[[package]] -name = "symbolic-proguard" -version = "7.5.0" -dependencies = [ - "proguard", - "symbolic-common", -] - -[[package]] -name = "symbolic-sourcemap" -version = "7.5.0" -dependencies = [ - "failure", - "sourcemap", -] - -[[package]] -name = "symbolic-symcache" -version = "7.5.0" -dependencies = [ - "dmsort", - "failure", - "fnv", - "num", - "symbolic-common", - "symbolic-debuginfo", -] - -[[package]] -name = "symbolic-unreal" -version = "7.5.0" -dependencies = [ - "anylog", - "bytes", - "chrono", - "elementtree", - "failure", - "flate2", - "lazy_static", - "regex", - "scroll", - "serde", -] - -[[package]] -name = "syn" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -dependencies = [ - "libc", - "redox_syscall", - "winapi", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" - -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" -dependencies = [ - "smallvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "uuid" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" -dependencies = [ - "serde", - "sha1", -] - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "xml-rs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" - -[[package]] -name = "zip" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df134e83b8f0f8153a094c7b0fd79dfebe437f1d76e7715afa18ed95ebe2fd7" -dependencies = [ - "bzip2", - "crc32fast", - "flate2", - "podio", - "time", -] diff --git a/examples/addr2line/Cargo.toml b/examples/addr2line/Cargo.toml new file mode 100644 index 000000000..d11e5a52d --- /dev/null +++ b/examples/addr2line/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "addr2line" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic", features = ["demangle"] } diff --git a/examples/addr2line.rs b/examples/addr2line/src/main.rs similarity index 100% rename from examples/addr2line.rs rename to examples/addr2line/src/main.rs diff --git a/examples/dump_cfi/Cargo.toml b/examples/dump_cfi/Cargo.toml new file mode 100644 index 000000000..e8689fe79 --- /dev/null +++ b/examples/dump_cfi/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "dump_cfi" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic", features = ["minidump"] } diff --git a/examples/dump_cfi.rs b/examples/dump_cfi/src/main.rs similarity index 100% rename from examples/dump_cfi.rs rename to examples/dump_cfi/src/main.rs diff --git a/examples/dump_sources/Cargo.toml b/examples/dump_sources/Cargo.toml new file mode 100644 index 000000000..047ac75b2 --- /dev/null +++ b/examples/dump_sources/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "dump_sources" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic" } diff --git a/examples/dump_sources.rs b/examples/dump_sources/src/main.rs similarity index 100% rename from examples/dump_sources.rs rename to examples/dump_sources/src/main.rs diff --git a/examples/minidump_stackwalk/Cargo.toml b/examples/minidump_stackwalk/Cargo.toml new file mode 100644 index 000000000..1fd89e0ef --- /dev/null +++ b/examples/minidump_stackwalk/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "minidump_stackwalk" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic", features = ["minidump", "symcache", "demangle"] } +walkdir = "2.3.1" diff --git a/examples/minidump_stackwalk.rs b/examples/minidump_stackwalk/src/main.rs similarity index 100% rename from examples/minidump_stackwalk.rs rename to examples/minidump_stackwalk/src/main.rs diff --git a/examples/object_debug/Cargo.toml b/examples/object_debug/Cargo.toml new file mode 100644 index 000000000..2880677f1 --- /dev/null +++ b/examples/object_debug/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "object_debug" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic" } diff --git a/examples/object_debug.rs b/examples/object_debug/src/main.rs similarity index 100% rename from examples/object_debug.rs rename to examples/object_debug/src/main.rs diff --git a/examples/symcache_debug/Cargo.toml b/examples/symcache_debug/Cargo.toml new file mode 100644 index 000000000..6bb737f75 --- /dev/null +++ b/examples/symcache_debug/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "symcache_debug" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic", features = ["symcache", "demangle"] } diff --git a/examples/symcache_debug.rs b/examples/symcache_debug/src/main.rs similarity index 100% rename from examples/symcache_debug.rs rename to examples/symcache_debug/src/main.rs diff --git a/examples/unreal_engine_crash/Cargo.toml b/examples/unreal_engine_crash/Cargo.toml new file mode 100644 index 000000000..3e2c5c440 --- /dev/null +++ b/examples/unreal_engine_crash/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "unreal_engine_crash" +version = "0.1.0" +authors = ["Jan Michael Auer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.0" +failure = "0.1.7" +symbolic = { path = "../../symbolic", features = ["unreal"] } diff --git a/examples/unreal_engine_crash.rs b/examples/unreal_engine_crash/src/main.rs similarity index 100% rename from examples/unreal_engine_crash.rs rename to examples/unreal_engine_crash/src/main.rs diff --git a/py/setup.py b/py/setup.py index 4300077b5..817dac2e4 100644 --- a/py/setup.py +++ b/py/setup.py @@ -19,8 +19,8 @@ readme = f.read() -if os.path.isfile("../cabi/Cargo.toml"): - with open("../cabi/Cargo.toml") as f: +if os.path.isfile("../symbolic-cabi/Cargo.toml"): + with open("../symbolic-cabi/Cargo.toml") as f: version = _version_re.search(f.read()).group(1) else: with open("version.txt") as f: @@ -44,7 +44,7 @@ def run(self): def build_native(spec): - cmd = ["cargo", "build"] + cmd = ["cargo", "build", "-p", "symbolic-cabi"] if not DEBUG_BUILD: cmd.append("--release") target = "release" @@ -52,7 +52,7 @@ def build_native(spec): target = "debug" # Step 0: find rust sources - if not os.path.isfile("../cabi/Cargo.toml"): + if not os.path.isfile("../symbolic-cabi/Cargo.toml"): scratchpad = tempfile.mkdtemp() @atexit.register @@ -64,9 +64,9 @@ def delete_scratchpad(): zf = zipfile.ZipFile("rustsrc.zip") zf.extractall(scratchpad) - rust_path = scratchpad + "/rustsrc/cabi" + rust_path = scratchpad + "/rustsrc" else: - rust_path = "../cabi" + rust_path = ".." scratchpad = None # Step 1: build the rust library @@ -78,8 +78,10 @@ def delete_scratchpad(): rtld_flags.append("NODELETE") spec.add_cffi_module( module_path="symbolic._lowlevel", - dylib=lambda: build.find_dylib("symbolic", in_path="target/%s" % target), - header_filename=lambda: build.find_header("symbolic.h", in_path="include"), + dylib=lambda: build.find_dylib("symbolic_cabi", in_path="target/%s" % target), + header_filename=lambda: build.find_header( + "symbolic.h", in_path="symbolic-cabi/include" + ), rtld_flags=rtld_flags, ) diff --git a/py/tests/test_debug.py b/py/tests/test_debug.py index c1e1d2eee..e5fd32d67 100644 --- a/py/tests/test_debug.py +++ b/py/tests/test_debug.py @@ -89,7 +89,7 @@ def test_normalize_debug_id(): == "dfb8e43a-f242-3d73-a453-aeb6a777ef75-a" ) assert ( - normalize_debug_id("dfb8e43af2423d73a453aeb6a777ef75-a") + normalize_debug_id("dfb8e43af2423d73a453aeb6a777ef75a") == "dfb8e43a-f242-3d73-a453-aeb6a777ef75-a" ) assert ( diff --git a/run b/run index 9eb6c46f5..d61b0fb4d 100755 --- a/run +++ b/run @@ -26,4 +26,4 @@ EXAMPLE="$1"; shift set -x -cargo run --quiet --all-features --example $EXAMPLE $FLAGS -- "$@" +cargo run --quiet --package $EXAMPLE $FLAGS -- "$@" diff --git a/scripts/bump-version b/scripts/bump-version index b598fd3f7..1ab8c6a91 100755 --- a/scripts/bump-version +++ b/scripts/bump-version @@ -12,6 +12,3 @@ echo "Bumping version: ${NEW_VERSION}" find . -name Cargo.toml -type f -exec sed -i '' -e "s/^version.*/version = \"$NEW_VERSION\"/" {} \; find . -name Cargo.toml -type f -exec sed -i '' -e "s/^\(symbolic.*version = \)\"[^\"]*\"/\\1\"$NEW_VERSION\"/" {} \; cargo update -p symbolic --precise "${NEW_VERSION}" - -cd cabi/ -cargo update -p symbolic --precise "${NEW_VERSION}" diff --git a/scripts/cargo-publish-all b/scripts/cargo-publish-all deleted file mode 100755 index 38e263cf6..000000000 --- a/scripts/cargo-publish-all +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -import os -import json -import subprocess - -def sort_by_dep(unsorted): - sorted = [] - unsorted = dict(unsorted) - while unsorted: - for node, edges in unsorted.items(): - for edge in edges: - if edge in unsorted: - break - else: - del unsorted[node] - sorted.append((node, edges)) - return sorted - - -def load_metadata(): - return json.loads(subprocess.Popen( - 'cargo metadata --no-deps --format-version=1', - shell=True, stdout=subprocess.PIPE).communicate()[0]) - - -def get_packages(): - metadata = load_metadata() - graph = [] - for pkg in metadata['packages']: - graph.append(( - pkg['name'], - [x['name'] for x in pkg['dependencies'] if x['name'].startswith('symbolic-')] - )) - return sort_by_dep(graph) - -for pkg, deps in get_packages(): - # this is a bit of a hack - if os.path.isdir(pkg): - subprocess.Popen(['cargo', 'publish'], cwd=pkg).wait() - else: - subprocess.Popen(['cargo', 'publish']).wait() diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index d63061020..000000000 --- a/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Symbolic works with symbols and debug info. -//! -//! This library implements various utilities to help Sentry -//! symbolicate stacktraces. It is built to also be used independently -//! of Sentry and in parts. - -#![warn(missing_docs)] - -#[doc(inline)] -pub use symbolic_common as common; -#[doc(inline)] -#[cfg(feature = "debuginfo")] -pub use symbolic_debuginfo as debuginfo; -#[doc(inline)] -#[cfg(feature = "demangle")] -pub use symbolic_demangle as demangle; -#[doc(inline)] -#[cfg(feature = "minidump")] -pub use symbolic_minidump as minidump; -#[doc(inline)] -#[cfg(feature = "proguard")] -#[deprecated = "use the `proguard` crate directly"] -pub use symbolic_proguard as proguard; -#[doc(inline)] -#[cfg(feature = "sourcemap")] -pub use symbolic_sourcemap as sourcemap; -#[doc(inline)] -#[cfg(feature = "symcache")] -pub use symbolic_symcache as symcache; -#[doc(inline)] -#[cfg(feature = "unreal")] -pub use symbolic_unreal as unreal; diff --git a/cabi/Cargo.toml b/symbolic-cabi/Cargo.toml similarity index 76% rename from cabi/Cargo.toml rename to symbolic-cabi/Cargo.toml index 3771e95c0..c8c170850 100644 --- a/cabi/Cargo.toml +++ b/symbolic-cabi/Cargo.toml @@ -14,20 +14,14 @@ traces from native applications, minidumps, minified JavaScripts or ProGuard optimized Android apps. """ edition = "2018" +publish = false [lib] -name = "symbolic" crate-type = ["cdylib"] -[workspace] - -[profile.release] -debug = true -lto = true - [dependencies] serde_json = "1.0.40" failure = "0.1.5" apple-crash-report-parser = { version = "0.4.0", features = ["with_serde"] } -symbolic = { version = "7.5.0", path = "..", features = ["debuginfo", "demangle", "minidump", "proguard", "sourcemap", "symcache", "unreal-serde"] } +symbolic = { version = "7.5.0", path = "../symbolic", features = ["debuginfo", "demangle", "minidump", "proguard", "sourcemap", "symcache", "unreal-serde"] } proguard = { version = "4.0.1", features = ["uuid"] } diff --git a/cabi/Makefile b/symbolic-cabi/Makefile similarity index 91% rename from cabi/Makefile rename to symbolic-cabi/Makefile index c24f88f13..346ea5c2c 100644 --- a/cabi/Makefile +++ b/symbolic-cabi/Makefile @@ -31,4 +31,4 @@ include/symbolic.h: *.toml src/*.rs target/debug/c-tests/%: c-tests/%.c include/symbolic.h @mkdir -p target/debug/c-tests - $(CC) -Iinclude -Ltarget/debug -lsymbolic $< -o $@ + $(CC) -Iinclude -L../target/debug -lsymbolic_cabi $< -o $@ diff --git a/cabi/README.md b/symbolic-cabi/README.md similarity index 96% rename from cabi/README.md rename to symbolic-cabi/README.md index fcb79a8d1..e7f735d36 100644 --- a/cabi/README.md +++ b/symbolic-cabi/README.md @@ -14,7 +14,7 @@ Building the dynamic library has the same requirements as building the `symbolic - A checkout of this repository and all its GIT submodules. To build, run `make release` in this directory. This creates a release build of the dynamic library -in `cabi/target/release/libsymbolic.*`. +in `target/release/libsymbolic.*`. ## Usage @@ -41,7 +41,7 @@ int main() { In your application, point to the symbolic include directory and specify the symbolic library: ```bash -$(CC) -Isymbolic/cabi/include -Lsymbolic/cabi/target/release -lsymbolic -o myprogram main.c +$(CC) -Isymbolic/symbolic-cabi/include -Lsymbolic/target/release -lsymbolic_cabi -o myprogram main.c ``` ## Development diff --git a/cabi/c-tests/common.c b/symbolic-cabi/c-tests/common.c similarity index 100% rename from cabi/c-tests/common.c rename to symbolic-cabi/c-tests/common.c diff --git a/cabi/c-tests/demangle b/symbolic-cabi/c-tests/demangle similarity index 100% rename from cabi/c-tests/demangle rename to symbolic-cabi/c-tests/demangle diff --git a/cabi/c-tests/demangle.c b/symbolic-cabi/c-tests/demangle.c similarity index 100% rename from cabi/c-tests/demangle.c rename to symbolic-cabi/c-tests/demangle.c diff --git a/cabi/c-tests/object.c b/symbolic-cabi/c-tests/object.c similarity index 100% rename from cabi/c-tests/object.c rename to symbolic-cabi/c-tests/object.c diff --git a/cabi/cbindgen.toml b/symbolic-cabi/cbindgen.toml similarity index 100% rename from cabi/cbindgen.toml rename to symbolic-cabi/cbindgen.toml diff --git a/cabi/include/symbolic.h b/symbolic-cabi/include/symbolic.h similarity index 99% rename from cabi/include/symbolic.h rename to symbolic-cabi/include/symbolic.h index 338147833..59bc2711a 100644 --- a/cabi/include/symbolic.h +++ b/symbolic-cabi/include/symbolic.h @@ -79,6 +79,7 @@ enum SymbolicErrorCode { SYMBOLIC_ERROR_CODE_APPLE_CRASH_REPORT_PARSE_ERROR_INVALID_INCIDENT_IDENTIFIER = 8002, SYMBOLIC_ERROR_CODE_APPLE_CRASH_REPORT_PARSE_ERROR_INVALID_REPORT_VERSION = 8003, SYMBOLIC_ERROR_CODE_APPLE_CRASH_REPORT_PARSE_ERROR_INVALID_TIMESTAMP = 8004, + SYMBOLIC_ERROR_CODE_APPLE_CRASH_REPORT_PARSE_ERROR_INVALID_IMAGE_IDENTIFIER = 8005, }; typedef uint32_t SymbolicErrorCode; diff --git a/cabi/src/common.rs b/symbolic-cabi/src/common.rs similarity index 100% rename from cabi/src/common.rs rename to symbolic-cabi/src/common.rs diff --git a/cabi/src/core.rs b/symbolic-cabi/src/core.rs similarity index 98% rename from cabi/src/core.rs rename to symbolic-cabi/src/core.rs index 0b1eadbc7..d283a4f95 100644 --- a/cabi/src/core.rs +++ b/symbolic-cabi/src/core.rs @@ -218,11 +218,12 @@ pub enum SymbolicErrorCode { AppleCrashReportParseErrorInvalidIncidentIdentifier = 8002, AppleCrashReportParseErrorInvalidReportVersion = 8003, AppleCrashReportParseErrorInvalidTimestamp = 8004, + AppleCrashReportParseErrorInvalidImageIdentifier = 8005, } impl SymbolicErrorCode { /// This maps all errors that can possibly happen. - #[allow(clippy::cyclomatic_complexity)] + // #[allow(clippy::cyclomatic_complexity)] pub fn from_error(error: &Error) -> SymbolicErrorCode { for cause in error.iter_chain() { if cause.downcast_ref::().is_some() { @@ -388,6 +389,9 @@ impl SymbolicErrorCode { ParseError::InvalidIncidentIdentifier(_) => { SymbolicErrorCode::AppleCrashReportParseErrorInvalidIncidentIdentifier } + ParseError::InvalidImageIdentifier(_) => { + SymbolicErrorCode::AppleCrashReportParseErrorInvalidImageIdentifier + } ParseError::InvalidReportVersion(_) => { SymbolicErrorCode::AppleCrashReportParseErrorInvalidReportVersion } diff --git a/cabi/src/debuginfo.rs b/symbolic-cabi/src/debuginfo.rs similarity index 100% rename from cabi/src/debuginfo.rs rename to symbolic-cabi/src/debuginfo.rs diff --git a/cabi/src/demangle.rs b/symbolic-cabi/src/demangle.rs similarity index 100% rename from cabi/src/demangle.rs rename to symbolic-cabi/src/demangle.rs diff --git a/cabi/src/lib.rs b/symbolic-cabi/src/lib.rs similarity index 79% rename from cabi/src/lib.rs rename to symbolic-cabi/src/lib.rs index 519c4f192..7eb1f43f6 100644 --- a/cabi/src/lib.rs +++ b/symbolic-cabi/src/lib.rs @@ -1,5 +1,6 @@ -//! Exposes a C-ABI for symbolic -#![allow(clippy::cast_ptr_alignment)] +//! Exposes a C-ABI for symbolic. + +#![allow(clippy::cast_ptr_alignment, clippy::missing_safety_doc)] #[macro_use] mod utils; diff --git a/cabi/src/minidump.rs b/symbolic-cabi/src/minidump.rs similarity index 100% rename from cabi/src/minidump.rs rename to symbolic-cabi/src/minidump.rs diff --git a/cabi/src/proguard.rs b/symbolic-cabi/src/proguard.rs similarity index 100% rename from cabi/src/proguard.rs rename to symbolic-cabi/src/proguard.rs diff --git a/cabi/src/sourcemap.rs b/symbolic-cabi/src/sourcemap.rs similarity index 100% rename from cabi/src/sourcemap.rs rename to symbolic-cabi/src/sourcemap.rs diff --git a/cabi/src/symcache.rs b/symbolic-cabi/src/symcache.rs similarity index 100% rename from cabi/src/symcache.rs rename to symbolic-cabi/src/symcache.rs diff --git a/cabi/src/unreal.rs b/symbolic-cabi/src/unreal.rs similarity index 100% rename from cabi/src/unreal.rs rename to symbolic-cabi/src/unreal.rs diff --git a/cabi/src/utils.rs b/symbolic-cabi/src/utils.rs similarity index 100% rename from cabi/src/utils.rs rename to symbolic-cabi/src/utils.rs diff --git a/common/Cargo.toml b/symbolic-common/Cargo.toml similarity index 90% rename from common/Cargo.toml rename to symbolic-common/Cargo.toml index bec72a1a1..06fdda023 100644 --- a/common/Cargo.toml +++ b/symbolic-common/Cargo.toml @@ -17,6 +17,9 @@ ProGuard optimized Android apps. """ edition = "2018" +[package.metadata.docs.rs] +all-features = true + [dependencies] debugid = "0.7.1" failure = "0.1.5" @@ -26,7 +29,7 @@ serde_ = { package = "serde", version = "1.0.88", optional = true, features = [" uuid = "0.8.1" [dev-dependencies] -symbolic-testutils = { path = "../testutils" } +symbolic-testutils = { path = "../symbolic-testutils" } tempfile = "3.1.0" [features] diff --git a/common/README.md b/symbolic-common/README.md similarity index 100% rename from common/README.md rename to symbolic-common/README.md diff --git a/common/src/byteview.rs b/symbolic-common/src/byteview.rs similarity index 100% rename from common/src/byteview.rs rename to symbolic-common/src/byteview.rs diff --git a/common/src/cell.rs b/symbolic-common/src/cell.rs similarity index 100% rename from common/src/cell.rs rename to symbolic-common/src/cell.rs diff --git a/common/src/fail.rs b/symbolic-common/src/fail.rs similarity index 100% rename from common/src/fail.rs rename to symbolic-common/src/fail.rs diff --git a/common/src/heuristics.rs b/symbolic-common/src/heuristics.rs similarity index 100% rename from common/src/heuristics.rs rename to symbolic-common/src/heuristics.rs diff --git a/common/src/lib.rs b/symbolic-common/src/lib.rs similarity index 100% rename from common/src/lib.rs rename to symbolic-common/src/lib.rs diff --git a/common/src/path.rs b/symbolic-common/src/path.rs similarity index 100% rename from common/src/path.rs rename to symbolic-common/src/path.rs diff --git a/common/src/types.rs b/symbolic-common/src/types.rs similarity index 100% rename from common/src/types.rs rename to symbolic-common/src/types.rs diff --git a/debuginfo/Cargo.toml b/symbolic-debuginfo/Cargo.toml similarity index 85% rename from debuginfo/Cargo.toml rename to symbolic-debuginfo/Cargo.toml index a8d79c3b5..0ea3020d9 100644 --- a/debuginfo/Cargo.toml +++ b/symbolic-debuginfo/Cargo.toml @@ -19,6 +19,9 @@ exclude = [ "tests/**/*", ] +[package.metadata.docs.rs] +all-features = true + [dependencies] dmsort = "1.0.0" failure = "0.1.5" @@ -36,9 +39,9 @@ regex = "1.3.5" serde = { version = "1.0.94", features = ["derive"] } serde_json = "1.0.40" smallvec = "1.2.0" -symbolic-common = { version = "7.5.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } zip = "0.5.2" [dev-dependencies] insta = "0.15.0" -symbolic-testutils = { path = "../testutils" } +symbolic-testutils = { path = "../symbolic-testutils" } diff --git a/debuginfo/src/base.rs b/symbolic-debuginfo/src/base.rs similarity index 100% rename from debuginfo/src/base.rs rename to symbolic-debuginfo/src/base.rs diff --git a/debuginfo/src/breakpad.pest b/symbolic-debuginfo/src/breakpad.pest similarity index 100% rename from debuginfo/src/breakpad.pest rename to symbolic-debuginfo/src/breakpad.pest diff --git a/debuginfo/src/breakpad.rs b/symbolic-debuginfo/src/breakpad.rs similarity index 100% rename from debuginfo/src/breakpad.rs rename to symbolic-debuginfo/src/breakpad.rs diff --git a/debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs similarity index 100% rename from debuginfo/src/dwarf.rs rename to symbolic-debuginfo/src/dwarf.rs diff --git a/debuginfo/src/elf.rs b/symbolic-debuginfo/src/elf.rs similarity index 100% rename from debuginfo/src/elf.rs rename to symbolic-debuginfo/src/elf.rs diff --git a/debuginfo/src/lib.rs b/symbolic-debuginfo/src/lib.rs similarity index 100% rename from debuginfo/src/lib.rs rename to symbolic-debuginfo/src/lib.rs diff --git a/debuginfo/src/macho.rs b/symbolic-debuginfo/src/macho.rs similarity index 100% rename from debuginfo/src/macho.rs rename to symbolic-debuginfo/src/macho.rs diff --git a/debuginfo/src/object.rs b/symbolic-debuginfo/src/object.rs similarity index 100% rename from debuginfo/src/object.rs rename to symbolic-debuginfo/src/object.rs diff --git a/debuginfo/src/pdb.rs b/symbolic-debuginfo/src/pdb.rs similarity index 100% rename from debuginfo/src/pdb.rs rename to symbolic-debuginfo/src/pdb.rs diff --git a/debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs similarity index 100% rename from debuginfo/src/pe.rs rename to symbolic-debuginfo/src/pe.rs diff --git a/debuginfo/src/private.rs b/symbolic-debuginfo/src/private.rs similarity index 100% rename from debuginfo/src/private.rs rename to symbolic-debuginfo/src/private.rs diff --git a/debuginfo/src/sourcebundle.rs b/symbolic-debuginfo/src/sourcebundle.rs similarity index 100% rename from debuginfo/src/sourcebundle.rs rename to symbolic-debuginfo/src/sourcebundle.rs diff --git a/debuginfo/tests/fixtures/CppConsoleApp.exe b/symbolic-debuginfo/tests/fixtures/CppConsoleApp.exe similarity index 100% rename from debuginfo/tests/fixtures/CppConsoleApp.exe rename to symbolic-debuginfo/tests/fixtures/CppConsoleApp.exe diff --git a/debuginfo/tests/fixtures/CppConsoleApp.pdb b/symbolic-debuginfo/tests/fixtures/CppConsoleApp.pdb similarity index 100% rename from debuginfo/tests/fixtures/CppConsoleApp.pdb rename to symbolic-debuginfo/tests/fixtures/CppConsoleApp.pdb diff --git a/debuginfo/tests/fixtures/CppConsoleApp.pdb.sym b/symbolic-debuginfo/tests/fixtures/CppConsoleApp.pdb.sym similarity index 100% rename from debuginfo/tests/fixtures/CppConsoleApp.pdb.sym rename to symbolic-debuginfo/tests/fixtures/CppConsoleApp.pdb.sym diff --git a/debuginfo/tests/fixtures/crash.exe b/symbolic-debuginfo/tests/fixtures/crash.exe similarity index 100% rename from debuginfo/tests/fixtures/crash.exe rename to symbolic-debuginfo/tests/fixtures/crash.exe diff --git a/debuginfo/tests/fixtures/crash.pdb b/symbolic-debuginfo/tests/fixtures/crash.pdb similarity index 100% rename from debuginfo/tests/fixtures/crash.pdb rename to symbolic-debuginfo/tests/fixtures/crash.pdb diff --git a/debuginfo/tests/fixtures/crash.sym b/symbolic-debuginfo/tests/fixtures/crash.sym similarity index 100% rename from debuginfo/tests/fixtures/crash.sym rename to symbolic-debuginfo/tests/fixtures/crash.sym diff --git a/debuginfo/tests/fixtures/msvcrt.dll b/symbolic-debuginfo/tests/fixtures/msvcrt.dll similarity index 100% rename from debuginfo/tests/fixtures/msvcrt.dll rename to symbolic-debuginfo/tests/fixtures/msvcrt.dll diff --git a/debuginfo/tests/snapshots/test_objects__breakpad_files.snap b/symbolic-debuginfo/tests/snapshots/test_objects__breakpad_files.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__breakpad_files.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__breakpad_files.snap diff --git a/debuginfo/tests/snapshots/test_objects__breakpad_functions.snap b/symbolic-debuginfo/tests/snapshots/test_objects__breakpad_functions.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__breakpad_functions.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__breakpad_functions.snap diff --git a/debuginfo/tests/snapshots/test_objects__breakpad_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__breakpad_symbols.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__breakpad_symbols.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__breakpad_symbols.snap diff --git a/debuginfo/tests/snapshots/test_objects__elf_files.snap b/symbolic-debuginfo/tests/snapshots/test_objects__elf_files.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__elf_files.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__elf_files.snap diff --git a/debuginfo/tests/snapshots/test_objects__elf_functions.snap b/symbolic-debuginfo/tests/snapshots/test_objects__elf_functions.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__elf_functions.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__elf_functions.snap diff --git a/debuginfo/tests/snapshots/test_objects__elf_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__elf_symbols.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap diff --git a/debuginfo/tests/snapshots/test_objects__mach_files.snap b/symbolic-debuginfo/tests/snapshots/test_objects__mach_files.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__mach_files.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__mach_files.snap diff --git a/debuginfo/tests/snapshots/test_objects__mach_functions.snap b/symbolic-debuginfo/tests/snapshots/test_objects__mach_functions.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__mach_functions.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__mach_functions.snap diff --git a/debuginfo/tests/snapshots/test_objects__mach_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__mach_symbols.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__mach_symbols.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__mach_symbols.snap diff --git a/debuginfo/tests/snapshots/test_objects__pdb_files.snap b/symbolic-debuginfo/tests/snapshots/test_objects__pdb_files.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__pdb_files.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__pdb_files.snap diff --git a/debuginfo/tests/snapshots/test_objects__pdb_functions.snap b/symbolic-debuginfo/tests/snapshots/test_objects__pdb_functions.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__pdb_functions.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__pdb_functions.snap diff --git a/debuginfo/tests/snapshots/test_objects__pdb_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap similarity index 100% rename from debuginfo/tests/snapshots/test_objects__pdb_symbols.snap rename to symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap diff --git a/debuginfo/tests/test_objects.rs b/symbolic-debuginfo/tests/test_objects.rs similarity index 100% rename from debuginfo/tests/test_objects.rs rename to symbolic-debuginfo/tests/test_objects.rs diff --git a/demangle/Cargo.toml b/symbolic-demangle/Cargo.toml similarity index 86% rename from demangle/Cargo.toml rename to symbolic-demangle/Cargo.toml index 269e92cd7..2cdb0129a 100644 --- a/demangle/Cargo.toml +++ b/symbolic-demangle/Cargo.toml @@ -20,11 +20,14 @@ exclude = [ "tests/**/*", ] +[package.metadata.docs.rs] +all-features = true + [dependencies] cpp_demangle = "0.3.0" msvc-demangler = "0.8.0" rustc-demangle = "0.1.16" -symbolic-common = { version = "7.5.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } [build-dependencies] cc = "1.0.50" diff --git a/demangle/README.md b/symbolic-demangle/README.md similarity index 100% rename from demangle/README.md rename to symbolic-demangle/README.md diff --git a/demangle/build.rs b/symbolic-demangle/build.rs similarity index 100% rename from demangle/build.rs rename to symbolic-demangle/build.rs diff --git a/demangle/src/lib.rs b/symbolic-demangle/src/lib.rs similarity index 100% rename from demangle/src/lib.rs rename to symbolic-demangle/src/lib.rs diff --git a/demangle/src/swiftdemangle.cpp b/symbolic-demangle/src/swiftdemangle.cpp similarity index 100% rename from demangle/src/swiftdemangle.cpp rename to symbolic-demangle/src/swiftdemangle.cpp diff --git a/demangle/tests/test_cpp.rs b/symbolic-demangle/tests/test_cpp.rs similarity index 100% rename from demangle/tests/test_cpp.rs rename to symbolic-demangle/tests/test_cpp.rs diff --git a/demangle/tests/test_detection.rs b/symbolic-demangle/tests/test_detection.rs similarity index 100% rename from demangle/tests/test_detection.rs rename to symbolic-demangle/tests/test_detection.rs diff --git a/demangle/tests/test_msvc.rs b/symbolic-demangle/tests/test_msvc.rs similarity index 100% rename from demangle/tests/test_msvc.rs rename to symbolic-demangle/tests/test_msvc.rs diff --git a/demangle/tests/test_objcpp.rs b/symbolic-demangle/tests/test_objcpp.rs similarity index 100% rename from demangle/tests/test_objcpp.rs rename to symbolic-demangle/tests/test_objcpp.rs diff --git a/demangle/tests/test_swift.rs b/symbolic-demangle/tests/test_swift.rs similarity index 100% rename from demangle/tests/test_swift.rs rename to symbolic-demangle/tests/test_swift.rs diff --git a/demangle/tests/utils/mod.rs b/symbolic-demangle/tests/utils/mod.rs similarity index 100% rename from demangle/tests/utils/mod.rs rename to symbolic-demangle/tests/utils/mod.rs diff --git a/demangle/vendor/swift/1-arguments.patch b/symbolic-demangle/vendor/swift/1-arguments.patch similarity index 100% rename from demangle/vendor/swift/1-arguments.patch rename to symbolic-demangle/vendor/swift/1-arguments.patch diff --git a/demangle/vendor/swift/LICENSE.txt b/symbolic-demangle/vendor/swift/LICENSE.txt similarity index 100% rename from demangle/vendor/swift/LICENSE.txt rename to symbolic-demangle/vendor/swift/LICENSE.txt diff --git a/demangle/vendor/swift/LICENSE_LLVM.txt b/symbolic-demangle/vendor/swift/LICENSE_LLVM.txt similarity index 100% rename from demangle/vendor/swift/LICENSE_LLVM.txt rename to symbolic-demangle/vendor/swift/LICENSE_LLVM.txt diff --git a/demangle/vendor/swift/README.md b/symbolic-demangle/vendor/swift/README.md similarity index 100% rename from demangle/vendor/swift/README.md rename to symbolic-demangle/vendor/swift/README.md diff --git a/demangle/vendor/swift/include/llvm-c/DataTypes.h b/symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h similarity index 100% rename from demangle/vendor/swift/include/llvm-c/DataTypes.h rename to symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h diff --git a/demangle/vendor/swift/include/llvm/ADT/None.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/None.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/None.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/None.h diff --git a/demangle/vendor/swift/include/llvm/ADT/Optional.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/Optional.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h diff --git a/demangle/vendor/swift/include/llvm/ADT/STLExtras.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/STLExtras.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h diff --git a/demangle/vendor/swift/include/llvm/ADT/SmallVector.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/SmallVector.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/SmallVector.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/SmallVector.h diff --git a/demangle/vendor/swift/include/llvm/ADT/StringRef.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/StringRef.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/StringRef.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/StringRef.h diff --git a/demangle/vendor/swift/include/llvm/ADT/StringSwitch.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/StringSwitch.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/StringSwitch.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/StringSwitch.h diff --git a/demangle/vendor/swift/include/llvm/ADT/iterator.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/iterator.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/iterator.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/iterator.h diff --git a/demangle/vendor/swift/include/llvm/ADT/iterator_range.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/iterator_range.h similarity index 100% rename from demangle/vendor/swift/include/llvm/ADT/iterator_range.h rename to symbolic-demangle/vendor/swift/include/llvm/ADT/iterator_range.h diff --git a/demangle/vendor/swift/include/llvm/Config/abi-breaking.h b/symbolic-demangle/vendor/swift/include/llvm/Config/abi-breaking.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Config/abi-breaking.h rename to symbolic-demangle/vendor/swift/include/llvm/Config/abi-breaking.h diff --git a/demangle/vendor/swift/include/llvm/Config/llvm-config.h b/symbolic-demangle/vendor/swift/include/llvm/Config/llvm-config.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Config/llvm-config.h rename to symbolic-demangle/vendor/swift/include/llvm/Config/llvm-config.h diff --git a/demangle/vendor/swift/include/llvm/Support/AlignOf.h b/symbolic-demangle/vendor/swift/include/llvm/Support/AlignOf.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/AlignOf.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/AlignOf.h diff --git a/demangle/vendor/swift/include/llvm/Support/Casting.h b/symbolic-demangle/vendor/swift/include/llvm/Support/Casting.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/Casting.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/Casting.h diff --git a/demangle/vendor/swift/include/llvm/Support/Compiler.h b/symbolic-demangle/vendor/swift/include/llvm/Support/Compiler.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/Compiler.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/Compiler.h diff --git a/demangle/vendor/swift/include/llvm/Support/DataTypes.h b/symbolic-demangle/vendor/swift/include/llvm/Support/DataTypes.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/DataTypes.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/DataTypes.h diff --git a/demangle/vendor/swift/include/llvm/Support/ErrorHandling.h b/symbolic-demangle/vendor/swift/include/llvm/Support/ErrorHandling.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/ErrorHandling.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/ErrorHandling.h diff --git a/demangle/vendor/swift/include/llvm/Support/MathExtras.h b/symbolic-demangle/vendor/swift/include/llvm/Support/MathExtras.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/MathExtras.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/MathExtras.h diff --git a/demangle/vendor/swift/include/llvm/Support/MemAlloc.h b/symbolic-demangle/vendor/swift/include/llvm/Support/MemAlloc.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/MemAlloc.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/MemAlloc.h diff --git a/demangle/vendor/swift/include/llvm/Support/SwapByteOrder.h b/symbolic-demangle/vendor/swift/include/llvm/Support/SwapByteOrder.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/SwapByteOrder.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/SwapByteOrder.h diff --git a/demangle/vendor/swift/include/llvm/Support/raw_ostream.h b/symbolic-demangle/vendor/swift/include/llvm/Support/raw_ostream.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/raw_ostream.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/raw_ostream.h diff --git a/demangle/vendor/swift/include/llvm/Support/type_traits.h b/symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h similarity index 100% rename from demangle/vendor/swift/include/llvm/Support/type_traits.h rename to symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h diff --git a/demangle/vendor/swift/include/swift/AST/Ownership.h b/symbolic-demangle/vendor/swift/include/swift/AST/Ownership.h similarity index 100% rename from demangle/vendor/swift/include/swift/AST/Ownership.h rename to symbolic-demangle/vendor/swift/include/swift/AST/Ownership.h diff --git a/demangle/vendor/swift/include/swift/AST/ReferenceStorage.def b/symbolic-demangle/vendor/swift/include/swift/AST/ReferenceStorage.def similarity index 100% rename from demangle/vendor/swift/include/swift/AST/ReferenceStorage.def rename to symbolic-demangle/vendor/swift/include/swift/AST/ReferenceStorage.def diff --git a/demangle/vendor/swift/include/swift/Basic/InlineBitfield.h b/symbolic-demangle/vendor/swift/include/swift/Basic/InlineBitfield.h similarity index 100% rename from demangle/vendor/swift/include/swift/Basic/InlineBitfield.h rename to symbolic-demangle/vendor/swift/include/swift/Basic/InlineBitfield.h diff --git a/demangle/vendor/swift/include/swift/Basic/LLVM.h b/symbolic-demangle/vendor/swift/include/swift/Basic/LLVM.h similarity index 100% rename from demangle/vendor/swift/include/swift/Basic/LLVM.h rename to symbolic-demangle/vendor/swift/include/swift/Basic/LLVM.h diff --git a/demangle/vendor/swift/include/swift/Basic/STLExtras.h b/symbolic-demangle/vendor/swift/include/swift/Basic/STLExtras.h similarity index 100% rename from demangle/vendor/swift/include/swift/Basic/STLExtras.h rename to symbolic-demangle/vendor/swift/include/swift/Basic/STLExtras.h diff --git a/demangle/vendor/swift/include/swift/Demangling/Demangle.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/Demangle.h rename to symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h diff --git a/demangle/vendor/swift/include/swift/Demangling/DemangleNodes.def b/symbolic-demangle/vendor/swift/include/swift/Demangling/DemangleNodes.def similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/DemangleNodes.def rename to symbolic-demangle/vendor/swift/include/swift/Demangling/DemangleNodes.def diff --git a/demangle/vendor/swift/include/swift/Demangling/Demangler.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangler.h similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/Demangler.h rename to symbolic-demangle/vendor/swift/include/swift/Demangling/Demangler.h diff --git a/demangle/vendor/swift/include/swift/Demangling/ManglingMacros.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/ManglingMacros.h similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/ManglingMacros.h rename to symbolic-demangle/vendor/swift/include/swift/Demangling/ManglingMacros.h diff --git a/demangle/vendor/swift/include/swift/Demangling/ManglingUtils.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/ManglingUtils.h similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/ManglingUtils.h rename to symbolic-demangle/vendor/swift/include/swift/Demangling/ManglingUtils.h diff --git a/demangle/vendor/swift/include/swift/Demangling/Punycode.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Punycode.h similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/Punycode.h rename to symbolic-demangle/vendor/swift/include/swift/Demangling/Punycode.h diff --git a/demangle/vendor/swift/include/swift/Demangling/StandardTypesMangling.def b/symbolic-demangle/vendor/swift/include/swift/Demangling/StandardTypesMangling.def similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/StandardTypesMangling.def rename to symbolic-demangle/vendor/swift/include/swift/Demangling/StandardTypesMangling.def diff --git a/demangle/vendor/swift/include/swift/Demangling/ValueWitnessMangling.def b/symbolic-demangle/vendor/swift/include/swift/Demangling/ValueWitnessMangling.def similarity index 100% rename from demangle/vendor/swift/include/swift/Demangling/ValueWitnessMangling.def rename to symbolic-demangle/vendor/swift/include/swift/Demangling/ValueWitnessMangling.def diff --git a/demangle/vendor/swift/include/swift/Runtime/BackDeployment.h b/symbolic-demangle/vendor/swift/include/swift/Runtime/BackDeployment.h similarity index 100% rename from demangle/vendor/swift/include/swift/Runtime/BackDeployment.h rename to symbolic-demangle/vendor/swift/include/swift/Runtime/BackDeployment.h diff --git a/demangle/vendor/swift/include/swift/Runtime/CMakeConfig.h b/symbolic-demangle/vendor/swift/include/swift/Runtime/CMakeConfig.h similarity index 100% rename from demangle/vendor/swift/include/swift/Runtime/CMakeConfig.h rename to symbolic-demangle/vendor/swift/include/swift/Runtime/CMakeConfig.h diff --git a/demangle/vendor/swift/include/swift/Runtime/Config.h b/symbolic-demangle/vendor/swift/include/swift/Runtime/Config.h similarity index 100% rename from demangle/vendor/swift/include/swift/Runtime/Config.h rename to symbolic-demangle/vendor/swift/include/swift/Runtime/Config.h diff --git a/demangle/vendor/swift/include/swift/Strings.h b/symbolic-demangle/vendor/swift/include/swift/Strings.h similarity index 100% rename from demangle/vendor/swift/include/swift/Strings.h rename to symbolic-demangle/vendor/swift/include/swift/Strings.h diff --git a/demangle/vendor/swift/lib/Demangling/CMakeLists.txt b/symbolic-demangle/vendor/swift/lib/Demangling/CMakeLists.txt similarity index 100% rename from demangle/vendor/swift/lib/Demangling/CMakeLists.txt rename to symbolic-demangle/vendor/swift/lib/Demangling/CMakeLists.txt diff --git a/demangle/vendor/swift/lib/Demangling/Context.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/Context.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/Context.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/Context.cpp diff --git a/demangle/vendor/swift/lib/Demangling/Demangler.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/Demangler.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/Demangler.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/Demangler.cpp diff --git a/demangle/vendor/swift/lib/Demangling/ManglingUtils.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/ManglingUtils.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/ManglingUtils.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/ManglingUtils.cpp diff --git a/demangle/vendor/swift/lib/Demangling/NodeDumper.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/NodeDumper.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/NodeDumper.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/NodeDumper.cpp diff --git a/demangle/vendor/swift/lib/Demangling/NodePrinter.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/NodePrinter.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp diff --git a/demangle/vendor/swift/lib/Demangling/OldDemangler.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/OldDemangler.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/OldDemangler.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/OldDemangler.cpp diff --git a/demangle/vendor/swift/lib/Demangling/OldRemangler.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/OldRemangler.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/OldRemangler.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/OldRemangler.cpp diff --git a/demangle/vendor/swift/lib/Demangling/Punycode.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/Punycode.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/Punycode.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/Punycode.cpp diff --git a/demangle/vendor/swift/lib/Demangling/Remangler.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/Remangler.cpp similarity index 100% rename from demangle/vendor/swift/lib/Demangling/Remangler.cpp rename to symbolic-demangle/vendor/swift/lib/Demangling/Remangler.cpp diff --git a/demangle/vendor/swift/lib/Demangling/RemanglerBase.h b/symbolic-demangle/vendor/swift/lib/Demangling/RemanglerBase.h similarity index 100% rename from demangle/vendor/swift/lib/Demangling/RemanglerBase.h rename to symbolic-demangle/vendor/swift/lib/Demangling/RemanglerBase.h diff --git a/demangle/vendor/swift/stdlib/public/SwiftShims/Visibility.h b/symbolic-demangle/vendor/swift/stdlib/public/SwiftShims/Visibility.h similarity index 100% rename from demangle/vendor/swift/stdlib/public/SwiftShims/Visibility.h rename to symbolic-demangle/vendor/swift/stdlib/public/SwiftShims/Visibility.h diff --git a/demangle/vendor/swift/update.py b/symbolic-demangle/vendor/swift/update.py similarity index 100% rename from demangle/vendor/swift/update.py rename to symbolic-demangle/vendor/swift/update.py diff --git a/minidump/Cargo.toml b/symbolic-minidump/Cargo.toml similarity index 78% rename from minidump/Cargo.toml rename to symbolic-minidump/Cargo.toml index 2a7706b70..9be448559 100644 --- a/minidump/Cargo.toml +++ b/symbolic-minidump/Cargo.toml @@ -26,17 +26,20 @@ include = [ "/Cargo.toml", ] +[package.metadata.docs.rs] +all-features = true + [dependencies] failure = "0.1.5" lazy_static = "1.4.0" regex = "1.3.5" serde = { version = "1.0.94", optional = true } -symbolic-common = { version = "7.5.0", path = "../common" } -symbolic-debuginfo = { version = "7.5.0", path = "../debuginfo" } +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } +symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo" } [build-dependencies] cc = { version = "1.0.50", features = ["parallel"] } [dev-dependencies] insta = "0.15.0" -symbolic-testutils = { path = "../testutils" } +symbolic-testutils = { path = "../symbolic-testutils" } diff --git a/minidump/build.rs b/symbolic-minidump/build.rs similarity index 100% rename from minidump/build.rs rename to symbolic-minidump/build.rs diff --git a/minidump/cpp/c_mapping.h b/symbolic-minidump/cpp/c_mapping.h similarity index 100% rename from minidump/cpp/c_mapping.h rename to symbolic-minidump/cpp/c_mapping.h diff --git a/minidump/cpp/c_string.cpp b/symbolic-minidump/cpp/c_string.cpp similarity index 100% rename from minidump/cpp/c_string.cpp rename to symbolic-minidump/cpp/c_string.cpp diff --git a/minidump/cpp/c_string.h b/symbolic-minidump/cpp/c_string.h similarity index 100% rename from minidump/cpp/c_string.h rename to symbolic-minidump/cpp/c_string.h diff --git a/minidump/cpp/data_definitions.h b/symbolic-minidump/cpp/data_definitions.h similarity index 100% rename from minidump/cpp/data_definitions.h rename to symbolic-minidump/cpp/data_definitions.h diff --git a/minidump/cpp/data_structures.cpp b/symbolic-minidump/cpp/data_structures.cpp similarity index 100% rename from minidump/cpp/data_structures.cpp rename to symbolic-minidump/cpp/data_structures.cpp diff --git a/minidump/cpp/data_structures.h b/symbolic-minidump/cpp/data_structures.h similarity index 100% rename from minidump/cpp/data_structures.h rename to symbolic-minidump/cpp/data_structures.h diff --git a/minidump/cpp/memstream.h b/symbolic-minidump/cpp/memstream.h similarity index 100% rename from minidump/cpp/memstream.h rename to symbolic-minidump/cpp/memstream.h diff --git a/minidump/cpp/mmap_symbol_supplier.cpp b/symbolic-minidump/cpp/mmap_symbol_supplier.cpp similarity index 100% rename from minidump/cpp/mmap_symbol_supplier.cpp rename to symbolic-minidump/cpp/mmap_symbol_supplier.cpp diff --git a/minidump/cpp/mmap_symbol_supplier.h b/symbolic-minidump/cpp/mmap_symbol_supplier.h similarity index 100% rename from minidump/cpp/mmap_symbol_supplier.h rename to symbolic-minidump/cpp/mmap_symbol_supplier.h diff --git a/minidump/cpp/processor.cpp b/symbolic-minidump/cpp/processor.cpp similarity index 100% rename from minidump/cpp/processor.cpp rename to symbolic-minidump/cpp/processor.cpp diff --git a/minidump/cpp/processor.h b/symbolic-minidump/cpp/processor.h similarity index 100% rename from minidump/cpp/processor.h rename to symbolic-minidump/cpp/processor.h diff --git a/minidump/src/cfi.rs b/symbolic-minidump/src/cfi.rs similarity index 100% rename from minidump/src/cfi.rs rename to symbolic-minidump/src/cfi.rs diff --git a/minidump/src/lib.rs b/symbolic-minidump/src/lib.rs similarity index 100% rename from minidump/src/lib.rs rename to symbolic-minidump/src/lib.rs diff --git a/minidump/src/processor.rs b/symbolic-minidump/src/processor.rs similarity index 100% rename from minidump/src/processor.rs rename to symbolic-minidump/src/processor.rs diff --git a/minidump/src/utils.rs b/symbolic-minidump/src/utils.rs similarity index 100% rename from minidump/src/utils.rs rename to symbolic-minidump/src/utils.rs diff --git a/minidump/tests/snapshots/test_cfi__cfi_elf.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_elf.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_elf.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_elf.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_macho.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_macho.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_macho.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_macho.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_pdb_windows.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_pdb_windows.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_pdb_windows.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_pdb_windows.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_pe_windows.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_pe_windows.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_pe_windows.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_pe_windows.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_sym_linux.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_linux.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_sym_linux.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_linux.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_sym_macos.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_macos.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_sym_macos.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_macos.snap diff --git a/minidump/tests/snapshots/test_cfi__cfi_sym_windows.snap b/symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_windows.snap similarity index 100% rename from minidump/tests/snapshots/test_cfi__cfi_sym_windows.snap rename to symbolic-minidump/tests/snapshots/test_cfi__cfi_sym_windows.snap diff --git a/minidump/tests/snapshots/test_processor__process_state_linux.snap b/symbolic-minidump/tests/snapshots/test_processor__process_state_linux.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__process_state_linux.snap rename to symbolic-minidump/tests/snapshots/test_processor__process_state_linux.snap diff --git a/minidump/tests/snapshots/test_processor__process_state_macos.snap b/symbolic-minidump/tests/snapshots/test_processor__process_state_macos.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__process_state_macos.snap rename to symbolic-minidump/tests/snapshots/test_processor__process_state_macos.snap diff --git a/minidump/tests/snapshots/test_processor__process_state_windows.snap b/symbolic-minidump/tests/snapshots/test_processor__process_state_windows.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__process_state_windows.snap rename to symbolic-minidump/tests/snapshots/test_processor__process_state_windows.snap diff --git a/minidump/tests/snapshots/test_processor__referenced_modules_linux.snap b/symbolic-minidump/tests/snapshots/test_processor__referenced_modules_linux.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__referenced_modules_linux.snap rename to symbolic-minidump/tests/snapshots/test_processor__referenced_modules_linux.snap diff --git a/minidump/tests/snapshots/test_processor__referenced_modules_macos.snap b/symbolic-minidump/tests/snapshots/test_processor__referenced_modules_macos.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__referenced_modules_macos.snap rename to symbolic-minidump/tests/snapshots/test_processor__referenced_modules_macos.snap diff --git a/minidump/tests/snapshots/test_processor__referenced_modules_windows.snap b/symbolic-minidump/tests/snapshots/test_processor__referenced_modules_windows.snap similarity index 100% rename from minidump/tests/snapshots/test_processor__referenced_modules_windows.snap rename to symbolic-minidump/tests/snapshots/test_processor__referenced_modules_windows.snap diff --git a/minidump/tests/test_cfi.rs b/symbolic-minidump/tests/test_cfi.rs similarity index 100% rename from minidump/tests/test_cfi.rs rename to symbolic-minidump/tests/test_cfi.rs diff --git a/minidump/tests/test_processor.rs b/symbolic-minidump/tests/test_processor.rs similarity index 100% rename from minidump/tests/test_processor.rs rename to symbolic-minidump/tests/test_processor.rs diff --git a/minidump/third_party/breakpad b/symbolic-minidump/third_party/breakpad similarity index 100% rename from minidump/third_party/breakpad rename to symbolic-minidump/third_party/breakpad diff --git a/minidump/third_party/lss b/symbolic-minidump/third_party/lss similarity index 100% rename from minidump/third_party/lss rename to symbolic-minidump/third_party/lss diff --git a/proguard/Cargo.toml b/symbolic-proguard/Cargo.toml similarity index 83% rename from proguard/Cargo.toml rename to symbolic-proguard/Cargo.toml index 1d6653b6b..a7e93ff48 100644 --- a/proguard/Cargo.toml +++ b/symbolic-proguard/Cargo.toml @@ -16,6 +16,9 @@ optimized applications. """ edition = "2018" +[package.metadata.docs.rs] +all-features = true + [dependencies] proguard = { version = "4.0.1", features = ["uuid"] } -symbolic-common = { version = "7.5.0", path = "../common" } +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } diff --git a/proguard/src/lib.rs b/symbolic-proguard/src/lib.rs similarity index 100% rename from proguard/src/lib.rs rename to symbolic-proguard/src/lib.rs diff --git a/sourcemap/Cargo.toml b/symbolic-sourcemap/Cargo.toml similarity index 91% rename from sourcemap/Cargo.toml rename to symbolic-sourcemap/Cargo.toml index 7f7812720..426c1bf66 100644 --- a/sourcemap/Cargo.toml +++ b/symbolic-sourcemap/Cargo.toml @@ -15,6 +15,9 @@ source code or stack traces. """ edition = "2018" +[package.metadata.docs.rs] +all-features = true + [dependencies] failure = "0.1.5" sourcemap = "5.0.0" diff --git a/sourcemap/src/lib.rs b/symbolic-sourcemap/src/lib.rs similarity index 100% rename from sourcemap/src/lib.rs rename to symbolic-sourcemap/src/lib.rs diff --git a/sourcemap/tests/fixtures/README.md b/symbolic-sourcemap/tests/fixtures/README.md similarity index 100% rename from sourcemap/tests/fixtures/README.md rename to symbolic-sourcemap/tests/fixtures/README.md diff --git a/sourcemap/tests/fixtures/react-native-hermes.map b/symbolic-sourcemap/tests/fixtures/react-native-hermes.map similarity index 100% rename from sourcemap/tests/fixtures/react-native-hermes.map rename to symbolic-sourcemap/tests/fixtures/react-native-hermes.map diff --git a/sourcemap/tests/fixtures/react-native-metro.js b/symbolic-sourcemap/tests/fixtures/react-native-metro.js similarity index 100% rename from sourcemap/tests/fixtures/react-native-metro.js rename to symbolic-sourcemap/tests/fixtures/react-native-metro.js diff --git a/sourcemap/tests/fixtures/react-native-metro.js.map b/symbolic-sourcemap/tests/fixtures/react-native-metro.js.map similarity index 100% rename from sourcemap/tests/fixtures/react-native-metro.js.map rename to symbolic-sourcemap/tests/fixtures/react-native-metro.js.map diff --git a/symcache/Cargo.toml b/symbolic-symcache/Cargo.toml similarity index 74% rename from symcache/Cargo.toml rename to symbolic-symcache/Cargo.toml index c879eb774..9578fac3b 100644 --- a/symcache/Cargo.toml +++ b/symbolic-symcache/Cargo.toml @@ -19,18 +19,21 @@ exclude = [ "tests/**/*", ] +[package.metadata.docs.rs] +all-features = true + [dependencies] dmsort = "1.0.0" failure = "0.1.5" fnv = "1.0.6" num = "0.2.1" -symbolic-common = { version = "7.5.0", path = "../common" } -symbolic-debuginfo = { version = "7.5.0", path = "../debuginfo" } +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } +symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo" } [dev-dependencies] insta = "0.15.0" criterion = "0.3.1" -symbolic-testutils = { path = "../testutils" } +symbolic-testutils = { path = "../symbolic-testutils" } [features] bench = [] diff --git a/symcache/benches/bench_writer.rs b/symbolic-symcache/benches/bench_writer.rs similarity index 100% rename from symcache/benches/bench_writer.rs rename to symbolic-symcache/benches/bench_writer.rs diff --git a/symcache/src/cache.rs b/symbolic-symcache/src/cache.rs similarity index 100% rename from symcache/src/cache.rs rename to symbolic-symcache/src/cache.rs diff --git a/symcache/src/error.rs b/symbolic-symcache/src/error.rs similarity index 100% rename from symcache/src/error.rs rename to symbolic-symcache/src/error.rs diff --git a/symcache/src/format.rs b/symbolic-symcache/src/format.rs similarity index 100% rename from symcache/src/format.rs rename to symbolic-symcache/src/format.rs diff --git a/symcache/src/lib.rs b/symbolic-symcache/src/lib.rs similarity index 100% rename from symcache/src/lib.rs rename to symbolic-symcache/src/lib.rs diff --git a/symcache/src/writer.rs b/symbolic-symcache/src/writer.rs similarity index 100% rename from symcache/src/writer.rs rename to symbolic-symcache/src/writer.rs diff --git a/symcache/tests/snapshots/test_cache__functions_linux.snap b/symbolic-symcache/tests/snapshots/test_cache__functions_linux.snap similarity index 100% rename from symcache/tests/snapshots/test_cache__functions_linux.snap rename to symbolic-symcache/tests/snapshots/test_cache__functions_linux.snap diff --git a/symcache/tests/snapshots/test_cache__functions_macos.snap b/symbolic-symcache/tests/snapshots/test_cache__functions_macos.snap similarity index 100% rename from symcache/tests/snapshots/test_cache__functions_macos.snap rename to symbolic-symcache/tests/snapshots/test_cache__functions_macos.snap diff --git a/symcache/tests/snapshots/test_cache__lookup.snap b/symbolic-symcache/tests/snapshots/test_cache__lookup.snap similarity index 100% rename from symcache/tests/snapshots/test_cache__lookup.snap rename to symbolic-symcache/tests/snapshots/test_cache__lookup.snap diff --git a/symcache/tests/snapshots/test_writer__functions_linux.snap b/symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap similarity index 100% rename from symcache/tests/snapshots/test_writer__functions_linux.snap rename to symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap diff --git a/symcache/tests/snapshots/test_writer__functions_macos.snap b/symbolic-symcache/tests/snapshots/test_writer__functions_macos.snap similarity index 100% rename from symcache/tests/snapshots/test_writer__functions_macos.snap rename to symbolic-symcache/tests/snapshots/test_writer__functions_macos.snap diff --git a/symcache/tests/test_cache.rs b/symbolic-symcache/tests/test_cache.rs similarity index 100% rename from symcache/tests/test_cache.rs rename to symbolic-symcache/tests/test_cache.rs diff --git a/symcache/tests/test_compat.rs b/symbolic-symcache/tests/test_compat.rs similarity index 100% rename from symcache/tests/test_compat.rs rename to symbolic-symcache/tests/test_compat.rs diff --git a/symcache/tests/test_writer.rs b/symbolic-symcache/tests/test_writer.rs similarity index 100% rename from symcache/tests/test_writer.rs rename to symbolic-symcache/tests/test_writer.rs diff --git a/testutils/Cargo.toml b/symbolic-testutils/Cargo.toml similarity index 71% rename from testutils/Cargo.toml rename to symbolic-testutils/Cargo.toml index c5bcad865..72babfb56 100644 --- a/testutils/Cargo.toml +++ b/symbolic-testutils/Cargo.toml @@ -5,4 +5,7 @@ license = "MIT" edition = "2018" publish = false +[package.metadata.docs.rs] +all-features = true + [dependencies] diff --git a/testutils/fixtures/linux/crash b/symbolic-testutils/fixtures/linux/crash similarity index 100% rename from testutils/fixtures/linux/crash rename to symbolic-testutils/fixtures/linux/crash diff --git a/testutils/fixtures/linux/crash.debug b/symbolic-testutils/fixtures/linux/crash.debug similarity index 100% rename from testutils/fixtures/linux/crash.debug rename to symbolic-testutils/fixtures/linux/crash.debug diff --git a/testutils/fixtures/linux/crash.sym b/symbolic-testutils/fixtures/linux/crash.sym similarity index 100% rename from testutils/fixtures/linux/crash.sym rename to symbolic-testutils/fixtures/linux/crash.sym diff --git a/testutils/fixtures/linux/mini.dmp b/symbolic-testutils/fixtures/linux/mini.dmp similarity index 100% rename from testutils/fixtures/linux/mini.dmp rename to symbolic-testutils/fixtures/linux/mini.dmp diff --git a/testutils/fixtures/macos/crash b/symbolic-testutils/fixtures/macos/crash similarity index 100% rename from testutils/fixtures/macos/crash rename to symbolic-testutils/fixtures/macos/crash diff --git a/testutils/fixtures/macos/crash.dSYM/Contents/Info.plist b/symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Info.plist similarity index 100% rename from testutils/fixtures/macos/crash.dSYM/Contents/Info.plist rename to symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Info.plist diff --git a/testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/crash b/symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/crash similarity index 100% rename from testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/crash rename to symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/crash diff --git a/testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/invalid b/symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/invalid similarity index 100% rename from testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/invalid rename to symbolic-testutils/fixtures/macos/crash.dSYM/Contents/Resources/DWARF/invalid diff --git a/testutils/fixtures/macos/crash.sym b/symbolic-testutils/fixtures/macos/crash.sym similarity index 100% rename from testutils/fixtures/macos/crash.sym rename to symbolic-testutils/fixtures/macos/crash.sym diff --git a/testutils/fixtures/macos/mini.dmp b/symbolic-testutils/fixtures/macos/mini.dmp similarity index 100% rename from testutils/fixtures/macos/mini.dmp rename to symbolic-testutils/fixtures/macos/mini.dmp diff --git a/testutils/fixtures/macos/other.dSYM/Contents/Resources/DWARF/invalid b/symbolic-testutils/fixtures/macos/other.dSYM/Contents/Resources/DWARF/invalid similarity index 100% rename from testutils/fixtures/macos/other.dSYM/Contents/Resources/DWARF/invalid rename to symbolic-testutils/fixtures/macos/other.dSYM/Contents/Resources/DWARF/invalid diff --git a/testutils/fixtures/regression/large_symbol.sym b/symbolic-testutils/fixtures/regression/large_symbol.sym similarity index 100% rename from testutils/fixtures/regression/large_symbol.sym rename to symbolic-testutils/fixtures/regression/large_symbol.sym diff --git a/testutils/fixtures/symcache/compat/v1.symc b/symbolic-testutils/fixtures/symcache/compat/v1.symc similarity index 100% rename from testutils/fixtures/symcache/compat/v1.symc rename to symbolic-testutils/fixtures/symcache/compat/v1.symc diff --git a/testutils/fixtures/symcache/current/linux.symc b/symbolic-testutils/fixtures/symcache/current/linux.symc similarity index 100% rename from testutils/fixtures/symcache/current/linux.symc rename to symbolic-testutils/fixtures/symcache/current/linux.symc diff --git a/testutils/fixtures/symcache/current/macos.symc b/symbolic-testutils/fixtures/symcache/current/macos.symc similarity index 100% rename from testutils/fixtures/symcache/current/macos.symc rename to symbolic-testutils/fixtures/symcache/current/macos.symc diff --git a/testutils/fixtures/unreal/unreal_crash b/symbolic-testutils/fixtures/unreal/unreal_crash similarity index 100% rename from testutils/fixtures/unreal/unreal_crash rename to symbolic-testutils/fixtures/unreal/unreal_crash diff --git a/testutils/fixtures/unreal/unreal_crash_apple b/symbolic-testutils/fixtures/unreal/unreal_crash_apple similarity index 100% rename from testutils/fixtures/unreal/unreal_crash_apple rename to symbolic-testutils/fixtures/unreal/unreal_crash_apple diff --git a/testutils/fixtures/windows/CrashWithException.exe b/symbolic-testutils/fixtures/windows/CrashWithException.exe similarity index 100% rename from testutils/fixtures/windows/CrashWithException.exe rename to symbolic-testutils/fixtures/windows/CrashWithException.exe diff --git a/testutils/fixtures/windows/CrashWithException.pdb b/symbolic-testutils/fixtures/windows/CrashWithException.pdb similarity index 100% rename from testutils/fixtures/windows/CrashWithException.pdb rename to symbolic-testutils/fixtures/windows/CrashWithException.pdb diff --git a/testutils/fixtures/windows/CrashWithException.pdb.sym b/symbolic-testutils/fixtures/windows/CrashWithException.pdb.sym similarity index 100% rename from testutils/fixtures/windows/CrashWithException.pdb.sym rename to symbolic-testutils/fixtures/windows/CrashWithException.pdb.sym diff --git a/testutils/fixtures/windows/crash.exe b/symbolic-testutils/fixtures/windows/crash.exe similarity index 100% rename from testutils/fixtures/windows/crash.exe rename to symbolic-testutils/fixtures/windows/crash.exe diff --git a/testutils/fixtures/windows/crash.pdb b/symbolic-testutils/fixtures/windows/crash.pdb similarity index 100% rename from testutils/fixtures/windows/crash.pdb rename to symbolic-testutils/fixtures/windows/crash.pdb diff --git a/testutils/fixtures/windows/crash.sym b/symbolic-testutils/fixtures/windows/crash.sym similarity index 100% rename from testutils/fixtures/windows/crash.sym rename to symbolic-testutils/fixtures/windows/crash.sym diff --git a/testutils/fixtures/windows/mini.dmp b/symbolic-testutils/fixtures/windows/mini.dmp similarity index 100% rename from testutils/fixtures/windows/mini.dmp rename to symbolic-testutils/fixtures/windows/mini.dmp diff --git a/testutils/src/lib.rs b/symbolic-testutils/src/lib.rs similarity index 100% rename from testutils/src/lib.rs rename to symbolic-testutils/src/lib.rs diff --git a/unreal/Cargo.toml b/symbolic-unreal/Cargo.toml similarity index 90% rename from unreal/Cargo.toml rename to symbolic-unreal/Cargo.toml index 4212f6fde..cad0f6b5b 100644 --- a/unreal/Cargo.toml +++ b/symbolic-unreal/Cargo.toml @@ -19,6 +19,9 @@ exclude = [ "tests/**/*", ] +[package.metadata.docs.rs] +all-features = true + [features] serde = ["serde_", "chrono/serde"] @@ -36,4 +39,4 @@ serde_ = { package = "serde", version = "1.0.94", optional = true, features = [" [dev-dependencies] insta = "0.15.0" -symbolic-testutils = { path = "../testutils" } +symbolic-testutils = { path = "../symbolic-testutils" } diff --git a/unreal/src/container.rs b/symbolic-unreal/src/container.rs similarity index 100% rename from unreal/src/container.rs rename to symbolic-unreal/src/container.rs diff --git a/unreal/src/context.rs b/symbolic-unreal/src/context.rs similarity index 100% rename from unreal/src/context.rs rename to symbolic-unreal/src/context.rs diff --git a/unreal/src/error.rs b/symbolic-unreal/src/error.rs similarity index 100% rename from unreal/src/error.rs rename to symbolic-unreal/src/error.rs diff --git a/unreal/src/lib.rs b/symbolic-unreal/src/lib.rs similarity index 100% rename from unreal/src/lib.rs rename to symbolic-unreal/src/lib.rs diff --git a/unreal/src/logs.rs b/symbolic-unreal/src/logs.rs similarity index 100% rename from unreal/src/logs.rs rename to symbolic-unreal/src/logs.rs diff --git a/unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap b/symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap similarity index 100% rename from unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap rename to symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap diff --git a/unreal/tests/test_unreal_crash_parse.rs b/symbolic-unreal/tests/test_unreal_crash_parse.rs similarity index 100% rename from unreal/tests/test_unreal_crash_parse.rs rename to symbolic-unreal/tests/test_unreal_crash_parse.rs diff --git a/symbolic/Cargo.toml b/symbolic/Cargo.toml new file mode 100644 index 000000000..2e601d19a --- /dev/null +++ b/symbolic/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "symbolic" +version = "7.5.0" +license = "MIT" +authors = [ + "Armin Ronacher ", + "Jan Michael Auer ", +] +documentation = "https://docs.rs/symbolic" +homepage = "https://github.com/getsentry/symbolic" +repository = "https://github.com/getsentry/symbolic" +readme = "README.md" +description = """ +A library to symbolicate and process stack traces from native applications, +minidumps, Unreal Engine 4, minified JavaScripts or ProGuard optimized Android apps. +""" +edition = "2018" + +[package.metadata.docs.rs] +all-features = true + +[features] +default = ["debuginfo"] +common-serde = ["symbolic-common/serde"] +debuginfo = ["symbolic-debuginfo"] +debuginfo-serde = ["debuginfo", "common-serde"] +demangle = ["symbolic-demangle"] +minidump = ["symbolic-minidump", "debuginfo"] +minidump-serde = ["minidump", "debuginfo-serde", "symbolic-minidump/serde"] +proguard = ["symbolic-proguard"] +sourcemap = ["symbolic-sourcemap"] +symcache = ["symbolic-symcache", "debuginfo"] +unreal = ["symbolic-unreal"] +unreal-serde = ["unreal", "common-serde", "symbolic-unreal/serde"] + +[dependencies] +symbolic-common = { version = "7.5.0", path = "../symbolic-common" } +symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo", optional = true } +symbolic-demangle = { version = "7.5.0", path = "../symbolic-demangle", optional = true } +symbolic-minidump = { version = "7.5.0", path = "../symbolic-minidump", optional = true } +symbolic-proguard = { version = "7.5.0", path = "../symbolic-proguard", optional = true } +symbolic-sourcemap = { version = "7.5.0", path = "../symbolic-sourcemap", optional = true } +symbolic-symcache = { version = "7.5.0", path = "../symbolic-symcache", optional = true } +symbolic-unreal = { version = "7.5.0", path = "../symbolic-unreal", optional = true } + +[badges] +travis-ci = { repository = "getsentry/symbolic", branch = "master" } diff --git a/symbolic/README.md b/symbolic/README.md new file mode 100644 index 000000000..14855d419 --- /dev/null +++ b/symbolic/README.md @@ -0,0 +1,67 @@ +[![Build Status](https://travis-ci.org/getsentry/symbolic.svg?branch=master)](https://travis-ci.org/getsentry/symbolic) + +# symbolic + +[Symbolic](https://docs.rs/symbolic) is a library written in Rust which is used at +[Sentry](https://sentry.io/) to implement symbolication of native stack traces, sourcemap +handling for minified JavaScript and more. It consists of multiple largely independent crates +which are bundled together into a C and Python library so it can be used independently of Rust. + +## What's in the package + +Symbolic provides the following functionality: + +- Symbolication based on custom cache files (symcache) +- Symbol cache file generators from: + - Mach, ELF and PE symbol tables + - Mach and ELF embedded DWARF data + - PDB CodeView debug information + - Breakpad symbol files +- Demangling support + - C++ (GCC, clang and MSVC) + - Objective C / Objective C++ + - Rust + - Swift +- JavaScript sourcemap expansion + - Basic token mapping + - Heuristics to find original function names based on minified sources + - Indexed sourcemap to sourcemap merging +- Proguard function mappings +- Minidump / Breakpad processing + - Generate Breakpad symbol files from Mach, ELF and PDBs + - Process Minidumps to retrieve stack traces +- Convenient C and Python library +- Processing of Unreal Engine 4 native crash reports + - Extract and process minidumps + - Expose logs and UE4 context information + +## Usage + +Add `symbolic` as a dependency to your `Cargo.toml`. You will most likely want to activate some +of the features: + +- **`debuginfo`** (default): Contains support for various object file formats and debugging + information. Currently, this comprises MachO and ELF (with DWARF debugging), PE and PDB, as + well as Breakpad symbols. +- **`demangle`**: Demangling for Rust, C++, Swift and Objective C symbols. This feature requires + a C++14 compiler on the PATH. +- **`minidump`**: Rust bindings for the Breakpad Minidump processor. Additionally, this includes + facilities to extract stack unwinding information (sometimes called CFI) from object files. + This feature requires a C++11 compiler on the PATH. +- **`proguard`**: Processing of Proguard mapping files to look up mangled Java function paths. +- **`sourcemap`**: Processing and expansion of JavaScript source maps, as well as lookups for + minified function names. +- **`symcache`**: An optimized, platform-independent storage for common debugging information. + This allows blazing fast symbolication of instruction addresses to function names and file + locations. +- **`unreal`**: Processing of Unreal Engine 4 crash reports. + +There are also alternate versions for some of the above features that additionally add +implementations for `serde::{Deserialize, Serialize}` on suitable types: + +- **`common-serde`** +- **`debuginfo-serde`** +- **`minidump-serde`** +- **`unreal-serde`** + +License: MIT diff --git a/symbolic/src/lib.rs b/symbolic/src/lib.rs new file mode 100644 index 000000000..0943f884b --- /dev/null +++ b/symbolic/src/lib.rs @@ -0,0 +1,88 @@ +//! [Symbolic](https://docs.rs/symbolic) is a library written in Rust which is used at +//! [Sentry](https://sentry.io/) to implement symbolication of native stack traces, sourcemap +//! handling for minified JavaScript and more. It consists of multiple largely independent crates +//! which are bundled together into a C and Python library so it can be used independently of Rust. +//! +//! # What's in the package +//! +//! Symbolic provides the following functionality: +//! +//! - Symbolication based on custom cache files (symcache) +//! - Symbol cache file generators from: +//! - Mach, ELF and PE symbol tables +//! - Mach and ELF embedded DWARF data +//! - PDB CodeView debug information +//! - Breakpad symbol files +//! - Demangling support +//! - C++ (GCC, clang and MSVC) +//! - Objective C / Objective C++ +//! - Rust +//! - Swift +//! - JavaScript sourcemap expansion +//! - Basic token mapping +//! - Heuristics to find original function names based on minified sources +//! - Indexed sourcemap to sourcemap merging +//! - Proguard function mappings +//! - Minidump / Breakpad processing +//! - Generate Breakpad symbol files from Mach, ELF and PDBs +//! - Process Minidumps to retrieve stack traces +//! - Convenient C and Python library +//! - Processing of Unreal Engine 4 native crash reports +//! - Extract and process minidumps +//! - Expose logs and UE4 context information +//! +//! # Usage +//! +//! Add `symbolic` as a dependency to your `Cargo.toml`. You will most likely want to activate some +//! of the features: +//! +//! - **`debuginfo`** (default): Contains support for various object file formats and debugging +//! information. Currently, this comprises MachO and ELF (with DWARF debugging), PE and PDB, as +//! well as Breakpad symbols. +//! - **`demangle`**: Demangling for Rust, C++, Swift and Objective C symbols. This feature requires +//! a C++14 compiler on the PATH. +//! - **`minidump`**: Rust bindings for the Breakpad Minidump processor. Additionally, this includes +//! facilities to extract stack unwinding information (sometimes called CFI) from object files. +//! This feature requires a C++11 compiler on the PATH. +//! - **`proguard`**: Processing of Proguard mapping files to look up mangled Java function paths. +//! - **`sourcemap`**: Processing and expansion of JavaScript source maps, as well as lookups for +//! minified function names. +//! - **`symcache`**: An optimized, platform-independent storage for common debugging information. +//! This allows blazing fast symbolication of instruction addresses to function names and file +//! locations. +//! - **`unreal`**: Processing of Unreal Engine 4 crash reports. +//! +//! There are also alternate versions for some of the above features that additionally add +//! implementations for `serde::{Deserialize, Serialize}` on suitable types: +//! +//! - **`common-serde`** +//! - **`debuginfo-serde`** +//! - **`minidump-serde`** +//! - **`unreal-serde`** + +#![warn(missing_docs)] + +#[doc(inline)] +pub use symbolic_common as common; +#[doc(inline)] +#[cfg(feature = "debuginfo")] +pub use symbolic_debuginfo as debuginfo; +#[doc(inline)] +#[cfg(feature = "demangle")] +pub use symbolic_demangle as demangle; +#[doc(inline)] +#[cfg(feature = "minidump")] +pub use symbolic_minidump as minidump; +#[doc(inline)] +#[cfg(feature = "proguard")] +#[deprecated = "use the `proguard` crate directly"] +pub use symbolic_proguard as proguard; +#[doc(inline)] +#[cfg(feature = "sourcemap")] +pub use symbolic_sourcemap as sourcemap; +#[doc(inline)] +#[cfg(feature = "symcache")] +pub use symbolic_symcache as symcache; +#[doc(inline)] +#[cfg(feature = "unreal")] +pub use symbolic_unreal as unreal; From 4e01752589e8d7fef064b18a37359f97748e33a8 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 18 Sep 2020 23:02:21 +0200 Subject: [PATCH 09/22] ref: Remove deprecated proguard support (#267) --- py/symbolic/proguard.py | 52 +------------------ py/tests/test_proguard.py | 37 +------------- symbolic-cabi/Cargo.toml | 2 +- symbolic-cabi/include/symbolic.h | 54 +------------------- symbolic-cabi/src/proguard.rs | 86 -------------------------------- symbolic-proguard/Cargo.toml | 24 --------- symbolic-proguard/src/lib.rs | 71 -------------------------- symbolic/Cargo.toml | 2 - symbolic/src/lib.rs | 7 +-- 9 files changed, 5 insertions(+), 330 deletions(-) delete mode 100644 symbolic-proguard/Cargo.toml delete mode 100644 symbolic-proguard/src/lib.rs diff --git a/py/symbolic/proguard.py b/py/symbolic/proguard.py index e6c82a0cc..63d247acd 100644 --- a/py/symbolic/proguard.py +++ b/py/symbolic/proguard.py @@ -6,60 +6,10 @@ encode_str, decode_uuid, encode_path, - attached_refs, ) -__all__ = ["ProguardMappingView", "ProguardMapper", "JavaStackFrame"] - - -class ProguardMappingView(RustObject): - """Gives access to proguard mapping files. - - DEPRECATED: Use the `ProguardMapper` class instead. - """ - - __dealloc_func__ = lib.symbolic_proguardmappingview_free - - @classmethod - def from_bytes(cls, data): - """Constructs a mapping file from bytes.""" - data = bytes(data) - rv = cls._from_objptr( - rustcall(lib.symbolic_proguardmappingview_from_bytes, data, len(data)) - ) - # we need to keep this reference alive or we crash. hard. - attached_refs[rv] = data - return rv - - @classmethod - def open(cls, path): - """Constructs a mapping file from a path.""" - return cls._from_objptr( - rustcall(lib.symbolic_proguardmappingview_open, encode_path(path)) - ) - - @property - def uuid(self): - """Returns the UUID of the file.""" - return decode_uuid(self._methodcall(lib.symbolic_proguardmappingview_get_uuid)) - - @property - def has_line_info(self): - """True if the file contains line information.""" - return bool(self._methodcall(lib.symbolic_proguardmappingview_has_line_info)) - - def lookup(self, dotted_path, lineno=None): - """Given a dotted path and an optional line number this resolves - to the original dotted path. - """ - result = self._methodcall( - lib.symbolic_proguardmappingview_convert_dotted_path, - encode_str(dotted_path), - lineno or 0, - ) - - return decode_str(result, free=True) +__all__ = ["ProguardMapper", "JavaStackFrame"] class JavaStackFrame(object): diff --git a/py/tests/test_proguard.py b/py/tests/test_proguard.py index 8b5b9c01a..eebf0af8e 100644 --- a/py/tests/test_proguard.py +++ b/py/tests/test_proguard.py @@ -1,41 +1,6 @@ import os import uuid -from symbolic import ProguardMappingView, ProguardMapper - - -def test_basics(res_path): - with open(os.path.join(res_path, "proguard.txt"), "rb") as f: - mapping = f.read() - - view = ProguardMappingView.from_bytes(mapping) - assert view.has_line_info - assert view.uuid == uuid.UUID("a48ca62b-df26-544e-a8b9-2a5ce210d1d5") - - assert ( - view.lookup("android.support.constraint.ConstraintLayout$a") - == "android.support.constraint.ConstraintLayout$LayoutParams" - ) - - assert ( - view.lookup("android.support.constraint.a.b:a", 116) - == "android.support.constraint.solver.ArrayRow:createRowDefinition" - ) - - -def test_mmap(res_path): - view = ProguardMappingView.open(os.path.join(res_path, "proguard.txt")) - assert view.has_line_info - assert view.uuid == uuid.UUID("a48ca62b-df26-544e-a8b9-2a5ce210d1d5") - - assert ( - view.lookup("android.support.constraint.ConstraintLayout$a") - == "android.support.constraint.ConstraintLayout$LayoutParams" - ) - - assert ( - view.lookup("android.support.constraint.a.b:a", 116) - == "android.support.constraint.solver.ArrayRow:createRowDefinition" - ) +from symbolic import ProguardMapper def test_mapper(res_path): diff --git a/symbolic-cabi/Cargo.toml b/symbolic-cabi/Cargo.toml index c8c170850..682549d2c 100644 --- a/symbolic-cabi/Cargo.toml +++ b/symbolic-cabi/Cargo.toml @@ -23,5 +23,5 @@ crate-type = ["cdylib"] serde_json = "1.0.40" failure = "0.1.5" apple-crash-report-parser = { version = "0.4.0", features = ["with_serde"] } -symbolic = { version = "7.5.0", path = "../symbolic", features = ["debuginfo", "demangle", "minidump", "proguard", "sourcemap", "symcache", "unreal-serde"] } +symbolic = { version = "7.5.0", path = "../symbolic", features = ["debuginfo", "demangle", "minidump", "sourcemap", "symcache", "unreal-serde"] } proguard = { version = "4.0.1", features = ["uuid"] } diff --git a/symbolic-cabi/include/symbolic.h b/symbolic-cabi/include/symbolic.h index 59bc2711a..9987f88b4 100644 --- a/symbolic-cabi/include/symbolic.h +++ b/symbolic-cabi/include/symbolic.h @@ -3,7 +3,7 @@ #ifndef SYMBOLIC_H_INCLUDED #define SYMBOLIC_H_INCLUDED -/* Generated with cbindgen:0.14.3 */ +/* Generated with cbindgen:0.14.2 */ /* Warning, this file is autogenerated. Do not modify this manually. */ @@ -122,11 +122,6 @@ typedef struct SymbolicObject SymbolicObject; */ typedef struct SymbolicProguardMapper SymbolicProguardMapper; -/** - * Represents a proguard mapping view. - */ -typedef struct SymbolicProguardMappingView SymbolicProguardMappingView; - /** * Represents a sourcemap view. */ @@ -606,53 +601,6 @@ SymbolicProguardRemapResult symbolic_proguardmapper_remap_frame(const SymbolicPr */ void symbolic_proguardmapper_result_free(SymbolicProguardRemapResult *result); -/** - * Converts a dotted path at a line number. - * - * @deprecated: use `symbolic_proguardmapper_remap_class` or `symbolic_proguardmapper_remap_frame` instead - */ -SymbolicStr symbolic_proguardmappingview_convert_dotted_path(const SymbolicProguardMappingView *view, - const SymbolicStr *path, - uint32_t lineno); - -/** - * Frees a proguard mapping view. - * - * @deprecated: use `symbolic_proguardmapper_free` instead - */ -void symbolic_proguardmappingview_free(SymbolicProguardMappingView *view); - -/** - * Creates a proguard mapping view from bytes. - * - * This shares the underlying memory and does not copy it. - * - * @deprecated: use `symbolic_proguardmapper_open` instead - */ -SymbolicProguardMappingView *symbolic_proguardmappingview_from_bytes(const char *bytes, - uintptr_t len); - -/** - * Returns the UUID of a proguard mapping file. - * - * @deprecated: use `symbolic_proguardmapper_get_uuid` instead - */ -SymbolicUuid symbolic_proguardmappingview_get_uuid(SymbolicProguardMappingView *view); - -/** - * Returns true if the mapping file has line infos. - * - * @deprecated: use `symbolic_proguardmapper_has_line_info` instead - */ -bool symbolic_proguardmappingview_has_line_info(const SymbolicProguardMappingView *view); - -/** - * Creates a proguard mapping view from a path. - * - * @deprecated: use `symbolic_proguardmapper_open` instead - */ -SymbolicProguardMappingView *symbolic_proguardmappingview_open(const char *path); - /** * Frees a source map view. */ diff --git a/symbolic-cabi/src/proguard.rs b/symbolic-cabi/src/proguard.rs index 8ff121cd7..4a167ffba 100644 --- a/symbolic-cabi/src/proguard.rs +++ b/symbolic-cabi/src/proguard.rs @@ -1,97 +1,11 @@ -#![allow(deprecated)] - use std::ffi::CStr; use std::os::raw::c_char; -use std::slice; use symbolic::common::{AsSelf, ByteView, SelfCell}; -use symbolic::proguard::ProguardMappingView; use crate::core::{SymbolicStr, SymbolicUuid}; use crate::utils::ForeignObject; -/// Represents a proguard mapping view. -pub struct SymbolicProguardMappingView; - -impl ForeignObject for SymbolicProguardMappingView { - type RustObject = ProguardMappingView<'static>; -} - -ffi_fn! { - /// Creates a proguard mapping view from a path. - /// - /// @deprecated: use `symbolic_proguardmapper_open` instead - unsafe fn symbolic_proguardmappingview_open( - path: *const c_char - ) -> Result<*mut SymbolicProguardMappingView> { - let byteview = ByteView::open(CStr::from_ptr(path).to_str()?)?; - let proguard = ProguardMappingView::parse(byteview)?; - Ok(SymbolicProguardMappingView::from_rust(proguard)) - } -} - -ffi_fn! { - /// Creates a proguard mapping view from bytes. - /// - /// This shares the underlying memory and does not copy it. - /// - /// @deprecated: use `symbolic_proguardmapper_open` instead - unsafe fn symbolic_proguardmappingview_from_bytes( - bytes: *const c_char, - len: usize - ) -> Result<*mut SymbolicProguardMappingView> { - let slice = slice::from_raw_parts(bytes as *const _, len); - let byteview = ByteView::from_slice(slice); - let proguard = ProguardMappingView::parse(byteview)?; - Ok(SymbolicProguardMappingView::from_rust(proguard)) - } -} - -ffi_fn! { - /// Frees a proguard mapping view. - /// - /// @deprecated: use `symbolic_proguardmapper_free` instead - unsafe fn symbolic_proguardmappingview_free(view: *mut SymbolicProguardMappingView) { - SymbolicProguardMappingView::drop(view); - } -} - -ffi_fn! { - /// Returns the UUID of a proguard mapping file. - /// - /// @deprecated: use `symbolic_proguardmapper_get_uuid` instead - unsafe fn symbolic_proguardmappingview_get_uuid( - view: *mut SymbolicProguardMappingView, - ) -> Result { - Ok(SymbolicProguardMappingView::as_rust(view).uuid().into()) - } -} - -ffi_fn! { - /// Converts a dotted path at a line number. - /// - /// @deprecated: use `symbolic_proguardmapper_remap_class` or `symbolic_proguardmapper_remap_frame` instead - unsafe fn symbolic_proguardmappingview_convert_dotted_path( - view: *const SymbolicProguardMappingView, - path: *const SymbolicStr, - lineno: u32, - ) -> Result { - let path = (*path).as_str(); - Ok(SymbolicProguardMappingView::as_rust(view).convert_dotted_path(path, lineno).into()) - } -} - -ffi_fn! { - /// Returns true if the mapping file has line infos. - /// - /// @deprecated: use `symbolic_proguardmapper_has_line_info` instead - unsafe fn symbolic_proguardmappingview_has_line_info( - view: *const SymbolicProguardMappingView, - ) -> Result { - Ok(SymbolicProguardMappingView::as_rust(view).has_line_info()) - } -} - use proguard::{ProguardMapper, ProguardMapping, StackFrame}; /// Represents a Java Stack Frame. diff --git a/symbolic-proguard/Cargo.toml b/symbolic-proguard/Cargo.toml deleted file mode 100644 index a7e93ff48..000000000 --- a/symbolic-proguard/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "symbolic-proguard" -version = "7.5.0" -license = "MIT" -authors = [ - "Armin Ronacher ", - "Jan Michael Auer ", -] -documentation = "https://docs.rs/symbolic-proguard" -keywords = ["proguard", "retrace", "R8"] -homepage = "https://github.com/getsentry/symbolic" -repository = "https://github.com/getsentry/symbolic" -description = """ -A library to process ProGuard and R8 mapping files and symbolicate frames from -optimized applications. -""" -edition = "2018" - -[package.metadata.docs.rs] -all-features = true - -[dependencies] -proguard = { version = "4.0.1", features = ["uuid"] } -symbolic-common = { version = "7.5.0", path = "../symbolic-common" } diff --git a/symbolic-proguard/src/lib.rs b/symbolic-proguard/src/lib.rs deleted file mode 100644 index 4ab654f5a..000000000 --- a/symbolic-proguard/src/lib.rs +++ /dev/null @@ -1,71 +0,0 @@ -//! Provides proguard support. - -#![warn(missing_docs)] - -use std::io; - -use proguard::{ProguardMapper, ProguardMapping, StackFrame}; - -use symbolic_common::{AsSelf, ByteView, SelfCell, Uuid}; - -struct Inner<'a> { - mapping: ProguardMapping<'a>, - mapper: ProguardMapper<'a>, -} - -impl<'slf, 'a: 'slf> AsSelf<'slf> for Inner<'a> { - type Ref = Inner<'slf>; - - fn as_self(&'slf self) -> &Self::Ref { - &self - } -} - -/// A view over a proguard mapping text file. -#[deprecated = "use the `proguard` crate directly"] -pub struct ProguardMappingView<'a> { - inner: SelfCell, Inner<'a>>, -} - -#[allow(deprecated)] -impl<'a> ProguardMappingView<'a> { - /// Creates a new proguard mapping view from a byte slice. - pub fn parse(byteview: ByteView<'a>) -> Result { - let inner = SelfCell::new(byteview, |data| { - let mapping = ProguardMapping::new(unsafe { &*data }); - let mapper = ProguardMapper::new(mapping.clone()); - Inner { mapping, mapper } - }); - - Ok(ProguardMappingView { inner }) - } - - /// Returns the mapping UUID. - pub fn uuid(&self) -> Uuid { - self.inner.get().mapping.uuid() - } - - /// Returns true if this file has line infos. - pub fn has_line_info(&self) -> bool { - self.inner.get().mapping.has_line_info() - } - - /// Converts a dotted path. - pub fn convert_dotted_path(&self, path: &str, lineno: u32) -> String { - let mapper = &self.inner.get().mapper; - - let mut iter = path.splitn(2, ':'); - let cls_name = iter.next().unwrap_or(""); - match iter.next() { - Some(meth_name) => { - let mut mapped = - mapper.remap_frame(&StackFrame::new(cls_name, meth_name, lineno as usize)); - match mapped.next() { - Some(frame) => format!("{}:{}", frame.class(), frame.method()), - None => path.to_string(), - } - } - None => mapper.remap_class(cls_name).unwrap_or(cls_name).to_string(), - } - } -} diff --git a/symbolic/Cargo.toml b/symbolic/Cargo.toml index 2e601d19a..13a8a18c7 100644 --- a/symbolic/Cargo.toml +++ b/symbolic/Cargo.toml @@ -27,7 +27,6 @@ debuginfo-serde = ["debuginfo", "common-serde"] demangle = ["symbolic-demangle"] minidump = ["symbolic-minidump", "debuginfo"] minidump-serde = ["minidump", "debuginfo-serde", "symbolic-minidump/serde"] -proguard = ["symbolic-proguard"] sourcemap = ["symbolic-sourcemap"] symcache = ["symbolic-symcache", "debuginfo"] unreal = ["symbolic-unreal"] @@ -38,7 +37,6 @@ symbolic-common = { version = "7.5.0", path = "../symbolic-common" } symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo", optional = true } symbolic-demangle = { version = "7.5.0", path = "../symbolic-demangle", optional = true } symbolic-minidump = { version = "7.5.0", path = "../symbolic-minidump", optional = true } -symbolic-proguard = { version = "7.5.0", path = "../symbolic-proguard", optional = true } symbolic-sourcemap = { version = "7.5.0", path = "../symbolic-sourcemap", optional = true } symbolic-symcache = { version = "7.5.0", path = "../symbolic-symcache", optional = true } symbolic-unreal = { version = "7.5.0", path = "../symbolic-unreal", optional = true } diff --git a/symbolic/src/lib.rs b/symbolic/src/lib.rs index 0943f884b..9b1dcf86c 100644 --- a/symbolic/src/lib.rs +++ b/symbolic/src/lib.rs @@ -22,7 +22,7 @@ //! - Basic token mapping //! - Heuristics to find original function names based on minified sources //! - Indexed sourcemap to sourcemap merging -//! - Proguard function mappings +//! - Proguard function mappings (via `symbolic-cabi` only, use `proguard` crate instead) //! - Minidump / Breakpad processing //! - Generate Breakpad symbol files from Mach, ELF and PDBs //! - Process Minidumps to retrieve stack traces @@ -44,7 +44,6 @@ //! - **`minidump`**: Rust bindings for the Breakpad Minidump processor. Additionally, this includes //! facilities to extract stack unwinding information (sometimes called CFI) from object files. //! This feature requires a C++11 compiler on the PATH. -//! - **`proguard`**: Processing of Proguard mapping files to look up mangled Java function paths. //! - **`sourcemap`**: Processing and expansion of JavaScript source maps, as well as lookups for //! minified function names. //! - **`symcache`**: An optimized, platform-independent storage for common debugging information. @@ -74,10 +73,6 @@ pub use symbolic_demangle as demangle; #[cfg(feature = "minidump")] pub use symbolic_minidump as minidump; #[doc(inline)] -#[cfg(feature = "proguard")] -#[deprecated = "use the `proguard` crate directly"] -pub use symbolic_proguard as proguard; -#[doc(inline)] #[cfg(feature = "sourcemap")] pub use symbolic_sourcemap as sourcemap; #[doc(inline)] From d3873d6f462b78c723126eef1283f255cb642683 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Thu, 24 Sep 2020 09:39:30 +0200 Subject: [PATCH 10/22] ref: Replace failure with std::error::Error (#264) Co-authored-by: Arpad Borsos --- CHANGELOG.md | 7 ++ examples/addr2line/Cargo.toml | 2 +- examples/addr2line/src/main.rs | 16 +-- examples/dump_cfi/Cargo.toml | 2 +- examples/dump_cfi/src/main.rs | 16 +-- examples/dump_sources/Cargo.toml | 1 - examples/dump_sources/src/main.rs | 26 ++-- examples/minidump_stackwalk/Cargo.toml | 1 - examples/minidump_stackwalk/src/main.rs | 6 +- examples/object_debug/Cargo.toml | 1 - examples/object_debug/src/main.rs | 26 ++-- examples/symcache_debug/Cargo.toml | 2 +- examples/symcache_debug/src/main.rs | 8 +- examples/unreal_engine_crash/Cargo.toml | 1 - examples/unreal_engine_crash/src/main.rs | 3 +- symbolic-cabi/Cargo.toml | 1 - symbolic-cabi/src/core.rs | 119 +++++++++--------- symbolic-cabi/src/utils.rs | 13 +- symbolic-common/Cargo.toml | 2 - symbolic-common/src/byteview.rs | 5 +- symbolic-common/src/fail.rs | 80 ------------ symbolic-common/src/lib.rs | 2 - symbolic-common/src/types.rs | 24 +++- symbolic-debuginfo/Cargo.toml | 2 +- symbolic-debuginfo/src/base.rs | 24 +++- symbolic-debuginfo/src/breakpad.rs | 66 ++++------ symbolic-debuginfo/src/dwarf.rs | 43 +++---- symbolic-debuginfo/src/elf.rs | 17 +-- symbolic-debuginfo/src/macho.rs | 18 ++- symbolic-debuginfo/src/object.rs | 35 +++--- symbolic-debuginfo/src/pdb.rs | 42 ++----- symbolic-debuginfo/src/pe.rs | 8 +- symbolic-debuginfo/src/sourcebundle.rs | 96 ++++++++------- symbolic-debuginfo/tests/test_objects.rs | 4 +- symbolic-minidump/Cargo.toml | 2 +- symbolic-minidump/src/cfi.rs | 141 +++++++++++----------- symbolic-minidump/src/processor.rs | 22 +++- symbolic-minidump/tests/test_cfi.rs | 4 +- symbolic-minidump/tests/test_processor.rs | 4 +- symbolic-sourcemap/Cargo.toml | 1 - symbolic-sourcemap/src/lib.rs | 6 +- symbolic-symcache/Cargo.toml | 2 +- symbolic-symcache/src/cache.rs | 4 +- symbolic-symcache/src/error.rs | 53 +++----- symbolic-symcache/src/format.rs | 18 ++- symbolic-symcache/src/writer.rs | 27 ++--- symbolic-symcache/tests/test_cache.rs | 4 +- symbolic-symcache/tests/test_compat.rs | 4 +- symbolic-symcache/tests/test_writer.rs | 4 +- symbolic-unreal/Cargo.toml | 2 +- symbolic-unreal/src/context.rs | 2 +- symbolic-unreal/src/error.rs | 30 ++--- 52 files changed, 444 insertions(+), 605 deletions(-) delete mode 100644 symbolic-common/src/fail.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 11bee229d..203b59136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Unreleased + +**Breaking Changes**: + +- Usage of `failure` was removed, and all Error types were changed to only implement `std::error::Error` and related traits. +- `symbolic-proguard` was removed in favor of the `proguard` crate. Proguard is still supported via `symbolic-cabi` and the python API however. + ## 7.5.0 **Changes**: diff --git a/examples/addr2line/Cargo.toml b/examples/addr2line/Cargo.toml index d11e5a52d..232c13a85 100644 --- a/examples/addr2line/Cargo.toml +++ b/examples/addr2line/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.32" clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic", features = ["demangle"] } diff --git a/examples/addr2line/src/main.rs b/examples/addr2line/src/main.rs index ebd5c3827..51f1c6ae9 100644 --- a/examples/addr2line/src/main.rs +++ b/examples/addr2line/src/main.rs @@ -1,20 +1,12 @@ use std::borrow::Borrow; +use anyhow::{Context, Result}; use clap::{clap_app, ArgMatches}; -use failure::{Error, ResultExt}; use symbolic::common::{ByteView, Name}; use symbolic::debuginfo::{Function, Object}; use symbolic::demangle::Demangle; -fn print_error(error: &Error) { - eprintln!("Error: {}", error); - - for cause in error.iter_causes() { - eprintln!(" caused by {}", cause); - } -} - fn print_name<'a, N: Borrow>>(name: Option, matches: &ArgMatches<'_>) { match name.as_ref().map(Borrow::borrow) { None => print!("??"), @@ -36,7 +28,7 @@ fn print_range(start: u64, len: Option, matches: &ArgMatches<'_>) { } } -fn resolve(function: &Function<'_>, addr: u64, matches: &ArgMatches<'_>) -> Result { +fn resolve(function: &Function<'_>, addr: u64, matches: &ArgMatches<'_>) -> Result { if function.address > addr || function.address + function.size <= addr { return Ok(false); } @@ -76,7 +68,7 @@ fn resolve(function: &Function<'_>, addr: u64, matches: &ArgMatches<'_>) -> Resu Ok(false) } -fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> { +fn execute(matches: &ArgMatches<'_>) -> Result<()> { let path = matches.value_of("path").unwrap_or("a.out"); let view = ByteView::open(path).context("failed to open file")?; let object = Object::parse(&view).context("failed to parse file")?; @@ -127,6 +119,6 @@ fn main() { match execute(&matches) { Ok(()) => (), - Err(e) => print_error(&e), + Err(e) => eprintln!("{:?}", e), }; } diff --git a/examples/dump_cfi/Cargo.toml b/examples/dump_cfi/Cargo.toml index e8689fe79..9af56d81a 100644 --- a/examples/dump_cfi/Cargo.toml +++ b/examples/dump_cfi/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.32" clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic", features = ["minidump"] } diff --git a/examples/dump_cfi/src/main.rs b/examples/dump_cfi/src/main.rs index a4285b20c..bff2220d4 100644 --- a/examples/dump_cfi/src/main.rs +++ b/examples/dump_cfi/src/main.rs @@ -1,21 +1,13 @@ use std::path::Path; +use anyhow::Result; use clap::{App, Arg, ArgMatches}; -use failure::Error; use symbolic::common::{ByteView, DSymPathExt}; use symbolic::debuginfo::Object; use symbolic::minidump::cfi::AsciiCfiWriter; -fn print_error(error: &Error) { - eprintln!("Error: {:#?}", error); - - for cause in error.iter_causes() { - eprintln!(" caused by {}", cause); - } -} - -fn dump_cfi>(path: P) -> Result<(), Error> { +fn dump_cfi>(path: P) -> Result<()> { let path = path.as_ref(); let dsym_path = path.resolve_dsym(); @@ -36,7 +28,7 @@ fn dump_cfi>(path: P) -> Result<(), Error> { Ok(()) } -fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> { +fn execute(matches: &ArgMatches<'_>) -> Result<()> { let path = matches.value_of("path").unwrap(); dump_cfi(path) } @@ -56,6 +48,6 @@ fn main() { match execute(&matches) { Ok(()) => (), - Err(e) => print_error(&e), + Err(e) => eprintln!("{:?}", e), }; } diff --git a/examples/dump_sources/Cargo.toml b/examples/dump_sources/Cargo.toml index 047ac75b2..5d32f84b4 100644 --- a/examples/dump_sources/Cargo.toml +++ b/examples/dump_sources/Cargo.toml @@ -8,5 +8,4 @@ edition = "2018" [dependencies] clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic" } diff --git a/examples/dump_sources/src/main.rs b/examples/dump_sources/src/main.rs index af9009e3a..a2ec6a34d 100644 --- a/examples/dump_sources/src/main.rs +++ b/examples/dump_sources/src/main.rs @@ -1,21 +1,21 @@ use std::path::Path; use clap::{App, Arg, ArgMatches}; -use failure::Error; use symbolic::common::{ByteView, DSymPathExt}; use symbolic::debuginfo::sourcebundle::SourceBundleWriter; use symbolic::debuginfo::Archive; -fn print_error(error: &Error) { +fn print_error(mut error: &dyn std::error::Error) { println!("Error: {}", error); - for cause in error.iter_causes() { - println!(" caused by {}", cause); + while let Some(source) = error.source() { + println!(" caused by {}", source); + error = source; } } -fn write_object_sources(path: &Path, output_path: &Path) -> Result<(), Error> { +fn write_object_sources(path: &Path, output_path: &Path) -> Result<(), Box> { println!("Inspecting {}", path.display()); let dsym_path = path.resolve_dsym(); @@ -34,7 +34,7 @@ fn write_object_sources(path: &Path, output_path: &Path) -> Result<(), Error> { } Err(e) => { print!(" - "); - print_error(&e.into()); + print_error(&e); continue; } } @@ -43,18 +43,15 @@ fn write_object_sources(path: &Path, output_path: &Path) -> Result<(), Error> { Ok(()) } -fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> { +fn execute(matches: &ArgMatches<'_>) { let output_path = Path::new(matches.value_of("output").unwrap()); for path in matches.values_of("paths").unwrap_or_default() { - match write_object_sources(Path::new(&path), &output_path) { - Ok(()) => (), - Err(e) => print_error(&e), + if let Err(e) = write_object_sources(Path::new(&path), &output_path) { + print_error(e.as_ref()); } println!(); } - - Ok(()) } fn main() { @@ -79,8 +76,5 @@ fn main() { ) .get_matches(); - match execute(&matches) { - Ok(()) => (), - Err(e) => print_error(&e), - }; + execute(&matches); } diff --git a/examples/minidump_stackwalk/Cargo.toml b/examples/minidump_stackwalk/Cargo.toml index 1fd89e0ef..1a2c5db51 100644 --- a/examples/minidump_stackwalk/Cargo.toml +++ b/examples/minidump_stackwalk/Cargo.toml @@ -8,6 +8,5 @@ edition = "2018" [dependencies] clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic", features = ["minidump", "symcache", "demangle"] } walkdir = "2.3.1" diff --git a/examples/minidump_stackwalk/src/main.rs b/examples/minidump_stackwalk/src/main.rs index 369eaaab8..ce52784a0 100644 --- a/examples/minidump_stackwalk/src/main.rs +++ b/examples/minidump_stackwalk/src/main.rs @@ -3,7 +3,6 @@ use std::io::Cursor; use std::path::Path; use clap::{App, Arg, ArgMatches}; -use failure::Error; use walkdir::WalkDir; use symbolic::common::{Arch, ByteView, InstructionInfo, SelfCell}; @@ -11,9 +10,10 @@ use symbolic::debuginfo::{Archive, FileFormat, Object}; use symbolic::demangle::Demangle; use symbolic::minidump::cfi::CfiCache; use symbolic::minidump::processor::{CodeModuleId, FrameInfoMap, ProcessState, StackFrame}; -use symbolic::symcache::{LineInfo, SymCache, SymCacheWriter}; +use symbolic::symcache::{LineInfo, SymCache, SymCacheError, SymCacheWriter}; type SymCaches<'a> = BTreeMap, SymCache<'a>>>; +type Error = Box; fn collect_referenced_objects( path: P, @@ -124,7 +124,7 @@ fn symbolize<'a>( frame: &StackFrame, arch: Arch, crashing: bool, -) -> Result>>, Error> { +) -> Result>>, SymCacheError> { let module = match frame.module() { Some(module) => module, None => return Ok(None), diff --git a/examples/object_debug/Cargo.toml b/examples/object_debug/Cargo.toml index 2880677f1..9742d510f 100644 --- a/examples/object_debug/Cargo.toml +++ b/examples/object_debug/Cargo.toml @@ -8,5 +8,4 @@ edition = "2018" [dependencies] clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic" } diff --git a/examples/object_debug/src/main.rs b/examples/object_debug/src/main.rs index dbe3ed229..96725ad79 100644 --- a/examples/object_debug/src/main.rs +++ b/examples/object_debug/src/main.rs @@ -1,20 +1,20 @@ use std::path::Path; use clap::{App, Arg, ArgMatches}; -use failure::Error; use symbolic::common::{ByteView, DSymPathExt}; use symbolic::debuginfo::Archive; -fn print_error(error: &Error) { +fn print_error(mut error: &dyn std::error::Error) { println!("Error: {}", error); - for cause in error.iter_causes() { - println!(" caused by {}", cause); + while let Some(source) = error.source() { + println!(" caused by {}", source); + error = source; } } -fn inspect_object>(path: P) -> Result<(), Error> { +fn inspect_object>(path: P) -> Result<(), Box> { let path = path.as_ref(); println!("Inspecting {}", path.display()); @@ -42,7 +42,7 @@ fn inspect_object>(path: P) -> Result<(), Error> { } Err(e) => { print!(" - "); - print_error(&e.into()); + print_error(&e); continue; } } @@ -51,17 +51,14 @@ fn inspect_object>(path: P) -> Result<(), Error> { Ok(()) } -fn execute(matches: &ArgMatches<'_>) -> Result<(), Error> { +fn execute(matches: &ArgMatches<'_>) { for path in matches.values_of("paths").unwrap_or_default() { - match inspect_object(path) { - Ok(()) => (), - Err(e) => print_error(&e), + if let Err(e) = inspect_object(path) { + print_error(e.as_ref()) } println!(); } - - Ok(()) } fn main() { @@ -78,8 +75,5 @@ fn main() { ) .get_matches(); - match execute(&matches) { - Ok(()) => (), - Err(e) => print_error(&e), - }; + execute(&matches); } diff --git a/examples/symcache_debug/Cargo.toml b/examples/symcache_debug/Cargo.toml index 6bb737f75..8a19bbff4 100644 --- a/examples/symcache_debug/Cargo.toml +++ b/examples/symcache_debug/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.32" clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic", features = ["symcache", "demangle"] } diff --git a/examples/symcache_debug/src/main.rs b/examples/symcache_debug/src/main.rs index b0e9e4eed..3e0d69230 100644 --- a/examples/symcache_debug/src/main.rs +++ b/examples/symcache_debug/src/main.rs @@ -3,15 +3,15 @@ use std::io::{Cursor, Write}; use std::path::Path; use std::u64; +use anyhow::{anyhow, Result}; use clap::{App, Arg, ArgMatches}; -use failure::{err_msg, Error}; use symbolic::common::{Arch, ByteView, DSymPathExt, Language}; use symbolic::debuginfo::Archive; use symbolic::demangle::Demangle; use symbolic::symcache::{SymCache, SymCacheWriter}; -fn execute(matches: &ArgMatches) -> Result<(), Error> { +fn execute(matches: &ArgMatches) -> Result<()> { let buffer; let symcache; @@ -53,7 +53,7 @@ fn execute(matches: &ArgMatches) -> Result<(), Error> { let obj = match obj { Some(obj) => obj, - None => return Err(err_msg(format!("did not find architecture {}", arch))), + None => return Err(anyhow!("did not find architecture {}", arch)), }; let writer = SymCacheWriter::write_object(obj, Cursor::new(Vec::new()))?; @@ -73,7 +73,7 @@ fn execute(matches: &ArgMatches) -> Result<(), Error> { buffer = ByteView::open(file_path)?; symcache = SymCache::parse(&buffer)?; } else { - return Err(err_msg("No debug file or sym cache provided")); + return Err(anyhow!("No debug file or sym cache provided")); } // report diff --git a/examples/unreal_engine_crash/Cargo.toml b/examples/unreal_engine_crash/Cargo.toml index 3e2c5c440..0cd06f860 100644 --- a/examples/unreal_engine_crash/Cargo.toml +++ b/examples/unreal_engine_crash/Cargo.toml @@ -8,5 +8,4 @@ edition = "2018" [dependencies] clap = "2.33.0" -failure = "0.1.7" symbolic = { path = "../../symbolic", features = ["unreal"] } diff --git a/examples/unreal_engine_crash/src/main.rs b/examples/unreal_engine_crash/src/main.rs index 26371e8fa..473e1d778 100644 --- a/examples/unreal_engine_crash/src/main.rs +++ b/examples/unreal_engine_crash/src/main.rs @@ -3,11 +3,10 @@ use std::fs::File; use std::io::Read; use clap::{App, Arg, ArgMatches}; -use failure::Error; use symbolic::unreal::{Unreal4Crash, Unreal4FileType}; -fn execute(matches: &ArgMatches) -> Result<(), Error> { +fn execute(matches: &ArgMatches) -> Result<(), Box> { let crash_file_path = matches.value_of("crash_file_path").unwrap(); let mut file = File::open(crash_file_path)?; diff --git a/symbolic-cabi/Cargo.toml b/symbolic-cabi/Cargo.toml index 682549d2c..9b788422d 100644 --- a/symbolic-cabi/Cargo.toml +++ b/symbolic-cabi/Cargo.toml @@ -21,7 +21,6 @@ crate-type = ["cdylib"] [dependencies] serde_json = "1.0.40" -failure = "0.1.5" apple-crash-report-parser = { version = "0.4.0", features = ["with_serde"] } symbolic = { version = "7.5.0", path = "../symbolic", features = ["debuginfo", "demangle", "minidump", "sourcemap", "symcache", "unreal-serde"] } proguard = { version = "4.0.1", features = ["uuid"] } diff --git a/symbolic-cabi/src/core.rs b/symbolic-cabi/src/core.rs index d283a4f95..7e387cba1 100644 --- a/symbolic-cabi/src/core.rs +++ b/symbolic-cabi/src/core.rs @@ -6,7 +6,6 @@ use std::ptr; use std::slice; use std::str; -use failure::Error; use symbolic::common::Uuid; use crate::utils::{set_panic_hook, Panic, LAST_ERROR}; @@ -224,34 +223,36 @@ pub enum SymbolicErrorCode { impl SymbolicErrorCode { /// This maps all errors that can possibly happen. // #[allow(clippy::cyclomatic_complexity)] - pub fn from_error(error: &Error) -> SymbolicErrorCode { - for cause in error.iter_chain() { - if cause.downcast_ref::().is_some() { + pub fn from_error(error: &(dyn std::error::Error + 'static)) -> SymbolicErrorCode { + let mut source = Some(error); + + while let Some(error) = source { + if error.downcast_ref::().is_some() { return SymbolicErrorCode::Panic; } use std::io::Error as IoError; - if cause.downcast_ref::().is_some() { + if error.downcast_ref::().is_some() { return SymbolicErrorCode::IoError; } use symbolic::common::{ParseDebugIdError, UnknownArchError, UnknownLanguageError}; - if cause.downcast_ref::().is_some() { + if error.downcast_ref::().is_some() { return SymbolicErrorCode::UnknownArchError; - } else if cause.downcast_ref::().is_some() { + } else if error.downcast_ref::().is_some() { return SymbolicErrorCode::UnknownLanguageError; - } else if cause.downcast_ref::().is_some() { + } else if error.downcast_ref::().is_some() { return SymbolicErrorCode::ParseDebugIdError; } use symbolic::debuginfo::{ - dwarf::DwarfErrorKind, ObjectError, UnknownFileFormatError, UnknownObjectKindError, + dwarf::DwarfError, ObjectError, UnknownFileFormatError, UnknownObjectKindError, }; - if cause.downcast_ref::().is_some() { + if error.downcast_ref::().is_some() { return SymbolicErrorCode::UnknownObjectKindError; - } else if cause.downcast_ref::().is_some() { + } else if error.downcast_ref::().is_some() { return SymbolicErrorCode::UnknownFileFormatError; - } else if let Some(error) = cause.downcast_ref::() { + } else if let Some(error) = error.downcast_ref::() { return match error { ObjectError::UnsupportedObject => { SymbolicErrorCode::ObjectErrorUnsupportedObject @@ -261,20 +262,20 @@ impl SymbolicErrorCode { ObjectError::MachO(_) => SymbolicErrorCode::ObjectErrorBadMachOObject, ObjectError::Pdb(_) => SymbolicErrorCode::ObjectErrorBadPdbObject, ObjectError::Pe(_) => SymbolicErrorCode::ObjectErrorBadPeObject, - ObjectError::Dwarf(ref e) => match e.kind() { - DwarfErrorKind::InvalidUnitRef(_) => { + ObjectError::Dwarf(ref e) => match e { + DwarfError::InvalidUnitRef(_) => { SymbolicErrorCode::DwarfErrorInvalidUnitRef } - DwarfErrorKind::InvalidFileRef(_) => { + DwarfError::InvalidFileRef(_) => { SymbolicErrorCode::DwarfErrorInvalidFileRef } - DwarfErrorKind::UnexpectedInline => { + DwarfError::UnexpectedInline => { SymbolicErrorCode::DwarfErrorUnexpectedInline } - DwarfErrorKind::InvertedFunctionRange => { + DwarfError::InvertedFunctionRange => { SymbolicErrorCode::DwarfErrorInvertedFunctionRange } - DwarfErrorKind::CorruptedData => SymbolicErrorCode::DwarfErrorCorruptedData, + DwarfError::CorruptedData(_) => SymbolicErrorCode::DwarfErrorCorruptedData, _ => SymbolicErrorCode::DwarfErrorUnknown, }, ObjectError::SourceBundle(_) => SymbolicErrorCode::ObjectErrorBadSourceBundle, @@ -282,24 +283,24 @@ impl SymbolicErrorCode { }; } - use symbolic::minidump::cfi::{CfiError, CfiErrorKind}; - if let Some(error) = cause.downcast_ref::() { - return match error.kind() { - CfiErrorKind::MissingDebugInfo => SymbolicErrorCode::CfiErrorMissingDebugInfo, - CfiErrorKind::UnsupportedDebugFormat => { + use symbolic::minidump::cfi::CfiError; + if let Some(error) = error.downcast_ref::() { + return match error { + CfiError::MissingDebugInfo => SymbolicErrorCode::CfiErrorMissingDebugInfo, + CfiError::UnsupportedDebugFormat => { SymbolicErrorCode::CfiErrorUnsupportedDebugFormat } - CfiErrorKind::BadDebugInfo => SymbolicErrorCode::CfiErrorBadDebugInfo, - CfiErrorKind::UnsupportedArch => SymbolicErrorCode::CfiErrorUnsupportedArch, - CfiErrorKind::InvalidAddress => SymbolicErrorCode::CfiErrorInvalidAddress, - CfiErrorKind::WriteError => SymbolicErrorCode::CfiErrorWriteError, - CfiErrorKind::BadFileMagic => SymbolicErrorCode::CfiErrorBadFileMagic, + CfiError::BadDebugInfo(_) => SymbolicErrorCode::CfiErrorBadDebugInfo, + CfiError::UnsupportedArch(_) => SymbolicErrorCode::CfiErrorUnsupportedArch, + CfiError::InvalidAddress => SymbolicErrorCode::CfiErrorInvalidAddress, + CfiError::WriteError(_) => SymbolicErrorCode::CfiErrorWriteError, + CfiError::BadFileMagic => SymbolicErrorCode::CfiErrorBadFileMagic, _ => SymbolicErrorCode::CfiErrorUnknown, }; } use symbolic::minidump::processor::{ProcessMinidumpError, ProcessResult}; - if let Some(error) = cause.downcast_ref::() { + if let Some(error) = error.downcast_ref::() { return match error.kind() { // `Ok` is not used in errors ProcessResult::Ok => SymbolicErrorCode::Unknown, @@ -328,37 +329,37 @@ impl SymbolicErrorCode { } use symbolic::sourcemap::ParseSourceMapError; - if cause.downcast_ref::().is_some() { + if error.downcast_ref::().is_some() { return SymbolicErrorCode::ParseSourceMapError; } - use symbolic::symcache::{SymCacheError, SymCacheErrorKind}; - if let Some(error) = cause.downcast_ref::() { - return match error.kind() { - SymCacheErrorKind::BadFileMagic => SymbolicErrorCode::SymCacheErrorBadFileMagic, - SymCacheErrorKind::BadFileHeader => { + use symbolic::symcache::SymCacheError; + if let Some(error) = error.downcast_ref::() { + return match error { + SymCacheError::BadFileMagic => SymbolicErrorCode::SymCacheErrorBadFileMagic, + SymCacheError::BadFileHeader(_) => { SymbolicErrorCode::SymCacheErrorBadFileHeader } - SymCacheErrorKind::BadSegment => SymbolicErrorCode::SymCacheErrorBadSegment, - SymCacheErrorKind::BadCacheFile => SymbolicErrorCode::SymCacheErrorBadCacheFile, - SymCacheErrorKind::UnsupportedVersion => { + SymCacheError::BadSegment => SymbolicErrorCode::SymCacheErrorBadSegment, + SymCacheError::BadCacheFile => SymbolicErrorCode::SymCacheErrorBadCacheFile, + SymCacheError::UnsupportedVersion => { SymbolicErrorCode::SymCacheErrorUnsupportedVersion } - SymCacheErrorKind::BadDebugFile => SymbolicErrorCode::SymCacheErrorBadDebugFile, - SymCacheErrorKind::MissingDebugSection => { + SymCacheError::BadDebugFile(_) => SymbolicErrorCode::SymCacheErrorBadDebugFile, + SymCacheError::MissingDebugSection => { SymbolicErrorCode::SymCacheErrorMissingDebugSection } - SymCacheErrorKind::MissingDebugInfo => { + SymCacheError::MissingDebugInfo => { SymbolicErrorCode::SymCacheErrorMissingDebugInfo } - SymCacheErrorKind::UnsupportedDebugKind => { + SymCacheError::UnsupportedDebugKind => { SymbolicErrorCode::SymCacheErrorUnsupportedDebugKind } - SymCacheErrorKind::ValueTooLarge(_) => { + SymCacheError::ValueTooLarge(_) => { SymbolicErrorCode::SymCacheErrorValueTooLarge } - SymCacheErrorKind::WriteFailed => SymbolicErrorCode::SymCacheErrorWriteFailed, - SymCacheErrorKind::TooManyValues(_) => { + SymCacheError::WriteFailed(_) => SymbolicErrorCode::SymCacheErrorWriteFailed, + SymCacheError::TooManyValues(_) => { SymbolicErrorCode::SymCacheErrorTooManyValues } _ => SymbolicErrorCode::SymCacheErrorUnknown, @@ -366,7 +367,7 @@ impl SymbolicErrorCode { } use symbolic::unreal::Unreal4Error; - if let Some(error) = cause.downcast_ref::() { + if let Some(error) = error.downcast_ref::() { return match error { Unreal4Error::Empty => SymbolicErrorCode::Unreal4ErrorEmpty, Unreal4Error::BadCompression(_) => { @@ -383,7 +384,7 @@ impl SymbolicErrorCode { } use apple_crash_report_parser::ParseError; - if let Some(error) = cause.downcast_ref::() { + if let Some(error) = error.downcast_ref::() { return match error { ParseError::Io(_) => SymbolicErrorCode::AppleCrashReportParseErrorIo, ParseError::InvalidIncidentIdentifier(_) => { @@ -400,6 +401,8 @@ impl SymbolicErrorCode { } }; } + + source = error.source(); } SymbolicErrorCode::Unknown @@ -419,7 +422,7 @@ pub unsafe extern "C" fn symbolic_init() { pub unsafe extern "C" fn symbolic_err_get_last_code() -> SymbolicErrorCode { LAST_ERROR.with(|e| { if let Some(ref err) = *e.borrow() { - SymbolicErrorCode::from_error(err) + SymbolicErrorCode::from_error(err.as_ref()) } else { SymbolicErrorCode::NoError } @@ -435,9 +438,11 @@ pub unsafe extern "C" fn symbolic_err_get_last_message() -> SymbolicStr { use std::fmt::Write; LAST_ERROR.with(|e| { if let Some(ref err) = *e.borrow() { + let mut err = err.as_ref(); let mut msg = err.to_string(); - for cause in err.iter_causes() { + while let Some(cause) = err.source() { write!(&mut msg, "\n caused by: {}", cause).ok(); + err = cause; } SymbolicStr::from_string(msg) } else { @@ -449,21 +454,7 @@ pub unsafe extern "C" fn symbolic_err_get_last_message() -> SymbolicStr { /// Returns the panic information as string. #[no_mangle] pub unsafe extern "C" fn symbolic_err_get_backtrace() -> SymbolicStr { - LAST_ERROR.with(|e| { - if let Some(ref error) = *e.borrow() { - let backtrace = error.backtrace().to_string(); - if !backtrace.is_empty() { - use std::fmt::Write; - let mut out = String::new(); - write!(&mut out, "stacktrace: {}", backtrace).ok(); - SymbolicStr::from_string(out) - } else { - Default::default() - } - } else { - Default::default() - } - }) + SymbolicStr::default() } /// Clears the last error. diff --git a/symbolic-cabi/src/utils.rs b/symbolic-cabi/src/utils.rs index 9e79fd4e7..afd239d72 100644 --- a/symbolic-cabi/src/utils.rs +++ b/symbolic-cabi/src/utils.rs @@ -3,7 +3,7 @@ use std::mem; use std::panic; use std::thread; -use failure::{Error, Fail}; +type Error = Box; thread_local! { pub static LAST_ERROR: RefCell> = RefCell::new(None); @@ -46,10 +46,17 @@ pub trait ForeignObject: Sized { } /// An error thrown by `landingpad` in place of panics. -#[derive(Fail, Debug)] -#[fail(display = "symbolic panicked: {}", _0)] +#[derive(Debug)] pub struct Panic(String); +impl std::fmt::Display for Panic { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "symbolic panicked: {}", self.0) + } +} + +impl std::error::Error for Panic {} + fn set_last_error(err: Error) { LAST_ERROR.with(|e| { *e.borrow_mut() = Some(err); diff --git a/symbolic-common/Cargo.toml b/symbolic-common/Cargo.toml index 06fdda023..6af0756d5 100644 --- a/symbolic-common/Cargo.toml +++ b/symbolic-common/Cargo.toml @@ -22,7 +22,6 @@ all-features = true [dependencies] debugid = "0.7.1" -failure = "0.1.5" memmap = "0.7.0" stable_deref_trait = "1.1.1" serde_ = { package = "serde", version = "1.0.88", optional = true, features = ["derive"] } @@ -33,7 +32,6 @@ symbolic-testutils = { path = "../symbolic-testutils" } tempfile = "3.1.0" [features] -default = [] serde = ["serde_", "debugid/serde"] [badges] diff --git a/symbolic-common/src/byteview.rs b/symbolic-common/src/byteview.rs index 27fe0d898..7f23dcd19 100644 --- a/symbolic-common/src/byteview.rs +++ b/symbolic-common/src/byteview.rs @@ -236,11 +236,10 @@ mod tests { use std::io::Write; - use failure::Error; use tempfile::NamedTempFile; #[test] - fn test_open_empty_file() -> Result<(), Error> { + fn test_open_empty_file() -> Result<(), std::io::Error> { let tmp = NamedTempFile::new()?; let view = ByteView::open(&tmp.path())?; @@ -250,7 +249,7 @@ mod tests { } #[test] - fn test_open_file() -> Result<(), Error> { + fn test_open_file() -> Result<(), std::io::Error> { let mut tmp = NamedTempFile::new()?; tmp.write_all(b"1234")?; diff --git a/symbolic-common/src/fail.rs b/symbolic-common/src/fail.rs deleted file mode 100644 index 1f385e63d..000000000 --- a/symbolic-common/src/fail.rs +++ /dev/null @@ -1,80 +0,0 @@ -/// Defines an error type with a failure context and a kind. -/// -/// The kind enum needs to be defined explicitly, and has to implement `Fail` already. This macro -/// then defines an error type that wraps the kind in a `failure::Context` which makes it carry a -/// backtrace and allows nesting errors, and also defines the following methods on the error type: -/// -/// - `kind()`: Returns a reference to the error kind. -/// - `cause()`: Returns the causing error, if any. -/// - `backtrace()`: Returns the backtrace of this error (or the cause), if -/// `RUST_BACKTRACE` was set. -/// -/// In addition to this, the following conversions are defined for the error type: -/// - `From` -/// - `From>` -/// -/// # Examples -/// -/// ``` -/// use failure::Fail; -/// use symbolic_common::derive_failure; -/// -/// #[derive(Debug, Fail)] -/// enum MyErrorKind { -/// #[fail(display = "some")] Something, -/// #[fail(display = "else")] Else, -/// } -/// -/// derive_failure!(MyError, MyErrorKind); -/// -/// fn something() -> Result<(), MyError> { -/// Err(MyErrorKind::Something.into()) -/// } -/// ``` -#[macro_export] -macro_rules! derive_failure { - ($error:ident, $kind:ident $(, $meta:meta)* $(,)?) => { - $(#[$meta])* - #[derive(Debug)] - pub struct $error { - inner: ::failure::Context<$kind>, - } - - impl ::failure::Fail for $error { - fn cause(&self) -> Option<&dyn ::failure::Fail> { - self.inner.cause() - } - - fn backtrace(&self) -> Option<&::failure::Backtrace> { - self.inner.backtrace() - } - } - - impl ::std::fmt::Display for $error { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - self.inner.fmt(f) - } - } - - impl $error { - /// Returns the error kind of this error. - pub fn kind(&self) -> &$kind { - &self.inner.get_context() - } - } - - impl From<$kind> for $error { - fn from(kind: $kind) -> Self { - $error { - inner: ::failure::Context::new(kind), - } - } - } - - impl From<::failure::Context<$kind>> for $error { - fn from(inner: ::failure::Context<$kind>) -> Self { - $error { inner } - } - } - }; -} diff --git a/symbolic-common/src/lib.rs b/symbolic-common/src/lib.rs index 1c0dd1076..9f8287142 100644 --- a/symbolic-common/src/lib.rs +++ b/symbolic-common/src/lib.rs @@ -24,14 +24,12 @@ mod byteview; mod cell; -mod fail; mod heuristics; mod path; mod types; pub use crate::byteview::*; pub use crate::cell::*; -pub use crate::fail::*; pub use crate::heuristics::*; pub use crate::path::*; pub use crate::types::*; diff --git a/symbolic-common/src/types.rs b/symbolic-common/src/types.rs index 7af465a40..3704ea640 100644 --- a/symbolic-common/src/types.rs +++ b/symbolic-common/src/types.rs @@ -4,8 +4,6 @@ use std::borrow::Cow; use std::fmt; use std::str; -use failure::Fail; - #[cfg(feature = "serde")] use serde_::{Deserialize, Serialize}; @@ -223,10 +221,17 @@ impl Default for CpuFamily { } /// An error returned for an invalid [`Arch`](enum.Arch.html). -#[derive(Clone, Copy, Debug, Fail)] -#[fail(display = "unknown architecture")] +#[derive(Debug)] pub struct UnknownArchError; +impl fmt::Display for UnknownArchError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "unknown architecture") + } +} + +impl std::error::Error for UnknownArchError {} + /// An enumeration of CPU architectures and variants. /// /// The architectues are grouped into families, which can be retrieved by [`cpu_family`]. There are @@ -516,10 +521,17 @@ impl str::FromStr for Arch { } /// An error returned for an invalid [`Language`](enum.Language.html). -#[derive(Clone, Copy, Debug, Fail)] -#[fail(display = "unknown language")] +#[derive(Debug)] pub struct UnknownLanguageError; +impl fmt::Display for UnknownLanguageError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "unknown language") + } +} + +impl std::error::Error for UnknownLanguageError {} + /// A programming language declared in debugging information. /// /// In the context of function names or source code, the lanugage can help to determine appropriate diff --git a/symbolic-debuginfo/Cargo.toml b/symbolic-debuginfo/Cargo.toml index 0ea3020d9..1d5d4973c 100644 --- a/symbolic-debuginfo/Cargo.toml +++ b/symbolic-debuginfo/Cargo.toml @@ -24,7 +24,6 @@ all-features = true [dependencies] dmsort = "1.0.0" -failure = "0.1.5" fallible-iterator = "0.2.0" flate2 = { version = "1.0.13", features = ["rust_backend"], default-features = false } gimli = { version = "0.21.0", features = ["read", "std"], default-features = false } @@ -40,6 +39,7 @@ serde = { version = "1.0.94", features = ["derive"] } serde_json = "1.0.40" smallvec = "1.2.0" symbolic-common = { version = "7.5.0", path = "../symbolic-common" } +thiserror = "1.0.20" zip = "0.5.2" [dev-dependencies] diff --git a/symbolic-debuginfo/src/base.rs b/symbolic-debuginfo/src/base.rs index bccbeba43..7c8abb58d 100644 --- a/symbolic-debuginfo/src/base.rs +++ b/symbolic-debuginfo/src/base.rs @@ -4,15 +4,20 @@ use std::iter::FromIterator; use std::ops::{Bound, Deref, RangeBounds}; use std::str::FromStr; -use failure::Fail; - use symbolic_common::{clean_path, join_path, Arch, CodeId, DebugId, Name}; /// An error returned for unknown or invalid `ObjectKinds`. -#[derive(Debug, Fail, Clone, Copy)] -#[fail(display = "unknown object class")] +#[derive(Debug)] pub struct UnknownObjectKindError; +impl fmt::Display for UnknownObjectKindError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "unknown object class") + } +} + +impl std::error::Error for UnknownObjectKindError {} + /// Represents the designated use of the object file and hints at its contents. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] pub enum ObjectKind { @@ -123,10 +128,17 @@ impl FromStr for ObjectKind { } /// An error returned for unknown or invalid [`FileFormats`](enum.FileFormat.html). -#[derive(Debug, Fail, Clone, Copy)] -#[fail(display = "unknown file format")] +#[derive(Debug)] pub struct UnknownFileFormatError; +impl fmt::Display for UnknownFileFormatError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "unknown file format") + } +} + +impl std::error::Error for UnknownFileFormatError {} + /// Represents the physical object file format. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] pub enum FileFormat { diff --git a/symbolic-debuginfo/src/breakpad.rs b/symbolic-debuginfo/src/breakpad.rs index 085b4100e..c33e4294f 100644 --- a/symbolic-debuginfo/src/breakpad.rs +++ b/symbolic-debuginfo/src/breakpad.rs @@ -5,10 +5,10 @@ use std::collections::BTreeMap; use std::fmt; use std::str; -use failure::Fail; use pest::Parser; +use thiserror::Error; -use symbolic_common::{derive_failure, Arch, AsSelf, CodeId, DebugId, Name}; +use symbolic_common::{Arch, AsSelf, CodeId, DebugId, Name}; use crate::base::*; use crate::private::{Lines, Parse}; @@ -32,45 +32,27 @@ const BREAKPAD_HEADER_CAP: usize = 320; /// Placeholder used for missing function or symbol names. const UNKNOWN_NAME: &str = ""; -/// Variants of `BreakpadError`. +/// An error when dealing with [`BreakpadObject`](struct.BreakpadObject.html). #[non_exhaustive] -#[derive(Debug, Fail)] -pub enum BreakpadErrorKind { +#[derive(Debug, Error)] +pub enum BreakpadError { /// The symbol header (`MODULE` record) is missing. - #[fail(display = "missing breakpad symbol header")] + #[error("missing breakpad symbol header")] InvalidMagic, /// A part of the file is not encoded in valid UTF-8. - #[fail(display = "bad utf-8 sequence")] - BadEncoding(#[fail(cause)] str::Utf8Error), + #[error("bad utf-8 sequence")] + BadEncoding(#[from] str::Utf8Error), /// A record violates the Breakpad symbol syntax. - #[fail(display = "{}", _0)] - BadSyntax(pest::error::Error), + #[error(transparent)] + BadSyntax(#[from] pest::error::Error), /// Parsing of a record failed. - #[fail(display = "{}", _0)] + #[error("{0}")] Parse(&'static str), } -derive_failure!( - BreakpadError, - BreakpadErrorKind, - doc = "An error when dealing with [`BreakpadObject`](struct.BreakpadObject.html).", -); - -impl From for BreakpadError { - fn from(error: str::Utf8Error) -> Self { - BreakpadErrorKind::BadEncoding(error).into() - } -} - -impl From> for BreakpadError { - fn from(error: pest::error::Error) -> Self { - BreakpadErrorKind::BadSyntax(error).into() - } -} - // TODO(ja): Test the parser /// A [module record], constituting the header of a Breakpad file. @@ -152,7 +134,7 @@ impl<'d> BreakpadInfoRecord<'d> { } } - Err(BreakpadErrorKind::Parse("unknown INFO record").into()) + Err(BreakpadError::Parse("unknown INFO record")) } fn code_info_from_pair(pair: pest::iterators::Pair<'d, Rule>) -> Result { @@ -248,7 +230,7 @@ impl<'d> BreakpadFileRecord<'d> { match pair.as_rule() { Rule::file_id => { record.id = u64::from_str_radix(pair.as_str(), 10) - .map_err(|_| BreakpadErrorKind::Parse("file identifier"))?; + .map_err(|_| BreakpadError::Parse("file identifier"))?; } Rule::name => record.name = pair.as_str(), _ => unreachable!(), @@ -324,11 +306,11 @@ impl<'d> BreakpadPublicRecord<'d> { Rule::multiple => record.multiple = true, Rule::addr => { record.address = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("symbol address"))?; + .map_err(|_| BreakpadError::Parse("symbol address"))?; } Rule::param_size => { record.parameter_size = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("symbol parameter size"))?; + .map_err(|_| BreakpadError::Parse("symbol parameter size"))?; } Rule::name => record.name = pair.as_str(), _ => unreachable!(), @@ -413,15 +395,15 @@ impl<'d> BreakpadFuncRecord<'d> { Rule::multiple => record.multiple = true, Rule::addr => { record.address = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("function address"))?; + .map_err(|_| BreakpadError::Parse("function address"))?; } Rule::size => { record.size = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("function size"))?; + .map_err(|_| BreakpadError::Parse("function size"))?; } Rule::param_size => { record.parameter_size = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("function parameter size"))?; + .map_err(|_| BreakpadError::Parse("function parameter size"))?; } Rule::name => record.name = pair.as_str(), _ => unreachable!(), @@ -536,11 +518,11 @@ impl BreakpadLineRecord { match pair.as_rule() { Rule::addr => { record.address = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("line address"))?; + .map_err(|_| BreakpadError::Parse("line address"))?; } Rule::size => { record.size = u64::from_str_radix(pair.as_str(), 16) - .map_err(|_| BreakpadErrorKind::Parse("line size"))?; + .map_err(|_| BreakpadError::Parse("line size"))?; } Rule::line_num => { // NB: Breakpad does not allow negative line numbers and even tests that the @@ -548,11 +530,11 @@ impl BreakpadLineRecord { // been observed at least for ELF files, so handle them gracefully. record.line = i32::from_str_radix(pair.as_str(), 10) .map(|line| u64::from(line as u32)) - .map_err(|_| BreakpadErrorKind::Parse("line number"))?; + .map_err(|_| BreakpadError::Parse("line number"))?; } Rule::file_id => { record.file_id = u64::from_str_radix(pair.as_str(), 10) - .map_err(|_| BreakpadErrorKind::Parse("file number"))?; + .map_err(|_| BreakpadError::Parse("file number"))?; } _ => unreachable!(), } @@ -786,11 +768,11 @@ impl<'d> BreakpadObject<'d> { id: module .id .parse() - .map_err(|_| BreakpadErrorKind::Parse("module id"))?, + .map_err(|_| BreakpadError::Parse("module id"))?, arch: module .arch .parse() - .map_err(|_| BreakpadErrorKind::Parse("module architecture"))?, + .map_err(|_| BreakpadError::Parse("module architecture"))?, module, data, }) diff --git a/symbolic-debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs index 6cda0d5b8..7c56f874a 100644 --- a/symbolic-debuginfo/src/dwarf.rs +++ b/symbolic-debuginfo/src/dwarf.rs @@ -12,19 +12,20 @@ use std::fmt; use std::marker::PhantomData; use std::ops::Deref; -use failure::Fail; use fallible_iterator::FallibleIterator; use gimli::read::{AttributeValue, Range}; use gimli::{constants, UnitSectionOffset}; use lazycell::LazyCell; +use thiserror::Error; -use symbolic_common::{derive_failure, AsSelf, Language, Name, SelfCell}; +use symbolic_common::{AsSelf, Language, Name, SelfCell}; use crate::base::*; use crate::private::FunctionStack; #[doc(hidden)] pub use gimli; +pub use gimli::read::Error as GimliError; pub use gimli::RunTimeEndian as Endian; type Slice<'a> = gimli::read::EndianSlice<'a, Endian>; @@ -42,41 +43,29 @@ type IncompleteLineNumberProgram<'a> = gimli::read::IncompleteLineProgram = gimli::read::LineProgramHeader>; type LineProgramFileEntry<'a> = gimli::read::FileEntry>; -/// Variants of [`DwarfError`](struct.DwarfError.html). +/// An error handling [`DWARF`](trait.Dwarf.html) debugging information. #[non_exhaustive] -#[derive(Clone, Copy, Debug, Eq, Fail, PartialEq)] -pub enum DwarfErrorKind { +#[derive(Debug, Error)] +pub enum DwarfError { /// A compilation unit referenced by index does not exist. - #[fail(display = "compilation unit for offset {} does not exist", _0)] + #[error("compilation unit for offset {0} does not exist")] InvalidUnitRef(usize), /// A file record referenced by index does not exist. - #[fail(display = "referenced file {} does not exist", _0)] + #[error("referenced file {0} does not exist")] InvalidFileRef(u64), /// An inline record was encountered without an inlining parent. - #[fail(display = "unexpected inline function without parent")] + #[error("unexpected inline function without parent")] UnexpectedInline, /// The debug_ranges of a function are invalid. - #[fail(display = "function with inverted address range")] + #[error("function with inverted address range")] InvertedFunctionRange, /// The DWARF file is corrupted. See the cause for more information. - #[fail(display = "corrupted dwarf debug data")] - CorruptedData, -} - -derive_failure!( - DwarfError, - DwarfErrorKind, - doc = "An error handling [`DWARF`](trait.Dwarf.html) debugging information.", -); - -impl From for DwarfError { - fn from(error: gimli::read::Error) -> Self { - error.context(DwarfErrorKind::CorruptedData).into() - } + #[error("corrupted dwarf debug data")] + CorruptedData(#[from] GimliError), } /// DWARF section information including its data. @@ -526,7 +515,7 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { if low_pc > high_pc { // TODO: consider swallowing errors here? - return Err(DwarfErrorKind::InvertedFunctionRange.into()); + return Err(DwarfError::InvertedFunctionRange); } range_buf.push(Range { @@ -725,7 +714,7 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { // indicates invalid debug information. let parent = match stack.peek_mut() { Some(parent) => parent, - None => return Err(DwarfErrorKind::UnexpectedInline.into()), + None => return Err(DwarfError::UnexpectedInline), }; // Make sure there is correct line information for the call site of this inlined @@ -1064,7 +1053,7 @@ impl<'d> DwarfInfo<'d> { let index = match search_result { Ok(index) => index, - Err(0) => return Err(DwarfErrorKind::InvalidUnitRef(offset.0).into()), + Err(0) => return Err(DwarfError::InvalidUnitRef(offset.0)), Err(next_index) => next_index - 1, }; @@ -1075,7 +1064,7 @@ impl<'d> DwarfInfo<'d> { } } - Err(DwarfErrorKind::InvalidUnitRef(offset.0).into()) + Err(DwarfError::InvalidUnitRef(offset.0)) } /// Returns an iterator over all compilation units. diff --git a/symbolic-debuginfo/src/elf.rs b/symbolic-debuginfo/src/elf.rs index 9f210f800..7688b1270 100644 --- a/symbolic-debuginfo/src/elf.rs +++ b/symbolic-debuginfo/src/elf.rs @@ -4,10 +4,10 @@ use std::borrow::Cow; use std::fmt; use std::io::Cursor; -use failure::Fail; use flate2::{Decompress, FlushDecompress}; use goblin::elf::compression_header::{CompressionHeader, ELFCOMPRESS_ZLIB}; -use goblin::{container::Ctx, elf, error::Error as GoblinError, strtab}; +use goblin::{container::Ctx, elf, strtab}; +use thiserror::Error; use symbolic_common::{Arch, AsSelf, CodeId, DebugId, Uuid}; @@ -15,6 +15,9 @@ use crate::base::*; use crate::dwarf::{Dwarf, DwarfDebugSession, DwarfError, DwarfSection, Endian}; use crate::private::Parse; +#[doc(inline)] +pub use goblin::error::Error as GoblinError; + const UUID_SIZE: usize = 16; const PAGE_SIZE: usize = 4096; @@ -37,11 +40,11 @@ const MIPS_64_FLAGS: u32 = EF_MIPS_ABI_O64 | EF_MIPS_ABI_EABI64; /// An error when dealing with [`ElfObject`](struct.ElfObject.html). #[non_exhaustive] -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum ElfError { /// The data in the ELF file could not be parsed. - #[fail(display = "invalid ELF file")] - BadObject(#[fail(cause)] GoblinError), + #[error("invalid ELF file")] + BadObject(#[from] GoblinError), } /// Executable and Linkable Format, used for executables and libraries on Linux. @@ -61,9 +64,7 @@ impl<'d> ElfObject<'d> { /// Tries to parse an ELF object from the given slice. pub fn parse(data: &'d [u8]) -> Result { - elf::Elf::parse(data) - .map(|elf| ElfObject { elf, data }) - .map_err(ElfError::BadObject) + Ok(elf::Elf::parse(data).map(|elf| ElfObject { elf, data })?) } /// The container file format, which is always `FileFormat::Elf`. diff --git a/symbolic-debuginfo/src/macho.rs b/symbolic-debuginfo/src/macho.rs index 7f980438e..c7d1dc0b7 100644 --- a/symbolic-debuginfo/src/macho.rs +++ b/symbolic-debuginfo/src/macho.rs @@ -4,9 +4,9 @@ use std::borrow::Cow; use std::fmt; use std::io::Cursor; -use failure::Fail; use goblin::{error::Error as GoblinError, mach}; use smallvec::SmallVec; +use thiserror::Error; use symbolic_common::{Arch, AsSelf, CodeId, DebugId, Uuid}; @@ -16,11 +16,11 @@ use crate::private::{MonoArchive, MonoArchiveObjects, Parse}; /// An error when dealing with [`MachObject`](struct.MachObject.html). #[non_exhaustive] -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum MachError { /// The data in the MachO file could not be parsed. - #[fail(display = "invalid MachO file")] - BadObject(#[fail(cause)] GoblinError), + #[error("invalid MachO file")] + BadObject(#[from] GoblinError), } /// Mach Object containers, used for executables and debug companions on macOS and iOS. @@ -40,9 +40,7 @@ impl<'d> MachObject<'d> { /// Tries to parse a MachO from the given slice. pub fn parse(data: &'d [u8]) -> Result { - mach::MachO::parse(data, 0) - .map(|macho| MachObject { macho, data }) - .map_err(MachError::BadObject) + Ok(mach::MachO::parse(data, 0).map(|macho| MachObject { macho, data })?) } /// The container file format, which is always `FileFormat::MachO`. @@ -488,9 +486,7 @@ impl<'d> FatMachO<'d> { /// Tries to parse a fat MachO container from the given slice. pub fn parse(data: &'d [u8]) -> Result { - mach::MultiArch::new(data) - .map(|fat| FatMachO { fat, data }) - .map_err(MachError::BadObject) + Ok(mach::MultiArch::new(data).map(|fat| FatMachO { fat, data })?) } /// Returns an iterator over objects in this container. @@ -513,7 +509,7 @@ impl<'d> FatMachO<'d> { /// be parsed. pub fn object_by_index(&self, index: usize) -> Result>, MachError> { let arch = match self.fat.iter_arches().nth(index) { - Some(arch) => arch.map_err(MachError::BadObject)?, + Some(arch) => arch?, None => return Ok(None), }; diff --git a/symbolic-debuginfo/src/object.rs b/symbolic-debuginfo/src/object.rs index 7de19d1d1..81229aa23 100644 --- a/symbolic-debuginfo/src/object.rs +++ b/symbolic-debuginfo/src/object.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; -use failure::Fail; use goblin::Hint; +use thiserror::Error; use symbolic_common::{Arch, AsSelf, CodeId, DebugId}; @@ -60,40 +60,39 @@ macro_rules! map_result { /// An error when dealing with any kind of [`Object`](enum.Object.html). #[non_exhaustive] -#[allow(clippy::large_enum_variant)] -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum ObjectError { /// The object file format is not supported. - #[fail(display = "unsupported object file format")] + #[error("unsupported object file format")] UnsupportedObject, /// An error in a Breakpad ASCII symbol. - #[fail(display = "failed to process breakpad file")] - Breakpad(#[fail(cause)] BreakpadError), + #[error("failed to process breakpad file")] + Breakpad(#[from] BreakpadError), /// An error in an ELF file. - #[fail(display = "failed to process elf file")] - Elf(#[fail(cause)] ElfError), + #[error("failed to process elf file")] + Elf(#[from] ElfError), /// An error in a Mach object. - #[fail(display = "failed to process macho file")] - MachO(#[fail(cause)] MachError), + #[error("failed to process macho file")] + MachO(#[from] MachError), /// An error in a Program Database. - #[fail(display = "failed to process pdb file")] - Pdb(#[fail(cause)] PdbError), + #[error("failed to process pdb file")] + Pdb(#[from] PdbError), /// An error in a Portable Executable. - #[fail(display = "failed to process pe file")] - Pe(#[fail(cause)] PeError), + #[error("failed to process pe file")] + Pe(#[from] PeError), /// An error in DWARF debugging information. - #[fail(display = "failed to process dwarf info")] - Dwarf(#[fail(cause)] DwarfError), + #[error("failed to process dwarf info")] + Dwarf(#[from] DwarfError), /// An error in source bundles. - #[fail(display = "failed to process source bundle")] - SourceBundle(#[fail(cause)] SourceBundleError), + #[error("failed to process source bundle")] + SourceBundle(#[from] SourceBundleError), } /// Tries to infer the object type from the start of the given buffer. diff --git a/symbolic-debuginfo/src/pdb.rs b/symbolic-debuginfo/src/pdb.rs index 282f7b8dc..c3228171b 100644 --- a/symbolic-debuginfo/src/pdb.rs +++ b/symbolic-debuginfo/src/pdb.rs @@ -8,7 +8,6 @@ use std::fmt; use std::io::Cursor; use std::sync::Arc; -use failure::Fail; use lazycell::LazyCell; use parking_lot::RwLock; use pdb::{ @@ -16,10 +15,9 @@ use pdb::{ ModuleInfo, PdbInternalSectionOffset, ProcedureSymbol, SymbolData, }; use smallvec::SmallVec; +use thiserror::Error; -use symbolic_common::{ - derive_failure, Arch, AsSelf, CodeId, CpuFamily, DebugId, Name, SelfCell, Uuid, -}; +use symbolic_common::{Arch, AsSelf, CodeId, CpuFamily, DebugId, Name, SelfCell, Uuid}; use crate::base::*; use crate::private::{FunctionStack, Parse}; @@ -32,39 +30,21 @@ const MAGIC_BIG: &[u8] = b"Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00" #[doc(hidden)] pub use pdb; -/// Variants of [`PdbError`](struct.PdbError.html). +/// An error when dealing with [`PdbObject`](struct.PdbObject.html). #[non_exhaustive] -#[derive(Clone, Copy, Debug, Eq, Fail, PartialEq)] -pub enum PdbErrorKind { +#[derive(Debug, Error)] +pub enum PdbError { /// The PDB file is corrupted. See the cause for more information. - #[fail(display = "invalid pdb file")] - BadObject, + #[error("invalid pdb file")] + BadObject(#[from] pdb::Error), /// An inline record was encountered without an inlining parent. - #[fail(display = "unexpected inline function without parent")] + #[error("unexpected inline function without parent")] UnexpectedInline, /// Formatting of a type name failed - #[fail(display = "failed to format type name")] - FormattingFailed, -} - -derive_failure!( - PdbError, - PdbErrorKind, - doc = "An error when dealing with [`PdbObject`](struct.PdbObject.html)." -); - -impl From for PdbError { - fn from(error: pdb::Error) -> Self { - error.context(PdbErrorKind::BadObject).into() - } -} - -impl From for PdbError { - fn from(error: fmt::Error) -> Self { - error.context(PdbErrorKind::FormattingFailed).into() - } + #[error("failed to format type name")] + FormattingFailed(#[from] fmt::Error), } /// Program Database, the debug companion format on Windows. @@ -1066,7 +1046,7 @@ impl<'s> Unit<'s> { let parent_offset = proc_offsets .last() .map(|&(_, offset)| offset) - .ok_or_else(|| PdbError::from(PdbErrorKind::UnexpectedInline))?; + .ok_or(PdbError::UnexpectedInline)?; // We can assume that inlinees will be listed in the inlinee table. If missing, // skip silently instead of erroring out. Missing a single inline function is diff --git a/symbolic-debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs index dcaab2e57..0d33ae460 100644 --- a/symbolic-debuginfo/src/pe.rs +++ b/symbolic-debuginfo/src/pe.rs @@ -5,8 +5,8 @@ use std::fmt; use std::io::Cursor; use std::marker::PhantomData; -use failure::Fail; use goblin::{error::Error as GoblinError, pe}; +use thiserror::Error; use symbolic_common::{Arch, AsSelf, CodeId, DebugId, Uuid}; @@ -18,11 +18,11 @@ pub use goblin::pe::section_table::SectionTable; /// An error when dealing with [`PeObject`](struct.PeObject.html). #[non_exhaustive] -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum PeError { /// The data in the PE file could not be parsed. - #[fail(display = "invalid PE file")] - BadObject(#[fail(cause)] GoblinError), + #[error("invalid PE file")] + BadObject(#[from] GoblinError), } /// Detects if the PE is a packer stub. diff --git a/symbolic-debuginfo/src/sourcebundle.rs b/symbolic-debuginfo/src/sourcebundle.rs index 7ebb00f0f..d561ffc17 100644 --- a/symbolic-debuginfo/src/sourcebundle.rs +++ b/symbolic-debuginfo/src/sourcebundle.rs @@ -42,14 +42,14 @@ use std::io::{BufReader, BufWriter, Read, Seek, Write}; use std::path::Path; use std::sync::Arc; -use failure::{Fail, ResultExt}; use lazycell::LazyCell; use parking_lot::Mutex; use regex::Regex; use serde::{Deserialize, Serialize}; -use zip::{write::FileOptions, ZipWriter}; +use thiserror::Error; +use zip::{result::ZipError, write::FileOptions, ZipWriter}; -use symbolic_common::{derive_failure, Arch, AsSelf, CodeId, DebugId}; +use symbolic_common::{Arch, AsSelf, CodeId, DebugId}; use crate::base::*; use crate::private::Parse; @@ -71,28 +71,35 @@ lazy_static::lazy_static! { static ref SANE_PATH_RE: Regex = Regex::new(r#":?[/\\]+"#).unwrap(); } -/// Variants of [`SourceBundleError`](struct.SourceBundleError.html). +/// An error returned when handling [`SourceBundle`](struct.SourceBundle.html). #[non_exhaustive] -#[derive(Clone, Copy, Debug, Eq, Fail, PartialEq)] -pub enum SourceBundleErrorKind { +#[derive(Debug, Error)] +pub enum SourceBundleError { /// The source bundle container is damanged. - #[fail(display = "malformed zip archive")] - BadZip, + #[error("malformed zip archive")] + BadZip(#[source] ZipError), + + /// An error when reading/writing the manifest. + #[error("failed to read/write source bundle manifest")] + BadManifest(#[source] serde_json::Error), /// The `Object` contains invalid data and cannot be converted. - #[fail(display = "malformed debug info file")] - BadDebugFile, + #[error("malformed debug info file")] + BadDebugFile(#[source] Box), /// Generic error when writing a source bundle, most likely IO. - #[fail(display = "failed to write source bundle")] - WriteFailed, + #[error("failed to write source bundle")] + WriteFailed(#[source] ZipError), } -derive_failure!( - SourceBundleError, - SourceBundleErrorKind, - doc = "An error returned when handling `SourceBundles`.", -); +impl SourceBundleError { + fn bad_debug_file(err: E) -> Self + where + E: std::error::Error + Send + Sync + 'static, + { + SourceBundleError::BadDebugFile(Box::new(err)) + } +} /// Trims matching suffices of a string in-place. fn trim_end_matches(string: &mut String, pat: F) @@ -310,12 +317,12 @@ impl<'d> SourceBundle<'d> { /// Tries to parse a `SourceBundle` from the given slice. pub fn parse(data: &'d [u8]) -> Result, SourceBundleError> { let mut archive = zip::read::ZipArchive::new(std::io::Cursor::new(data)) - .context(SourceBundleErrorKind::BadZip)?; + .map_err(SourceBundleError::BadZip)?; let manifest_file = archive .by_name("manifest.json") - .context(SourceBundleErrorKind::BadZip)?; + .map_err(SourceBundleError::BadZip)?; let manifest = - serde_json::from_reader(manifest_file).context(SourceBundleErrorKind::BadZip)?; + serde_json::from_reader(manifest_file).map_err(SourceBundleError::BadManifest)?; Ok(SourceBundle { manifest: Arc::new(manifest), archive: Arc::new(Mutex::new(archive)), @@ -608,13 +615,12 @@ impl<'d> SourceBundleDebugSession<'d> { let mut archive = self.archive.lock(); let mut file = archive .by_name(zip_path) - .context(SourceBundleErrorKind::BadZip)?; + .map_err(SourceBundleError::BadZip)?; let mut source_content = String::new(); - match file.read_to_string(&mut source_content) { - Ok(_) => Ok(Some(source_content)), - Err(e) => Err(e).context(SourceBundleErrorKind::BadZip)?, - } + file.read_to_string(&mut source_content) + .map_err(|e| SourceBundleError::BadZip(ZipError::Io(e)))?; + Ok(Some(source_content)) } /// Looks up a file's source contents by its full canonicalized path. @@ -707,9 +713,9 @@ fn sanitize_bundle_path(path: &str) -> String { /// Note that dropping the writer /// /// ```no_run -/// # use failure::Error; use std::fs::File; +/// # use std::fs::File; /// # use symbolic_debuginfo::sourcebundle::{SourceBundleWriter, SourceFileInfo}; -/// # fn main() -> Result<(), Error> { +/// # fn main() -> Result<(), Box> { /// let mut bundle = SourceBundleWriter::create("bundle.zip")?; /// /// // Add file called "foo.txt" @@ -744,7 +750,7 @@ where let header = SourceBundleHeader::default(); writer .write_all(header.as_bytes()) - .context(SourceBundleErrorKind::WriteFailed)?; + .map_err(|e| SourceBundleError::WriteFailed(ZipError::Io(e)))?; Ok(SourceBundleWriter { manifest: SourceBundleManifest::new(), @@ -810,9 +816,9 @@ where /// appended to the file name. Any subsequent duplicate increases that counter. For example: /// /// ```no_run - /// # use failure::Error; use std::fs::File; + /// # use std::fs::File; /// # use symbolic_debuginfo::sourcebundle::{SourceBundleWriter, SourceFileInfo}; - /// # fn main() -> Result<(), Error> { + /// # fn main() -> Result<(), Box> { /// let mut bundle = SourceBundleWriter::create("bundle.zip")?; /// /// // Add file at "foo.txt" @@ -842,8 +848,9 @@ where self.writer .start_file(unique_path.clone(), FileOptions::default()) - .context(SourceBundleErrorKind::WriteFailed)?; - std::io::copy(&mut file, &mut self.writer).context(SourceBundleErrorKind::WriteFailed)?; + .map_err(SourceBundleError::WriteFailed)?; + std::io::copy(&mut file, &mut self.writer) + .map_err(|e| SourceBundleError::WriteFailed(ZipError::Io(e)))?; self.manifest.files.insert(unique_path, info); Ok(()) @@ -858,7 +865,7 @@ where pub fn write_object(self, object: &O, object_name: &str) -> Result where O: ObjectLike, - O::Error: Fail, + O::Error: std::error::Error + Send + Sync + 'static, { self.write_object_with_filter(object, object_name, |_| true) } @@ -879,13 +886,13 @@ where ) -> Result where O: ObjectLike, - O::Error: Fail, + O::Error: std::error::Error + Send + Sync + 'static, F: FnMut(&FileEntry) -> bool, { let mut files_handled = BTreeSet::new(); let session = object .debug_session() - .context(SourceBundleErrorKind::BadDebugFile)?; + .map_err(SourceBundleError::bad_debug_file)?; self.set_attribute("arch", object.arch().to_string()); self.set_attribute("debug_id", object.debug_id().to_string()); @@ -895,7 +902,7 @@ where } for file_result in session.files() { - let file = file_result.context(SourceBundleErrorKind::BadDebugFile)?; + let file = file_result.map_err(SourceBundleError::bad_debug_file)?; let filename = file.abs_path_str(); if files_handled.contains(&filename) { @@ -915,8 +922,7 @@ where info.set_ty(SourceFileType::Source); info.set_path(filename.clone()); - self.add_file(bundle_path, source, info) - .context(SourceBundleErrorKind::WriteFailed)?; + self.add_file(bundle_path, source, info)?; } files_handled.insert(filename); @@ -933,7 +939,7 @@ where self.write_manifest()?; self.writer .finish() - .context(SourceBundleErrorKind::WriteFailed)?; + .map_err(SourceBundleError::WriteFailed)?; self.finished = true; Ok(()) } @@ -969,10 +975,10 @@ where fn write_manifest(&mut self) -> Result<(), SourceBundleError> { self.writer .start_file(MANIFEST_PATH, FileOptions::default()) - .context(SourceBundleErrorKind::WriteFailed)?; + .map_err(SourceBundleError::WriteFailed)?; serde_json::to_writer(&mut self.writer, &self.manifest) - .context(SourceBundleErrorKind::WriteFailed)?; + .map_err(SourceBundleError::BadManifest)?; Ok(()) } @@ -993,7 +999,7 @@ impl SourceBundleWriter> { .create(true) .truncate(true) .open(path) - .context(SourceBundleErrorKind::WriteFailed)?; + .map_err(|e| SourceBundleError::WriteFailed(ZipError::Io(e)))?; Self::start(BufWriter::new(file)) } @@ -1005,10 +1011,8 @@ mod tests { use std::io::Cursor; - use failure::Error; - #[test] - fn test_has_file() -> Result<(), Error> { + fn test_has_file() -> Result<(), SourceBundleError> { let writer = Cursor::new(Vec::new()); let mut bundle = SourceBundleWriter::start(writer)?; @@ -1020,7 +1024,7 @@ mod tests { } #[test] - fn test_duplicate_files() -> Result<(), Error> { + fn test_duplicate_files() -> Result<(), SourceBundleError> { let writer = Cursor::new(Vec::new()); let mut bundle = SourceBundleWriter::start(writer)?; diff --git a/symbolic-debuginfo/tests/test_objects.rs b/symbolic-debuginfo/tests/test_objects.rs index 8df844fc8..1039b5cbe 100644 --- a/symbolic-debuginfo/tests/test_objects.rs +++ b/symbolic-debuginfo/tests/test_objects.rs @@ -1,11 +1,11 @@ use std::fmt; -use failure::Error; - use symbolic_common::ByteView; use symbolic_debuginfo::{FileEntry, Function, Object, SymbolMap}; use symbolic_testutils::fixture; +type Error = Box; + /// Helper to create neat snapshots for symbol tables. struct SymbolsDebug<'a>(&'a SymbolMap<'a>); diff --git a/symbolic-minidump/Cargo.toml b/symbolic-minidump/Cargo.toml index 9be448559..968935558 100644 --- a/symbolic-minidump/Cargo.toml +++ b/symbolic-minidump/Cargo.toml @@ -30,12 +30,12 @@ include = [ all-features = true [dependencies] -failure = "0.1.5" lazy_static = "1.4.0" regex = "1.3.5" serde = { version = "1.0.94", optional = true } symbolic-common = { version = "7.5.0", path = "../symbolic-common" } symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo" } +thiserror = "1.0.20" [build-dependencies] cc = { version = "1.0.50", features = ["parallel"] } diff --git a/symbolic-minidump/src/cfi.rs b/symbolic-minidump/src/cfi.rs index 8b144dfe5..c067ea6c4 100644 --- a/symbolic-minidump/src/cfi.rs +++ b/symbolic-minidump/src/cfi.rs @@ -21,19 +21,19 @@ use std::collections::HashMap; use std::io::{self, Write}; use std::ops::Range; -use failure::{Fail, ResultExt}; - -use symbolic_common::{derive_failure, Arch, ByteView, UnknownArchError}; -use symbolic_debuginfo::breakpad::{BreakpadObject, BreakpadStackRecord}; +use symbolic_common::{Arch, ByteView, UnknownArchError}; +use symbolic_debuginfo::breakpad::{BreakpadError, BreakpadObject, BreakpadStackRecord}; use symbolic_debuginfo::dwarf::gimli::{ BaseAddresses, CfaRule, CieOrFde, DebugFrame, EhFrame, Error, FrameDescriptionEntry, Reader, Register, RegisterRule, UninitializedUnwindContext, UnwindSection, }; -use symbolic_debuginfo::dwarf::Dwarf; +use symbolic_debuginfo::dwarf::{Dwarf, DwarfError, GimliError}; +use symbolic_debuginfo::elf::{ElfError, GoblinError}; use symbolic_debuginfo::pdb::pdb::{self, FallibleIterator, FrameData, Rva, StringTable}; -use symbolic_debuginfo::pdb::PdbObject; +use symbolic_debuginfo::pdb::{PdbError, PdbObject}; use symbolic_debuginfo::pe::{PeObject, RuntimeFunction, UnwindOperation}; -use symbolic_debuginfo::{Object, ObjectLike}; +use symbolic_debuginfo::{Object, ObjectError, ObjectLike}; +use thiserror::Error; /// The latest version of the file format. pub const CFICACHE_LATEST_VERSION: u32 = 1; @@ -45,48 +45,60 @@ const EMPTY_FUNCTION: RuntimeFunction = RuntimeFunction { unwind_info_address: 0, }; -/// Possible error kinds of `CfiError`. +/// An error returned by [`AsciiCfiWriter`](struct.AsciiCfiWriter.html). #[non_exhaustive] -#[derive(Debug, Fail, Copy, Clone)] -pub enum CfiErrorKind { +#[derive(Debug, Error)] +pub enum CfiError { /// Required debug sections are missing in the `Object` file. - #[fail(display = "missing cfi debug sections")] + #[error("missing cfi debug sections")] MissingDebugInfo, /// The debug information in the `Object` file is not supported. - #[fail(display = "unsupported debug format")] + #[error("unsupported debug format")] UnsupportedDebugFormat, /// The debug information in the `Object` file is invalid. - #[fail(display = "bad debug information")] - BadDebugInfo, + #[error("bad debug information")] + BadDebugInfo(#[from] Box), /// The `Object`s architecture is not supported by symbolic. - #[fail(display = "unsupported architecture")] - UnsupportedArch, + #[error("unsupported architecture")] + UnsupportedArch(#[from] UnknownArchError), /// CFI for an invalid address outside the mapped range was encountered. - #[fail(display = "invalid cfi address")] + #[error("invalid cfi address")] InvalidAddress, /// Generic error when writing CFI information, likely IO. - #[fail(display = "failed to write cfi")] - WriteError, + #[error("failed to write cfi")] + WriteError(#[from] io::Error), /// Invalid magic bytes in the cfi cache header. - #[fail(display = "bad cfi cache magic")] + #[error("bad cfi cache magic")] BadFileMagic, } -derive_failure!( - CfiError, - CfiErrorKind, - doc = "An error returned by [`AsciiCfiWriter`](struct.AsciiCfiWriter.html)." -); +impl From for CfiError { + fn from(e: BreakpadError) -> Self { + Box::new(ObjectError::from(e)).into() + } +} + +impl From for CfiError { + fn from(e: pdb::Error) -> Self { + Box::new(ObjectError::from(PdbError::from(e))).into() + } +} + +impl From for CfiError { + fn from(e: GoblinError) -> Self { + Box::new(ObjectError::from(ElfError::from(e))).into() + } +} -impl From for CfiError { - fn from(_: UnknownArchError) -> CfiError { - CfiErrorKind::UnsupportedArch.into() +impl From for CfiError { + fn from(e: GimliError) -> Self { + Box::new(ObjectError::from(DwarfError::from(e))).into() } } @@ -160,7 +172,7 @@ impl UnwindInfo { /// use symbolic_debuginfo::Object; /// use symbolic_minidump::cfi::AsciiCfiWriter; /// -/// # fn main() -> Result<(), failure::Error> { +/// # fn main() -> Result<(), Box> { /// let view = ByteView::open("/path/to/object")?; /// let object = Object::parse(&view)?; /// @@ -178,7 +190,7 @@ impl UnwindInfo { /// use symbolic_debuginfo::Object; /// use symbolic_minidump::cfi::AsciiCfiWriter; /// -/// # fn main() -> Result<(), failure::Error> { +/// # fn main() -> Result<(), Box> { /// let view = ByteView::open("/path/to/object")?; /// let object = Object::parse(&view)?; /// @@ -215,11 +227,10 @@ impl AsciiCfiWriter { fn process_breakpad(&mut self, object: &BreakpadObject<'_>) -> Result<(), CfiError> { for record in object.stack_records() { - match record.context(CfiErrorKind::BadDebugInfo)? { + match record? { BreakpadStackRecord::Cfi(r) => writeln!(self.inner, "STACK CFI {}", r.text), BreakpadStackRecord::Win(r) => writeln!(self.inner, "STACK WIN {}", r.text), - } - .context(CfiErrorKind::WriteError)? + }? } Ok(()) @@ -261,7 +272,7 @@ impl AsciiCfiWriter { let mut ctx = UninitializedUnwindContext::new(); let mut entries = info.section.entries(&info.bases); - while let Some(entry) = entries.next().context(CfiErrorKind::BadDebugInfo)? { + while let Some(entry) = entries.next()? { // We skip all Common Information Entries and only process Frame Description Items here. // The iterator yields partial FDEs which need their associated CIE passed in via a // callback. This function is provided by the UnwindSection (frame), which then parses @@ -293,9 +304,7 @@ impl AsciiCfiWriter { // Interpret all DWARF instructions of this Frame Description Entry. This gives us an unwind // table that contains rules for retrieving registers at every instruction address. These // rules can directly be transcribed to breakpad STACK CFI records. - let mut table = fde - .rows(&info.section, &info.bases, ctx) - .context(CfiErrorKind::BadDebugInfo)?; + let mut table = fde.rows(&info.section, &info.bases, ctx)?; // Collect all rows first, as we need to know the final end address in order to write the // CFI INIT record describing the extent of the whole unwind table. @@ -307,7 +316,7 @@ impl AsciiCfiWriter { Err(Error::UnknownCallFrameInstruction(_)) => continue, // NOTE: Temporary workaround for https://github.com/gimli-rs/gimli/pull/487 Err(Error::TooManyRegisterRules) => continue, - Err(e) => return Err(e.context(CfiErrorKind::BadDebugInfo).into()), + Err(e) => return Err(e.into()), } } @@ -338,11 +347,10 @@ impl AsciiCfiWriter { // normal STACK CFI record. if row.start_address() == start { let start_addr = start - info.load_address; - write!(line, "STACK CFI INIT {:x} {:x}", start_addr, length) - .context(CfiErrorKind::WriteError)?; + write!(line, "STACK CFI INIT {:x} {:x}", start_addr, length)?; } else { let start_addr = row.start_address() - info.load_address; - write!(line, "STACK CFI {:x}", start_addr).context(CfiErrorKind::WriteError)?; + write!(line, "STACK CFI {:x}", start_addr)?; } // Write the mandatory CFA rule for this row, followed by optional register rules. @@ -366,8 +374,7 @@ impl AsciiCfiWriter { if written { self.inner .write_all(&line) - .and_then(|_| writeln!(self.inner)) - .context(CfiErrorKind::WriteError)?; + .and_then(|_| writeln!(self.inner))?; } } } @@ -390,7 +397,7 @@ impl AsciiCfiWriter { CfaRule::Expression(_) => return Ok(false), }; - write!(target, " .cfa: {}", formatted).context(CfiErrorKind::WriteError)?; + write!(target, " .cfa: {}", formatted)?; Ok(true) } @@ -431,26 +438,26 @@ impl AsciiCfiWriter { } }; - write!(target, " {}: {}", register_name, formatted).context(CfiErrorKind::WriteError)?; + write!(target, " {}: {}", register_name, formatted)?; Ok(true) } fn process_pdb(&mut self, pdb: &PdbObject<'_>) -> Result<(), CfiError> { let mut pdb = pdb.inner().write(); - let frame_table = pdb.frame_table().context(CfiErrorKind::BadDebugInfo)?; - let address_map = pdb.address_map().context(CfiErrorKind::BadDebugInfo)?; + let frame_table = pdb.frame_table()?; + let address_map = pdb.address_map()?; // See `PdbDebugSession::build`. let string_table = match pdb.string_table() { Ok(string_table) => Some(string_table), Err(pdb::Error::StreamNameNotFound) => None, - Err(e) => Err(e).context(CfiErrorKind::BadDebugInfo)?, + Err(e) => return Err(e.into()), }; let mut frames = frame_table.iter(); let mut last_frame: Option = None; - while let Some(frame) = frames.next().context(CfiErrorKind::BadDebugInfo)? { + while let Some(frame) = frames.next()? { // Frame data information sometimes contains code_size values close to the maximum `u32` // value, such as `0xffffff6e`. Documentation does not describe the meaning of such // values, but clearly they are not actual code sizes. Since these values also always @@ -557,26 +564,21 @@ impl AsciiCfiWriter { frame.locals_size, frame.max_stack_size.unwrap_or(0), if program_or_bp { 1 } else { 0 }, - ) - .context(CfiErrorKind::WriteError)?; + )?; match frame.program { Some(ref prog_ref) => { let string_table = match string_table { Some(string_table) => string_table, - None => return Ok(writeln!(self.inner).context(CfiErrorKind::WriteError)?), + None => return Ok(writeln!(self.inner)?), }; - let program_string = prog_ref - .to_string_lossy(&string_table) - .context(CfiErrorKind::BadDebugInfo)?; + let program_string = prog_ref.to_string_lossy(&string_table)?; - writeln!(self.inner, "{}", program_string.trim()) - .context(CfiErrorKind::WriteError)?; + writeln!(self.inner, "{}", program_string.trim())?; } None => { - writeln!(self.inner, "{}", if program_or_bp { 1 } else { 0 }) - .context(CfiErrorKind::WriteError)?; + writeln!(self.inner, "{}", if program_or_bp { 1 } else { 0 })?; } } @@ -591,7 +593,7 @@ impl AsciiCfiWriter { }; for function_result in exception_data { - let function = function_result.context(CfiErrorKind::BadDebugInfo)?; + let function = function_result?; // Exception directories can contain zeroed out sections which need to be skipped. // Neither their start/end RVA nor the unwind info RVA is valid. @@ -610,9 +612,7 @@ impl AsciiCfiWriter { let mut next_function = Some(function); while let Some(next) = next_function { - let unwind_info = exception_data - .get_unwind_info(next, sections) - .context(CfiErrorKind::BadDebugInfo)?; + let unwind_info = exception_data.get_unwind_info(next, sections)?; for code_result in &unwind_info { // Due to variable length encoding of operator codes, there is little point in @@ -648,8 +648,7 @@ impl AsciiCfiWriter { "STACK CFI INIT {:x} {:x} .cfa: $rsp 8 + .ra: .cfa 8 - ^", function.begin_address, function.end_address - function.begin_address, - ) - .context(CfiErrorKind::WriteError)?; + )?; if machine_frame_offset > 0 { writeln!( @@ -659,15 +658,13 @@ impl AsciiCfiWriter { stack_size, stack_size - machine_frame_offset + 24, // old RSP offset stack_size - machine_frame_offset + 48, // entire frame offset - ) - .context(CfiErrorKind::WriteError)? + )? } else { writeln!( self.inner, "STACK CFI {:x} .cfa: $rsp {} +", function.begin_address, stack_size, - ) - .context(CfiErrorKind::WriteError)? + )? } } @@ -709,7 +706,7 @@ enum CfiCacheInner<'a> { /// use symbolic_debuginfo::Object; /// use symbolic_minidump::cfi::CfiCache; /// -/// # fn main() -> Result<(), failure::Error> { +/// # fn main() -> Result<(), Box> { /// let view = ByteView::open("/path/to/object")?; /// let object = Object::parse(&view)?; /// let cache = CfiCache::from_object(&object)?; @@ -722,7 +719,7 @@ enum CfiCacheInner<'a> { /// use symbolic_common::ByteView; /// use symbolic_minidump::cfi::CfiCache; /// -/// # fn main() -> Result<(), failure::Error> { +/// # fn main() -> Result<(), Box> { /// let view = ByteView::open("my.cficache")?; /// let cache = CfiCache::from_bytes(view)?; /// # Ok(()) @@ -751,7 +748,7 @@ impl<'a> CfiCache<'a> { return Ok(CfiCache { inner }); } - Err(CfiErrorKind::BadFileMagic.into()) + Err(CfiError::BadFileMagic) } /// Returns the cache file format version. diff --git a/symbolic-minidump/src/processor.rs b/symbolic-minidump/src/processor.rs index f6b4ec1ed..fcaf4b2bc 100644 --- a/symbolic-minidump/src/processor.rs +++ b/symbolic-minidump/src/processor.rs @@ -18,7 +18,6 @@ use std::os::raw::{c_char, c_void}; use std::str::FromStr; use std::{fmt, ptr, slice, str}; -use failure::Fail; use lazy_static::lazy_static; use regex::Regex; @@ -365,8 +364,10 @@ impl fmt::Display for FrameTrust { } } -/// Error when converting a string to FrameTrust. -#[derive(Clone, Copy, Debug)] +/// Error when converting a string to [`FrameTrust`]. +/// +/// [`FrameTrust`]: enum.FrameTrust.html +#[derive(Debug)] pub struct ParseFrameTrustError; impl fmt::Display for ParseFrameTrustError { @@ -392,6 +393,8 @@ impl FromStr for FrameTrust { } } +impl std::error::Error for ParseFrameTrustError {} + impl Default for FrameTrust { fn default() -> FrameTrust { FrameTrust::None @@ -758,18 +761,25 @@ impl fmt::Display for ProcessResult { } /// An error generated when trying to process a minidump. -#[derive(Debug, Fail, Copy, Clone)] +#[derive(Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[fail(display = "minidump processing failed: {}", _0)] pub struct ProcessMinidumpError(ProcessResult); impl ProcessMinidumpError { /// Returns the kind of this error. - pub fn kind(self) -> ProcessResult { + pub fn kind(&self) -> ProcessResult { self.0 } } +impl fmt::Display for ProcessMinidumpError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "minidump processing failed: {}", self.0) + } +} + +impl std::error::Error for ProcessMinidumpError {} + /// Internal type used to transfer Breakpad symbols over FFI. #[repr(C)] struct SymbolEntry { diff --git a/symbolic-minidump/tests/test_cfi.rs b/symbolic-minidump/tests/test_cfi.rs index ebc367399..92d3fc825 100644 --- a/symbolic-minidump/tests/test_cfi.rs +++ b/symbolic-minidump/tests/test_cfi.rs @@ -1,12 +1,12 @@ use std::str; -use failure::Error; - use symbolic_common::ByteView; use symbolic_debuginfo::Object; use symbolic_minidump::cfi::{AsciiCfiWriter, CfiCache}; use symbolic_testutils::fixture; +type Error = Box; + #[test] fn load_empty_cfi_cache() -> Result<(), Error> { let buffer = ByteView::from_slice(&[]); diff --git a/symbolic-minidump/tests/test_processor.rs b/symbolic-minidump/tests/test_processor.rs index 1a6a9b986..8d5e72d24 100644 --- a/symbolic-minidump/tests/test_processor.rs +++ b/symbolic-minidump/tests/test_processor.rs @@ -1,9 +1,9 @@ -use failure::Error; - use symbolic_common::ByteView; use symbolic_minidump::processor::ProcessState; use symbolic_testutils::fixture; +type Error = Box; + #[test] fn process_minidump_linux() -> Result<(), Error> { let buffer = ByteView::open(fixture("linux/mini.dmp"))?; diff --git a/symbolic-sourcemap/Cargo.toml b/symbolic-sourcemap/Cargo.toml index 426c1bf66..d805bb15f 100644 --- a/symbolic-sourcemap/Cargo.toml +++ b/symbolic-sourcemap/Cargo.toml @@ -19,5 +19,4 @@ edition = "2018" all-features = true [dependencies] -failure = "0.1.5" sourcemap = "5.0.0" diff --git a/symbolic-sourcemap/src/lib.rs b/symbolic-sourcemap/src/lib.rs index 13930aac1..e535aebe2 100644 --- a/symbolic-sourcemap/src/lib.rs +++ b/symbolic-sourcemap/src/lib.rs @@ -6,8 +6,6 @@ use std::borrow::Cow; use std::fmt; use std::ops::Deref; -use failure::Fail; - /// An error returned when parsing source maps. #[derive(Debug)] pub struct ParseSourceMapError(sourcemap::Error); @@ -23,8 +21,8 @@ impl fmt::Display for ParseSourceMapError { } } -impl Fail for ParseSourceMapError { - fn cause(&self) -> Option<&dyn Fail> { +impl std::error::Error for ParseSourceMapError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(match self.0 { sourcemap::Error::Io(ref err) => err, sourcemap::Error::Utf8(ref err) => err, diff --git a/symbolic-symcache/Cargo.toml b/symbolic-symcache/Cargo.toml index 9578fac3b..9b871da67 100644 --- a/symbolic-symcache/Cargo.toml +++ b/symbolic-symcache/Cargo.toml @@ -24,11 +24,11 @@ all-features = true [dependencies] dmsort = "1.0.0" -failure = "0.1.5" fnv = "1.0.6" num = "0.2.1" symbolic-common = { version = "7.5.0", path = "../symbolic-common" } symbolic-debuginfo = { version = "7.5.0", path = "../symbolic-debuginfo" } +thiserror = "1.0.20" [dev-dependencies] insta = "0.15.0" diff --git a/symbolic-symcache/src/cache.rs b/symbolic-symcache/src/cache.rs index 1846437f0..ad64e655e 100644 --- a/symbolic-symcache/src/cache.rs +++ b/symbolic-symcache/src/cache.rs @@ -2,7 +2,7 @@ use std::fmt; use symbolic_common::{Arch, AsSelf, DebugId, Language, Name}; -use crate::error::{SymCacheError, SymCacheErrorKind}; +use crate::error::SymCacheError; use crate::format; /// A platform independent symbolication cache. @@ -267,7 +267,7 @@ impl<'a> SymCache<'a> { if let Some((line_addr, file_id, line)) = self.run_to_line(fun, addr)? { // A missing file record indicates a bad symcache. let file_record = read_file_record(self.data, self.header.files, file_id)? - .ok_or_else(|| SymCacheErrorKind::BadCacheFile)?; + .ok_or_else(|| SymCacheError::BadCacheFile)?; // The address was found in the function's line records, so use // it directly. This should is the default case for all valid diff --git a/symbolic-symcache/src/error.rs b/symbolic-symcache/src/error.rs index c5f4dc423..bed529211 100644 --- a/symbolic-symcache/src/error.rs +++ b/symbolic-symcache/src/error.rs @@ -1,9 +1,6 @@ use std::fmt; -use failure::Fail; - -use symbolic_common::derive_failure; -use symbolic_debuginfo::ObjectError; +use thiserror::Error; #[doc(hidden)] #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -29,67 +26,55 @@ impl fmt::Display for ValueKind { } } -/// Variants of `SymCacheError`. +/// An error returned when handling [`SymCache`](struct.SymCache.html). #[non_exhaustive] -#[derive(Clone, Copy, Debug, Eq, Fail, PartialEq)] -pub enum SymCacheErrorKind { +#[derive(Debug, Error)] +pub enum SymCacheError { /// Invalid magic bytes in the symcache header. - #[fail(display = "bad symcache magic")] + #[error("bad symcache magic")] BadFileMagic, /// Invalid flags or fields in the symcache header. - #[fail(display = "invalid symcache header")] - BadFileHeader, + #[error("invalid symcache header")] + BadFileHeader(#[source] std::io::Error), /// A segment could not be read, likely due to IO errors. - #[fail(display = "cannot read symcache segment")] + #[error("cannot read symcache segment")] BadSegment, /// Contents in the symcache file are malformed. - #[fail(display = "malformed symcache file")] + #[error("malformed symcache file")] BadCacheFile, /// The symcache version is not known. - #[fail(display = "unsupported symcache version")] + #[error("unsupported symcache version")] UnsupportedVersion, /// The `Object` contains invalid data and cannot be converted. - #[fail(display = "malformed debug info file")] - BadDebugFile, + #[error("malformed debug info file")] + BadDebugFile(#[source] Box), /// A required debug section is missing in the `Object` file. - #[fail(display = "missing debug section")] + #[error("missing debug section")] MissingDebugSection, /// The `Object` file was stripped of debug information. - #[fail(display = "no debug information found in file")] + #[error("no debug information found in file")] MissingDebugInfo, /// The debug information in the `Object` file is not supported. - #[fail(display = "unsupported debug information")] + #[error("unsupported debug information")] UnsupportedDebugKind, /// A value cannot be written to symcache as it overflows the record size. - #[fail(display = "{} too large for symcache file format", _0)] + #[error("{0} too large for symcache file format")] ValueTooLarge(ValueKind), /// A value cannot be written to symcache as it overflows the segment counter. - #[fail(display = "too many {}s for symcache", _0)] + #[error("too many {0}s for symcache")] TooManyValues(ValueKind), /// Generic error when writing a symcache, most likely IO. - #[fail(display = "failed to write symcache")] - WriteFailed, -} - -derive_failure!( - SymCacheError, - SymCacheErrorKind, - doc = "An error returned when handling `SymCaches`.", -); - -impl From for SymCacheError { - fn from(error: ObjectError) -> SymCacheError { - error.context(SymCacheErrorKind::BadDebugFile).into() - } + #[error("failed to write symcache")] + WriteFailed(#[source] std::io::Error), } diff --git a/symbolic-symcache/src/format.rs b/symbolic-symcache/src/format.rs index 82d9d45e4..97d04063e 100644 --- a/symbolic-symcache/src/format.rs +++ b/symbolic-symcache/src/format.rs @@ -5,11 +5,9 @@ use std::fmt; use std::io; use std::marker::PhantomData; -use failure::ResultExt; - use symbolic_common::{DebugId, Uuid}; -use crate::error::{SymCacheError, SymCacheErrorKind}; +use crate::error::SymCacheError; /// The magic file preamble to identify symcache files. pub const SYMCACHE_MAGIC: [u8; 4] = *b"SYMC"; @@ -82,7 +80,7 @@ where let offset = self.offset as usize; let len = self.len.into() as usize; let size = std::mem::size_of::() * len; - let slice = get_slice(data, offset, size).context(SymCacheErrorKind::BadSegment)?; + let slice = get_slice(data, offset, size).map_err(|_| SymCacheError::BadSegment)?; Ok(unsafe { std::slice::from_raw_parts(slice.as_ptr() as *const T, len) }) } @@ -102,7 +100,7 @@ where /// Reads an entire binary segment as string. pub fn read_str<'a>(&self, data: &'a [u8]) -> Result<&'a str, SymCacheError> { let slice = self.read(data)?; - Ok(std::str::from_utf8(slice).context(SymCacheErrorKind::BadSegment)?) + Ok(std::str::from_utf8(slice).map_err(|_| SymCacheError::BadSegment)?) } } @@ -321,20 +319,20 @@ pub struct Header { impl Header { /// Parses the correct version of the SymCache [`Header`](struct.Header.html). pub fn parse(data: &[u8]) -> Result { - let preamble = get_record::(data, 0).context(SymCacheErrorKind::BadFileHeader)?; + let preamble = get_record::(data, 0).map_err(SymCacheError::BadFileHeader)?; if preamble.magic != SYMCACHE_MAGIC { - return Err(SymCacheErrorKind::BadFileMagic.into()); + return Err(SymCacheError::BadFileMagic); } Ok(match preamble.version { 1 => get_record::(data, 0) - .context(SymCacheErrorKind::BadFileHeader)? + .map_err(SymCacheError::BadFileHeader)? .into(), 2..=SYMCACHE_VERSION => get_record::(data, 0) - .context(SymCacheErrorKind::BadFileHeader)? + .map_err(SymCacheError::BadFileHeader)? .into(), - _ => return Err(SymCacheErrorKind::UnsupportedVersion.into()), + _ => return Err(SymCacheError::UnsupportedVersion), }) } } diff --git a/symbolic-symcache/src/writer.rs b/symbolic-symcache/src/writer.rs index a0fbde05d..b3abd5193 100644 --- a/symbolic-symcache/src/writer.rs +++ b/symbolic-symcache/src/writer.rs @@ -2,14 +2,13 @@ use std::borrow::Cow; use std::collections::HashMap; use std::io::{self, Seek, Write}; -use failure::{Fail, ResultExt}; use fnv::{FnvHashMap, FnvHashSet}; use num::FromPrimitive; use symbolic_common::{Arch, DebugId, Language}; use symbolic_debuginfo::{DebugSession, FileInfo, Function, LineInfo, ObjectLike, Symbol}; -use crate::error::{SymCacheError, SymCacheErrorKind, ValueKind}; +use crate::error::{SymCacheError, ValueKind}; use crate::format; // Performs a shallow check whether this function might contain any lines. @@ -69,7 +68,7 @@ where self.position = position; self.writer .seek(io::SeekFrom::Start(position)) - .context(SymCacheErrorKind::WriteFailed)?; + .map_err(SymCacheError::WriteFailed)?; Ok(()) } @@ -79,7 +78,7 @@ where fn write_bytes(&mut self, data: &[u8]) -> Result<(), SymCacheError> { self.writer .write_all(data) - .context(SymCacheErrorKind::WriteFailed)?; + .map_err(SymCacheError::WriteFailed)?; self.position += data.len() as u64; Ok(()) @@ -112,7 +111,7 @@ where let segment_pos = self.position as u32; let segment_len = - L::from_usize(data.len()).ok_or_else(|| SymCacheErrorKind::TooManyValues(kind))?; + L::from_usize(data.len()).ok_or_else(|| SymCacheError::TooManyValues(kind))?; self.write_bytes(bytes)?; Ok(format::Seg::new(segment_pos, segment_len)) @@ -198,19 +197,19 @@ where pub fn write_object(object: &O, target: W) -> Result where O: ObjectLike, - O::Error: Fail, + O::Error: std::error::Error + Send + Sync + 'static, { - let mut writer = SymCacheWriter::new(target).context(SymCacheErrorKind::WriteFailed)?; + let mut writer = SymCacheWriter::new(target)?; writer.set_arch(object.arch()); writer.set_debug_id(object.debug_id()); let session = object .debug_session() - .context(SymCacheErrorKind::BadDebugFile)?; + .map_err(|e| SymCacheError::BadDebugFile(Box::new(e)))?; for function in session.functions() { - let function = function.context(SymCacheErrorKind::BadDebugFile)?; + let function = function.map_err(|e| SymCacheError::BadDebugFile(Box::new(e)))?; writer.add_function(function)?; } @@ -374,7 +373,7 @@ where } if self.files.len() >= std::u16::MAX as usize { - return Err(SymCacheErrorKind::TooManyValues(ValueKind::File).into()); + return Err(SymCacheError::TooManyValues(ValueKind::File)); } let index = self.files.len() as u16; @@ -398,7 +397,7 @@ where // NB: We only use 48 bits to encode symbol offsets in function records. if self.symbols.len() >= 0x00ff_ffff { - return Err(SymCacheErrorKind::TooManyValues(ValueKind::Symbol).into()); + return Err(SymCacheError::TooManyValues(ValueKind::Symbol)); } // Avoid a potential reallocation by reusing name. @@ -477,7 +476,7 @@ where let symbol_id = self.insert_symbol(function.name.as_str().into())?; let comp_dir = self.write_path(function.compilation_dir)?; let lang = u8::from_u32(language as u32) - .ok_or_else(|| SymCacheErrorKind::ValueTooLarge(ValueKind::Language))?; + .ok_or_else(|| SymCacheError::ValueTooLarge(ValueKind::Language))?; let mut start_address = function.address; let mut lines = function.lines.iter().peekable(); @@ -534,7 +533,7 @@ where // functions to the file. let index = functions.len(); if index >= std::u32::MAX as usize { - return Err(SymCacheErrorKind::ValueTooLarge(ValueKind::Function).into()); + return Err(SymCacheError::ValueTooLarge(ValueKind::Function)); } // For optimization purposes, remember if all functions appear in order. If not, parent @@ -602,7 +601,7 @@ where let parent_offset = index - parent_index; if parent_offset > std::u16::MAX.into() { - return Err(SymCacheErrorKind::ValueTooLarge(ValueKind::ParentOffset).into()); + return Err(SymCacheError::ValueTooLarge(ValueKind::ParentOffset)); } record.parent_offset = parent_offset as u16; diff --git a/symbolic-symcache/tests/test_cache.rs b/symbolic-symcache/tests/test_cache.rs index 166b5ebc0..6a3ef2f1c 100644 --- a/symbolic-symcache/tests/test_cache.rs +++ b/symbolic-symcache/tests/test_cache.rs @@ -1,11 +1,11 @@ use std::fmt; -use failure::Error; - use symbolic_common::ByteView; use symbolic_symcache::SymCache; use symbolic_testutils::fixture; +type Error = Box; + /// Helper to create neat snapshots for symbol tables. struct FunctionsDebug<'a>(&'a SymCache<'a>); diff --git a/symbolic-symcache/tests/test_compat.rs b/symbolic-symcache/tests/test_compat.rs index 0394dba73..423c0c145 100644 --- a/symbolic-symcache/tests/test_compat.rs +++ b/symbolic-symcache/tests/test_compat.rs @@ -1,11 +1,9 @@ -use failure::Error; - use symbolic_common::ByteView; use symbolic_symcache::SymCache; use symbolic_testutils::fixture; #[test] -fn test_v1() -> Result<(), Error> { +fn test_v1() -> Result<(), Box> { let buffer = ByteView::open(fixture("symcache/compat/v1.symc"))?; let symcache = SymCache::parse(&buffer)?; diff --git a/symbolic-symcache/tests/test_writer.rs b/symbolic-symcache/tests/test_writer.rs index 9d860397e..2e2df474d 100644 --- a/symbolic-symcache/tests/test_writer.rs +++ b/symbolic-symcache/tests/test_writer.rs @@ -1,13 +1,13 @@ use std::fmt; use std::io::Cursor; -use failure::Error; - use symbolic_common::ByteView; use symbolic_debuginfo::Object; use symbolic_symcache::{SymCache, SymCacheWriter}; use symbolic_testutils::fixture; +type Error = Box; + /// Helper to create neat snapshots for symbol tables. struct FunctionsDebug<'a>(&'a SymCache<'a>); diff --git a/symbolic-unreal/Cargo.toml b/symbolic-unreal/Cargo.toml index cad0f6b5b..7b9caa23e 100644 --- a/symbolic-unreal/Cargo.toml +++ b/symbolic-unreal/Cargo.toml @@ -30,12 +30,12 @@ anylog = "0.5.0" bytes = "0.4.12" chrono = "0.4.7" elementtree = "0.5.0" -failure = "0.1.5" lazy_static = "1.4.0" flate2 = { version = "1.0.13", features = ["rust_backend"], default-features = false } regex = "1.3.5" scroll = { version = "0.10.1", features = ["derive"] } serde_ = { package = "serde", version = "1.0.94", optional = true, features = ["derive"] } +thiserror = "1.0.20" [dev-dependencies] insta = "0.15.0" diff --git a/symbolic-unreal/src/context.rs b/symbolic-unreal/src/context.rs index f8817cdd9..8dedc292d 100644 --- a/symbolic-unreal/src/context.rs +++ b/symbolic-unreal/src/context.rs @@ -352,7 +352,7 @@ fn load_data_bag(element: &Element) -> BTreeMap { impl Unreal4Context { /// Parses the unreal context XML file. pub fn parse(data: &[u8]) -> Result { - let root = Element::from_reader(data).map_err(Unreal4Error::InvalidXml)?; + let root = Element::from_reader(data)?; Ok(Unreal4Context { runtime_properties: Unreal4ContextRuntimeProperties::from_xml(&root), diff --git a/symbolic-unreal/src/error.rs b/symbolic-unreal/src/error.rs index 67a480c0f..d0783cf2f 100644 --- a/symbolic-unreal/src/error.rs +++ b/symbolic-unreal/src/error.rs @@ -1,36 +1,30 @@ -use failure::Fail; +use thiserror::Error; /// Errors related to parsing an UE4 crash file. #[non_exhaustive] -#[derive(Fail, Debug)] +#[derive(Error, Debug)] pub enum Unreal4Error { /// Empty data blob received. - #[fail(display = "empty crash")] + #[error("empty crash")] Empty, /// Invalid compressed data. - #[fail(display = "bad compression")] - BadCompression(std::io::Error), + #[error("bad compression")] + BadCompression(#[source] std::io::Error), /// Invalid contents of the crash file container. - #[fail(display = "invalid crash file contents")] - BadData(scroll::Error), + #[error("invalid crash file contents")] + BadData(#[from] scroll::Error), /// The crash file contains unexpected trailing data after the footer. - #[fail(display = "unexpected trailing data")] + #[error("unexpected trailing data")] TrailingData, /// Can't process a log entry. - #[fail(display = "invalid log entry")] - InvalidLogEntry(std::str::Utf8Error), + #[error("invalid log entry")] + InvalidLogEntry(#[source] std::str::Utf8Error), /// Invalid XML. - #[fail(display = "invalid xml")] - InvalidXml(elementtree::Error), -} - -impl From for Unreal4Error { - fn from(error: scroll::Error) -> Self { - Unreal4Error::BadData(error) - } + #[error("invalid xml")] + InvalidXml(#[from] elementtree::Error), } From 060794ff9b0bb8e21f72b9cc577282b525677df3 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Thu, 24 Sep 2020 14:22:59 +0200 Subject: [PATCH 11/22] ref: Remove all deprecated items (#271) --- CHANGELOG.md | 8 +++++++ py/symbolic/minidump.py | 16 ------------- symbolic-common/src/heuristics.rs | 24 ++++--------------- symbolic-common/src/types.rs | 24 ------------------- symbolic-debuginfo/src/dwarf.rs | 17 ------------- symbolic-unreal/src/context.rs | 14 +---------- ...sh_parse__contexts_runtime_properties.snap | 1 - 7 files changed, 14 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 203b59136..96cf5a26d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ - Usage of `failure` was removed, and all Error types were changed to only implement `std::error::Error` and related traits. - `symbolic-proguard` was removed in favor of the `proguard` crate. Proguard is still supported via `symbolic-cabi` and the python API however. +- Deprecated APIs have been removed: + - `InstructionInfo`'s fields are no longer public. + - `pointer_size`, `instruction_alignment` and `ip_register_name` have moved from `Arch` to `CpuFamily`. + - `Arch::register_name` as been moved to `CpuFamily::cfi_register_name`. + - `Dwarf::raw_data` and `Dwarf::section_data` have been replaced with the `raw_section` and `section` APIs. + - `Unreal4ContextRuntimeProperties::misc_primary_cpu_brand` is has been removed. +- Deprecated Python APIs have been removed: + - `CodeModule.id` and `CodeModule.name` Use `debug_id` and `code_file`, respectively. ## 7.5.0 diff --git a/py/symbolic/minidump.py b/py/symbolic/minidump.py index 83431eb27..f133d9c84 100644 --- a/py/symbolic/minidump.py +++ b/py/symbolic/minidump.py @@ -2,7 +2,6 @@ import shutil from datetime import datetime -import warnings from symbolic._compat import range_type from symbolic._lowlevel import lib, ffi @@ -81,21 +80,6 @@ def size(self): """Size of the loaded module in virtual memory""" return self._objptr.size - @property - def id(self): - warnings.warn( - "module.id is deprecated, use module.debug_id instead", DeprecationWarning - ) - return self.debug_id - - @property - def name(self): - warnings.warn( - "module.name is deprecated, use module.code_file instead", - DeprecationWarning, - ) - return self.code_file - class StackFrame(RustObject): """A single frame in the call stack of a crashed process""" diff --git a/symbolic-common/src/heuristics.rs b/symbolic-common/src/heuristics.rs index 04c4f5f4a..44cca5c9f 100644 --- a/symbolic-common/src/heuristics.rs +++ b/symbolic-common/src/heuristics.rs @@ -1,9 +1,5 @@ //! Heuristics for correcting instruction pointers based on the CPU architecture. -// The fields on `InstructionInfo` are deprecated and will be removed from the public interface in -// the next major release. They may still be used in this module. -#![allow(deprecated)] - use crate::types::{Arch, CpuFamily}; const SIGILL: u32 = 4; @@ -107,21 +103,11 @@ const SIGSEGV: u32 = 11; /// [`caller_address`]: struct.InstructionInfo.html#method.caller_address #[derive(Clone, Debug)] pub struct InstructionInfo { - #[doc(hidden)] - #[deprecated = "Use InstructionInfo::new() instead"] - pub addr: u64, - #[doc(hidden)] - #[deprecated = "Use InstructionInfo::new() instead"] - pub arch: Arch, - #[doc(hidden)] - #[deprecated = "Use is_crashing_frame() instead"] - pub crashing_frame: bool, - #[doc(hidden)] - #[deprecated = "Use signal() instead"] - pub signal: Option, - #[doc(hidden)] - #[deprecated = "Use ip_register_value() instead"] - pub ip_reg: Option, + addr: u64, + arch: Arch, + crashing_frame: bool, + signal: Option, + ip_reg: Option, } impl InstructionInfo { diff --git a/symbolic-common/src/types.rs b/symbolic-common/src/types.rs index 3704ea640..2bb2d2a70 100644 --- a/symbolic-common/src/types.rs +++ b/symbolic-common/src/types.rs @@ -414,24 +414,6 @@ impl Arch { } } - #[doc(hidden)] - #[deprecated = "use CpuFamily::pointer_size instead"] - pub fn pointer_size(self) -> Option { - self.cpu_family().pointer_size() - } - - #[doc(hidden)] - #[deprecated = "use CpuFamily::instruction_alignment instead"] - pub fn instruction_alignment(self) -> Option { - self.cpu_family().instruction_alignment() - } - - #[doc(hidden)] - #[deprecated = "use CpuFamily::ip_register_name instead"] - pub fn ip_register_name(self) -> Option<&'static str> { - self.cpu_family().ip_register_name() - } - /// Returns whether this architecture is well-known. /// /// This is trivially `true` for all architectures other than the `*Unknown` variants. @@ -455,12 +437,6 @@ impl Arch { _ => true, } } - - #[doc(hidden)] - #[deprecated = "use CpuFamily::cfi_register_name instead"] - pub fn register_name(self, register: u16) -> Option<&'static str> { - self.cpu_family().cfi_register_name(register) - } } impl Default for Arch { diff --git a/symbolic-debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs index 7c56f874a..a4d14aa3b 100644 --- a/symbolic-debuginfo/src/dwarf.rs +++ b/symbolic-debuginfo/src/dwarf.rs @@ -111,23 +111,6 @@ pub trait Dwarf<'data> { /// given by the architecture. fn endianity(&self) -> Endian; - #[doc(hidden)] - #[deprecated(note = "use raw_section instead")] - fn raw_data(&self, name: &str) -> Option<(u64, &'data [u8])> { - let section = self.raw_section(name)?; - match section.data { - Cow::Borrowed(data) => Some((section.offset, data)), - Cow::Owned(_) => None, - } - } - - #[doc(hidden)] - #[deprecated(note = "use section instead")] - fn section_data(&self, name: &str) -> Option<(u64, Cow<'data, [u8]>)> { - let section = self.section(name)?; - Some((section.offset, section.data)) - } - /// Returns information and raw data of a section. /// /// The section name is given without leading punctuation, such dots or underscores. For diff --git a/symbolic-unreal/src/context.rs b/symbolic-unreal/src/context.rs index 8dedc292d..eb6cee581 100644 --- a/symbolic-unreal/src/context.rs +++ b/symbolic-unreal/src/context.rs @@ -118,10 +118,6 @@ pub struct Unreal4ContextRuntimeProperties { /// Misc.CPUBrand #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_cpu_brand: Option, - #[doc(hidden)] - #[deprecated(note = "use misc_primary_gpu_brand instead")] - #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] - pub misc_primary_cpu_brand: Option, /// Misc.PrimaryGPUBrand #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub misc_primary_gpu_brand: Option, @@ -225,15 +221,7 @@ impl Unreal4ContextRuntimeProperties { } "Misc.CPUVendor" => rv.misc_cpu_vendor = get_text_or_none(&child), "Misc.CPUBrand" => rv.misc_cpu_brand = get_text_or_none(&child), - "Misc.PrimaryGPUBrand" => { - rv.misc_primary_gpu_brand = get_text_or_none(&child); - - #[allow(deprecated)] - { - // Shim a typo. To be removed with the next major release. - rv.misc_primary_cpu_brand = rv.misc_primary_gpu_brand.clone(); - } - } + "Misc.PrimaryGPUBrand" => rv.misc_primary_gpu_brand = get_text_or_none(&child), "Misc.OSVersionMajor" => rv.misc_os_version_major = get_text_or_none(&child), "Misc.OSVersionMinor" => rv.misc_os_version_minor = get_text_or_none(&child), "GameStateName" => rv.game_state_name = get_text_or_none(&child), diff --git a/symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap b/symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap index 3d85baaf3..9ca797630 100644 --- a/symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap +++ b/symbolic-unreal/tests/snapshots/test_unreal_crash_parse__contexts_runtime_properties.snap @@ -33,7 +33,6 @@ misc_number_of_cores: 6 misc_number_of_cores_inc_hyperthread: 6 misc_cpu_vendor: GenuineIntel misc_cpu_brand: Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz -misc_primary_cpu_brand: NVIDIA GeForce GTX 1080 misc_primary_gpu_brand: NVIDIA GeForce GTX 1080 misc_os_version_major: Windows 10 memory_stats_total_physical: 17112477696 From de8272ce33eb1e3c10e42ede5afc772cc43a94b6 Mon Sep 17 00:00:00 2001 From: Jan Michael Auer Date: Thu, 24 Sep 2020 16:25:19 +0200 Subject: [PATCH 12/22] ref(common): Change InstructionInfo setters to Option (#272) --- symbolic-cabi/src/symcache.rs | 15 ++++++--------- symbolic-common/src/heuristics.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/symbolic-cabi/src/symcache.rs b/symbolic-cabi/src/symcache.rs index bce69a038..98bc26d9e 100644 --- a/symbolic-cabi/src/symcache.rs +++ b/symbolic-cabi/src/symcache.rs @@ -199,16 +199,13 @@ ffi_fn! { let info = &*ii; let arch = (*info.arch).as_str().parse()?; - let mut real_info = InstructionInfo::new(arch, info.addr); - real_info.is_crashing_frame(info.crashing_frame); - if info.signal != 0 { - real_info.signal(info.signal); - } - if info.ip_reg != 0 { - real_info.ip_register_value(info.ip_reg); - } + let address = InstructionInfo::new(arch, info.addr) + .is_crashing_frame(info.crashing_frame) + .signal(Some(info.signal).filter(|&s| s != 0)) + .ip_register_value(Some(info.ip_reg).filter(|&r| r != 0)) + .caller_address(); - Ok(real_info.caller_address()) + Ok(address) } } diff --git a/symbolic-common/src/heuristics.rs b/symbolic-common/src/heuristics.rs index 44cca5c9f..3e6790f14 100644 --- a/symbolic-common/src/heuristics.rs +++ b/symbolic-common/src/heuristics.rs @@ -24,8 +24,8 @@ const SIGSEGV: u32 = 11; /// /// let caller_address = InstructionInfo::new(Arch::Arm64, 0x1337) /// .is_crashing_frame(false) -/// .signal(SIGSEGV) -/// .ip_register_value(0x4242) +/// .signal(Some(SIGSEGV)) +/// .ip_register_value(Some(0x4242)) /// .caller_address(); /// /// assert_eq!(caller_address, 0x1330); @@ -154,8 +154,8 @@ impl InstructionInfo { /// address adjustment. /// /// [`should_adjust_caller`]: struct.InstructionInfo.html#method.should_adjust_caller - pub fn signal(&mut self, signal: u32) -> &mut Self { - self.signal = Some(signal); + pub fn signal(&mut self, signal: Option) -> &mut Self { + self.signal = signal; self } @@ -166,8 +166,8 @@ impl InstructionInfo { /// caller address adjustment. /// /// [`should_adjust_caller`]: struct.InstructionInfo.html#method.should_adjust_caller - pub fn ip_register_value(&mut self, value: u64) -> &mut Self { - self.ip_reg = Some(value); + pub fn ip_register_value(&mut self, value: Option) -> &mut Self { + self.ip_reg = value; self } @@ -256,7 +256,7 @@ impl InstructionInfo { /// const SIGSEGV: u32 = 11; /// /// let is_crash = InstructionInfo::new(Arch::X86, 0x1337) - /// .signal(SIGSEGV) + /// .signal(Some(SIGSEGV)) /// .is_crash_signal(); /// /// assert!(is_crash); From 8c92e97138bb55c1efdd450d8695d849add5f54c Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Mon, 28 Sep 2020 12:33:38 +0200 Subject: [PATCH 13/22] ref: Introduce feature flags for demangling languages (#274) --- symbolic-demangle/Cargo.toml | 15 ++-- symbolic-demangle/build.rs | 41 +++++------ symbolic-demangle/src/lib.rs | 83 +++++++++++++++++------ symbolic-demangle/tests/test_cpp.rs | 2 + symbolic-demangle/tests/test_detection.rs | 66 ++++++++++-------- symbolic-demangle/tests/test_msvc.rs | 2 + symbolic-demangle/tests/test_objcpp.rs | 2 + symbolic-demangle/tests/test_swift.rs | 1 + 8 files changed, 142 insertions(+), 70 deletions(-) diff --git a/symbolic-demangle/Cargo.toml b/symbolic-demangle/Cargo.toml index 2cdb0129a..c6dc4a488 100644 --- a/symbolic-demangle/Cargo.toml +++ b/symbolic-demangle/Cargo.toml @@ -23,14 +23,21 @@ exclude = [ [package.metadata.docs.rs] all-features = true +[features] +default = ["cpp", "msvc", "rust", "swift"] +cpp = ["cpp_demangle"] +msvc = ["msvc-demangler"] +rust = ["rustc-demangle"] +swift = ["cc"] + [dependencies] -cpp_demangle = "0.3.0" -msvc-demangler = "0.8.0" -rustc-demangle = "0.1.16" +cpp_demangle = { version = "0.3.0", optional = true } +msvc-demangler = { version = "0.8.0", optional = true } +rustc-demangle = { version = "0.1.16", optional = true } symbolic-common = { version = "7.5.0", path = "../symbolic-common" } [build-dependencies] -cc = "1.0.50" +cc = { version = "1.0.50", optional = true } [badges] travis-ci = { repository = "getsentry/symbolic", branch = "master" } diff --git a/symbolic-demangle/build.rs b/symbolic-demangle/build.rs index da86326e9..4ce782eb0 100644 --- a/symbolic-demangle/build.rs +++ b/symbolic-demangle/build.rs @@ -1,21 +1,24 @@ fn main() { - cc::Build::new() - .cpp(true) - .files(&[ - "src/swiftdemangle.cpp", - "vendor/swift/lib/Demangling/Demangler.cpp", - "vendor/swift/lib/Demangling/Context.cpp", - "vendor/swift/lib/Demangling/ManglingUtils.cpp", - "vendor/swift/lib/Demangling/NodeDumper.cpp", - "vendor/swift/lib/Demangling/NodePrinter.cpp", - "vendor/swift/lib/Demangling/OldDemangler.cpp", - // "vendor/swift/lib/Demangling/OldRemangler.cpp", - "vendor/swift/lib/Demangling/Punycode.cpp", - "vendor/swift/lib/Demangling/Remangler.cpp", - ]) - .flag_if_supported("-std=c++14") - .flag("-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1") - .warnings(false) - .include("vendor/swift/include") - .compile("swiftdemangle"); + #[cfg(feature = "swift")] + { + cc::Build::new() + .cpp(true) + .files(&[ + "src/swiftdemangle.cpp", + "vendor/swift/lib/Demangling/Demangler.cpp", + "vendor/swift/lib/Demangling/Context.cpp", + "vendor/swift/lib/Demangling/ManglingUtils.cpp", + "vendor/swift/lib/Demangling/NodeDumper.cpp", + "vendor/swift/lib/Demangling/NodePrinter.cpp", + "vendor/swift/lib/Demangling/OldDemangler.cpp", + // "vendor/swift/lib/Demangling/OldRemangler.cpp", + "vendor/swift/lib/Demangling/Punycode.cpp", + "vendor/swift/lib/Demangling/Remangler.cpp", + ]) + .flag_if_supported("-std=c++14") + .flag("-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1") + .warnings(false) + .include("vendor/swift/include") + .compile("swiftdemangle"); + } } diff --git a/symbolic-demangle/src/lib.rs b/symbolic-demangle/src/lib.rs index 117a32e7b..acbdc9872 100644 --- a/symbolic-demangle/src/lib.rs +++ b/symbolic-demangle/src/lib.rs @@ -2,9 +2,9 @@ //! //! Currently supported languages are: //! -//! - C++ (GCC-style compilers and MSVC) -//! - Rust (both `legacy` and `v0`) -//! - Swift (up to Swift 5.2) +//! - C++ (GCC-style compilers and MSVC) (`features = ["cpp", "msvc"]`) +//! - Rust (both `legacy` and `v0`) (`features = ["rust"]`) +//! - Swift (up to Swift 5.2) (`features = ["swift"]`) //! - ObjC (only symbol detection) //! //! As the demangling schemes for the languages are different, the supported demangling features are @@ -16,25 +16,27 @@ //! # Examples //! //! ```rust +//! # #[cfg(feature = "cpp")] { //! use symbolic_common::{Language, Name}; //! use symbolic_demangle::{Demangle, DemangleOptions}; //! //! let name = Name::new("__ZN3std2io4Read11read_to_end17hb85a0f6802e14499E"); //! assert_eq!(name.detect_language(), Language::Rust); //! assert_eq!(name.try_demangle(DemangleOptions::default()), "std::io::Read::read_to_end"); +//! # } //! ``` #![warn(missing_docs)] use std::borrow::Cow; +#[cfg(feature = "swift")] use std::ffi::{CStr, CString}; +#[cfg(feature = "swift")] use std::os::raw::{c_char, c_int}; use symbolic_common::{Language, Name}; -use cpp_demangle::{DemangleOptions as CppOptions, Symbol as CppSymbol}; -use msvc_demangler::DemangleFlags as MsvcFlags; - +#[cfg(feature = "swift")] extern "C" { fn symbolic_demangle_swift( sym: *const c_char, @@ -96,13 +98,21 @@ fn is_maybe_msvc(ident: &str) -> bool { ident.starts_with('?') || ident.starts_with("@?") } +#[cfg(feature = "swift")] fn is_maybe_swift(ident: &str) -> bool { CString::new(ident) .map(|cstr| unsafe { symbolic_demangle_is_swift_symbol(cstr.as_ptr()) != 0 }) .unwrap_or(false) } +#[cfg(not(feature = "swift"))] +fn is_maybe_swift(_ident: &str) -> bool { + false +} + +#[cfg(feature = "msvc")] fn try_demangle_msvc(ident: &str, opts: DemangleOptions) -> Option { + use msvc_demangler::DemangleFlags as MsvcFlags; let flags = match opts.format { DemangleFormat::Full => MsvcFlags::COMPLETE, DemangleFormat::Short => { @@ -117,27 +127,42 @@ fn try_demangle_msvc(ident: &str, opts: DemangleOptions) -> Option { msvc_demangler::demangle(ident, flags).ok() } +#[cfg(not(feature = "msvc"))] +fn try_demangle_msvc(_ident: &str, _opts: DemangleOptions) -> Option { + None +} + fn try_demangle_cpp(ident: &str, opts: DemangleOptions) -> Option { if is_maybe_msvc(ident) { return try_demangle_msvc(ident, opts); } - let symbol = match CppSymbol::new(ident) { - Ok(symbol) => symbol, - Err(_) => return None, - }; + #[cfg(feature = "cpp")] + { + use cpp_demangle::{DemangleOptions as CppOptions, Symbol as CppSymbol}; - let mut cpp_options = CppOptions::new(); - if !opts.with_arguments { - cpp_options = cpp_options.no_params().no_return_type(); - } + let symbol = match CppSymbol::new(ident) { + Ok(symbol) => symbol, + Err(_) => return None, + }; - match symbol.demangle(&cpp_options) { - Ok(demangled) => Some(demangled), - Err(_) => None, + let mut cpp_options = CppOptions::new(); + if !opts.with_arguments { + cpp_options = cpp_options.no_params().no_return_type(); + } + + match symbol.demangle(&cpp_options) { + Ok(demangled) => Some(demangled), + Err(_) => None, + } + } + #[cfg(not(feature = "cpp"))] + { + None } } +#[cfg(feature = "rust")] fn try_demangle_rust(ident: &str, _opts: DemangleOptions) -> Option { match rustc_demangle::try_demangle(ident) { Ok(demangled) => Some(format!("{:#}", demangled)), @@ -145,6 +170,12 @@ fn try_demangle_rust(ident: &str, _opts: DemangleOptions) -> Option { } } +#[cfg(not(feature = "rust"))] +fn try_demangle_rust(_ident: &str, _opts: DemangleOptions) -> Option { + None +} + +#[cfg(feature = "swift")] fn try_demangle_swift(ident: &str, opts: DemangleOptions) -> Option { let mut buf = vec![0 as c_char; 4096]; let sym = match CString::new(ident) { @@ -171,6 +202,11 @@ fn try_demangle_swift(ident: &str, opts: DemangleOptions) -> Option { } } +#[cfg(not(feature = "swift"))] +fn try_demangle_swift(_ident: &str, _opts: DemangleOptions) -> Option { + None +} + fn try_demangle_objc(ident: &str, _opts: DemangleOptions) -> Option { Some(ident.to_string()) } @@ -220,11 +256,13 @@ pub trait Demangle { /// # Examples /// /// ``` + /// # #[cfg(feature = "cpp")] { /// use symbolic_common::Name; /// use symbolic_demangle::{Demangle, DemangleOptions}; /// /// assert_eq!(Name::new("_ZN3foo3barEv").demangle(DemangleOptions::default()), Some("foo::bar".to_string())); /// assert_eq!(Name::new("unknown").demangle(DemangleOptions::default()), None); + /// # } /// ``` fn demangle(&self, opts: DemangleOptions) -> Option; @@ -236,11 +274,13 @@ pub trait Demangle { /// # Examples /// /// ``` + /// # #[cfg(feature = "cpp")] { /// use symbolic_common::Name; /// use symbolic_demangle::{Demangle, DemangleOptions}; /// /// assert_eq!(Name::new("_ZN3foo3barEv").try_demangle(DemangleOptions::default()), "foo::bar"); /// assert_eq!(Name::new("unknown").try_demangle(DemangleOptions::default()), "unknown"); + /// # } /// ``` /// /// [`demangle`]: trait.Demangle.html#tymethod.demangle @@ -257,8 +297,11 @@ impl<'a> Demangle for Name<'a> { return Language::ObjC; } - if rustc_demangle::try_demangle(self.as_str()).is_ok() { - return Language::Rust; + #[cfg(feature = "rust")] + { + if rustc_demangle::try_demangle(self.as_str()).is_ok() { + return Language::Rust; + } } if is_maybe_cpp(self.as_str()) || is_maybe_msvc(self.as_str()) { @@ -298,7 +341,9 @@ impl<'a> Demangle for Name<'a> { /// # Examples /// /// ``` +/// # #[cfg(feature = "cpp")] { /// assert_eq!(symbolic_demangle::demangle("_ZN3foo3barEv"), "foo::bar"); +/// # } /// ``` /// /// [`Demangle::try_demangle`]: trait.Demangle.html#tymethod.try_demangle diff --git a/symbolic-demangle/tests/test_cpp.rs b/symbolic-demangle/tests/test_cpp.rs index f25b12aa0..56bbee512 100644 --- a/symbolic-demangle/tests/test_cpp.rs +++ b/symbolic-demangle/tests/test_cpp.rs @@ -2,6 +2,8 @@ //! We use cpp_demangle under the hood which runs the libiberty test suite //! Still, we run some basic regression tests here to detect demangling differences. +#![cfg(feature = "cpp")] + #[macro_use] mod utils; diff --git a/symbolic-demangle/tests/test_detection.rs b/symbolic-demangle/tests/test_detection.rs index 8d7859660..5844b3cd7 100644 --- a/symbolic-demangle/tests/test_detection.rs +++ b/symbolic-demangle/tests/test_detection.rs @@ -34,19 +34,6 @@ fn test_cpp_msvc() { assert_language("?h@@YAXH@Z ", Language::Cpp); } -#[test] -fn test_rust_legacy() { - assert_language( - "__ZN3std2io4Read11read_to_end17hb85a0f6802e14499E", - Language::Rust, - ); -} - -#[test] -fn test_rust_v0() { - assert_language("_RNvNtCs1234_7mycrate3foo3bar", Language::Rust); -} - #[test] fn test_objc_static() { assert_language("+[Foo bar:blub:]", Language::ObjC); @@ -57,21 +44,6 @@ fn test_objc_member() { assert_language("-[Foo bar:blub:]", Language::ObjC); } -#[test] -fn test_swift_old() { - assert_language("_T08mangling3barSiyKF", Language::Swift); -} - -#[test] -fn test_swift_4() { - assert_language("$S8mangling6curry1yyF", Language::Swift); -} - -#[test] -fn test_swift_5() { - assert_language("$s8mangling6curry1yyF", Language::Swift); -} - #[test] fn test_ambiguous_cpp_rust() { // This symbol might look like a legacy Rust symbol at first because of the _ZN...E schema, but @@ -83,3 +55,41 @@ fn test_ambiguous_cpp_rust() { Language::Cpp, ); } + +#[cfg(feature = "swift")] +mod swift_tests { + use super::*; + + #[test] + fn test_swift_old() { + assert_language("_T08mangling3barSiyKF", Language::Swift); + } + + #[test] + fn test_swift_4() { + assert_language("$S8mangling6curry1yyF", Language::Swift); + } + + #[test] + fn test_swift_5() { + assert_language("$s8mangling6curry1yyF", Language::Swift); + } +} + +#[cfg(feature = "rust")] +mod rust_tests { + use super::*; + + #[test] + fn test_rust_legacy() { + assert_language( + "__ZN3std2io4Read11read_to_end17hb85a0f6802e14499E", + Language::Rust, + ); + } + + #[test] + fn test_rust_v0() { + assert_language("_RNvNtCs1234_7mycrate3foo3bar", Language::Rust); + } +} diff --git a/symbolic-demangle/tests/test_msvc.rs b/symbolic-demangle/tests/test_msvc.rs index 040241422..73beb9d20 100644 --- a/symbolic-demangle/tests/test_msvc.rs +++ b/symbolic-demangle/tests/test_msvc.rs @@ -2,6 +2,8 @@ //! We use msvc_demangler under the hood which runs its own test suite. //! Tests here make it easier to detect regressions. +#![cfg(feature = "msvc")] + #[macro_use] mod utils; diff --git a/symbolic-demangle/tests/test_objcpp.rs b/symbolic-demangle/tests/test_objcpp.rs index 98718a7fa..d4dc44e7d 100644 --- a/symbolic-demangle/tests/test_objcpp.rs +++ b/symbolic-demangle/tests/test_objcpp.rs @@ -9,6 +9,7 @@ use symbolic_common::{Language, Name}; use symbolic_demangle::Demangle; #[test] +#[cfg(feature = "cpp")] fn test_demangle_objcpp() { assert_demangle!(Language::ObjCpp, utils::WITH_ARGS, { "+[Foo bar:blub:]" => "+[Foo bar:blub:]", @@ -19,6 +20,7 @@ fn test_demangle_objcpp() { } #[test] +#[cfg(feature = "cpp")] fn test_demangle_objcpp_no_args() { assert_demangle!(Language::ObjCpp, utils::WITHOUT_ARGS, { "+[Foo bar:blub:]" => "+[Foo bar:blub:]", diff --git a/symbolic-demangle/tests/test_swift.rs b/symbolic-demangle/tests/test_swift.rs index 6166cf937..9f3877c53 100644 --- a/symbolic-demangle/tests/test_swift.rs +++ b/symbolic-demangle/tests/test_swift.rs @@ -2,6 +2,7 @@ //! All functions were compiled with Swift 4.0 in a file called mangling.swift //! see https://github.com/apple/swift/blob/master/test/SILGen/mangling.swift #![allow(clippy::cognitive_complexity)] +#![cfg(feature = "swift")] #[macro_use] mod utils; From dfd18361f36af03809dbb93775c1045dc4fab067 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Wed, 30 Sep 2020 20:04:48 +0200 Subject: [PATCH 14/22] ci: Switch to GitHub Actions (#273) Co-authored-by: Jan Michael Auer --- .craft.yml | 2 +- .github/workflows/ci.yml | 112 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++ .travis.yml | 77 ----------------------- Makefile | 2 +- 5 files changed, 211 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.craft.yml b/.craft.yml index d7cdb0312..9b15ff868 100644 --- a/.craft.yml +++ b/.craft.yml @@ -10,7 +10,7 @@ targets: - name: github changelogPolicy: simple requireNames: - - /^symbolic-.*-py2.py3-none-macosx_10_13_x86_64.whl$/ + - /^symbolic-.*-py2.py3-none-macosx_10_15_x86_64.whl$/ - /^symbolic-.*-py2.py3-none-manylinux2010_i686.whl$/ - /^symbolic-.*-py2.py3-none-manylinux2010_x86_64.whl$/ - /^symbolic-.*.zip$/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..4d76eaddc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,112 @@ +name: CI + +on: + push: + branches: + - master + - "release/**" + pull_request: + +jobs: + lints: + name: Style/Linting + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - uses: Swatinem/rust-cache@v1 + with: + key: lints + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - run: make style-python + + - name: Run cargo clippy + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features --workspace --tests --examples -- -D clippy::all + + - run: make lint-python + + test-rust: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + name: Rust Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: Swatinem/rust-cache@v1 + with: + key: test-rust + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace --all-features + + test-python: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + name: Python Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + env: + SYMBOLIC_DEBUG: 1 + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - uses: Swatinem/rust-cache@v1 + with: + key: test-python + + - run: make test-python diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..f741e6f82 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release + +on: + push: + branches: + - "release/**" + +jobs: + python-wheel-mac: + name: Python macOS + runs-on: macos-10.15 + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - uses: actions/setup-python@v2 + with: + python-version: 2.7 + + - run: make wheel SYMBOLIC_PYTHON=python2 + + - uses: actions/setup-node@v1 + + - name: Upload to Zeus + env: + ZEUS_HOOK_BASE: ${{ secrets.ZEUS_HOOK_BASE }} + run: | + npm install -D @zeus-ci/cli + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --ref ${{ github.sha }} + npx zeus upload --build ${{ github.run_id }} --job ${{ github.job }} --type "application/zip+wheel" py/dist/* + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --status passed + + python-wheel-linux: + strategy: + fail-fast: false + matrix: + build-arch: [i686, x86_64] + + name: Python Linux ${{ matrix.build-arch }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Build in Docker + run: make wheel-manylinux IMAGE=quay.io/pypa/manylinux2010_${{ matrix.build-arch }} + + - uses: actions/setup-node@v1 + + - name: Upload to Zeus + env: + ZEUS_HOOK_BASE: ${{ secrets.ZEUS_HOOK_BASE }} + run: | + npm install -D @zeus-ci/cli + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --ref ${{ github.sha }} + npx zeus upload --build ${{ github.run_id }} --job ${{ github.job }} --type "application/zip+wheel" py/dist/* + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --status passed + + sdist: + name: Python sdist + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + with: + python-version: 2.7 + + - run: make sdist + + - uses: actions/setup-node@v1 + + - name: Upload to Zeus + env: + ZEUS_HOOK_BASE: ${{ secrets.ZEUS_HOOK_BASE }} + run: | + npm install -D @zeus-ci/cli + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --ref ${{ github.sha }} + npx zeus upload --build ${{ github.run_id }} --job ${{ github.job }} --type "application/zip+wheel" py/dist/* + npx zeus job update --build ${{ github.run_id }} --job ${{ github.job }} --status passed diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d2314bf95..000000000 --- a/.travis.yml +++ /dev/null @@ -1,77 +0,0 @@ -language: rust -os: linux - -git: - depth: 1 - -if: tag IS blank - -after_success: - - npm install -g @zeus-ci/cli - - test "$DEPLOY" && ( zeus upload -t "application/zip+wheel" py/dist/* || exit 1 ) - -jobs: - include: - # Rust test suite - - script: make style-rust - env: TEST=style-rust - - script: make lint-rust - env: TEST=lint-rust CXX=clang - - script: make test-rust - env: TEST=linux-rust CXX=clang - - os: osx - script: make test-rust - env: TEST=mac-rust - - # Python test suite - - name: "Python 3.7 Style/Linting" - language: python - python: "3.7" - script: - - make style-python - - make lint-python - env: TEST=style-python - - name: "Python 3.6 Tests (linux)" - before_install: - # multi-language jobs not currently possible, pyenv is used here. - # if we want later 3.6.x's it isn't possible AFAIK to update travis pyenv, - # so would need to install rustup + friends. - - pyenv install 3.6.3 - - pyenv global 3.6.3 - script: make test-python - env: TEST=linux-python CXX=clang SYMBOLIC_DEBUG=1 - - name: "Python 3.7 Tests (osx)" - os: osx - script: make test-python - env: TEST=mac-python SYMBOLIC_DEBUG=1 - - # Build wheels - - if: branch ~= /^release\/.+$/ - os: osx - script: make wheel SYMBOLIC_PYTHON=python2 - before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade node - env: DEPLOY=mac-wheel - osx_image: xcode9.4 - - if: branch ~= /^release\/.+$/ - script: make wheel-manylinux IMAGE=quay.io/pypa/manylinux2010_x86_64 - env: DEPLOY=linux-x86_64-wheel - services: - - docker - - if: branch ~= /^release\/.+$/ - script: make wheel-manylinux IMAGE=quay.io/pypa/manylinux2010_i686 - env: DEPLOY=linux-x86-wheel - services: - - docker - - if: branch ~= /^release\/.+$/ - script: make sdist - env: DEPLOY=sdist - -notifications: - webhooks: - urls: - - https://zeus.ci/hooks/3be2453a-c595-11e7-8cdd-0a580a28020a/public/provider/travis/webhook - on_success: always - on_failure: always - on_start: always - on_cancel: always - on_error: always diff --git a/Makefile b/Makefile index e68d48876..c5a5bfe72 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ wheel: .venv/bin/python .PHONY: wheel wheel-manylinux: - docker run --rm -it -v $(CURDIR):/work -w /work/py $(IMAGE) sh manylinux.sh + docker run --rm -v $(CURDIR):/work -w /work/py $(IMAGE) sh manylinux.sh .PHONY: wheel-manylinux # Tests From 913516ed63f6687158e567029fa70dea269ff1c5 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 9 Oct 2020 13:20:39 +0200 Subject: [PATCH 15/22] fix: Add a SymbolIterator and Lifetimes to ObjectLike trait (#277) Co-authored-by: Jan Michael Auer --- symbolic-debuginfo/src/base.rs | 11 ++-- symbolic-debuginfo/src/breakpad.rs | 57 ++++++++++----------- symbolic-debuginfo/src/dwarf.rs | 2 +- symbolic-debuginfo/src/elf.rs | 59 +++++++++++----------- symbolic-debuginfo/src/macho.rs | 23 +++++---- symbolic-debuginfo/src/object.rs | 57 ++++++++++----------- symbolic-debuginfo/src/pdb.rs | 58 +++++++++++----------- symbolic-debuginfo/src/pe.rs | 49 +++++++++--------- symbolic-debuginfo/src/sourcebundle.rs | 69 ++++++++++++++------------ symbolic-minidump/src/cfi.rs | 8 +-- symbolic-symcache/src/writer.rs | 4 +- 11 files changed, 205 insertions(+), 192 deletions(-) diff --git a/symbolic-debuginfo/src/base.rs b/symbolic-debuginfo/src/base.rs index 7c8abb58d..c8923fe72 100644 --- a/symbolic-debuginfo/src/base.rs +++ b/symbolic-debuginfo/src/base.rs @@ -625,13 +625,16 @@ pub trait DebugSession { } /// An object containing debug information. -pub trait ObjectLike { +pub trait ObjectLike<'data, 'object> { /// Errors thrown when reading information from this object. type Error; /// A session that allows optimized access to debugging information. type Session: DebugSession; + /// The iterator over the symbols in the public symbol table. + type SymbolIterator: Iterator>; + /// The container format of this file. fn file_format(&self) -> FileFormat; @@ -657,10 +660,10 @@ pub trait ObjectLike { fn has_symbols(&self) -> bool; /// Returns an iterator over symbols in the public symbol table. - fn symbols(&self) -> DynIterator<'_, Symbol<'_>>; + fn symbols(&'object self) -> Self::SymbolIterator; /// Returns an ordered map of symbols in the symbol table. - fn symbol_map(&self) -> SymbolMap<'_>; + fn symbol_map(&self) -> SymbolMap<'data>; /// Determines whether this object contains debug information. fn has_debug_info(&self) -> bool; @@ -674,7 +677,7 @@ pub trait ObjectLike { /// Constructing this session will also work if the object does not contain debugging /// information, in which case the session will be a no-op. This can be checked via /// [`has_debug_info`](trait.ObjectLike.html#tymethod.has_debug_info). - fn debug_session(&self) -> Result; + fn debug_session(&'object self) -> Result; /// Determines whether this object contains stack unwinding information. fn has_unwind_info(&self) -> bool; diff --git a/symbolic-debuginfo/src/breakpad.rs b/symbolic-debuginfo/src/breakpad.rs index c33e4294f..512f0a565 100644 --- a/symbolic-debuginfo/src/breakpad.rs +++ b/symbolic-debuginfo/src/breakpad.rs @@ -734,21 +734,21 @@ impl<'d> Iterator for BreakpadStackRecords<'d> { /// > compactness. /// /// The full documentation resides [here](https://chromium.googlesource.com/breakpad/breakpad/+/refs/heads/master/docs/symbol_files.md). -pub struct BreakpadObject<'d> { +pub struct BreakpadObject<'data> { id: DebugId, arch: Arch, - module: BreakpadModuleRecord<'d>, - data: &'d [u8], + module: BreakpadModuleRecord<'data>, + data: &'data [u8], } -impl<'d> BreakpadObject<'d> { +impl<'data> BreakpadObject<'data> { /// Tests whether the buffer could contain a Breakpad object. pub fn test(data: &[u8]) -> bool { data.starts_with(b"MODULE ") } /// Tries to parse a Breakpad object from the given slice. - pub fn parse(data: &'d [u8]) -> Result { + pub fn parse(data: &'data [u8]) -> Result { // Ensure that we do not read the entire file at once. let header = if data.len() > BREAKPAD_HEADER_CAP { match str::from_utf8(&data[..BREAKPAD_HEADER_CAP]) { @@ -813,7 +813,7 @@ impl<'d> BreakpadObject<'d> { /// This is the name of the original debug file that was used to create the Breakpad file. On /// Windows, this will have a `.pdb` extension, on other platforms that name is likely /// equivalent to the name of the code file (shared library or executable). - pub fn name(&self) -> &'d str { + pub fn name(&self) -> &'data str { self.module.name } @@ -836,14 +836,14 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> BreakpadSymbolIterator<'d> { + pub fn symbols(&self) -> BreakpadSymbolIterator<'data> { BreakpadSymbolIterator { records: self.public_records(), } } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { self.symbols().collect() } @@ -861,7 +861,7 @@ impl<'d> BreakpadObject<'d> { /// Constructing this session will also work if the object does not contain debugging /// information, in which case the session will be a no-op. This can be checked via /// [`has_debug_info`](struct.BreakpadObject.html#method.has_debug_info). - pub fn debug_session(&self) -> Result, BreakpadError> { + pub fn debug_session(&self) -> Result, BreakpadError> { Ok(BreakpadDebugSession { file_map: self.file_map(), func_records: self.func_records(), @@ -879,7 +879,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over info records. - pub fn info_records(&self) -> BreakpadInfoRecords<'d> { + pub fn info_records(&self) -> BreakpadInfoRecords<'data> { BreakpadInfoRecords { lines: Lines::new(self.data), finished: false, @@ -887,7 +887,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over file records. - pub fn file_records(&self) -> BreakpadFileRecords<'d> { + pub fn file_records(&self) -> BreakpadFileRecords<'data> { BreakpadFileRecords { lines: Lines::new(self.data), finished: false, @@ -895,7 +895,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns a map for file name lookups by id. - pub fn file_map(&self) -> BreakpadFileMap<'d> { + pub fn file_map(&self) -> BreakpadFileMap<'data> { self.file_records() .filter_map(Result::ok) .map(|file| (file.id, file.name)) @@ -903,7 +903,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over public symbol records. - pub fn public_records(&self) -> BreakpadPublicRecords<'d> { + pub fn public_records(&self) -> BreakpadPublicRecords<'data> { BreakpadPublicRecords { lines: Lines::new(self.data), finished: false, @@ -911,7 +911,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over function records. - pub fn func_records(&self) -> BreakpadFuncRecords<'d> { + pub fn func_records(&self) -> BreakpadFuncRecords<'data> { BreakpadFuncRecords { lines: Lines::new(self.data), finished: false, @@ -919,7 +919,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns an iterator over stack frame records. - pub fn stack_records(&self) -> BreakpadStackRecords<'d> { + pub fn stack_records(&self) -> BreakpadStackRecords<'data> { BreakpadStackRecords { lines: Lines::new(self.data), finished: false, @@ -927,7 +927,7 @@ impl<'d> BreakpadObject<'d> { } /// Returns the raw data of the Breakpad file. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { self.data } } @@ -946,7 +946,7 @@ impl fmt::Debug for BreakpadObject<'_> { } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for BreakpadObject<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for BreakpadObject<'data> { type Ref = BreakpadObject<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -954,21 +954,22 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for BreakpadObject<'d> { } } -impl<'d> Parse<'d> for BreakpadObject<'d> { +impl<'data> Parse<'data> for BreakpadObject<'data> { type Error = BreakpadError; fn test(data: &[u8]) -> bool { Self::test(data) } - fn parse(data: &'d [u8]) -> Result { + fn parse(data: &'data [u8]) -> Result { Self::parse(data) } } -impl<'d> ObjectLike for BreakpadObject<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for BreakpadObject<'data> { type Error = BreakpadError; - type Session = BreakpadDebugSession<'d>; + type Session = BreakpadDebugSession<'data>; + type SymbolIterator = BreakpadSymbolIterator<'data>; fn file_format(&self) -> FileFormat { self.file_format() @@ -998,11 +999,11 @@ impl<'d> ObjectLike for BreakpadObject<'d> { self.has_symbols() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + fn symbols(&self) -> Self::SymbolIterator { + self.symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } @@ -1026,12 +1027,12 @@ impl<'d> ObjectLike for BreakpadObject<'d> { /// An iterator over symbols in the Breakpad object. /// /// Returned by [`BreakpadObject::symbols`](struct.BreakpadObject.html#method.symbols). -pub struct BreakpadSymbolIterator<'d> { - records: BreakpadPublicRecords<'d>, +pub struct BreakpadSymbolIterator<'data> { + records: BreakpadPublicRecords<'data>, } -impl<'d> Iterator for BreakpadSymbolIterator<'d> { - type Item = Symbol<'d>; +impl<'data> Iterator for BreakpadSymbolIterator<'data> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { while let Some(result) = self.records.next() { diff --git a/symbolic-debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs index a4d14aa3b..32d224860 100644 --- a/symbolic-debuginfo/src/dwarf.rs +++ b/symbolic-debuginfo/src/dwarf.rs @@ -1161,7 +1161,7 @@ impl<'d> DwarfDebugSession<'d> { } } -impl<'d> DebugSession for DwarfDebugSession<'d> { +impl<'data> DebugSession for DwarfDebugSession<'data> { type Error = DwarfError; fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { diff --git a/symbolic-debuginfo/src/elf.rs b/symbolic-debuginfo/src/elf.rs index 7688b1270..362ba870d 100644 --- a/symbolic-debuginfo/src/elf.rs +++ b/symbolic-debuginfo/src/elf.rs @@ -48,12 +48,12 @@ pub enum ElfError { } /// Executable and Linkable Format, used for executables and libraries on Linux. -pub struct ElfObject<'d> { - elf: elf::Elf<'d>, - data: &'d [u8], +pub struct ElfObject<'data> { + elf: elf::Elf<'data>, + data: &'data [u8], } -impl<'d> ElfObject<'d> { +impl<'data> ElfObject<'data> { /// Tests whether the buffer could contain an ELF object. pub fn test(data: &[u8]) -> bool { match goblin::peek(&mut Cursor::new(data)) { @@ -63,7 +63,7 @@ impl<'d> ElfObject<'d> { } /// Tries to parse an ELF object from the given slice. - pub fn parse(data: &'d [u8]) -> Result { + pub fn parse(data: &'data [u8]) -> Result { Ok(elf::Elf::parse(data).map(|elf| ElfObject { elf, data })?) } @@ -84,7 +84,7 @@ impl<'d> ElfObject<'d> { } /// The binary's soname, if any. - pub fn name(&self) -> Option<&'d str> { + pub fn name(&self) -> Option<&'data str> { self.elf.soname } @@ -208,7 +208,7 @@ impl<'d> ElfObject<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> ElfSymbolIterator<'d, '_> { + pub fn symbols(&self) -> ElfSymbolIterator<'data, '_> { ElfSymbolIterator { symbols: self.elf.syms.iter(), strtab: &self.elf.strtab, @@ -218,7 +218,7 @@ impl<'d> ElfObject<'d> { } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { self.symbols().collect() } @@ -239,7 +239,7 @@ impl<'d> ElfObject<'d> { /// Constructing this session will also work if the object does not contain debugging /// information, in which case the session will be a no-op. This can be checked via /// [`has_debug_info`](struct.ElfObject.html#method.has_debug_info). - pub fn debug_session(&self) -> Result, DwarfError> { + pub fn debug_session(&self) -> Result, DwarfError> { let symbols = self.symbol_map(); DwarfDebugSession::parse(self, symbols, self.load_address(), self.kind()) } @@ -255,7 +255,7 @@ impl<'d> ElfObject<'d> { } /// Returns the raw data of the ELF file. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { self.data } @@ -295,7 +295,7 @@ impl<'d> ElfObject<'d> { } /// Locates and reads a section in an ELF binary. - fn find_section(&self, name: &str) -> Option<(bool, DwarfSection<'d>)> { + fn find_section(&self, name: &str) -> Option<(bool, DwarfSection<'data>)> { for header in &self.elf.section_headers { // NB: Symbolic does not support MIPS, but if it did we would also need to check // SHT_MIPS_DWARF sections. @@ -350,7 +350,7 @@ impl<'d> ElfObject<'d> { /// Depending on the compiler and linker, the build ID can be declared in a /// PT_NOTE program header entry, the ".note.gnu.build-id" section, or even /// both. - fn find_build_id(&self) -> Option<&'d [u8]> { + fn find_build_id(&self) -> Option<&'data [u8]> { // First, search the note program headers (PT_NOTE) for a NT_GNU_BUILD_ID. // We swallow all errors during this process and simply fall back to the // next method below. @@ -423,7 +423,7 @@ impl fmt::Debug for ElfObject<'_> { } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for ElfObject<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for ElfObject<'data> { type Ref = ElfObject<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -431,21 +431,22 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for ElfObject<'d> { } } -impl<'d> Parse<'d> for ElfObject<'d> { +impl<'data> Parse<'data> for ElfObject<'data> { type Error = ElfError; fn test(data: &[u8]) -> bool { Self::test(data) } - fn parse(data: &'d [u8]) -> Result { + fn parse(data: &'data [u8]) -> Result { Self::parse(data) } } -impl<'d> ObjectLike for ElfObject<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for ElfObject<'data> { type Error = DwarfError; - type Session = DwarfDebugSession<'d>; + type Session = DwarfDebugSession<'data>; + type SymbolIterator = ElfSymbolIterator<'data, 'object>; fn file_format(&self) -> FileFormat { self.file_format() @@ -475,11 +476,11 @@ impl<'d> ObjectLike for ElfObject<'d> { self.has_symbols() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + fn symbols(&'object self) -> Self::SymbolIterator { + self.symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } @@ -500,7 +501,7 @@ impl<'d> ObjectLike for ElfObject<'d> { } } -impl<'d> Dwarf<'d> for ElfObject<'d> { +impl<'data> Dwarf<'data> for ElfObject<'data> { fn endianity(&self) -> Endian { if self.elf.little_endian { Endian::Little @@ -509,12 +510,12 @@ impl<'d> Dwarf<'d> for ElfObject<'d> { } } - fn raw_section(&self, name: &str) -> Option> { + fn raw_section(&self, name: &str) -> Option> { let (_, section) = self.find_section(name)?; Some(section) } - fn section(&self, name: &str) -> Option> { + fn section(&self, name: &str) -> Option> { let (compressed, mut section) = self.find_section(name)?; if compressed { @@ -529,15 +530,15 @@ impl<'d> Dwarf<'d> for ElfObject<'d> { /// An iterator over symbols in the ELF file. /// /// Returned by [`ElfObject::symbols`](struct.ElfObject.html#method.symbols). -pub struct ElfSymbolIterator<'d, 'o> { - symbols: elf::sym::SymIterator<'d>, - strtab: &'o strtab::Strtab<'d>, - sections: &'o [elf::SectionHeader], +pub struct ElfSymbolIterator<'data, 'object> { + symbols: elf::sym::SymIterator<'data>, + strtab: &'object strtab::Strtab<'data>, + sections: &'object [elf::SectionHeader], load_addr: u64, } -impl<'d, 'o> Iterator for ElfSymbolIterator<'d, 'o> { - type Item = Symbol<'d>; +impl<'data, 'object> Iterator for ElfSymbolIterator<'data, 'object> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { while let Some(symbol) = self.symbols.next() { diff --git a/symbolic-debuginfo/src/macho.rs b/symbolic-debuginfo/src/macho.rs index c7d1dc0b7..7df684360 100644 --- a/symbolic-debuginfo/src/macho.rs +++ b/symbolic-debuginfo/src/macho.rs @@ -279,9 +279,10 @@ impl<'d> Parse<'d> for MachObject<'d> { } } -impl<'d> ObjectLike for MachObject<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for MachObject<'data> { type Error = DwarfError; - type Session = DwarfDebugSession<'d>; + type Session = DwarfDebugSession<'data>; + type SymbolIterator = MachOSymbolIterator<'data>; fn file_format(&self) -> FileFormat { self.file_format() @@ -311,11 +312,11 @@ impl<'d> ObjectLike for MachObject<'d> { self.has_symbols() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + fn symbols(&self) -> Self::SymbolIterator { + self.symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } @@ -336,7 +337,7 @@ impl<'d> ObjectLike for MachObject<'d> { } } -impl<'d> Dwarf<'d> for MachObject<'d> { +impl<'data> Dwarf<'data> for MachObject<'data> { fn endianity(&self) -> Endian { if self.macho.little_endian { Endian::Little @@ -345,7 +346,7 @@ impl<'d> Dwarf<'d> for MachObject<'d> { } } - fn raw_section(&self, section_name: &str) -> Option> { + fn raw_section(&self, section_name: &str) -> Option> { for segment in &self.macho.segments { for section in segment { if let Ok((header, data)) = section { @@ -378,14 +379,14 @@ impl<'d> Dwarf<'d> for MachObject<'d> { /// An iterator over symbols in the MachO file. /// /// Returned by [`MachObject::symbols`](struct.MachObject.html#method.symbols). -pub struct MachOSymbolIterator<'d> { - symbols: mach::symbols::SymbolIterator<'d>, +pub struct MachOSymbolIterator<'data> { + symbols: mach::symbols::SymbolIterator<'data>, sections: SmallVec<[usize; 2]>, vmaddr: u64, } -impl<'d> Iterator for MachOSymbolIterator<'d> { - type Item = Symbol<'d>; +impl<'data> Iterator for MachOSymbolIterator<'data> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { while let Some(next) = self.symbols.next() { diff --git a/symbolic-debuginfo/src/object.rs b/symbolic-debuginfo/src/object.rs index 81229aa23..a26519cb0 100644 --- a/symbolic-debuginfo/src/object.rs +++ b/symbolic-debuginfo/src/object.rs @@ -131,22 +131,22 @@ pub fn peek(data: &[u8], archive: bool) -> FileFormat { /// A generic object file providing uniform access to various file formats. #[allow(clippy::large_enum_variant)] #[derive(Debug)] -pub enum Object<'d> { +pub enum Object<'data> { /// Breakpad ASCII symbol. - Breakpad(BreakpadObject<'d>), + Breakpad(BreakpadObject<'data>), /// Executable and Linkable Format, used on Linux. - Elf(ElfObject<'d>), + Elf(ElfObject<'data>), /// Mach Objects, used on macOS and iOS derivatives. - MachO(MachObject<'d>), + MachO(MachObject<'data>), /// Program Database, the debug companion format on Windows. - Pdb(PdbObject<'d>), + Pdb(PdbObject<'data>), /// Portable Executable, an extension of COFF used on Windows. - Pe(PeObject<'d>), + Pe(PeObject<'data>), /// A source bundle - SourceBundle(SourceBundle<'d>), + SourceBundle(SourceBundle<'data>), } -impl<'d> Object<'d> { +impl<'data> Object<'data> { /// Tests whether the buffer could contain an object. pub fn test(data: &[u8]) -> bool { Self::peek(data) != FileFormat::Unknown @@ -158,7 +158,7 @@ impl<'d> Object<'d> { } /// Tries to parse a supported object from the given slice. - pub fn parse(data: &'d [u8]) -> Result { + pub fn parse(data: &'data [u8]) -> Result { macro_rules! parse_object { ($kind:ident, $file:ident, $data:expr) => { Object::$kind($file::parse(data).map_err(ObjectError::$kind)?) @@ -228,12 +228,12 @@ impl<'d> Object<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> SymbolIterator<'d, '_> { + pub fn symbols(&self) -> SymbolIterator<'data, '_> { map_inner!(self, Object(ref o) => SymbolIterator(o.symbols())) } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { match_inner!(self, Object(ref o) => o.symbol_map()) } @@ -255,7 +255,7 @@ impl<'d> Object<'d> { /// Constructing this session will also work if the object does not contain debugging /// information, in which case the session will be a no-op. This can be checked via /// [`has_debug_info`](enum.Object.html#method.has_debug_info). - pub fn debug_session(&self) -> Result, ObjectError> { + pub fn debug_session(&self) -> Result, ObjectError> { match *self { Object::Breakpad(ref o) => o .debug_session() @@ -295,12 +295,12 @@ impl<'d> Object<'d> { } /// Returns the raw data of the underlying buffer. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { match_inner!(self, Object(ref o) => o.data()) } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for Object<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for Object<'data> { type Ref = Object<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -308,9 +308,10 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for Object<'d> { } } -impl<'d> ObjectLike for Object<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for Object<'data> { type Error = ObjectError; - type Session = ObjectDebugSession<'d>; + type Session = ObjectDebugSession<'data>; + type SymbolIterator = SymbolIterator<'data, 'object>; fn file_format(&self) -> FileFormat { self.file_format() @@ -340,12 +341,12 @@ impl<'d> ObjectLike for Object<'d> { self.has_symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - unsafe { std::mem::transmute(Box::new(self.symbols()) as DynIterator<'_, _>) } + fn symbols(&'object self) -> Self::SymbolIterator { + self.symbols() } fn has_debug_info(&self) -> bool { @@ -500,17 +501,17 @@ impl<'s> Iterator for ObjectFileIterator<'s> { /// A generic symbol iterator #[allow(missing_docs)] -pub enum SymbolIterator<'d, 'o> { - Breakpad(BreakpadSymbolIterator<'d>), - Elf(ElfSymbolIterator<'d, 'o>), - MachO(MachOSymbolIterator<'d>), - Pdb(PdbSymbolIterator<'d, 'o>), - Pe(PeSymbolIterator<'d, 'o>), - SourceBundle(SourceBundleSymbolIterator<'d>), +pub enum SymbolIterator<'data, 'object> { + Breakpad(BreakpadSymbolIterator<'data>), + Elf(ElfSymbolIterator<'data, 'object>), + MachO(MachOSymbolIterator<'data>), + Pdb(PdbSymbolIterator<'data, 'object>), + Pe(PeSymbolIterator<'data, 'object>), + SourceBundle(SourceBundleSymbolIterator<'data>), } -impl<'d, 'o> Iterator for SymbolIterator<'d, 'o> { - type Item = Symbol<'d>; +impl<'data, 'object> Iterator for SymbolIterator<'data, 'object> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { match_inner!(self, SymbolIterator(ref mut iter) => iter.next()) diff --git a/symbolic-debuginfo/src/pdb.rs b/symbolic-debuginfo/src/pdb.rs index c3228171b..91cc9496d 100644 --- a/symbolic-debuginfo/src/pdb.rs +++ b/symbolic-debuginfo/src/pdb.rs @@ -22,7 +22,7 @@ use symbolic_common::{Arch, AsSelf, CodeId, CpuFamily, DebugId, Name, SelfCell, use crate::base::*; use crate::private::{FunctionStack, Parse}; -type Pdb<'d> = pdb::PDB<'d, Cursor<&'d [u8]>>; +type Pdb<'data> = pdb::PDB<'data, Cursor<&'data [u8]>>; const MAGIC_BIG: &[u8] = b"Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00"; @@ -50,12 +50,12 @@ pub enum PdbError { /// Program Database, the debug companion format on Windows. /// /// This object is a sole debug companion to [`PeObject`](../pdb/struct.PdbObject.html). -pub struct PdbObject<'d> { - pdb: Arc>>, - debug_info: Arc>, - pdb_info: pdb::PDBInformation<'d>, - public_syms: pdb::SymbolTable<'d>, - data: &'d [u8], +pub struct PdbObject<'data> { + pdb: Arc>>, + debug_info: Arc>, + pdb_info: pdb::PDBInformation<'data>, + public_syms: pdb::SymbolTable<'data>, + data: &'data [u8], } // NB: The pdb crate simulates mmap behavior on any Read + Seek type. This implementation requires @@ -65,7 +65,7 @@ pub struct PdbObject<'d> { unsafe impl Send for PdbObject<'_> {} unsafe impl Sync for PdbObject<'_> {} -impl<'d> PdbObject<'d> { +impl<'data> PdbObject<'data> { /// Tests whether the buffer could contain an PDB object. pub fn test(data: &[u8]) -> bool { // NB: "Microsoft C/C++ program database 2.00" is not supported by the pdb crate, so there @@ -74,7 +74,7 @@ impl<'d> PdbObject<'d> { } /// Tries to parse a PDB object from the given slice. - pub fn parse(data: &'d [u8]) -> Result { + pub fn parse(data: &'data [u8]) -> Result { let mut pdb = Pdb::open(Cursor::new(data))?; let dbi = pdb.debug_information()?; let pdbi = pdb.pdb_information()?; @@ -155,7 +155,7 @@ impl<'d> PdbObject<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> PdbSymbolIterator<'d, '_> { + pub fn symbols(&self) -> PdbSymbolIterator<'data, '_> { PdbSymbolIterator { symbols: self.public_syms.iter(), address_map: self.pdb.write().address_map().ok(), @@ -163,7 +163,7 @@ impl<'d> PdbObject<'d> { } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { self.symbols().collect() } @@ -182,7 +182,7 @@ impl<'d> PdbObject<'d> { } /// Constructs a debugging session. - pub fn debug_session(&self) -> Result, PdbError> { + pub fn debug_session(&self) -> Result, PdbError> { PdbDebugSession::build(self) } @@ -196,12 +196,12 @@ impl<'d> PdbObject<'d> { } /// Returns the raw data of the ELF file. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { self.data } #[doc(hidden)] - pub fn inner(&self) -> &RwLock> { + pub fn inner(&self) -> &RwLock> { &self.pdb } } @@ -219,7 +219,7 @@ impl fmt::Debug for PdbObject<'_> { } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for PdbObject<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for PdbObject<'data> { type Ref = PdbObject<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -227,21 +227,22 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for PdbObject<'d> { } } -impl<'d> Parse<'d> for PdbObject<'d> { +impl<'data> Parse<'data> for PdbObject<'data> { type Error = PdbError; fn test(data: &[u8]) -> bool { Self::test(data) } - fn parse(data: &'d [u8]) -> Result { + fn parse(data: &'data [u8]) -> Result { Self::parse(data) } } -impl<'d> ObjectLike for PdbObject<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for PdbObject<'data> { type Error = PdbError; - type Session = PdbDebugSession<'d>; + type Session = PdbDebugSession<'data>; + type SymbolIterator = PdbSymbolIterator<'data, 'object>; fn file_format(&self) -> FileFormat { self.file_format() @@ -271,12 +272,11 @@ impl<'d> ObjectLike for PdbObject<'d> { self.has_symbols() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - // TODO: Avoid this transmute by introducing explicit lifetimes on the trait. - unsafe { std::mem::transmute(Box::new(self.symbols()) as DynIterator<'_, _>) } + fn symbols(&'object self) -> Self::SymbolIterator { + self.symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } @@ -311,13 +311,13 @@ pub(crate) fn arch_from_machine(machine: MachineType) -> Arch { /// An iterator over symbols in the PDB file. /// /// Returned by [`PdbObject::symbols`](struct.PdbObject.html#method.symbols). -pub struct PdbSymbolIterator<'d, 'o> { - symbols: pdb::SymbolIter<'o>, - address_map: Option>, +pub struct PdbSymbolIterator<'data, 'object> { + symbols: pdb::SymbolIter<'object>, + address_map: Option>, } -impl<'d, 'o> Iterator for PdbSymbolIterator<'d, 'o> { - type Item = Symbol<'d>; +impl<'data, 'object> Iterator for PdbSymbolIterator<'data, 'object> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { let address_map = self.address_map.as_ref()?; @@ -336,7 +336,7 @@ impl<'d, 'o> Iterator for PdbSymbolIterator<'d, 'o> { let cow = public.name.to_string(); // pdb::SymbolIter offers data bound to its own lifetime since it holds the // buffer containing public symbols. The contract requires that we return - // `Symbol<'d>`, so we cannot return zero-copy symbols here. + // `Symbol<'data>`, so we cannot return zero-copy symbols here. let name = Cow::from(String::from(if cow.starts_with('_') { &cow[1..] } else { diff --git a/symbolic-debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs index 0d33ae460..57220e5c6 100644 --- a/symbolic-debuginfo/src/pe.rs +++ b/symbolic-debuginfo/src/pe.rs @@ -52,13 +52,13 @@ fn is_pe_stub(pe: &pe::PE<'_>) -> bool { /// While in rare instances, PE files might contain debug information, this case is not supported. /// /// [`PdbObject`]: ../pdb/struct.PdbObject.html -pub struct PeObject<'d> { - pe: pe::PE<'d>, - data: &'d [u8], +pub struct PeObject<'data> { + pe: pe::PE<'data>, + data: &'data [u8], is_stub: bool, } -impl<'d> PeObject<'d> { +impl<'data> PeObject<'data> { /// Tests whether the buffer could contain an PE object. pub fn test(data: &[u8]) -> bool { match goblin::peek(&mut Cursor::new(data)) { @@ -68,7 +68,7 @@ impl<'d> PeObject<'d> { } /// Tries to parse a PE object from the given slice. - pub fn parse(data: &'d [u8]) -> Result { + pub fn parse(data: &'data [u8]) -> Result { let pe = pe::PE::parse(data).map_err(PeError::BadObject)?; let is_stub = is_pe_stub(&pe); Ok(PeObject { pe, data, is_stub }) @@ -168,14 +168,14 @@ impl<'d> PeObject<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> PeSymbolIterator<'d, '_> { + pub fn symbols(&self) -> PeSymbolIterator<'data, '_> { PeSymbolIterator { exports: self.pe.exports.iter(), } } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { self.symbols().collect() } @@ -192,7 +192,7 @@ impl<'d> PeObject<'d> { } /// Constructs a no-op debugging session. - pub fn debug_session(&self) -> Result, PeError> { + pub fn debug_session(&self) -> Result, PeError> { Ok(PeDebugSession { _ph: PhantomData }) } @@ -202,7 +202,7 @@ impl<'d> PeObject<'d> { } /// Returns the raw data of the PE file. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { self.data } @@ -237,7 +237,7 @@ impl fmt::Debug for PeObject<'_> { } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for PeObject<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for PeObject<'data> { type Ref = PeObject<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -245,21 +245,22 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for PeObject<'d> { } } -impl<'d> Parse<'d> for PeObject<'d> { +impl<'data> Parse<'data> for PeObject<'data> { type Error = PeError; fn test(data: &[u8]) -> bool { Self::test(data) } - fn parse(data: &'d [u8]) -> Result { + fn parse(data: &'data [u8]) -> Result { Self::parse(data) } } -impl<'d> ObjectLike for PeObject<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for PeObject<'data> { type Error = PeError; - type Session = PeDebugSession<'d>; + type Session = PeDebugSession<'data>; + type SymbolIterator = PeSymbolIterator<'data, 'object>; fn file_format(&self) -> FileFormat { self.file_format() @@ -289,11 +290,11 @@ impl<'d> ObjectLike for PeObject<'d> { self.has_symbols() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + fn symbols(&'object self) -> Self::SymbolIterator { + self.symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } @@ -317,12 +318,12 @@ impl<'d> ObjectLike for PeObject<'d> { /// An iterator over symbols in the PE file. /// /// Returned by [`PeObject::symbols`](struct.PeObject.html#method.symbols). -pub struct PeSymbolIterator<'d, 'o> { - exports: std::slice::Iter<'o, pe::export::Export<'d>>, +pub struct PeSymbolIterator<'data, 'object> { + exports: std::slice::Iter<'object, pe::export::Export<'data>>, } -impl<'d, 'o> Iterator for PeSymbolIterator<'d, 'o> { - type Item = Symbol<'d>; +impl<'data, 'object> Iterator for PeSymbolIterator<'data, 'object> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { self.exports.next().map(|export| Symbol { @@ -338,11 +339,11 @@ impl<'d, 'o> Iterator for PeSymbolIterator<'d, 'o> { /// Since debug information in PE containers is not supported, this session consists of NoOps and /// always returns empty results. #[derive(Debug)] -pub struct PeDebugSession<'d> { - _ph: PhantomData<&'d ()>, +pub struct PeDebugSession<'data> { + _ph: PhantomData<&'data ()>, } -impl<'d> PeDebugSession<'d> { +impl<'data> PeDebugSession<'data> { /// Returns an iterator over all functions in this debug file. pub fn functions(&self) -> PeFunctionIterator<'_> { std::iter::empty() diff --git a/symbolic-debuginfo/src/sourcebundle.rs b/symbolic-debuginfo/src/sourcebundle.rs index d561ffc17..6b23133f0 100644 --- a/symbolic-debuginfo/src/sourcebundle.rs +++ b/symbolic-debuginfo/src/sourcebundle.rs @@ -286,10 +286,10 @@ struct SourceBundleManifest { /// /// [`SourceBundleWriter`]: struct.SourceBundleWriter.html /// [module level documentation]: index.html -pub struct SourceBundle<'d> { +pub struct SourceBundle<'data> { manifest: Arc, - archive: Arc>>>, - data: &'d [u8], + archive: Arc>>>, + data: &'data [u8], } impl fmt::Debug for SourceBundle<'_> { @@ -308,14 +308,14 @@ impl fmt::Debug for SourceBundle<'_> { } } -impl<'d> SourceBundle<'d> { +impl<'data> SourceBundle<'data> { /// Tests whether the buffer could contain a `SourceBundle`. pub fn test(bytes: &[u8]) -> bool { bytes.starts_with(&BUNDLE_MAGIC) } /// Tries to parse a `SourceBundle` from the given slice. - pub fn parse(data: &'d [u8]) -> Result, SourceBundleError> { + pub fn parse(data: &'data [u8]) -> Result, SourceBundleError> { let mut archive = zip::read::ZipArchive::new(std::io::Cursor::new(data)) .map_err(SourceBundleError::BadZip)?; let manifest_file = archive @@ -420,14 +420,14 @@ impl<'d> SourceBundle<'d> { } /// Returns an iterator over symbols in the public symbol table. - pub fn symbols(&self) -> SourceBundleSymbolIterator<'d> { + pub fn symbols(&self) -> SourceBundleSymbolIterator<'data> { SourceBundleSymbolIterator { _marker: std::marker::PhantomData, } } /// Returns an ordered map of symbols in the symbol table. - pub fn symbol_map(&self) -> SymbolMap<'d> { + pub fn symbol_map(&self) -> SymbolMap<'data> { self.symbols().collect() } @@ -443,7 +443,7 @@ impl<'d> SourceBundle<'d> { /// A debugging session loads certain information from the object file and creates caches for /// efficient access to various records in the debug information. Since this can be quite a /// costly process, try to reuse the debugging session as long as possible. - pub fn debug_session(&self) -> Result, SourceBundleError> { + pub fn debug_session(&self) -> Result, SourceBundleError> { Ok(SourceBundleDebugSession { manifest: self.manifest.clone(), archive: self.archive.clone(), @@ -462,7 +462,7 @@ impl<'d> SourceBundle<'d> { } /// Returns the raw data of the source bundle. - pub fn data(&self) -> &'d [u8] { + pub fn data(&self) -> &'data [u8] { self.data } @@ -472,7 +472,7 @@ impl<'d> SourceBundle<'d> { } } -impl<'slf, 'd: 'slf> AsSelf<'slf> for SourceBundle<'d> { +impl<'slf, 'data: 'slf> AsSelf<'slf> for SourceBundle<'data> { type Ref = SourceBundle<'slf>; fn as_self(&'slf self) -> &Self::Ref { @@ -480,21 +480,22 @@ impl<'slf, 'd: 'slf> AsSelf<'slf> for SourceBundle<'d> { } } -impl<'d> Parse<'d> for SourceBundle<'d> { +impl<'data> Parse<'data> for SourceBundle<'data> { type Error = SourceBundleError; - fn parse(data: &'d [u8]) -> Result { + fn parse(data: &'data [u8]) -> Result { SourceBundle::parse(data) } - fn test(data: &'d [u8]) -> bool { + fn test(data: &'data [u8]) -> bool { SourceBundle::test(data) } } -impl<'d> ObjectLike for SourceBundle<'d> { +impl<'data: 'object, 'object> ObjectLike<'data, 'object> for SourceBundle<'data> { type Error = SourceBundleError; - type Session = SourceBundleDebugSession<'d>; + type Session = SourceBundleDebugSession<'data>; + type SymbolIterator = SourceBundleSymbolIterator<'data>; fn file_format(&self) -> FileFormat { self.file_format() @@ -524,12 +525,12 @@ impl<'d> ObjectLike for SourceBundle<'d> { self.has_symbols() } - fn symbol_map(&self) -> SymbolMap<'_> { + fn symbol_map(&self) -> SymbolMap<'data> { self.symbol_map() } - fn symbols(&self) -> DynIterator<'_, Symbol<'_>> { - Box::new(self.symbols()) + fn symbols(&self) -> Self::SymbolIterator { + self.symbols() } fn has_debug_info(&self) -> bool { @@ -552,12 +553,12 @@ impl<'d> ObjectLike for SourceBundle<'d> { /// An iterator yielding symbols from a source bundle /// /// This is always yielding no results. -pub struct SourceBundleSymbolIterator<'d> { - _marker: std::marker::PhantomData<&'d [u8]>, +pub struct SourceBundleSymbolIterator<'data> { + _marker: std::marker::PhantomData<&'data [u8]>, } -impl<'d> Iterator for SourceBundleSymbolIterator<'d> { - type Item = Symbol<'d>; +impl<'data> Iterator for SourceBundleSymbolIterator<'data> { + type Item = Symbol<'data>; fn next(&mut self) -> Option { None @@ -567,13 +568,13 @@ impl<'d> Iterator for SourceBundleSymbolIterator<'d> { impl std::iter::FusedIterator for SourceBundleSymbolIterator<'_> {} /// Debug session for SourceBundle objects. -pub struct SourceBundleDebugSession<'d> { +pub struct SourceBundleDebugSession<'data> { manifest: Arc, - archive: Arc>>>, + archive: Arc>>>, files_by_path: LazyCell>, } -impl<'d> SourceBundleDebugSession<'d> { +impl<'data> SourceBundleDebugSession<'data> { /// Returns an iterator over all source files in this debug file. pub fn files(&self) -> SourceBundleFileIterator<'_> { SourceBundleFileIterator { @@ -637,7 +638,7 @@ impl<'d> SourceBundleDebugSession<'d> { } } -impl<'d> DebugSession for SourceBundleDebugSession<'d> { +impl<'data> DebugSession for SourceBundleDebugSession<'data> { type Error = SourceBundleError; fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { @@ -862,10 +863,14 @@ where /// sources could be resolved. Otherwise, an error is returned if writing the bundle fails. /// /// This finishes the source bundle and flushes the underlying writer. - pub fn write_object(self, object: &O, object_name: &str) -> Result + pub fn write_object<'data, 'object, O, E>( + self, + object: &'object O, + object_name: &str, + ) -> Result where - O: ObjectLike, - O::Error: std::error::Error + Send + Sync + 'static, + O: ObjectLike<'data, 'object, Error = E>, + E: std::error::Error + Send + Sync + 'static, { self.write_object_with_filter(object, object_name, |_| true) } @@ -878,14 +883,14 @@ where /// This finishes the source bundle and flushes the underlying writer. /// /// Before a file is written a callback is invoked which can return `false` to skip a file. - pub fn write_object_with_filter( + pub fn write_object_with_filter<'data, 'object, O, F>( mut self, - object: &O, + object: &'object O, object_name: &str, mut filter: F, ) -> Result where - O: ObjectLike, + O: ObjectLike<'data, 'object>, O::Error: std::error::Error + Send + Sync + 'static, F: FnMut(&FileEntry) -> bool, { diff --git a/symbolic-minidump/src/cfi.rs b/symbolic-minidump/src/cfi.rs index c067ea6c4..5615f64bd 100644 --- a/symbolic-minidump/src/cfi.rs +++ b/symbolic-minidump/src/cfi.rs @@ -131,9 +131,9 @@ struct UnwindInfo { } impl UnwindInfo { - pub fn new(object: &O, addr: u64, mut section: U) -> Self + pub fn new<'d: 'o, 'o, O, R>(object: &O, addr: u64, mut section: U) -> Self where - O: ObjectLike, + O: ObjectLike<'d, 'o>, R: Reader, U: UnwindSectionExt, { @@ -236,9 +236,9 @@ impl AsciiCfiWriter { Ok(()) } - fn process_dwarf<'o, O>(&mut self, object: &O) -> Result<(), CfiError> + fn process_dwarf<'d: 'o, 'o, O>(&mut self, object: &O) -> Result<(), CfiError> where - O: ObjectLike + Dwarf<'o>, + O: ObjectLike<'d, 'o> + Dwarf<'o>, { let endian = object.endianity(); diff --git a/symbolic-symcache/src/writer.rs b/symbolic-symcache/src/writer.rs index b3abd5193..617151298 100644 --- a/symbolic-symcache/src/writer.rs +++ b/symbolic-symcache/src/writer.rs @@ -194,9 +194,9 @@ where W: Write + Seek, { /// Converts an entire object into a SymCache. - pub fn write_object(object: &O, target: W) -> Result + pub fn write_object<'d, 'o, O>(object: &'o O, target: W) -> Result where - O: ObjectLike, + O: ObjectLike<'d, 'o>, O::Error: std::error::Error + Send + Sync + 'static, { let mut writer = SymCacheWriter::new(target)?; From af741b93ab5cb43c15de6d14c0002482dd05d9d4 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 9 Oct 2020 13:29:45 +0200 Subject: [PATCH 16/22] fix: Implement new clippy advice (#280) --- symbolic-common/src/heuristics.rs | 5 +---- symbolic-common/src/types.rs | 16 ++++++++-------- symbolic-debuginfo/src/elf.rs | 8 ++++---- symbolic-debuginfo/src/macho.rs | 16 ++++++++-------- symbolic-debuginfo/src/pe.rs | 5 +---- symbolic-minidump/src/processor.rs | 5 +---- symbolic-unreal/src/container.rs | 8 ++++---- 7 files changed, 27 insertions(+), 36 deletions(-) diff --git a/symbolic-common/src/heuristics.rs b/symbolic-common/src/heuristics.rs index 3e6790f14..63e48d26e 100644 --- a/symbolic-common/src/heuristics.rs +++ b/symbolic-common/src/heuristics.rs @@ -262,10 +262,7 @@ impl InstructionInfo { /// assert!(is_crash); /// ``` pub fn is_crash_signal(&self) -> bool { - match self.signal { - Some(SIGILL) | Some(SIGBUS) | Some(SIGSEGV) => true, - _ => false, - } + matches!(self.signal, Some(SIGILL) | Some(SIGBUS) | Some(SIGSEGV)) } /// Determines whether the given address should be adjusted to resolve the call site of a stack diff --git a/symbolic-common/src/types.rs b/symbolic-common/src/types.rs index 2bb2d2a70..525c2da43 100644 --- a/symbolic-common/src/types.rs +++ b/symbolic-common/src/types.rs @@ -427,15 +427,15 @@ impl Arch { /// assert!(!Arch::X86Unknown.well_known()); /// ``` pub fn well_known(self) -> bool { - match self { + !matches!( + self, Arch::Unknown - | Arch::ArmUnknown - | Arch::Arm64Unknown - | Arch::X86Unknown - | Arch::Amd64Unknown - | Arch::Arm64_32Unknown => false, - _ => true, - } + | Arch::ArmUnknown + | Arch::Arm64Unknown + | Arch::X86Unknown + | Arch::Amd64Unknown + | Arch::Arm64_32Unknown + ) } } diff --git a/symbolic-debuginfo/src/elf.rs b/symbolic-debuginfo/src/elf.rs index 362ba870d..7761cb46f 100644 --- a/symbolic-debuginfo/src/elf.rs +++ b/symbolic-debuginfo/src/elf.rs @@ -56,10 +56,10 @@ pub struct ElfObject<'data> { impl<'data> ElfObject<'data> { /// Tests whether the buffer could contain an ELF object. pub fn test(data: &[u8]) -> bool { - match goblin::peek(&mut Cursor::new(data)) { - Ok(goblin::Hint::Elf(_)) => true, - _ => false, - } + matches!( + goblin::peek(&mut Cursor::new(data)), + Ok(goblin::Hint::Elf(_)) + ) } /// Tries to parse an ELF object from the given slice. diff --git a/symbolic-debuginfo/src/macho.rs b/symbolic-debuginfo/src/macho.rs index 7df684360..0672c4685 100644 --- a/symbolic-debuginfo/src/macho.rs +++ b/symbolic-debuginfo/src/macho.rs @@ -32,10 +32,10 @@ pub struct MachObject<'d> { impl<'d> MachObject<'d> { /// Tests whether the buffer could contain a MachO object. pub fn test(data: &[u8]) -> bool { - match goblin::peek(&mut Cursor::new(data)) { - Ok(goblin::Hint::Mach(_)) => true, - _ => false, - } + matches!( + goblin::peek(&mut Cursor::new(data)), + Ok(goblin::Hint::Mach(_)) + ) } /// Tries to parse a MachO from the given slice. @@ -479,10 +479,10 @@ pub struct FatMachO<'d> { impl<'d> FatMachO<'d> { /// Tests whether the buffer could contain an ELF object. pub fn test(data: &[u8]) -> bool { - match goblin::peek(&mut Cursor::new(data)) { - Ok(goblin::Hint::MachFat(_)) => true, - _ => false, - } + matches!( + goblin::peek(&mut Cursor::new(data)), + Ok(goblin::Hint::MachFat(_)) + ) } /// Tries to parse a fat MachO container from the given slice. diff --git a/symbolic-debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs index 57220e5c6..418ae3c3d 100644 --- a/symbolic-debuginfo/src/pe.rs +++ b/symbolic-debuginfo/src/pe.rs @@ -61,10 +61,7 @@ pub struct PeObject<'data> { impl<'data> PeObject<'data> { /// Tests whether the buffer could contain an PE object. pub fn test(data: &[u8]) -> bool { - match goblin::peek(&mut Cursor::new(data)) { - Ok(goblin::Hint::PE) => true, - _ => false, - } + matches!(goblin::peek(&mut Cursor::new(data)), Ok(goblin::Hint::PE)) } /// Tries to parse a PE object from the given slice. diff --git a/symbolic-minidump/src/processor.rs b/symbolic-minidump/src/processor.rs index fcaf4b2bc..d3b508ddb 100644 --- a/symbolic-minidump/src/processor.rs +++ b/symbolic-minidump/src/processor.rs @@ -736,10 +736,7 @@ impl ProcessResult { /// Depending on the result, the process state might only contain partial information. For a /// full minidump, check for `ProcessResult::Ok` instead. pub fn is_usable(self) -> bool { - match self { - ProcessResult::Ok | ProcessResult::NoThreadList => true, - _ => false, - } + matches!(self, ProcessResult::Ok | ProcessResult::NoThreadList) } } diff --git a/symbolic-unreal/src/container.rs b/symbolic-unreal/src/container.rs index 132a189e1..1910cbee2 100644 --- a/symbolic-unreal/src/container.rs +++ b/symbolic-unreal/src/container.rs @@ -357,10 +357,10 @@ fn test_parse_empty_buffer() { let result = Unreal4Crash::parse(crash); - assert!(match result.expect_err("empty crash") { - Unreal4Error::Empty => true, - _ => false, - }) + assert!(matches!( + result.expect_err("empty crash"), + Unreal4Error::Empty + )) } #[test] From 744e4adb599d9a76ec7484839da52d866362e710 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Tue, 13 Oct 2020 12:31:18 +0200 Subject: [PATCH 17/22] ref: Add File/FunctionIterator and lifetimes to DebugSession (#279) --- symbolic-debuginfo/src/base.rs | 14 ++++-- symbolic-debuginfo/src/breakpad.rs | 20 +++++---- symbolic-debuginfo/src/dwarf.rs | 18 ++++---- symbolic-debuginfo/src/object.rs | 12 +++--- symbolic-debuginfo/src/pdb.rs | 12 +++--- symbolic-debuginfo/src/pe.rs | 12 +++--- symbolic-debuginfo/src/sourcebundle.rs | 59 +++++++------------------- 7 files changed, 68 insertions(+), 79 deletions(-) diff --git a/symbolic-debuginfo/src/base.rs b/symbolic-debuginfo/src/base.rs index c8923fe72..f8a61d399 100644 --- a/symbolic-debuginfo/src/base.rs +++ b/symbolic-debuginfo/src/base.rs @@ -602,10 +602,16 @@ pub type DynIterator<'a, T> = Box + 'a>; /// - Read headers of compilation units (compilands) to resolve cross-unit references. /// /// [`ObjectLike::debug_session`]: trait.ObjectLike.html#tymethod.debug_session -pub trait DebugSession { +pub trait DebugSession<'session> { /// The error returned when reading debug information fails. type Error; + /// An iterator over all functions in this debug file. + type FunctionIterator: Iterator, Self::Error>>; + + /// An iterator over all source files referenced by this debug file. + type FileIterator: Iterator, Self::Error>>; + /// Returns an iterator over all functions in this debug file. /// /// Functions are iterated in the order they are declared in their compilation units. The @@ -613,10 +619,10 @@ pub trait DebugSession { /// /// Note that the iterator holds a mutable borrow on the debug session, which allows it to use /// caches and optimize resources while resolving function and line information. - fn functions(&self) -> DynIterator<'_, Result, Self::Error>>; + fn functions(&'session self) -> Self::FunctionIterator; /// Returns an iterator over all source files referenced by this debug file. - fn files(&self) -> DynIterator<'_, Result, Self::Error>>; + fn files(&'session self) -> Self::FileIterator; /// Looks up a file's source contents by its full canonicalized path. /// @@ -630,7 +636,7 @@ pub trait ObjectLike<'data, 'object> { type Error; /// A session that allows optimized access to debugging information. - type Session: DebugSession; + type Session: for<'session> DebugSession<'session, Error = Self::Error>; /// The iterator over the symbols in the public symbol table. type SymbolIterator: Iterator>; diff --git a/symbolic-debuginfo/src/breakpad.rs b/symbolic-debuginfo/src/breakpad.rs index 512f0a565..4dcba113a 100644 --- a/symbolic-debuginfo/src/breakpad.rs +++ b/symbolic-debuginfo/src/breakpad.rs @@ -1050,12 +1050,12 @@ impl<'data> Iterator for BreakpadSymbolIterator<'data> { } /// Debug session for Breakpad objects. -pub struct BreakpadDebugSession<'d> { - file_map: BreakpadFileMap<'d>, - func_records: BreakpadFuncRecords<'d>, +pub struct BreakpadDebugSession<'data> { + file_map: BreakpadFileMap<'data>, + func_records: BreakpadFuncRecords<'data>, } -impl<'d> BreakpadDebugSession<'d> { +impl<'data> BreakpadDebugSession<'data> { /// Returns an iterator over all functions in this debug file. pub fn functions(&self) -> BreakpadFunctionIterator<'_> { BreakpadFunctionIterator { @@ -1079,15 +1079,17 @@ impl<'d> BreakpadDebugSession<'d> { } } -impl<'d> DebugSession for BreakpadDebugSession<'d> { +impl<'data, 'session> DebugSession<'session> for BreakpadDebugSession<'data> { type Error = BreakpadError; + type FunctionIterator = BreakpadFunctionIterator<'session>; + type FileIterator = BreakpadFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.functions()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.files()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { diff --git a/symbolic-debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs index 32d224860..aa5484adc 100644 --- a/symbolic-debuginfo/src/dwarf.rs +++ b/symbolic-debuginfo/src/dwarf.rs @@ -1115,16 +1115,16 @@ pub struct DwarfDebugSession<'data> { cell: SelfCell>, DwarfInfo<'data>>, } -impl<'d> DwarfDebugSession<'d> { +impl<'data> DwarfDebugSession<'data> { /// Parses a dwarf debugging information from the given DWARF file. pub fn parse( dwarf: &D, - symbol_map: SymbolMap<'d>, + symbol_map: SymbolMap<'data>, load_address: u64, kind: ObjectKind, ) -> Result where - D: Dwarf<'d>, + D: Dwarf<'data>, { let sections = DwarfSections::from_dwarf(dwarf)?; let cell = SelfCell::try_new(Box::new(sections), |sections| { @@ -1161,15 +1161,17 @@ impl<'d> DwarfDebugSession<'d> { } } -impl<'data> DebugSession for DwarfDebugSession<'data> { +impl<'data, 'session> DebugSession<'session> for DwarfDebugSession<'data> { type Error = DwarfError; + type FunctionIterator = DwarfFunctionIterator<'session>; + type FileIterator = DwarfFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.functions()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.files()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { diff --git a/symbolic-debuginfo/src/object.rs b/symbolic-debuginfo/src/object.rs index a26519cb0..cd20ef4c3 100644 --- a/symbolic-debuginfo/src/object.rs +++ b/symbolic-debuginfo/src/object.rs @@ -426,15 +426,17 @@ impl<'d> ObjectDebugSession<'d> { } } -impl DebugSession for ObjectDebugSession<'_> { +impl<'session> DebugSession<'session> for ObjectDebugSession<'_> { type Error = ObjectError; + type FunctionIterator = ObjectFunctionIterator<'session>; + type FileIterator = ObjectFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.functions()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.files()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { diff --git a/symbolic-debuginfo/src/pdb.rs b/symbolic-debuginfo/src/pdb.rs index 91cc9496d..d5346fcad 100644 --- a/symbolic-debuginfo/src/pdb.rs +++ b/symbolic-debuginfo/src/pdb.rs @@ -598,15 +598,17 @@ impl<'d> PdbDebugSession<'d> { } } -impl DebugSession for PdbDebugSession<'_> { +impl<'session> DebugSession<'session> for PdbDebugSession<'_> { type Error = PdbError; + type FunctionIterator = PdbFunctionIterator<'session>; + type FileIterator = PdbFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.functions()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.files()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { diff --git a/symbolic-debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs index 418ae3c3d..a25f5d017 100644 --- a/symbolic-debuginfo/src/pe.rs +++ b/symbolic-debuginfo/src/pe.rs @@ -359,15 +359,17 @@ impl<'data> PeDebugSession<'data> { } } -impl DebugSession for PeDebugSession<'_> { +impl<'session> DebugSession<'session> for PeDebugSession<'_> { type Error = PeError; + type FunctionIterator = PeFunctionIterator<'session>; + type FileIterator = PeFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(std::iter::empty()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(std::iter::empty()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { diff --git a/symbolic-debuginfo/src/sourcebundle.rs b/symbolic-debuginfo/src/sourcebundle.rs index 6b23133f0..b47d9e7d7 100644 --- a/symbolic-debuginfo/src/sourcebundle.rs +++ b/symbolic-debuginfo/src/sourcebundle.rs @@ -421,9 +421,7 @@ impl<'data> SourceBundle<'data> { /// Returns an iterator over symbols in the public symbol table. pub fn symbols(&self) -> SourceBundleSymbolIterator<'data> { - SourceBundleSymbolIterator { - _marker: std::marker::PhantomData, - } + std::iter::empty() } /// Returns an ordered map of symbols in the symbol table. @@ -550,22 +548,8 @@ impl<'data: 'object, 'object> ObjectLike<'data, 'object> for SourceBundle<'data> } } -/// An iterator yielding symbols from a source bundle -/// -/// This is always yielding no results. -pub struct SourceBundleSymbolIterator<'data> { - _marker: std::marker::PhantomData<&'data [u8]>, -} - -impl<'data> Iterator for SourceBundleSymbolIterator<'data> { - type Item = Symbol<'data>; - - fn next(&mut self) -> Option { - None - } -} - -impl std::iter::FusedIterator for SourceBundleSymbolIterator<'_> {} +/// An iterator yielding symbols from a source bundle. +pub type SourceBundleSymbolIterator<'data> = std::iter::Empty>; /// Debug session for SourceBundle objects. pub struct SourceBundleDebugSession<'data> { @@ -584,9 +568,7 @@ impl<'data> SourceBundleDebugSession<'data> { /// Returns an iterator over all functions in this debug file. pub fn functions(&self) -> SourceBundleFunctionIterator<'_> { - SourceBundleFunctionIterator { - _marker: std::marker::PhantomData, - } + std::iter::empty() } /// Create a reverse mapping of source paths to ZIP paths. @@ -638,15 +620,17 @@ impl<'data> SourceBundleDebugSession<'data> { } } -impl<'data> DebugSession for SourceBundleDebugSession<'data> { +impl<'data, 'session> DebugSession<'session> for SourceBundleDebugSession<'data> { type Error = SourceBundleError; + type FunctionIterator = SourceBundleFunctionIterator<'session>; + type FileIterator = SourceBundleFileIterator<'session>; - fn functions(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.functions()) + fn functions(&'session self) -> Self::FunctionIterator { + self.functions() } - fn files(&self) -> DynIterator<'_, Result, Self::Error>> { - Box::new(self.files()) + fn files(&'session self) -> Self::FileIterator { + self.files() } fn source_by_path(&self, path: &str) -> Result>, Self::Error> { @@ -672,19 +656,8 @@ impl<'s> Iterator for SourceBundleFileIterator<'s> { } /// An iterator over functions in a SourceBundle object. -pub struct SourceBundleFunctionIterator<'d> { - _marker: std::marker::PhantomData<&'d [u8]>, -} - -impl<'s> Iterator for SourceBundleFunctionIterator<'s> { - type Item = Result, SourceBundleError>; - - fn next(&mut self) -> Option { - None - } -} - -impl std::iter::FusedIterator for SourceBundleFunctionIterator<'_> {} +pub type SourceBundleFunctionIterator<'s> = + std::iter::Empty, SourceBundleError>>; impl SourceBundleManifest { /// Creates a new, empty manifest. @@ -883,15 +856,15 @@ where /// This finishes the source bundle and flushes the underlying writer. /// /// Before a file is written a callback is invoked which can return `false` to skip a file. - pub fn write_object_with_filter<'data, 'object, O, F>( + pub fn write_object_with_filter<'data, 'object, O, E, F>( mut self, object: &'object O, object_name: &str, mut filter: F, ) -> Result where - O: ObjectLike<'data, 'object>, - O::Error: std::error::Error + Send + Sync + 'static, + O: ObjectLike<'data, 'object, Error = E>, + E: std::error::Error + Send + Sync + 'static, F: FnMut(&FileEntry) -> bool, { let mut files_handled = BTreeSet::new(); From 390e3c7817cacd1772b8e59d38d12cfa36c6c671 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Mon, 19 Oct 2020 15:41:05 +0200 Subject: [PATCH 18/22] feat(demangle): Update swift demangler to 5.3 (#282) --- symbolic-demangle/vendor/swift/.gitignore | 1 + .../vendor/swift/1-arguments.patch | 24 +- symbolic-demangle/vendor/swift/README.md | 10 +- .../vendor/swift/include/llvm-c/DataTypes.h | 90 --- .../vendor/swift/include/llvm/ADT/Optional.h | 2 +- .../vendor/swift/include/llvm/ADT/STLExtras.h | 631 +++++++++++++++--- .../swift/include/llvm/ADT/SmallVector.h | 107 ++- .../vendor/swift/include/llvm/ADT/StringRef.h | 38 +- .../vendor/swift/include/llvm/ADT/iterator.h | 20 +- .../swift/include/llvm/Config/llvm-config.h | 10 +- .../swift/include/llvm/Support/Casting.h | 64 +- .../swift/include/llvm/Support/Compiler.h | 88 +-- .../swift/include/llvm/Support/DataTypes.h | 16 - .../include/llvm/Support/ErrorHandling.h | 11 +- .../swift/include/llvm/Support/MathExtras.h | 82 ++- .../swift/include/llvm/Support/MemAlloc.h | 23 +- .../include/llvm/Support/SwapByteOrder.h | 160 ----- .../swift/include/llvm/Support/raw_ostream.h | 93 +-- .../swift/include/llvm/Support/type_traits.h | 13 +- .../swift/include/swift/Basic/STLExtras.h | 86 +-- .../swift/include/swift/Demangling/Demangle.h | 3 + .../swift/Demangling/DemangleNodes.def | 12 + .../include/swift/Demangling/Demangler.h | 6 +- .../swift/include/swift/Runtime/Config.h | 99 +++ .../vendor/swift/lib/Demangling/Demangler.cpp | 133 ++-- .../swift/lib/Demangling/NodeDumper.cpp | 6 + .../swift/lib/Demangling/NodePrinter.cpp | 143 +++- .../swift/lib/Demangling/OldRemangler.cpp | 53 +- .../vendor/swift/lib/Demangling/Remangler.cpp | 115 +++- .../stdlib/public/SwiftShims/Visibility.h | 2 +- symbolic-demangle/vendor/swift/update.py | 2 +- 31 files changed, 1356 insertions(+), 787 deletions(-) create mode 100644 symbolic-demangle/vendor/swift/.gitignore delete mode 100644 symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h delete mode 100644 symbolic-demangle/vendor/swift/include/llvm/Support/DataTypes.h delete mode 100644 symbolic-demangle/vendor/swift/include/llvm/Support/SwapByteOrder.h diff --git a/symbolic-demangle/vendor/swift/.gitignore b/symbolic-demangle/vendor/swift/.gitignore new file mode 100644 index 000000000..a3efd38a8 --- /dev/null +++ b/symbolic-demangle/vendor/swift/.gitignore @@ -0,0 +1 @@ +swift-source diff --git a/symbolic-demangle/vendor/swift/1-arguments.patch b/symbolic-demangle/vendor/swift/1-arguments.patch index 9faaee417..337870584 100644 --- a/symbolic-demangle/vendor/swift/1-arguments.patch +++ b/symbolic-demangle/vendor/swift/1-arguments.patch @@ -1,13 +1,13 @@ -commit 575a6035e76e73eacc99d43a412d0afa2068dd25 -Author: Jan Michael Auer -Date: Sun Apr 5 16:39:15 2020 +0200 +commit af26ebbf5f3bb03c92739b19127f5c2c5b402e4a +Author: Arpad Borsos +Date: Mon Oct 19 13:28:23 2020 +0200 feat(demangle): Add option to skip Swift function parameters -diff --git a/demangle/vendor/swift/include/swift/Demangling/Demangle.h b/demangle/vendor/swift/include/swift/Demangling/Demangle.h -index 2a8fd6c..c377a00 100644 ---- a/demangle/vendor/swift/include/swift/Demangling/Demangle.h -+++ b/demangle/vendor/swift/include/swift/Demangling/Demangle.h +diff --git a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h +index ce3a4b5..df88a9c 100644 +--- a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h ++++ b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h @@ -57,6 +57,7 @@ struct DemangleOptions { bool ShortenArchetype = false; bool ShowPrivateDiscriminators = true; @@ -16,11 +16,11 @@ index 2a8fd6c..c377a00 100644 std::function GenericParameterName = genericParameterName; -diff --git a/demangle/vendor/swift/lib/Demangling/NodePrinter.cpp b/demangle/vendor/swift/lib/Demangling/NodePrinter.cpp -index 097be7f..266506e 100644 ---- a/demangle/vendor/swift/lib/Demangling/NodePrinter.cpp -+++ b/demangle/vendor/swift/lib/Demangling/NodePrinter.cpp -@@ -728,6 +728,11 @@ private: +diff --git a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp +index 1e39291..0784608 100644 +--- a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp ++++ b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp +@@ -738,6 +738,11 @@ private: setInvalid(); return; } diff --git a/symbolic-demangle/vendor/swift/README.md b/symbolic-demangle/vendor/swift/README.md index 182edd58a..3bc62550c 100644 --- a/symbolic-demangle/vendor/swift/README.md +++ b/symbolic-demangle/vendor/swift/README.md @@ -3,7 +3,7 @@ This folder contains a vendored subset of the [Swift Programming Language]. The Swift library is reduced to the demangler only to reduce the size of this package. -The current version is **Swift 5.2.1**. +The current version is **Swift 5.3**. ## Sentry Modifications @@ -23,11 +23,11 @@ patch is maintained in `1-arguments.patch`. ``` 3. Check out dependencies: ``` - $ ./swift/utils/update-checkout --clone-with-ssh + $ ./swift/utils/update-checkout --clone ``` - 4. Check out the release banch of the latest release: + 4. Check out the release branch of the latest release: ``` - $ git checkout swift-5.2.1-RELEASE + $ git checkout swift-5.3-RELEASE ``` 5. Build the complete swift project (be very patient, this may take long): ``` @@ -37,7 +37,7 @@ patch is maintained in `1-arguments.patch`. 2. **Copy updated sources and headers from the checkout to this library:** 1. Run the update script in this directory (requires Python 3): ``` - $ ./update.py + $ ./update.py swift-source ``` 2. Check for modifications. 3. Commit _"feat(demangle): Import libswift demangle x.x.x"_ before proceeding. diff --git a/symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h b/symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h deleted file mode 100644 index 893b22b49..000000000 --- a/symbolic-demangle/vendor/swift/include/llvm-c/DataTypes.h +++ /dev/null @@ -1,90 +0,0 @@ -/*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\ -|* *| -|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| -|* Exceptions. *| -|* See https://llvm.org/LICENSE.txt for license information. *| -|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This file contains definitions to figure out the size of _HOST_ data types.*| -|* This file is important because different host OS's define different macros,*| -|* which makes portability tough. This file exports the following *| -|* definitions: *| -|* *| -|* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*| -|* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *| -|* *| -|* No library is required when using these functions. *| -|* *| -|*===----------------------------------------------------------------------===*/ - -/* Please leave this file C-compatible. */ - -#ifndef LLVM_C_DATATYPES_H -#define LLVM_C_DATATYPES_H - -#ifdef __cplusplus -#include -#else -#include -#endif - -#include -#include - -#ifndef _MSC_VER - -#if !defined(UINT32_MAX) -# error "The standard header is not C++11 compliant. Must #define "\ - "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h" -#endif - -#if !defined(UINT32_C) -# error "The standard header is not C++11 compliant. Must #define "\ - "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h" -#endif - -/* Note that includes , if this is a C99 system. */ -#include - -#ifdef _AIX -// GCC is strict about defining large constants: they must have LL modifier. -#undef INT64_MAX -#undef INT64_MIN -#endif - -#else /* _MSC_VER */ -#ifdef __cplusplus -#include -#include -#else -#include -#include -#endif -#include - -#if defined(_WIN64) -typedef signed __int64 ssize_t; -#else -typedef signed int ssize_t; -#endif /* _WIN64 */ - -#endif /* _MSC_VER */ - -/* Set defaults for constants which we cannot find. */ -#if !defined(INT64_MAX) -# define INT64_MAX 9223372036854775807LL -#endif -#if !defined(INT64_MIN) -# define INT64_MIN ((-INT64_MAX)-1) -#endif -#if !defined(UINT64_MAX) -# define UINT64_MAX 0xffffffffffffffffULL -#endif - -#ifndef HUGE_VALF -#define HUGE_VALF (float)HUGE_VAL -#endif - -#endif /* LLVM_C_DATATYPES_H */ diff --git a/symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h index c84f9aa8b..c64b82352 100644 --- a/symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h +++ b/symbolic-demangle/vendor/swift/include/llvm/ADT/Optional.h @@ -269,7 +269,7 @@ template class Optional { /// Apply a function to the value if present; otherwise return None. template - auto map(const Function &F) const + auto map(const Function &F) const LLVM_LVALUE_FUNCTION -> Optional { if (*this) return F(getValue()); return None; diff --git a/symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h b/symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h index b61dab245..50b688b36 100644 --- a/symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h +++ b/symbolic-demangle/vendor/swift/include/llvm/ADT/STLExtras.h @@ -50,6 +50,10 @@ namespace detail { template using IterOfRange = decltype(std::begin(std::declval())); +template +using ValueOfRange = typename std::remove_reference()))>::type; + } // end namespace detail //===----------------------------------------------------------------------===// @@ -75,6 +79,79 @@ template struct make_const_ref { typename std::add_const::type>::type; }; +/// Utilities for detecting if a given trait holds for some set of arguments +/// 'Args'. For example, the given trait could be used to detect if a given type +/// has a copy assignment operator: +/// template +/// using has_copy_assign_t = decltype(std::declval() +/// = std::declval()); +/// bool fooHasCopyAssign = is_detected::value; +namespace detail { +template using void_t = void; +template class Op, class... Args> struct detector { + using value_t = std::false_type; +}; +template