wkz / ply

Light-weight Dynamic Tracer for Linux
https://wkz.github.io/ply
GNU General Public License v2.0
399 stars 152 forks source link

printing issue of aggregated data on arm 32 #15

Closed ccb3 closed 5 years ago

ccb3 commented 5 years ago

On arm 32 bit system the following print occured when printing comms in an aggregated map.

# ply 't:sched/sched_switch { @[data->next_comm] = count(); }'
ply: active
^Cply: deactivating

@:
{ kworker/u4:3    }: 1
{ 
000:  70 6c 79 00 68 00 67 65  74 74 79 00 00 00 00 00   ply.h.ge tty.....
 }: 1
{ 
000:  73 73 64 70 64 00 72 2f  30 00 00 00 00 00 00 00   ssdpd.r/ 0.......
 }: 1
{ kworker/0:1     }: 2
{ kworker/1:3     }: 3
{ rcu_preempt     }: 6
{ swapper/1       }: 12
{ watchdogd       }: 24
{ swapper/0       }: 42
wkz commented 5 years ago

This is a tough one. The reason you're seeing the hexdump is that the output from the kernel is not sanitized. ply will print a char [] as a string iff it consists of only printable characters and if only NULs follows the first NUL. Otherwise it will fallback to a hexdump.

The motivation behind this decision is that a tracer should never hide information from the user. If you see ssdpd, you should know that there's nothing else hiding after the NUL.

I'll close this for now. Please let me know if you have a better solution to this problem.