/usr/share/systemtap/tapset/linux/kretprobe.stp is in systemtap-common 2.6-0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | // kretprobe data tapset
// Copyright (C) 2009, 2011 Red Hat Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
// This is an internally-used tapset for sharing data between kretprobe
// entry / return handlers. See the function
// dwarf_var_expanding_visitor::gen_kretprobe_saved_return
// for details.
//
// Note, invalid calls are silently ignored...
%{
static void *
_kretprobe_data(struct kretprobe_instance *pi, size_t offset, size_t length)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
size_t end = offset + length;
if (end > offset && pi && end <= pi->rp->data_size)
return &pi->data[offset];
#endif
return NULL;
}
%}
function _get_kretprobe_long:long(i:long) %{ /* pure */
size_t offset = STAP_ARG_i * sizeof(int64_t);
const int64_t *data = _kretprobe_data(CONTEXT->ips.krp.pi, offset, sizeof(int64_t));
STAP_RETVALUE = data ? *data : 0;
%}
function _set_kretprobe_long(i:long, value:long) %{ /* impure */
size_t offset = STAP_ARG_i * sizeof(int64_t);
int64_t *data = _kretprobe_data(CONTEXT->ips.krp.pi, offset, sizeof(int64_t));
if (data)
*data = STAP_ARG_value;
%}
function _get_kretprobe_string:string(i:long) %{ /* pure */
size_t offset = CONTEXT->ips.krp.pi_longs * sizeof(int64_t) +
STAP_ARG_i * MAXSTRINGLEN;
const char *data = _kretprobe_data(CONTEXT->ips.krp.pi, offset, MAXSTRINGLEN);
strlcpy(STAP_RETVALUE, data ?: "", MAXSTRINGLEN);
%}
function _set_kretprobe_string(i:long, value:string) %{ /* impure */
size_t offset = CONTEXT->ips.krp.pi_longs * sizeof(int64_t) +
STAP_ARG_i * MAXSTRINGLEN;
char *data = _kretprobe_data(CONTEXT->ips.krp.pi, offset, MAXSTRINGLEN);
if (data)
strlcpy(data, STAP_ARG_value, MAXSTRINGLEN);
%}
|