| 1 |
function check(name, value, expected) |
| 2 |
{ |
| 3 |
if (value == expected) |
| 4 |
printf ("sdt_asm PASS: %s\n", name) |
| 5 |
else |
| 6 |
printf ("sdt_asm FAIL: %s (%#x != %#x)\n", name, value, expected) |
| 7 |
} |
| 8 |
|
| 9 |
probe process(@1).mark("a") |
| 10 |
{ |
| 11 |
check("ah", $arg1, 0x30) |
| 12 |
check("al", $arg2, 0x40) |
| 13 |
check("ax", $arg3, 0x3040) |
| 14 |
check("eax", $arg4, 0x10203040) |
| 15 |
} |
| 16 |
|
| 17 |
probe process(@1).mark("rax") ? |
| 18 |
{ |
| 19 |
check("rax", $arg1, 0x1020304010203040) |
| 20 |
} |
| 21 |
|
| 22 |
probe process(@1).mark("b") |
| 23 |
{ |
| 24 |
check("bh", $arg1, 0x31) |
| 25 |
check("bl", $arg2, 0x41) |
| 26 |
check("bx", $arg3, 0x3141) |
| 27 |
check("ebx", $arg4, 0x11213141) |
| 28 |
} |
| 29 |
|
| 30 |
probe process(@1).mark("rbx") ? |
| 31 |
{ |
| 32 |
check("rbx", $arg1, 0x1121314111213141) |
| 33 |
} |
| 34 |
|
| 35 |
probe process(@1).mark("c") |
| 36 |
{ |
| 37 |
check("ch", $arg1, 0x32) |
| 38 |
check("cl", $arg2, 0x42) |
| 39 |
check("cx", $arg3, 0x3242) |
| 40 |
check("ecx", $arg4, 0x12223242) |
| 41 |
} |
| 42 |
|
| 43 |
probe process(@1).mark("rcx") ? |
| 44 |
{ |
| 45 |
check("rcx", $arg1, 0x1222324212223242) |
| 46 |
} |
| 47 |
|
| 48 |
probe process(@1).mark("d") |
| 49 |
{ |
| 50 |
check("dh", $arg1, 0x33) |
| 51 |
check("dl", $arg2, 0x43) |
| 52 |
check("dx", $arg3, 0x3343) |
| 53 |
check("edx", $arg4, 0x13233343) |
| 54 |
} |
| 55 |
|
| 56 |
probe process(@1).mark("rdx") ? |
| 57 |
{ |
| 58 |
check("rdx", $arg1, 0x1323334313233343) |
| 59 |
} |
| 60 |
|
| 61 |
probe process(@1).mark("si") |
| 62 |
{ |
| 63 |
check("sil", $arg1, 0x44) |
| 64 |
check("si", $arg2, 0x3444) |
| 65 |
check("esi", $arg3, 0x14243444) |
| 66 |
} |
| 67 |
|
| 68 |
probe process(@1).mark("rsi") ? |
| 69 |
{ |
| 70 |
check("rsi", $arg1, 0x1424344414243444) |
| 71 |
} |
| 72 |
|
| 73 |
probe process(@1).mark("di") |
| 74 |
{ |
| 75 |
check("dil", $arg1, 0x45) |
| 76 |
check("di", $arg2, 0x3545) |
| 77 |
check("edi", $arg3, 0x15253545) |
| 78 |
} |
| 79 |
|
| 80 |
probe process(@1).mark("rdi") ? |
| 81 |
{ |
| 82 |
check("rdi", $arg1, 0x1525354515253545) |
| 83 |
} |
| 84 |
|
| 85 |
probe process(@1).mark("bp") |
| 86 |
{ |
| 87 |
check("bp", $arg1, 0x3646) |
| 88 |
check("ebp", $arg2, 0x16263646) |
| 89 |
} |
| 90 |
|
| 91 |
probe process(@1).mark("rbp") ? |
| 92 |
{ |
| 93 |
check("rbp", $arg1, 0x1626364616263646) |
| 94 |
} |
| 95 |
|
| 96 |
# Dyninst can't deal with the corrupted sp here. |
| 97 |
# (maybe in the future it could use a private stack?) |
| 98 |
%( runtime != "dyninst" %? |
| 99 |
probe process(@1).mark("sp") |
| 100 |
{ |
| 101 |
check("sp", $arg1, 0x3747) |
| 102 |
check("esp", $arg2, 0x17273747) |
| 103 |
} |
| 104 |
|
| 105 |
probe process(@1).mark("rsp") ? |
| 106 |
{ |
| 107 |
check("rsp", $arg1, 0x1727374717273747) |
| 108 |
} |
| 109 |
%) |
| 110 |
|
| 111 |
probe process(@1).mark("r8") ? |
| 112 |
{ |
| 113 |
check("r8b", $arg1, 0x48) |
| 114 |
check("r8w", $arg2, 0x3848) |
| 115 |
check("r8d", $arg3, 0x18283848) |
| 116 |
check("r8x", $arg4, 0x1828384818283848) |
| 117 |
} |
| 118 |
|
| 119 |
probe process(@1).mark("r9") ? |
| 120 |
{ |
| 121 |
check("r9b", $arg1, 0x49) |
| 122 |
check("r9w", $arg2, 0x3949) |
| 123 |
check("r9d", $arg3, 0x19293949) |
| 124 |
check("r9x", $arg4, 0x1929394919293949) |
| 125 |
} |
| 126 |
|
| 127 |
probe process(@1).mark("r10") ? |
| 128 |
{ |
| 129 |
check("r10b", $arg1, 0x4a) |
| 130 |
check("r10w", $arg2, 0x3a4a) |
| 131 |
check("r10d", $arg3, 0x1a2a3a4a) |
| 132 |
check("r10x", $arg4, 0x1a2a3a4a1a2a3a4a) |
| 133 |
} |
| 134 |
|
| 135 |
probe process(@1).mark("r11") ? |
| 136 |
{ |
| 137 |
check("r11b", $arg1, 0x4b) |
| 138 |
check("r11w", $arg2, 0x3b4b) |
| 139 |
check("r11d", $arg3, 0x1b2b3b4b) |
| 140 |
check("r11x", $arg4, 0x1b2b3b4b1b2b3b4b) |
| 141 |
} |
| 142 |
|
| 143 |
probe process(@1).mark("r12") ? |
| 144 |
{ |
| 145 |
check("r12b", $arg1, 0x4c) |
| 146 |
check("r12w", $arg2, 0x3c4c) |
| 147 |
check("r12d", $arg3, 0x1c2c3c4c) |
| 148 |
check("r12x", $arg4, 0x1c2c3c4c1c2c3c4c) |
| 149 |
} |
| 150 |
|
| 151 |
probe process(@1).mark("r13") ? |
| 152 |
{ |
| 153 |
check("r13b", $arg1, 0x4d) |
| 154 |
check("r13w", $arg2, 0x3d4d) |
| 155 |
check("r13d", $arg3, 0x1d2d3d4d) |
| 156 |
check("r13x", $arg4, 0x1d2d3d4d1d2d3d4d) |
| 157 |
} |
| 158 |
|
| 159 |
probe process(@1).mark("r14") ? |
| 160 |
{ |
| 161 |
check("r14b", $arg1, 0x4e) |
| 162 |
check("r14w", $arg2, 0x3e4e) |
| 163 |
check("r14d", $arg3, 0x1e2e3e4e) |
| 164 |
check("r14x", $arg4, 0x1e2e3e4e1e2e3e4e) |
| 165 |
} |
| 166 |
|
| 167 |
probe process(@1).mark("r15") ? |
| 168 |
{ |
| 169 |
check("r15b", $arg1, 0x4f) |
| 170 |
check("r15w", $arg2, 0x3f4f) |
| 171 |
check("r15d", $arg3, 0x1f2f3f4f) |
| 172 |
check("r15x", $arg4, 0x1f2f3f4f1f2f3f4f) |
| 173 |
} |
| 174 |
|
| 175 |
probe process(@1).mark("memory") ? |
| 176 |
{ |
| 177 |
check("mem1", $arg1, 7) |
| 178 |
check("mem2", $arg2, 7) |
| 179 |
check("mem3", $arg3, 7) |
| 180 |
} |
| 181 |
|
| 182 |
# PR14369: make sure a bad $var doesn't prevent the probes from being found at all |
| 183 |
# Should always pass runtime, as failure is actually in translation |
| 184 |
# NB: as above, excluding sp/rsp for dyninst |
| 185 |
probe %( runtime == "dyninst" |
| 186 |
%? process(@1).mark("*[!p]"), process(@1).mark("*[!s]p") |
| 187 |
%: process(@1).mark("*") %) |
| 188 |
{ |
| 189 |
check($$name . "@defined", @defined($no_such_var), 0) |
| 190 |
} |