]> granicus.if.org Git - strace/blobdiff - stream.c
2004-09-03 Roland McGrath <roland@redhat.com>
[strace] / stream.c
index 42bfcc8fd121a4e2eaeca913c7fea9dba39d6afc..68be3a46468de4b7cac4cb9513dc089fb50b4227 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -29,6 +29,7 @@
  */
 
 #include "defs.h"
+#include <sys/syscall.h>
 
 #ifdef HAVE_POLL_H
 #include <poll.h>
@@ -49,7 +50,7 @@
 #include <sys/tihdr.h>
 #endif
 
-#if defined(HAVE_SYS_STREAM_H) || defined(linux) || defined(FREEBSD)
+#if defined(HAVE_SYS_STREAM_H) || defined(LINUX) || defined(FREEBSD)
 
 #ifndef HAVE_STROPTS_H
 #define RS_HIPRI 1
@@ -69,7 +70,7 @@ struct strbuf {
 #endif /* HAVE_SYS_TIUSER_H */
 
 #ifndef FREEBSD
-static struct xlat msgflags[] = {
+static const struct xlat msgflags[] = {
        { RS_HIPRI,     "RS_HIPRI"      },
        { 0,            NULL            },
 };
@@ -177,9 +178,8 @@ struct tcb *tcp;
        return RVAL_HEX | RVAL_STR;
 }
 
-#ifdef HAVE_PUTPMSG
-
-static struct xlat pmsgflags[] = {
+#if defined SYS_putpmsg || defined SYS_getpmsg
+static const struct xlat pmsgflags[] = {
 #ifdef MSG_HIPRI
        { MSG_HIPRI,    "MSG_HIPRI"     },
 #endif
@@ -191,7 +191,9 @@ static struct xlat pmsgflags[] = {
 #endif
        { 0,            NULL            },
 };
+#endif
 
+#ifdef SYS_putpmsg
 int
 sys_putpmsg(tcp)
 struct tcb *tcp;
@@ -212,7 +214,9 @@ struct tcb *tcp;
        }
        return 0;
 }
+#endif /* SYS_putpmsg */
 
+#ifdef SYS_getpmsg
 int
 sys_getpmsg(tcp)
 struct tcb *tcp;
@@ -263,14 +267,14 @@ struct tcb *tcp;
        }
        return RVAL_HEX | RVAL_STR;
 }
+#endif /* SYS_getpmsg */
 
-#endif /* HAVE_PUTPMSG */
 #endif /* !FREEBSD */
 
 
 #ifdef HAVE_SYS_POLL_H
 
-static struct xlat pollflags[] = {
+static const struct xlat pollflags[] = {
 #ifdef POLLIN
        { POLLIN,       "POLLIN"        },
        { POLLPRI,      "POLLPRI"       },
@@ -363,9 +367,9 @@ struct tcb *tcp;
 }
 #endif
 
-#if !defined(linux) && !defined(FREEBSD)
+#if !defined(LINUX) && !defined(FREEBSD)
 
-static struct xlat stream_flush_options[] = {
+static const struct xlat stream_flush_options[] = {
        { FLUSHR,       "FLUSHR"        },
        { FLUSHW,       "FLUSHW"        },
        { FLUSHRW,      "FLUSHRW"       },
@@ -375,7 +379,7 @@ static struct xlat stream_flush_options[] = {
        { 0,            NULL            },
 };
 
-static struct xlat stream_setsig_flags[] = {
+static const struct xlat stream_setsig_flags[] = {
        { S_INPUT,      "S_INPUT"       },
        { S_HIPRI,      "S_HIPRI"       },
        { S_OUTPUT,     "S_OUTPUT"      },
@@ -404,14 +408,14 @@ static struct xlat stream_setsig_flags[] = {
        { 0,            NULL            },
 };
 
-static struct xlat stream_read_options[] = {
+static const struct xlat stream_read_options[] = {
        { RNORM,        "RNORM"         },
        { RMSGD,        "RMSGD"         },
        { RMSGN,        "RMSGN"         },
        { 0,            NULL            },
 };
 
-static struct xlat stream_read_flags[] = {
+static const struct xlat stream_read_flags[] = {
 #ifdef RPROTDAT
        { RPROTDAT,     "RPROTDAT"      },
 #endif
@@ -429,7 +433,7 @@ static struct xlat stream_read_flags[] = {
 #endif
 
 #ifdef I_SWROPT
-static struct xlat stream_write_flags[] = {
+static const struct xlat stream_write_flags[] = {
        { SNDZERO,      "SNDZERO"       },
        { SNDPIPE,      "SNDPIPE"       },
        { 0,            NULL            },
@@ -437,7 +441,7 @@ static struct xlat stream_write_flags[] = {
 #endif /* I_SWROPT */
 
 #ifdef I_ATMARK
-static struct xlat stream_atmark_options[] = {
+static const struct xlat stream_atmark_options[] = {
        { ANYMARK,      "ANYMARK"       },
        { LASTMARK,     "LASTMARK"      },
        { 0,            NULL            },
@@ -445,7 +449,7 @@ static struct xlat stream_atmark_options[] = {
 #endif /* I_ATMARK */
 
 #ifdef TI_BIND
-static struct xlat transport_user_options[] = {
+static const struct xlat transport_user_options[] = {
        { T_CONN_REQ,   "T_CONN_REQ"    },
        { T_CONN_RES,   "T_CONN_RES"    },
        { T_DISCON_REQ, "T_DISCON_REQ"  },
@@ -460,7 +464,7 @@ static struct xlat transport_user_options[] = {
        { 0,            NULL            },
 };
 
-static struct xlat transport_user_flags [] = {
+static const struct xlat transport_user_flags [] = {
        { 0,            "0"             },
        { T_MORE,       "T_MORE"        },
        { T_EXPEDITED,  "T_EXPEDITED"   },
@@ -477,14 +481,14 @@ static struct xlat transport_user_flags [] = {
 };
 
 
-#ifdef HAVE_T_OPTHDR
+#ifdef HAVE_STRUCT_T_OPTHDR
 
-static struct xlat xti_level [] = {
+static const struct xlat xti_level [] = {
        { XTI_GENERIC,  "XTI_GENERIC"   },
        { 0,            NULL            },
 };
 
-static struct xlat xti_generic [] = {
+static const struct xlat xti_generic [] = {
        { XTI_DEBUG,    "XTI_DEBUG"     },
        { XTI_LINGER,   "XTI_LINGER"    },
        { XTI_RCVBUF,   "XTI_RCVBUF"    },
@@ -556,11 +560,11 @@ struct tcb *tcp;
 long addr;
 int len;
 {
-       /* We don't know how to tell if TLI (socket) or XTI 
+       /* We don't know how to tell if TLI (socket) or XTI
           optmgmt is being used yet, assume TLI. */
-#if defined (HAVE_OPTHDR)
+#if defined (HAVE_STRUCT_OPTHDR)
        print_sock_optmgmt (tcp, addr, len);
-#elif defined (HAVE_T_OPTHDR)
+#elif defined (HAVE_STRUCT_T_OPTHDR)
        print_xti_optmgmt (tcp, addr, len);
 #else
        printstr (tcp, addr, len);
@@ -570,14 +574,14 @@ int len;
 
 
 
-static struct xlat service_type [] = {
+static const struct xlat service_type [] = {
        { T_COTS,       "T_COTS"        },
        { T_COTS_ORD,   "T_COTS_ORD"    },
        { T_CLTS,       "T_CLTS"        },
        { 0,            NULL            },
 };
 
-static struct xlat ts_state [] = {
+static const struct xlat ts_state [] = {
        { TS_UNBND,     "TS_UNBND"      },
        { TS_WACK_BREQ, "TS_WACK_BREQ"  },
        { TS_WACK_UREQ, "TS_WACK_UREQ"  },
@@ -598,7 +602,7 @@ static struct xlat ts_state [] = {
        { 0,            NULL            },
 };
 
-static struct xlat provider_flags [] = {
+static const struct xlat provider_flags [] = {
        { 0,            "0"             },
        { SENDZERO,     "SENDZERO"      },
        { EXPINLINE,    "EXPINLINE"     },
@@ -607,7 +611,7 @@ static struct xlat provider_flags [] = {
 };
 
 
-static struct xlat tli_errors [] = {
+static const struct xlat tli_errors [] = {
        { TBADADDR,     "TBADADDR"      },
        { TBADOPT,      "TBADOPT"       },
        { TACCES,       "TACCES"        },
@@ -668,8 +672,8 @@ int len;
        while (0)
 
 #define COMMA() \
-       do { if (c++) tprintf (", "); } while (0) 
-                
+       do { if (c++) tprintf (", "); } while (0)
+
 
 #define STRUCT(struct, elem, print)                                    \
        do {                                                            \
@@ -692,7 +696,7 @@ int len;
        while (0)
 
 #define ADDR(struct, elem) STRUCT (struct, elem, printstr)
-       
+
        switch (m.type) {
 #ifdef T_CONN_REQ
            case T_CONN_REQ:    /* connect request   */
@@ -704,8 +708,13 @@ int len;
 #ifdef T_CONN_RES
            case T_CONN_RES:    /* connect response   */
                GET (T_CONN_RES, conn_res);
+#ifdef HAVE_STRUCT_T_CONN_RES_QUEUE_PTR
                COMMA ();
                tprintf ("QUEUE=%p", m.conn_res.QUEUE_ptr);
+#elif defined HAVE_STRUCT_T_CONN_RES_ACCEPTOR_ID
+               COMMA ();
+               tprintf ("ACCEPTOR=%#lx", m.conn_res.ACCEPTOR_id);
+#endif
                ADDR (conn_res, OPT);
                COMMA ();
                tprintf ("SEQ=%ld", m.conn_res.SEQ_number);
@@ -909,7 +918,7 @@ int len;
 #undef ADDR
 #undef COMMA
 #undef STRUCT
-       
+
        return 0;
 }
 
@@ -923,7 +932,7 @@ struct tcb *tcp;
 int arg;
 {
        struct strioctl si;
-       char *name;
+       struct ioctlent *iop;
        int in_and_out;
        int timod = 0;
 #ifdef SI_GETUDATA
@@ -938,10 +947,12 @@ int arg;
                return 1;
        }
        if (entering(tcp)) {
-               name = ioctl_lookup(si.ic_cmd);
-               if (name)
-                       tprintf(", {ic_cmd=%s", name);
-               else
+               iop = ioctl_lookup(si.ic_cmd);
+               if (iop) {
+                       tprintf(", {ic_cmd=%s", iop->symbol);
+                       while ((iop = ioctl_next_match(iop)))
+                               tprintf(" or %s", iop->symbol);
+               } else
                        tprintf(", {ic_cmd=%#x", si.ic_cmd);
                if (si.ic_timout == INFTIM)
                        tprintf(", ic_timout=INFTIM, ");
@@ -1054,7 +1065,7 @@ int arg;
                break;
 #endif /* SI_GETUDATA */
        default:
-               printstr(tcp, (int) si.ic_dp, si.ic_len);
+               printstr(tcp, (long) si.ic_dp, si.ic_len);
                break;
        }
        if (exiting(tcp)) {
@@ -1064,7 +1075,7 @@ int arg;
                        return RVAL_STR + 1;
                }
        }
-       
+
        return 1;
 }
 
@@ -1287,7 +1298,6 @@ int code, arg;
        }
 }
 
-#endif /* !linux && !FREEBSD */ 
-
-#endif /* HAVE_SYS_STREAM_H || linux || FREEBSD */
+#endif /* !LINUX && !FREEBSD */
 
+#endif /* HAVE_SYS_STREAM_H || LINUX || FREEBSD */