perf trace beauty ioctl: fix off-by-one error in table
PATCH 1/1 perf trace beauty ioctl: fix off-by-one error in table
While tracing a program that calls isatty(3), I noticed that strace reported TCGETS for the request argument of the underlying ioctl(2) syscall while perf trace reported TCSETS. strace is corrrect. The bug in perf was due to the tty ioctl beauty table starting at 0x5400 rather than 0x5401.
--- tools/perf/trace/beauty/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/ioctl.c +1 -1
@@ -21,7 +21,7 @@static size_t ioctl__scnprintf_tty_cmd (int nr,int dir,char *bf,size_t size) {static const char *ioctl_tty_cmd[] = { -"TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" , + [_IOC_NR (TCGETS )] ="TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" ,"TCSETAF" ,"TCSBRK" ,"TCXONC" ,"TCFLSH" ,"TIOCEXCL" ,"TIOCNXCL" ,"TIOCSCTTY" ,"TIOCGPGRP" ,"TIOCSPGRP" ,"TIOCOUTQ" ,"TIOCSTI" ,"TIOCGWINSZ" ,"TIOCSWINSZ" ,"TIOCMGET" ,"TIOCMBIS" ,"TIOCMBIC" ,"TIOCMSET" ,"TIOCGSOFTCAR" ,"TIOCSSOFTCAR" ,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
AppliedEm Thu, Aug 22, 2019 at 08:36:25PM -0700, Benjamin Peterson escreveu:
Quoted 4 lines
While tracing a program that calls isatty(3), I noticed that strace reported TCGETS for the request argument of the underlying ioctl(2) syscall while perf trace reported TCSETS. strace is corrrect. The bug in perf was due to the tty ioctl beauty table starting at
0x5400rather than0x5401.
Applied, thanks a lot!
- Arnaldo
Quoted 21 lines
Fixes 1cc47f2d46206d67285aea0ca7e8450af571da13 ("perf trace beauty ioctl: Improve 'cmd' beautifier")Signed-off-by Benjamin Peterson <[email protected]>--- tools/perf/trace/beauty/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/trace/beauty/ioctl.c +1
-1@@ -21,7 +21,7 @@static size_t ioctl__scnprintf_tty_cmd (int nr,int dir,char *bf,size_t size) {static const char *ioctl_tty_cmd[] = { -"TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" , + [_IOC_NR (TCGETS )] ="TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" ,"TCSETAF" ,"TCSBRK" ,"TCXONC" ,"TCFLSH" ,"TIOCEXCL" ,"TIOCNXCL" ,"TIOCSCTTY" ,"TIOCGPGRP" ,"TIOCSPGRP" ,"TIOCOUTQ" ,"TIOCSTI" ,"TIOCGWINSZ" ,"TIOCSWINSZ" ,"TIOCMGET" ,"TIOCMBIS" ,"TIOCMBIC" ,"TIOCMSET" ,"TIOCGSOFTCAR" ,"TIOCSSOFTCAR" ,Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo
[tip: perf/core] perf trace beauty ioctl: Fix off-by-one error in cmd->string table
In reply to Benjamin PetersonThe following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: b92675f4a9c02dd78052645597dac9e270679ddf Gitweb: https://git.kernel.org/tip/b92675f4a9c02dd78052645597dac9e270679ddf Author: Benjamin Peterson <[email protected]> AuthorDate: Thu, 22 Aug 2019 20:36:25 -07:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Mon, 26 Aug 2019 11:58:29 -03:00
perf trace beauty ioctl: Fix off-by-one error in cmd->string table
While tracing a program that calls isatty(3), I noticed that strace reported TCGETS for the request argument of the underlying ioctl(2) syscall while perf trace reported TCSETS. strace is corrrect. The bug in perf was due to the tty ioctl beauty table starting at 0x5400 rather than 0x5401.
Committer testing:
Using augmented_raw_syscalls.o and settings to make 'perf trace' use strace formatting, i.e. with this in ~/.perfconfig
# cat ~/.perfconfig [trace] add_events = /home/acme/git/linux/tools/perf/examples/bpf/augmented_raw_syscalls.c show_zeros = yes show_duration = no no_inherit = yes show_timestamp = no show_arg_names = no args_alignment = 40 show_prefix = yes
# strace -e ioctl stty > /dev/null
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, 0x7fff8a9b0860) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(1, TCGETS, 0x7fff8a9b0540) = -1 ENOTTY (Inappropriate ioctl for device)
+++ exited with 0 +++
#Before:
# perf trace -e ioctl stty > /dev/null ioctl(0, TCSETS, 0x7fff2cf79f20) = 0 ioctl(1, TIOCSWINSZ, 0x7fff2cf79f40) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(1, TCSETS, 0x7fff2cf79c20) = -1 ENOTTY (Inappropriate ioctl for device) #
After:
# perf trace -e ioctl stty > /dev/null ioctl(0, TCGETS, 0x7ffed0763920) = 0 ioctl(1, TIOCGWINSZ, 0x7ffed0763940) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(1, TCGETS, 0x7ffed0763620) = -1 ENOTTY (Inappropriate ioctl for device) #
--- tools/perf/trace/beauty/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/ioctl.c +1 -1
@@ -21,7 +21,7 @@static size_t ioctl__scnprintf_tty_cmd (int nr,int dir,char *bf,size_t size) {static const char *ioctl_tty_cmd[] = { -"TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" , + [_IOC_NR (TCGETS )] ="TCGETS" ,"TCSETS" ,"TCSETSW" ,"TCSETSF" ,"TCGETA" ,"TCSETA" ,"TCSETAW" ,"TCSETAF" ,"TCSBRK" ,"TCXONC" ,"TCFLSH" ,"TIOCEXCL" ,"TIOCNXCL" ,"TIOCSCTTY" ,"TIOCGPGRP" ,"TIOCSPGRP" ,"TIOCOUTQ" ,"TIOCSTI" ,"TIOCGWINSZ" ,"TIOCSWINSZ" ,"TIOCMGET" ,"TIOCMBIS" ,"TIOCMBIC" ,"TIOCMSET" ,"TIOCGSOFTCAR" ,"TIOCSSOFTCAR" ,