Skip to content

Commit

Permalink
Fix fbcode TARGETS for compiling with procfs 0.15.1
Browse files Browse the repository at this point in the history
Summary:
- Fix top level dirs:
  - frl_ee_infra
  - fbcode_devx
  - hermetic_infra
  - hphp/hack
  - remote_execution
  - service_capacity/projection_framework

Going to need to lean on people to help test here once CI passes ...

Reviewed By: aijayadams

Differential Revision: D49899458

fbshipit-source-id: 4eaa7c3b07bfcf5d23c4ed71a9050ffa2b9ac777
  • Loading branch information
cooperlees authored and facebook-github-bot committed Oct 4, 2023
1 parent bda439e commit 74d1642
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
17 changes: 13 additions & 4 deletions reverie-ptrace/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn show_proc_maps(maps: &procfs::process::MemoryMap) -> String {
_ => String::from(""),
};
let s = format!(
"{:x}-{:x} {} {:08x} {:02x}:{:02x} {}",
"{:x}-{:x} {:?} {:08x} {:02x}:{:02x} {}",
maps.address.0, maps.address.1, maps.perms, maps.offset, maps.dev.0, maps.dev.1, maps.inode
);
res.push_str(&s);
Expand All @@ -98,7 +98,11 @@ fn task_rip_is_valid(pid: Pid, rip: u64) -> bool {
if let Ok(mapping) = procfs::process::Process::new(pid.as_raw()).and_then(|p| p.maps()) {
has_valid_rip = mapping
.iter()
.find(|e| e.perms.contains('x') && e.address.0 <= rip && e.address.1 > rip + 0x10)
.find(|e| {
e.perms.contains(procfs::process::MMPermissions::EXECUTE)
&& e.address.0 <= rip
&& e.address.1 > rip + 0x10
})
.cloned();
}
has_valid_rip.is_some()
Expand Down Expand Up @@ -136,8 +140,13 @@ pub fn show_fault_context(task: &Stopped, sig: signal::Signal) {
}

procfs::process::Process::new(task.pid().as_raw())
.and_then(|p| p.maps())
.unwrap_or_else(|_| Vec::new())
.map_or_else(
|_| Vec::new(),
|p| match p.maps() {
Ok(maps) => maps.memory_maps,
Err(_) => Vec::new(),
},
)
.iter()
.for_each(|e| {
debug!("{}", show_proc_maps(e));
Expand Down
27 changes: 21 additions & 6 deletions reverie-ptrace/src/vdso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ lazy_static! {
fn vdso_get_symbols_info() -> HashMap<&'static str, (u64, usize)> {
let mut res = HashMap::new();
procfs::process::Process::new(unistd::getpid().as_raw())
.and_then(|p| p.maps())
.unwrap_or_else(|_| Vec::new())
.map_or_else(
|_| Vec::new(),
|p| match p.maps() {
Ok(maps) => maps.memory_maps,
Err(_) => Vec::new(),
},
)
.iter()
.find(|e| e.pathname == procfs::process::MMapPath::Vdso)
.and_then(|vdso| {
Expand Down Expand Up @@ -243,8 +248,13 @@ where
T: Tool,
{
if let Some(vdso) = procfs::process::Process::new(guest.pid().as_raw())
.and_then(|p| p.maps())
.unwrap_or_else(|_| Vec::new())
.map_or_else(
|_| Vec::new(),
|p| match p.maps() {
Ok(maps) => maps.memory_maps,
Err(_) => Vec::new(),
},
)
.iter()
.find(|e| e.pathname == procfs::process::MMapPath::Vdso)
{
Expand Down Expand Up @@ -304,8 +314,13 @@ mod tests {
fn can_find_vdso() {
assert!(
procfs::process::Process::new(unistd::getpid().as_raw())
.and_then(|p| p.maps())
.unwrap_or_else(|_| Vec::new())
.map_or_else(
|_| Vec::new(),
|p| match p.maps() {
Ok(maps) => maps.memory_maps,
Err(_) => Vec::new(),
},
)
.iter()
.any(|e| e.pathname == procfs::process::MMapPath::Vdso)
);
Expand Down

0 comments on commit 74d1642

Please sign in to comment.