00001 #ifndef _CURRENT_C_ 00002 #define _CURRENT_C_ 00003 00004 /* -*- linux-c -*- */ 00005 /** @file current.c 00006 * @brief Functions to get the current state. 00007 */ 00008 /** @addtogroup current Current State 00009 * Functions to get the current state. 00010 * @{ 00011 */ 00012 00013 00014 /** Get the current return address. 00015 * Call from kprobes (not jprobes). 00016 * @param regs The pt_regs saved by the kprobe. 00017 * @return The return address saved in esp or rsp. 00018 * @note i386 and x86_64 only so far. 00019 */ 00020 00021 unsigned long _stp_ret_addr (struct pt_regs *regs) 00022 { 00023 #ifdef __x86_64__ 00024 unsigned long *ra = (unsigned long *)regs->rsp; 00025 #else 00026 unsigned long *ra = (unsigned long *)regs->esp; 00027 #endif 00028 if (ra) 00029 return *ra; 00030 else 00031 return 0; 00032 } 00033 /** @} */ 00034 #endif /* _CURRENT_C_ */