|
|
@ -1,4 +1,5 @@
|
|
|
|
use core::ffi::c_void;
|
|
|
|
use core::ffi::c_void;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{bindings::pt_regs, BpfContext};
|
|
|
|
use crate::{bindings::pt_regs, BpfContext};
|
|
|
|
|
|
|
|
|
|
|
|
pub struct ProbeContext {
|
|
|
|
pub struct ProbeContext {
|
|
|
@ -50,7 +51,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM1")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM1")]
|
|
|
|
/// Utility to get the First Parameter
|
|
|
|
/// Utility to get the First Parameter
|
|
|
|
pub unsafe fn parm1(&self) -> *const c_void {
|
|
|
|
pub fn parm1(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rdi as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rdi as *const c_void;
|
|
|
@ -61,7 +62,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM2")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM2")]
|
|
|
|
/// Utility to get the Second Parameter
|
|
|
|
/// Utility to get the Second Parameter
|
|
|
|
pub unsafe fn parm2(&self) -> *const c_void {
|
|
|
|
pub fn parm2(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rsi as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rsi as *const c_void;
|
|
|
@ -72,7 +73,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM3")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM3")]
|
|
|
|
/// Utility to get the Third Parameter
|
|
|
|
/// Utility to get the Third Parameter
|
|
|
|
pub unsafe fn parm3(&self) -> *const c_void {
|
|
|
|
pub fn parm3(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rdx as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rdx as *const c_void;
|
|
|
@ -83,7 +84,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM4")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM4")]
|
|
|
|
/// Utility to get the Fourth Parameter
|
|
|
|
/// Utility to get the Fourth Parameter
|
|
|
|
pub unsafe fn parm4(&self) -> *const c_void {
|
|
|
|
pub fn parm4(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rcx as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rcx as *const c_void;
|
|
|
@ -94,7 +95,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM5")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM5")]
|
|
|
|
/// Utility to get the Fifth Parameter
|
|
|
|
/// Utility to get the Fifth Parameter
|
|
|
|
pub unsafe fn parm5(&self) -> *const c_void {
|
|
|
|
pub fn parm5(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.r8 as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.r8 as *const c_void;
|
|
|
@ -105,7 +106,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_PARM6")]
|
|
|
|
#[doc(alias = "PT_REGS_PARM6")]
|
|
|
|
/// Utility to get the Sixth Parameter (not available for s390x)
|
|
|
|
/// Utility to get the Sixth Parameter (not available for s390x)
|
|
|
|
pub unsafe fn parm6(&self) -> *const c_void {
|
|
|
|
pub fn parm6(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.r9 as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.r9 as *const c_void;
|
|
|
@ -119,7 +120,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_RET")]
|
|
|
|
#[doc(alias = "PT_REGS_RET")]
|
|
|
|
/// Utility to get the Stack Pointer
|
|
|
|
/// Utility to get the Stack Pointer
|
|
|
|
pub unsafe fn ret(&self) -> *const c_void {
|
|
|
|
pub fn ret(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rsp as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rsp as *const c_void;
|
|
|
@ -131,7 +132,7 @@ impl Regs {
|
|
|
|
#[doc(alias = "PT_REGS_FP")]
|
|
|
|
#[doc(alias = "PT_REGS_FP")]
|
|
|
|
/// Utility to get the Frame Pointer
|
|
|
|
/// Utility to get the Frame Pointer
|
|
|
|
/// Only available with CONFIG_FRAME_POINTER enabled on kernel.
|
|
|
|
/// Only available with CONFIG_FRAME_POINTER enabled on kernel.
|
|
|
|
pub unsafe fn fp(&self) -> *const c_void {
|
|
|
|
pub fn fp(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rbp as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rbp as *const c_void;
|
|
|
@ -154,7 +155,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_IP")]
|
|
|
|
#[doc(alias = "PT_REGS_IP")]
|
|
|
|
/// Utility to get the Instruction Pointer register
|
|
|
|
/// Utility to get the Instruction Pointer register
|
|
|
|
pub unsafe fn ip(&self) -> *const c_void {
|
|
|
|
pub fn ip(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rip as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rip as *const c_void;
|
|
|
@ -165,7 +166,7 @@ impl Regs {
|
|
|
|
|
|
|
|
|
|
|
|
#[doc(alias = "PT_REGS_SP")]
|
|
|
|
#[doc(alias = "PT_REGS_SP")]
|
|
|
|
/// Utility to get the Stack Pointer
|
|
|
|
/// Utility to get the Stack Pointer
|
|
|
|
pub unsafe fn sp(&self) -> *const c_void {
|
|
|
|
pub fn sp(&self) -> *const c_void {
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
// assert!(self.regs.is_null(),"You should ensure that the registers are not null");
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
|
|
|
return unsafe { &*(self.regs) }.rsp as *const c_void;
|
|
|
|
return unsafe { &*(self.regs) }.rsp as *const c_void;
|
|
|
|