Skip to content

Commit

Permalink
examples/rust: provide file name context
Browse files Browse the repository at this point in the history
The tracecon example tries to read the glibc library
"/lib/x86_64-linux-gnu/libc.so.6", but normally in rpm
system it is located in "/lib64/libc.so.6"
  • Loading branch information
rogercoll authored and anakryiko committed Mar 15, 2022
1 parent 84d69aa commit d6f8b82
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/rust/tracecon/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, bail, Result};
use anyhow::{anyhow, bail, Context, Result};
use core::time::Duration;
use libbpf_rs::PerfBufferBuilder;
use object::Object;
Expand Down Expand Up @@ -46,7 +46,8 @@ fn bump_memlock_rlimit() -> Result<()> {

fn get_symbol_address(so_path: &str, fn_name: &str) -> Result<usize> {
let path = Path::new(so_path);
let buffer = fs::read(path)?;
let buffer =
fs::read(path).with_context(|| format!("could not read file `{}`", path.display()))?;
let file = object::File::parse(buffer.as_slice())?;

let mut symbols = file.dynamic_symbols();
Expand Down

0 comments on commit d6f8b82

Please sign in to comment.