uaddr
Action
_usymaddr uaddr(uintptr_t address)
uaddr
translates the specified address according to the setting of the uresolve
option. For more information, see DTrace User Address Symbol Resolution.
By default, uaddr
formats an address as a symbol and, if appropriate, a hexadecimal offset. The following example shows uaddr
translating the known address of a variable into its name:
# dtrace -n 'pid$target::main:entry{ uaddr(0x5037d0); }' -c date
dtrace: description 'pid$target::main:entry' matched 1 probe
Tue Jun 28 13:57:58 BST 2016
dtrace: pid 113190 has exited
CPU ID FUNCTION:NAME
0 4193 main:entry date`clock_val
Another example, truncated for brevity, shows the display of offsets within a symbol:
# dtrace -n "pid\$target::main:{uaddr(uregs[R_PC])}" -c date
dtrace: description 'pid$target::main:' matched 188 probes
Tue Jun 28 13:59:35 BST 2016
dtrace: pid 113192 has exited
CPU ID FUNCTION:NAME
7 4194 main:entry date`main
7 4195 main:0 date`main
7 4196 main:1 date`main+0x1
7 4197 main:4 date`main+0x4
7 4198 main:5 date`main+0x5
7 4199 main:7 date`main+0x7
7 4200 main:9 date`main+0x9
7 4201 main:b date`main+0xb
7 4202 main:d date`main+0xd
7 4203 main:11 date`main+0x11
7 4204 main:13 date`main+0x13
7 4205 main:16 date`main+0x16
7 4206 main:1d date`main+0x1d
7 4207 main:22 date`main+0x22
7 4208 main:27 date`main+0x27
If the load object contains suitable DWARF
then uaddr
can format an address as the file name and line number of the corresponding source code. For the following example, date
has been built with DWARF
. The DTrace invocation is identical to the previous example except for the use of the uresolve
option:
# dtrace -x uresolve=basename -n "pid\$target::main:{uaddr(uregs[R_PC])}" -c date
dtrace: description 'pid$target::main:' matched 188 probes
Tue Jun 28 14:02:03 BST 2016
dtrace: pid 113194 has exited
CPU ID FUNCTION:NAME
4 4194 main:entry date.c:123
4 4195 main:0 date.c:123
4 4196 main:1 date.c:123
4 4197 main:4 date.c:123
4 4198 main:5 date.c:123
4 4199 main:7 date.c:123
4 4200 main:9 date.c:123
4 4201 main:b date.c:123
4 4202 main:d date.c:123
4 4203 main:11 date.c:123
4 4204 main:13 date.c:123
4 4205 main:16 date.c:129
4 4206 main:1d date.c:129
4 4207 main:22 date.c:129
4 4208 main:27 date.c:131
4 4209 main:2e date.c:131
4 4210 main:33 date.c:133
4 4211 main:3a date.c:133
4 4212 main:3c date.c:133
4 4213 main:3f date.c:133
4 4214 main:44 date.c:133
4 4215 main:47 date.c:133
4 4216 main:4a date.c:133
4 4217 main:4d date.c:133
4 4258 main:ea date.c:151
4 4259 main:f1 date.c:151
Each line corresponds to more than one instruction. It may be useful to discard duplicates by using the uniq
command. The following example reveals the complete path through the function:
# dtrace -q -x uresolve=basename -n 'pid\$target::main:{uaddr(uregs[R_PC]);printf("\n")}' -c date | uniq
Tue Jun 28 14:10:50 BST 2016
date.c:123
date.c:129
date.c:131
date.c:133
date.c:151
date.c:152
date.c:155
date.c:158
date.c:171
date.c:172
date.c:174
date.c:182
date.c:193
date.c:195
date.c:200
date.c:209
date.c:215
date.c:216
date.c:218
date.c:221
If the load object contains suitable DWARF
and uaddr
is used as an aggregation key, uaddr
represents a single line of source code and not a single address, as shown in the following example:
# dtrace -x uresolve=basename -n 'pid\$target::main:{@[uaddr(uregs[R_PC])]=count()}' -c date
dtrace: description 'pid\$target::main:' matched 188 probes
Tue Jun 28 14:13:51 BST 2016
dtrace: pid 113213 has exited
date.c:152 1
date.c:131 2
date.c:158 2
date.c:174 2
date.c:182 2
date.c:218 2
date.c:129 3
date.c:151 3
date.c:171 3
date.c:193 3
date.c:195 3
date.c:155 4
date.c:172 4
date.c:200 4
date.c:209 4
date.c:215 5
date.c:216 6
date.c:133 8
date.c:221 10
date.c:123 11