Skip to content

Commit

Permalink
Remove FindAddrOpts::obj_file_name flag
Browse files Browse the repository at this point in the history
It's unclear what we gain from making the object file name retrieval
conditional: the string is readily present unconditionally and so all we
save is an allocation. On top of that, this flag isn't even exposed so
it's complexity for nothing. Remove it.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o authored and danielocfb committed Oct 27, 2023
1 parent ee5c0f0 commit f6aa44b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 10 deletions.
2 changes: 0 additions & 2 deletions src/dwarf/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ mod tests {
.join("test-stable-addresses-dwarf-only.bin");
let opts = FindAddrOpts {
offset_in_file: false,
obj_file_name: false,
sym_type: SymType::Function,
};
let resolver = DwarfResolver::open(test_dwarf.as_ref(), true).unwrap();
Expand All @@ -318,7 +317,6 @@ mod tests {
.join("test-stable-addresses-dwarf-only.bin");
let opts = FindAddrOpts {
offset_in_file: false,
obj_file_name: false,
sym_type: SymType::Variable,
};
let resolver = DwarfResolver::open(test_dwarf.as_ref(), true).unwrap();
Expand Down
4 changes: 1 addition & 3 deletions src/elf/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ impl SymResolver for ElfResolver {
sym.file_offset = off;
}
}
if opts.obj_file_name {
sym.obj_file_name = Some(self.file_name.clone())
}
sym.obj_file_name = Some(self.file_name.clone())
});
Ok(syms)
}
Expand Down
1 change: 0 additions & 1 deletion src/inspect/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl Inspector {
pub fn lookup(&self, names: &[&str], src: &Source) -> Result<Vec<Vec<SymInfo>>> {
let opts = FindAddrOpts {
offset_in_file: true,
obj_file_name: true,
sym_type: SymType::Unknown,
};

Expand Down
2 changes: 0 additions & 2 deletions src/inspect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ pub(crate) struct FindAddrOpts {
/// Return the offset of the symbol from the first byte of the
/// object file if it is true. (False by default)
pub offset_in_file: bool,
/// Return the name of the object file if it is true. (False by default)
pub obj_file_name: bool,
/// Return the symbol(s) matching a given type. Unknown, by default,
/// means all types.
pub sym_type: SymType,
Expand Down
1 change: 0 additions & 1 deletion src/ksym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ mod tests {
let name = sym.name.clone();
let opts = FindAddrOpts {
offset_in_file: false,
obj_file_name: false,
sym_type: SymType::Function,
};
let found = resolver.find_addr(&name, &opts).unwrap();
Expand Down
1 change: 0 additions & 1 deletion src/normalize/normalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ mod tests {
let opts = FindAddrOpts {
sym_type: SymType::Function,
offset_in_file: true,
..Default::default()
};
let syms = elf_parser.find_addr("the_answer", &opts).unwrap();
// There is only one symbol with this address in there.
Expand Down

0 comments on commit f6aa44b

Please sign in to comment.