In raspberry :why the function `getregs` in module `ptrace` not found in `ptrace`

backgroud

about raspberry pi :Linux raspberrypi 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l GNU/Linux
cargo.toml:

[dependencies]
nix = "0.19.1"
libc = "0.2.68"
rustyline = "8.2.0"
gimli = { git = "https://github.com/gimli-rs/gimli", rev = "ad23cdb2", default-features = false, features = ["read"] }
object = { version = "0.25.3", default-features = false, features = ["read"] }
memmap = "0.7"
addr2line = "0.15.0"

problem

in function:

use nix::sys::ptrace;
--snip--
...
pub fn wait(&self, options: Option<WaitPidFlag>) -> Result<Status, nix::Error> {
        Ok(match waitpid(self.pid(), options)? {
            WaitStatus::Exited(_pid, exit_code) => Status::Exited(exit_code),
            WaitStatus::Signaled(_pid, signal, _core_dumped) => Status::Signaled(signal),
            WaitStatus::Stopped(_pid, signal) => {
                let regs = ptrace::**getregs**(self.pid())?;
                Status::Stopped(signal, regs.rip as usize)
            }
            other => panic!("waitpid returned unexpected status: {:?}", other),
        })
    }

have problem

cannot find function `getregs` in module `ptrace`
not found in `ptrace`

in ptrace ,the mod.rs

///! Provides helpers for making ptrace system calls 

#[cfg(any(target_os = "android", target_os = "linux"))]
mod linux;

#[cfg(any(target_os = "android", target_os = "linux"))]
pub use self::linux::*;

#[cfg(any(target_os = "dragonfly",
          target_os = "freebsd",
          target_os = "macos",
          target_os = "netbsd",
          target_os = "openbsd"))]
mod bsd;

#[cfg(any(target_os = "dragonfly",
          target_os = "freebsd",
          target_os = "macos",
          target_os = "netbsd",
          target_os = "openbsd"
          ))]
pub use self::bsd::*;

get into the linux mod ,found that in linux.rs ,the getregs existes

pub fn getregs(pid: Pid) -> Result<user_regs_struct> {
    ptrace_get_data::<user_regs_struct>(Request::PTRACE_GETREGS, pid)
}

I have tried to make the linux mod public in the ptrace mod,still got the problem

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.