]> granicus.if.org Git - strace/blobdiff - term.c
tests: check decoding of vcpu auxstr
[strace] / term.c
diff --git a/term.c b/term.c
index 62a2efebd5fe155882beab78a36513c8b8bd1b37..cfb878b0fa561e8974b4369441ac2cfdbb5867b6 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-2018 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "xlat/modem_flags.h"
 
 static void
-decode_termios(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_termios(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct termios tios;
-       int i;
-
-       if (!verbose(tcp))
-               return;
 
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &tios))
@@ -67,21 +64,17 @@ decode_termios(struct tcb *const tcp, const kernel_ureg_t addr)
        if (!(tios.c_lflag & ICANON))
                tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
                        tios.c_cc[VMIN], tios.c_cc[VTIME]);
-       tprints("c_cc=\"");
-       for (i = 0; i < NCCS; i++)
-               tprintf("\\x%02x", tios.c_cc[i]);
-       tprints("\"}");
+       tprints("c_cc=");
+       print_quoted_string((char *) tios.c_cc, NCCS, QUOTE_FORCE_HEX);
+       tprints("}");
 }
 
 static void
-decode_termio(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_termio(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct termio tio;
        int i;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &tio))
                return;
@@ -116,13 +109,10 @@ decode_termio(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_winsize(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_winsize(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct winsize ws;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &ws))
                return;
@@ -132,13 +122,10 @@ decode_winsize(struct tcb *const tcp, const kernel_ureg_t addr)
 
 #ifdef TIOCGSIZE
 static void
-decode_ttysize(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_ttysize(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct ttysize ts;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &ts))
                return;
@@ -148,13 +135,10 @@ decode_ttysize(struct tcb *const tcp, const kernel_ureg_t addr)
 #endif
 
 static void
-decode_modem_flags(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_modem_flags(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        int i;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &i))
                return;
@@ -165,7 +149,7 @@ decode_modem_flags(struct tcb *const tcp, const kernel_ureg_t addr)
 
 int
 term_ioctl(struct tcb *const tcp, const unsigned int code,
-          const kernel_ureg_t arg)
+          const kernel_ulong_t arg)
 {
        switch (code) {
        /* struct termios */
@@ -176,6 +160,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGLCKTRMIOS:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETS:
 #ifdef TCSETS2
        case TCSETS2:
@@ -196,6 +181,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TCGETA:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETA:
        case TCSETAW:
        case TCSETAF:
@@ -206,6 +192,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGWINSZ:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSWINSZ:
                decode_winsize(tcp, arg);
                break;
@@ -215,6 +202,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCGSIZE:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSSIZE:
                decode_ttysize(tcp, arg);
                break;
@@ -223,11 +211,11 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        /* ioctls with a direct decodable arg */
        case TCXONC:
                tprints(", ");
-               printxval_long(tcxonc_options, arg, "TC???");
+               printxval64(tcxonc_options, arg, "TC???");
                break;
        case TCFLSH:
                tprints(", ");
-               printxval_long(tcflsh_options, arg, "TC???");
+               printxval64(tcflsh_options, arg, "TC???");
                break;
        case TCSBRK:
        case TCSBRKP:
@@ -239,6 +227,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        case TIOCMGET:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
@@ -261,6 +250,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
 #endif
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSPGRP:
        case TIOCSETD:
        case FIONBIO:
@@ -275,7 +265,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
        /* ioctls with an indirect parameter displayed as a char */
        case TIOCSTI:
                tprints(", ");
-               printstr(tcp, arg, 1);
+               printstrn(tcp, arg, 1);
                break;
 
        /* ioctls with no parameters */
@@ -302,5 +292,5 @@ term_ioctl(struct tcb *const tcp, const unsigned int code,
                return RVAL_DECODED;
        }
 
-       return RVAL_DECODED | 1;
+       return RVAL_IOCTL_DECODED;
 }