| 1 |
/** |
| 2 |
* sfunction set_user_string - Writes a string to user memory |
| 3 |
* @addr: The user address to write the string to |
| 4 |
* @val: The string which is to be written |
| 5 |
* |
| 6 |
* Description: Writes the given string to a given user memory address. |
| 7 |
* Reports an error when writing to the given address fails. |
| 8 |
* Requires the use of guru mode (-g). |
| 9 |
*/ |
| 10 |
function set_user_string (addr:long, val:string) %{ /* guru */ |
| 11 |
__label__ deref_fault; |
| 12 |
store_uderef_string (STAP_ARG_val, STAP_ARG_addr, MAXSTRINGLEN); |
| 13 |
if (0) { |
| 14 |
deref_fault: /* branched to from store_deref_string() */ |
| 15 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 16 |
"user string copy fault at 0x%lx [man error::fault]", (uintptr_t) STAP_ARG_addr); |
| 17 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 18 |
} |
| 19 |
%} |
| 20 |
|
| 21 |
/** |
| 22 |
* sfunction set_user_string_n - Writes a string of given length to user memory |
| 23 |
* @addr: The user address to write the string to |
| 24 |
* @n: The maximum length of the string |
| 25 |
* @val: The string which is to be written |
| 26 |
* |
| 27 |
* Description: Writes the given string up to a maximum given length to a given |
| 28 |
* user memory address. Reports an error on string copy fault. |
| 29 |
* Requires the use of guru mode (-g). |
| 30 |
*/ |
| 31 |
function set_user_string_n (addr:long, n:long, val:string) %{ /* guru */ |
| 32 |
__label__ deref_fault; |
| 33 |
int64_t len = clamp_t(int64_t, STAP_ARG_n + 1, 1, MAXSTRINGLEN); |
| 34 |
store_uderef_string (STAP_ARG_val, STAP_ARG_addr, len); |
| 35 |
if (0) { |
| 36 |
deref_fault: /* branched to from store_deref_string() */ |
| 37 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 38 |
"user string copy fault at 0x%lx [man error::fault]", (uintptr_t) STAP_ARG_addr); |
| 39 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 40 |
} |
| 41 |
%} |
| 42 |
|
| 43 |
/** |
| 44 |
* sfunction set_user_string_arg - Writes a string to user memory. |
| 45 |
* @addr: The user address to write the string to |
| 46 |
* @val: The string which is to be written |
| 47 |
* |
| 48 |
* Description: Writes the given string to a given user memory address. |
| 49 |
* Reports a warning on string copy fault. |
| 50 |
* Requires the use of guru mode (-g). |
| 51 |
*/ |
| 52 |
function set_user_string_arg (addr:long, val:string) { /* guru */ |
| 53 |
if (val != user_string_nofault(addr)) { |
| 54 |
try { |
| 55 |
set_user_string_n(addr, strlen(val), val) |
| 56 |
} catch { |
| 57 |
warn(sprintf("unable to write %s to 0x%lx", val, addr)) |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* sfunction set_user_long - Writes a long value to user memory |
| 64 |
* @addr: The user address to write the long to |
| 65 |
* @val: The long which is to be written |
| 66 |
* |
| 67 |
* Description: Writes the long value to a given user memory address. |
| 68 |
* Reports an error when writing to the given address fails. |
| 69 |
* Requires the use of guru mode (-g). |
| 70 |
*/ |
| 71 |
function set_user_long (addr:long, val:long) %{ /* guru */ |
| 72 |
__label__ deref_fault; |
| 73 |
uwrite((long *) (uintptr_t) STAP_ARG_addr, STAP_ARG_val); |
| 74 |
if (0) { |
| 75 |
deref_fault: /* branched to from uwrite() */ |
| 76 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 77 |
"user long copy fault at 0x%p [man error::fault]", (void *) (uintptr_t) STAP_ARG_addr); |
| 78 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 79 |
} |
| 80 |
%} |
| 81 |
|
| 82 |
/** |
| 83 |
* sfunction set_user_int - Writes an int value to user memory |
| 84 |
* @addr: The user address to write the int to |
| 85 |
* @val: The int which is to be written |
| 86 |
* |
| 87 |
* Description: Writes the int value to a given user memory address. |
| 88 |
* Reports an error when writing to the given address fails. |
| 89 |
* Requires the use of guru mode (-g). |
| 90 |
*/ |
| 91 |
function set_user_int (addr:long, val:long) %{ /* guru */ |
| 92 |
__label__ deref_fault; |
| 93 |
uwrite((int *) (uintptr_t) STAP_ARG_addr, STAP_ARG_val); |
| 94 |
if (0) { |
| 95 |
deref_fault: /* branched to from uwrite() */ |
| 96 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 97 |
"user int copy fault at 0x%p [man error::fault]", (void *) (uintptr_t) STAP_ARG_addr); |
| 98 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 99 |
} |
| 100 |
%} |
| 101 |
|
| 102 |
/** |
| 103 |
* sfunction set_user_short - Writes a short value to user memory |
| 104 |
* @addr: The user address to write the short to |
| 105 |
* @val: The short which is to be written |
| 106 |
* |
| 107 |
* Description: Writes the short value to a given user memory address. |
| 108 |
* Reports an error when writing to the given address fails. |
| 109 |
* Requires the use of guru mode (-g). |
| 110 |
*/ |
| 111 |
function set_user_short (addr:long, val:long) %{ /* guru */ |
| 112 |
__label__ deref_fault; |
| 113 |
uwrite((short *) (uintptr_t) STAP_ARG_addr, STAP_ARG_val); |
| 114 |
if (0) { |
| 115 |
deref_fault: /* branched to from uwrite() */ |
| 116 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 117 |
"user short copy fault at 0x%p [man error::fault]", (void *) (uintptr_t) STAP_ARG_addr); |
| 118 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 119 |
} |
| 120 |
%} |
| 121 |
|
| 122 |
/** |
| 123 |
* sfunction set_user_char - Writes a char value to user memory |
| 124 |
* @addr: The user address to write the char to |
| 125 |
* @val: The char which is to be written |
| 126 |
* |
| 127 |
* Description: Writes the char value to a given user memory address. |
| 128 |
* Reports an error when writing to the given address fails. |
| 129 |
* Requires the use of guru mode (-g). |
| 130 |
*/ |
| 131 |
function set_user_char (addr:long, val:long) %{ /* guru */ |
| 132 |
__label__ deref_fault; |
| 133 |
uwrite((char *) (uintptr_t) STAP_ARG_addr, STAP_ARG_val); |
| 134 |
if (0) { |
| 135 |
deref_fault: /* branched to from uwrite() */ |
| 136 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 137 |
"user char copy fault at 0x%p [man error::fault]", (void *) (uintptr_t) STAP_ARG_addr); |
| 138 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 139 |
} |
| 140 |
%} |
| 141 |
|
| 142 |
/** |
| 143 |
* sfunction set_user_pointer - Writes a pointer value to user memory. |
| 144 |
* @addr: The user address to write the pointer to |
| 145 |
* @val: The pointer which is to be written |
| 146 |
* |
| 147 |
* Description: Writes the pointer value to a given user memory address. |
| 148 |
* Reports an error when writing to the given address fails. |
| 149 |
* Requires the use of guru mode (-g). |
| 150 |
*/ |
| 151 |
function set_user_pointer (addr:long, val:long) %{ /* guru */ |
| 152 |
__label__ deref_fault; |
| 153 |
uwrite((void **) (uintptr_t) STAP_ARG_addr, (uintptr_t)STAP_ARG_val); |
| 154 |
if (0) { |
| 155 |
deref_fault: /* branched to from uwrite() */ |
| 156 |
snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), |
| 157 |
"user pointer copy fault at 0x%p [man error::fault]", (void *) (uintptr_t) STAP_ARG_addr); |
| 158 |
CONTEXT->last_error = CONTEXT->error_buffer; |
| 159 |
} |
| 160 |
%} |
| 161 |
|