Skip to content

Commit

Permalink
Report proper unsupported error from GsymResolver::find_addr()
Browse files Browse the repository at this point in the history
Report a proper error from GsymResolver::find_addr(), which currently
isn't supported. This functionality should not be accessible through
public functions, so there shouldn't be any change in perceived
semantics to users.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o authored and danielocfb committed Jan 9, 2024
1 parent 03604a5 commit 60cb30b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/gsym/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::symbolize::IntSym;
use crate::symbolize::Reason;
use crate::symbolize::SrcLang;
use crate::Addr;
use crate::Error;
use crate::IntoError as _;
use crate::Result;
use crate::SymResolver;
Expand Down Expand Up @@ -204,7 +205,9 @@ impl SymResolver for GsymResolver<'_> {
) -> Result<Vec<SymInfo<'slf>>> {
// It is inefficient to find the address of a symbol with
// Gsym. We may support it in the future if needed.
Ok(Vec::new())
Err(Error::with_unsupported(
"Gsym resolver does not currently support lookup by name",
))
}

#[cfg_attr(feature = "tracing", crate::log::instrument(skip(self), fields(file = debug(&self.file_name))))]
Expand Down Expand Up @@ -340,6 +343,8 @@ mod tests {

use test_log::test;

use crate::ErrorKind;


/// Exercise the `Debug` representation of various types.
#[test]
Expand Down Expand Up @@ -429,9 +434,9 @@ mod tests {
.join("data")
.join("test-stable-addresses.gsym");
let resolver = GsymResolver::new(test_gsym).unwrap();
let syms = resolver
let err = resolver
.find_addr("factorial", &FindAddrOpts::default())
.unwrap();
assert_eq!(syms, Vec::new());
.unwrap_err();
assert_eq!(err.kind(), ErrorKind::Unsupported);
}
}

0 comments on commit 60cb30b

Please sign in to comment.