Skip to content

Commit

Permalink
fix: dump-sources for non-embedded sources
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Feb 15, 2023
1 parent 174e3b6 commit 9ef7c86
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/commands/debug_files/dump_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
}

fn print_object_sources(object: &Object) -> Result<()> {
if !object.has_sources() {
let debug_session = object.debug_session()?;

// We're not using object.has_sources() because it only reports on embedded sources, not referenced files.
if debug_session.files().next().is_none() {
println!(
"{} {} has no sources.",
object.file_format(),
Expand All @@ -59,11 +62,10 @@ fn print_object_sources(object: &Object) -> Result<()> {
object.file_format(),
object.debug_id()
);
let debug_session = object.debug_session()?;
for file in debug_session.files() {
let file = file?;
println!(" {}", file.path_str());
let abs_path = file.abs_path_str();
println!(" {}", &abs_path);
match debug_session.source_by_path(abs_path.as_str())? {
Some(source) => {
println!(" Embedded, {} bytes", source.len());
Expand All @@ -72,7 +74,7 @@ fn print_object_sources(object: &Object) -> Result<()> {
if Path::new(&abs_path).exists() {
println!(" Not embedded, but available on the local disk.");
} else {
println!(" Not available in file or on disk.");
println!(" Not embedded nor available locally at the referenced path.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```
$ SENTRY_ALLOW_FAILURE=1 sentry-cli debug-files dump-sources tests/integration/_fixtures/Sentry.Samples.Console.Basic-embedded-ppdb-with-sources.dll
$ sentry-cli debug-files dump-sources tests/integration/_fixtures/Sentry.Samples.Console.Basic-embedded-ppdb-with-sources.dll
? success
pe 623535c7-c0ea-4dee-b99b-4669e99a7ecc-a878d1fa has no sources.
portablepdb 623535c7-c0ea-4dee-b99b-4669e99a7ecc-a878d1fa references sources:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```
$ sentry-cli debug-files dump-sources tests/integration/_fixtures/Sentry.Samples.Console.Basic.pdb
? success
portablepdb 54fdf14a-41a1-426a-a073-8185e11a89d6-83920e6f references sources:
C:/dev/sentry-dotnet/samples/Sentry.Samples.Console.Basic/Program.cs
Not embedded nor available locally at the referenced path.
C:/dev/sentry-dotnet/samples/Sentry.Samples.Console.Basic/obj/Release/net6.0/Sentry.Samples.Console.Basic.GlobalUsings.g.cs
Not embedded nor available locally at the referenced path.
C:/dev/sentry-dotnet/samples/Sentry.Samples.Console.Basic/obj/Release/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
Not embedded nor available locally at the referenced path.
C:/dev/sentry-dotnet/samples/Sentry.Samples.Console.Basic/obj/Release/net6.0/Sentry.Samples.Console.Basic.AssemblyInfo.cs
Not embedded nor available locally at the referenced path.

```
1 change: 1 addition & 0 deletions tests/integration/debug_files/dump_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ use crate::integration::register_test;
#[test]
fn command_debug_files_dump_sources() {
register_test("debug_files/debug_files-dump_sources-dll-embedded-ppdb-with-sources.trycmd");
register_test("debug_files/debug_files-dump_sources-ppdb.trycmd");
}

0 comments on commit 9ef7c86

Please sign in to comment.