diff options
author | hunt <hunt> | 2005-03-29 18:07:58 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-03-29 18:07:58 +0000 |
commit | e32551b18f4560056d2d482f5e1505b1b98fa82a (patch) | |
tree | 4e9e07a9b46a4fd5dea27732571cbb04c0ef5dee /runtime/current.c | |
parent | 13b35bb112459702e7371ecc89d7deb789818a86 (diff) | |
download | systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.tar.gz systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.tar.xz systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.zip |
*** empty log message ***
Diffstat (limited to 'runtime/current.c')
-rw-r--r-- | runtime/current.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/current.c b/runtime/current.c new file mode 100644 index 00000000..78820c40 --- /dev/null +++ b/runtime/current.c @@ -0,0 +1,34 @@ +#ifndef _CURRENT_C_ +#define _CURRENT_C_ + +/* -*- linux-c -*- */ +/** @file current.c + * @brief Functions to get the current state. + */ +/** @addtogroup current Current State + * Functions to get the current state. + * @{ + */ + + +/** Get the current return address. + * Call from kprobes (not jprobes). + * @param regs The pt_regs saved by the kprobe. + * @return The return address saved in esp or rsp. + * @note i386 and x86_64 only so far. + */ + +unsigned long _stp_ret_addr (struct pt_regs *regs) +{ +#ifdef __x86_64__ + unsigned long *ra = (unsigned long *)regs->rsp; +#else + unsigned long *ra = (unsigned long *)regs->esp; +#endif + if (ra) + return *ra; + else + return 0; +} +/** @} */ +#endif /* _CURRENT_C_ */ |