All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements
@ 2016-06-08 20:24 Laurent Vivier
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace Laurent Vivier
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier

These patches for linux-user strace are living for years in my tree.

Laurent Vivier (5):
  linux-user: add socketcall() strace
  linux-user: correct setsockopt() strace.
  linux-user: add socket() strace
  linux-user: fix clone() strace
  linux-user: update get_thread_area/set_thread_area strace

 include/exec/user/abitypes.h |  23 ++
 linux-user/strace.c          | 601 ++++++++++++++++++++++++++++++++++++++++++-
 linux-user/strace.list       |   8 +-
 linux-user/syscall_defs.h    |  22 +-
 4 files changed, 635 insertions(+), 19 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace
  2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
@ 2016-06-08 20:24 ` Laurent Vivier
  2016-06-10 12:51   ` Peter Maydell
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace Laurent Vivier
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier

From: Laurent Vivier <Laurent@Vivier.EU>

Signed-off-by: Laurent Vivier <Laurent@Vivier.EU>
---
 include/exec/user/abitypes.h |  23 ++
 linux-user/strace.c          | 550 +++++++++++++++++++++++++++++++++++++++++++
 linux-user/strace.list       |   2 +-
 linux-user/syscall_defs.h    |  22 +-
 4 files changed, 592 insertions(+), 5 deletions(-)

diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index 80eedac..e33b1f8 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -46,6 +46,15 @@ static inline abi_ulong tswapal(abi_ulong v)
     return tswap32(v);
 }
 
+static inline abi_ulong abi_ntohl(abi_ulong v)
+{
+#if defined(HOST_BIG_ENDIAN)
+    return v;
+#else
+    return bswap_32(v);
+#endif
+}
+
 #else
 typedef target_ulong abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
 typedef target_long abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
@@ -62,5 +71,19 @@ static inline abi_ulong tswapal(abi_ulong v)
     return tswapl(v);
 }
 
+static inline abi_ulong abi_ntohl(abi_ulong v)
+{
+#if defined(HOST_BIG_ENDIAN)
+    return v;
+#else
+#if TARGET_LONG_SIZE == 4
+    return bswap_32(v);
+#else
+    return bswap_64(v);
+#endif
+#endif
+}
+
+
 #endif
 #endif
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 0810c85..a7b24e2 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -6,6 +6,9 @@
 #include <sys/select.h>
 #include <sys/mount.h>
 #include <sys/mman.h>
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#include <linux/if_packet.h>
 #include <sched.h>
 #include "qemu.h"
 
@@ -58,10 +61,15 @@ UNUSED static void print_open_flags(abi_long, int);
 UNUSED static void print_syscall_prologue(const struct syscallname *);
 UNUSED static void print_syscall_epilogue(const struct syscallname *);
 UNUSED static void print_string(abi_long, int);
+UNUSED static void print_buf(abi_long addr, abi_long len, int last);
 UNUSED static void print_raw_param(const char *, abi_long, int);
 UNUSED static void print_timeval(abi_ulong, int);
 UNUSED static void print_number(abi_long, int);
 UNUSED static void print_signal(abi_ulong, int);
+UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen);
+UNUSED static void print_socket_domain(int domain);
+UNUSED static void print_socket_type(int type);
+UNUSED static void print_socket_protocol(int domain, int type, int protocol);
 
 /*
  * Utility functions
@@ -147,6 +155,165 @@ print_signal(abi_ulong arg, int last)
     gemu_log("%s%s", signal_name, get_comma(last));
 }
 
+static void
+print_sockaddr(abi_ulong addr, abi_long addrlen)
+{
+    struct target_sockaddr *sa;
+    int i;
+    int sa_family;
+
+    sa = lock_user(VERIFY_READ, addr, addrlen, 1);
+    if (sa) {
+        sa_family = tswap16(sa->sa_family);
+        switch (sa_family) {
+        case AF_UNIX: {
+            struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
+            int i;
+            gemu_log("{sun_family=AF_UNIX,sun_path=\"");
+            for (i = 0; i < addrlen -
+                            offsetof(struct target_sockaddr_un, sun_path) &&
+                 un->sun_path[i]; i++) {
+                gemu_log("%c", un->sun_path[i]);
+            }
+            gemu_log("\"}");
+            break;
+        }
+        case AF_INET: {
+            struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
+            uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
+            gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
+                     ntohs(in->sin_port));
+            gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
+                     c[0], c[1], c[2], c[3]);
+            gemu_log("}");
+            break;
+        }
+        case AF_PACKET: {
+            struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
+            uint8_t *c = (uint8_t *)&ll->sll_addr;
+            gemu_log("{sll_family=AF_PACKET,"
+                     "sll_protocol=htons(0x%04x),if%d,pkttype=",
+                     ntohs(ll->sll_protocol), ll->sll_ifindex);
+            switch (ll->sll_pkttype) {
+            case PACKET_HOST:
+                gemu_log("PACKET_HOST");
+                break;
+            case PACKET_BROADCAST:
+                gemu_log("PACKET_BROADCAST");
+                break;
+            case PACKET_MULTICAST:
+                gemu_log("PACKET_MULTICAST");
+                break;
+            case PACKET_OTHERHOST:
+                gemu_log("PACKET_OTHERHOST");
+                break;
+            case PACKET_OUTGOING:
+                gemu_log("PACKET_OUTGOING");
+                break;
+            default:
+                gemu_log("%d", ll->sll_pkttype);
+                break;
+            }
+            gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
+                     c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
+            gemu_log("}");
+            break;
+        }
+        default:
+            gemu_log("{sa_family=%d, sa_data={", sa->sa_family);
+            for (i = 0; i < 13; i++) {
+                gemu_log("%02x, ", sa->sa_data[i]);
+            }
+            gemu_log("%02x}", sa->sa_data[i]);
+            gemu_log("}");
+            break;
+        }
+        unlock_user(sa, addr, 0);
+    } else {
+        print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
+    }
+    gemu_log(", "TARGET_ABI_FMT_ld, addrlen);
+}
+
+static void
+print_socket_domain(int domain)
+{
+    switch (domain) {
+    case PF_UNIX:
+        gemu_log("PF_UNIX");
+        break;
+    case PF_INET:
+        gemu_log("PF_INET");
+        break;
+    case PF_PACKET:
+        gemu_log("PF_PACKET");
+        break;
+    default:
+        gemu_log("%d", domain);
+        break;
+    }
+}
+
+static void
+print_socket_type(int type)
+{
+    switch (type) {
+    case TARGET_SOCK_DGRAM:
+        gemu_log("SOCK_DGRAM");
+        break;
+    case TARGET_SOCK_STREAM:
+        gemu_log("SOCK_STREAM");
+        break;
+    case TARGET_SOCK_RAW:
+        gemu_log("SOCK_RAW");
+        break;
+    case TARGET_SOCK_RDM:
+        gemu_log("SOCK_RDM");
+        break;
+    case TARGET_SOCK_SEQPACKET:
+        gemu_log("SOCK_SEQPACKET");
+        break;
+    case TARGET_SOCK_PACKET:
+        gemu_log("SOCK_PACKET");
+        break;
+    }
+}
+
+static void
+print_socket_protocol(int domain, int type, int protocol)
+{
+    if (domain == AF_PACKET ||
+        type == TARGET_SOCK_PACKET) {
+        switch (protocol) {
+        case 0x0003:
+            gemu_log("ETH_P_ALL");
+            break;
+        default:
+            gemu_log("%d", protocol);
+        }
+        return;
+    }
+
+    switch (protocol) {
+    case IPPROTO_IP:
+        gemu_log("IPPROTO_IP");
+        break;
+    case IPPROTO_TCP:
+        gemu_log("IPPROTO_TCP");
+        break;
+    case IPPROTO_UDP:
+        gemu_log("IPPROTO_UDP");
+        break;
+    case IPPROTO_RAW:
+        gemu_log("IPPROTO_RAW");
+        break;
+    default:
+        gemu_log("%d", protocol);
+        break;
+    }
+}
+
+
 #ifdef TARGET_NR__newselect
 static void
 print_fdset(int n, abi_ulong target_fds_addr)
@@ -498,6 +665,26 @@ UNUSED static struct flags clone_flags[] = {
     FLAG_END,
 };
 
+UNUSED static struct flags msg_flags[] = {
+    /* send */
+    FLAG_GENERIC(MSG_CONFIRM),
+    FLAG_GENERIC(MSG_DONTROUTE),
+    FLAG_GENERIC(MSG_DONTWAIT),
+    FLAG_GENERIC(MSG_EOR),
+    FLAG_GENERIC(MSG_MORE),
+    FLAG_GENERIC(MSG_NOSIGNAL),
+    FLAG_GENERIC(MSG_OOB),
+    /* recv */
+    FLAG_GENERIC(MSG_CMSG_CLOEXEC),
+    FLAG_GENERIC(MSG_ERRQUEUE),
+    FLAG_GENERIC(MSG_PEEK),
+    FLAG_GENERIC(MSG_TRUNC),
+    FLAG_GENERIC(MSG_WAITALL),
+    /* recvmsg */
+    FLAG_GENERIC(MSG_CTRUNC),
+    FLAG_END,
+};
+
 /*
  * print_xxx utility functions.  These are used to print syscall
  * parameters in certain format.  All of these have parameter
@@ -619,6 +806,36 @@ print_string(abi_long addr, int last)
     }
 }
 
+#define MAX_PRINT_BUF 40
+static void
+print_buf(abi_long addr, abi_long len, int last)
+{
+    uint8_t *s;
+    int i;
+
+    s = lock_user(VERIFY_READ, addr, len, 1);
+    if (s) {
+        gemu_log("\"");
+        for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
+            if (isprint(s[i])) {
+                gemu_log("%c", s[i]);
+            } else {
+                gemu_log("\\%o", s[i]);
+            }
+        }
+        gemu_log("\"");
+        if (i != len) {
+            gemu_log("...");
+        }
+        if (!last) {
+            gemu_log(",");
+        }
+        unlock_user(s, addr, 0);
+    } else {
+        print_pointer(addr, last);
+    }
+}
+
 /*
  * Prints out raw parameter using given format.  Caller needs
  * to do byte swapping if needed.
@@ -1004,6 +1221,339 @@ print__llseek(const struct syscallname *name,
 }
 #endif
 
+#if defined(TARGET_NR_socketcall)
+static void
+print_socketcall(const struct syscallname *name,
+                 abi_long arg0, abi_long arg1, abi_long arg2,
+                 abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    const int n = sizeof(abi_ulong);
+    const char *socketcallname;
+
+    switch (arg0) {
+    case SOCKOP_bind: {
+        abi_ulong sockfd, addr, addrlen;
+
+        socketcallname = "bind";
+
+print_sockaddr:
+        get_user_ual(sockfd, arg1);
+        get_user_ual(addr, arg1 + n);
+        get_user_ual(addrlen, arg1 + 2 * n);
+
+        gemu_log("%s(", socketcallname);
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        print_sockaddr(addr, addrlen);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_connect:
+        socketcallname = "connect";
+        goto print_sockaddr;
+    case SOCKOP_accept:
+        socketcallname = "accept";
+        goto print_sockaddr;
+    case SOCKOP_getsockname:
+        socketcallname = "getsockname";
+        goto print_sockaddr;
+    case SOCKOP_getpeername:
+        socketcallname = "getpeername";
+        goto print_sockaddr;
+    case SOCKOP_socket: {
+        abi_ulong domain, type, protocol;
+
+        get_user_ual(domain, arg1);
+        get_user_ual(type, arg1 + n);
+        get_user_ual(protocol, arg1 + 2 * n);
+        gemu_log("socket(");
+        print_socket_domain(domain);
+        gemu_log(",");
+        print_socket_type(type);
+        gemu_log(",");
+        if (domain == AF_PACKET ||
+            type == TARGET_SOCK_PACKET) {
+            protocol = tswapal(protocol); /* restore network endian long */
+            protocol = abi_ntohl(protocol); /* a host endian long */
+        }
+        print_socket_protocol(domain, type, protocol);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_listen: {
+        abi_ulong sockfd, backlog;
+
+        get_user_ual(sockfd, arg1);
+        get_user_ual(backlog, arg1 + n);
+
+        gemu_log("listen(");
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_socketpair: {
+        abi_ulong domain, type, protocol, tab;
+
+        get_user_ual(domain, arg1);
+        get_user_ual(type, arg1 + n);
+        get_user_ual(protocol, arg1 + 2 * n);
+        get_user_ual(tab, arg1 + 3 * n);
+
+        gemu_log("socketpair(");
+        print_socket_domain(domain);
+        gemu_log(",");
+        print_socket_type(type);
+        gemu_log(",");
+        print_socket_protocol(domain, type, protocol);
+        gemu_log(",");
+        print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_send: {
+        abi_ulong sockfd, msg, len, flags;
+
+        socketcallname = "send";
+
+print_sock:
+        get_user_ual(sockfd, arg1);
+        get_user_ual(msg, arg1 + n);
+        get_user_ual(len, arg1 + 2 * n);
+        get_user_ual(flags, arg1 + 3 * n);
+
+        gemu_log("%s(", socketcallname);
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        print_buf(msg, len, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, len, 0);
+        print_flags(msg_flags, flags, 1);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_recv:
+        socketcallname = "recv";
+        goto print_sock;
+    case SOCKOP_sendto: {
+        abi_ulong sockfd, msg, len, flags, addr, addrlen;
+
+        socketcallname = "sendto";
+
+print_msgaddr:
+        get_user_ual(sockfd, arg1);
+        get_user_ual(msg, arg1 + n);
+        get_user_ual(len, arg1 + 2 * n);
+        get_user_ual(flags, arg1 + 3 * n);
+        get_user_ual(addr, arg1 + 4 * n);
+        get_user_ual(addrlen, arg1 + 5 * n);
+
+        gemu_log("%s(", socketcallname);
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        print_buf(msg, len, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, len, 0);
+        print_flags(msg_flags, flags, 0);
+        print_sockaddr(addr, addrlen);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_recvfrom:
+        socketcallname = "recvfrom";
+        goto print_msgaddr;
+    case SOCKOP_shutdown: {
+        abi_ulong sockfd, how;
+
+        get_user_ual(sockfd, arg1);
+        get_user_ual(how, arg1 + n);
+
+        gemu_log("shutdown(");
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        switch (how) {
+        case SHUT_RD:
+            gemu_log("SHUT_RD");
+            break;
+        case SHUT_WR:
+            gemu_log("SHUT_WR");
+            break;
+        case SHUT_RDWR:
+            gemu_log("SHUT_RDWR");
+            break;
+        default:
+            print_raw_param(TARGET_ABI_FMT_ld, how, 1);
+            break;
+        }
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_sendmsg: {
+        abi_ulong sockfd, msg, flags;
+
+        socketcallname = "sendmsg";
+print_msg:
+        get_user_ual(sockfd, arg1);
+        get_user_ual(msg, arg1 + n);
+        get_user_ual(flags, arg1 + 2 * n);
+
+        gemu_log("%s(", socketcallname);
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        print_pointer(msg, 0);
+        print_flags(msg_flags, flags, 1);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_recvmsg:
+        socketcallname = "recvmsg";
+        goto print_msg;
+    case SOCKOP_setsockopt: {
+        abi_ulong sockfd, level, optname, optval, optlen;
+
+        socketcallname = "setsockopt";
+
+print_sockopt:
+        get_user_ual(sockfd, arg1);
+        get_user_ual(level, arg1 + n);
+        get_user_ual(optname, arg1 + 2 * n);
+        get_user_ual(optval, arg1 + 3 * n);
+        get_user_ual(optlen, arg1 + 4 * n);
+
+        gemu_log("%s(", socketcallname);
+        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+        switch (level) {
+        case SOL_TCP:
+            gemu_log("SOL_TCP,");
+            print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
+            print_pointer(optval, 0);
+            break;
+        case SOL_IP:
+            gemu_log("SOL_IP,");
+            print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
+            print_pointer(optval, 0);
+            break;
+        case SOL_RAW:
+            gemu_log("SOL_RAW,");
+            print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
+            print_pointer(optval, 0);
+            break;
+        case TARGET_SOL_SOCKET:
+            gemu_log("SOL_SOCKET,");
+            switch (optname) {
+            case TARGET_SO_DEBUG:
+                gemu_log("SO_DEBUG,");
+print_optint:
+                print_number(optval, 0);
+                break;
+            case TARGET_SO_REUSEADDR:
+                gemu_log("SO_REUSEADDR,");
+                goto print_optint;
+            case TARGET_SO_TYPE:
+                gemu_log("SO_TYPE,");
+                goto print_optint;
+            case TARGET_SO_ERROR:
+                gemu_log("SO_ERROR,");
+                goto print_optint;
+            case TARGET_SO_DONTROUTE:
+                gemu_log("SO_DONTROUTE,");
+                goto print_optint;
+            case TARGET_SO_BROADCAST:
+                gemu_log("SO_BROADCAST,");
+                goto print_optint;
+            case TARGET_SO_SNDBUF:
+                gemu_log("SO_SNDBUF,");
+                goto print_optint;
+            case TARGET_SO_RCVBUF:
+                gemu_log("SO_RCVBUF,");
+                goto print_optint;
+            case TARGET_SO_KEEPALIVE:
+                gemu_log("SO_KEEPALIVE,");
+                goto print_optint;
+            case TARGET_SO_OOBINLINE:
+                gemu_log("SO_OOBINLINE,");
+                goto print_optint;
+            case TARGET_SO_NO_CHECK:
+                gemu_log("SO_NO_CHECK,");
+                goto print_optint;
+            case TARGET_SO_PRIORITY:
+                gemu_log("SO_PRIORITY,");
+                goto print_optint;
+            case TARGET_SO_BSDCOMPAT:
+                gemu_log("SO_BSDCOMPAT,");
+                goto print_optint;
+            case TARGET_SO_PASSCRED:
+                gemu_log("SO_PASSCRED,");
+                goto print_optint;
+            case TARGET_SO_TIMESTAMP:
+                gemu_log("SO_TIMESTAMP,");
+                goto print_optint;
+            case TARGET_SO_RCVLOWAT:
+                gemu_log("SO_RCVLOWAT,");
+                goto print_optint;
+            case TARGET_SO_RCVTIMEO:
+                gemu_log("SO_RCVTIMEO,");
+                goto print_optint;
+            case TARGET_SO_SNDTIMEO:
+                gemu_log("SO_SNDTIMEO,");
+                goto print_optint;
+            case TARGET_SO_ATTACH_FILTER: {
+                struct target_sock_fprog *fprog;
+
+                gemu_log("SO_ATTACH_FILTER,");
+
+                if (lock_user_struct(VERIFY_READ, fprog, optval,  0)) {
+                    struct target_sock_filter *filter;
+                    gemu_log("{");
+                    if (lock_user_struct(VERIFY_READ, filter,
+                                         tswapal(fprog->filter),  0)) {
+                        int i;
+                        for (i = 0; i < tswap16(fprog->len) - 1; i++) {
+                            gemu_log("[%d]{0x%x,%d,%d,0x%x},",
+                                     i, tswap16(filter[i].code),
+                                     filter[i].jt, filter[i].jf,
+                                     tswap32(filter[i].k));
+                        }
+                        gemu_log("[%d]{0x%x,%d,%d,0x%x}",
+                                 i, tswap16(filter[i].code),
+                                 filter[i].jt, filter[i].jf,
+                                 tswap32(filter[i].k));
+                    } else {
+                        gemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
+                    }
+                    gemu_log(",%d},", tswap16(fprog->len));
+                    unlock_user(fprog, optval, 0);
+                } else {
+                    print_pointer(optval, 0);
+                }
+                break;
+            }
+            default:
+                print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
+                print_pointer(optval, 0);
+                break;
+            }
+            break;
+        default:
+            print_raw_param(TARGET_ABI_FMT_ld, level, 0);
+            print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
+            print_pointer(optval, 0);
+            break;
+        }
+        print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
+        gemu_log(")");
+        break;
+    }
+    case SOCKOP_getsockopt:
+        socketcallname = "getsockopt";
+        goto print_sockopt;
+    default:
+        print_syscall_prologue(name);
+        print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
+        print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
+        print_syscall_epilogue(name);
+        break;
+    }
+}
+#endif
+
 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
     defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
 static void
diff --git a/linux-user/strace.list b/linux-user/strace.list
index aa0cd73..b379497 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1294,7 +1294,7 @@
 { TARGET_NR_socket, "socket" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_socketcall
-{ TARGET_NR_socketcall, "socketcall" , NULL, NULL, NULL },
+{ TARGET_NR_socketcall, "socketcall" , NULL, print_socketcall, NULL },
 #endif
 #ifdef TARGET_NR_socketpair
 { TARGET_NR_socketpair, "socketpair" , NULL, NULL, NULL },
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 34af15a..6270f79 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -135,6 +135,24 @@ struct target_sockaddr_ll {
     uint8_t  sll_addr[8];  /* Physical layer address */
 };
 
+struct target_sockaddr_un {
+    uint16_t su_family;
+    uint8_t sun_path[108];
+};
+
+struct target_in_addr {
+    uint32_t s_addr; /* big endian */
+};
+
+struct target_sockaddr_in {
+  uint16_t sin_family;
+  int16_t sin_port; /* big endian */
+  struct target_in_addr sin_addr;
+  uint8_t __pad[sizeof(struct target_sockaddr) -
+                sizeof(uint16_t) - sizeof(int16_t) -
+                sizeof(struct target_in_addr)];
+};
+
 struct target_sock_filter {
     abi_ushort code;
     uint8_t jt;
@@ -147,10 +165,6 @@ struct target_sock_fprog {
     abi_ulong filter;
 };
 
-struct target_in_addr {
-    uint32_t s_addr; /* big endian */
-};
-
 struct target_ip_mreq {
     struct target_in_addr imr_multiaddr;
     struct target_in_addr imr_address;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace.
  2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace Laurent Vivier
@ 2016-06-08 20:24 ` Laurent Vivier
  2016-06-10 12:53   ` Peter Maydell
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace Laurent Vivier
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier, Laurent Vivier

From: Laurent Vivier <Laurent@Vivier.EU>

Parameter of SO_RCVTIMEO and SO_SNDTIMEO is timeval, not int.

To test this, you can use :

QEMU_STRACE= ping localhost 2>&1 |grep TIMEO
568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) = 0
568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) = 0

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index a7b24e2..398e56e 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1486,10 +1486,12 @@ print_optint:
                 goto print_optint;
             case TARGET_SO_RCVTIMEO:
                 gemu_log("SO_RCVTIMEO,");
-                goto print_optint;
+                print_timeval(optval, 0);
+                break;
             case TARGET_SO_SNDTIMEO:
                 gemu_log("SO_SNDTIMEO,");
-                goto print_optint;
+                print_timeval(optval, 0);
+                break;
             case TARGET_SO_ATTACH_FILTER: {
                 struct target_sock_fprog *fprog;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace
  2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace Laurent Vivier
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace Laurent Vivier
@ 2016-06-08 20:24 ` Laurent Vivier
  2016-06-10 12:54   ` Peter Maydell
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace Laurent Vivier
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace Laurent Vivier
  4 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.c    | 24 ++++++++++++++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 398e56e..0c3675c 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1221,6 +1221,30 @@ print__llseek(const struct syscallname *name,
 }
 #endif
 
+#if defined(TARGET_NR_socket)
+static void
+print_socket(const struct syscallname *name,
+             abi_long arg0, abi_long arg1, abi_long arg2,
+             abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    abi_ulong domain = arg0, type = arg1, protocol = arg2;
+
+    print_syscall_prologue(name);
+    print_socket_domain(domain);
+    gemu_log(",");
+    print_socket_type(type);
+    gemu_log(",");
+    if (domain == AF_PACKET ||
+        type == TARGET_SOCK_PACKET) {
+        protocol = tswapal(protocol); /* restore network endian long */
+        protocol = abi_ntohl(protocol); /* a host endian long */
+    }
+    print_socket_protocol(domain, type, protocol);
+    print_syscall_epilogue(name);
+}
+
+#endif
+
 #if defined(TARGET_NR_socketcall)
 static void
 print_socketcall(const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index b379497..7c54dc6 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1291,7 +1291,7 @@
 { TARGET_NR_sigsuspend, "sigsuspend" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_socket
-{ TARGET_NR_socket, "socket" , NULL, NULL, NULL },
+{ TARGET_NR_socket, "socket" , NULL, print_socket, NULL },
 #endif
 #ifdef TARGET_NR_socketcall
 { TARGET_NR_socketcall, "socketcall" , NULL, print_socketcall, NULL },
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace
  2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
                   ` (2 preceding siblings ...)
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace Laurent Vivier
@ 2016-06-08 20:24 ` Laurent Vivier
  2016-06-10 13:13   ` Peter Maydell
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace Laurent Vivier
  4 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 0c3675c..ec39750 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -964,27 +964,30 @@ print_clone(const struct syscallname *name,
     abi_long arg3, abi_long arg4, abi_long arg5)
 {
     print_syscall_prologue(name);
-#if defined(TARGET_M68K)
+#if defined(TARGET_MICROBLAZE)
     print_flags(clone_flags, arg0, 0);
-    print_raw_param("newsp=0x" TARGET_ABI_FMT_lx, arg1, 1);
-#elif defined(TARGET_SH4) || defined(TARGET_ALPHA)
+    print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0);
+    print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 0);
+    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg5, 0);
+    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
+#elif defined(TARGET_CLONE_BACKWARDS)
     print_flags(clone_flags, arg0, 0);
     print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0);
     print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
-    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 0);
-    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 1);
-#elif defined(TARGET_CRIS)
-    print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg0, 0);
+    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0);
+    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
+#elif defined(TARGET_CLONE_BACKWARDS2)
     print_flags(clone_flags, arg1, 0);
+    print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg0, 0);
     print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
-    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0);
-    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
+    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 0);
+    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 1);
 #else
     print_flags(clone_flags, arg0, 0);
     print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0);
     print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
-    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0);
-    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
+    print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 0);
+    print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 1);
 #endif
     print_syscall_epilogue(name);
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace
  2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
                   ` (3 preceding siblings ...)
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace Laurent Vivier
@ 2016-06-08 20:24 ` Laurent Vivier
  2016-06-10 13:04   ` Peter Maydell
  4 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2016-06-08 20:24 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel, Laurent Vivier

       int get_thread_area(struct user_desc *u_info);
       int set_thread_area(struct user_desc *u_info);

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.list | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 7c54dc6..9c0259c 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -337,7 +337,7 @@
 { TARGET_NR_getsockopt, "getsockopt" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_get_thread_area
-{ TARGET_NR_get_thread_area, "get_thread_area" , NULL, NULL, NULL },
+{ TARGET_NR_get_thread_area, "get_thread_area", "%s(%p)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_gettid
 { TARGET_NR_gettid, "gettid" , NULL, NULL, NULL },
@@ -1234,7 +1234,7 @@
 { TARGET_NR_setsockopt, "setsockopt" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_set_thread_area
-{ TARGET_NR_set_thread_area, "set_thread_area" , NULL, NULL, NULL },
+{ TARGET_NR_set_thread_area, "set_thread_area", "%s(%p)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_set_tid_address
 { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL },
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace Laurent Vivier
@ 2016-06-10 12:51   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2016-06-10 12:51 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Riku Voipio, QEMU Developers

On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
> From: Laurent Vivier <Laurent@Vivier.EU>
>
> Signed-off-by: Laurent Vivier <Laurent@Vivier.EU>
> ---
>  include/exec/user/abitypes.h |  23 ++
>  linux-user/strace.c          | 550 +++++++++++++++++++++++++++++++++++++++++++
>  linux-user/strace.list       |   2 +-
>  linux-user/syscall_defs.h    |  22 +-
>  4 files changed, 592 insertions(+), 5 deletions(-)

I have a few comments, but this mostly looks good.

> diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
> index 80eedac..e33b1f8 100644
> --- a/include/exec/user/abitypes.h
> +++ b/include/exec/user/abitypes.h
> @@ -46,6 +46,15 @@ static inline abi_ulong tswapal(abi_ulong v)
>      return tswap32(v);
>  }
>
> +static inline abi_ulong abi_ntohl(abi_ulong v)
> +{
> +#if defined(HOST_BIG_ENDIAN)
> +    return v;
> +#else
> +    return bswap_32(v);
> +#endif
> +}
> +
>  #else
>  typedef target_ulong abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
>  typedef target_long abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
> @@ -62,5 +71,19 @@ static inline abi_ulong tswapal(abi_ulong v)
>      return tswapl(v);
>  }
>
> +static inline abi_ulong abi_ntohl(abi_ulong v)
> +{
> +#if defined(HOST_BIG_ENDIAN)
> +    return v;
> +#else
> +#if TARGET_LONG_SIZE == 4
> +    return bswap_32(v);
> +#else
> +    return bswap_64(v);
> +#endif
> +#endif
> +}
> +
> +
>  #endif
>  #endif

I suspect we don't actually need an abi_ntohl() -- see below.

> @@ -1004,6 +1221,339 @@ print__llseek(const struct syscallname *name,
>  }
>  #endif
>
> +#if defined(TARGET_NR_socketcall)
> +static void
> +print_socketcall(const struct syscallname *name,
> +                 abi_long arg0, abi_long arg1, abi_long arg2,
> +                 abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    const int n = sizeof(abi_ulong);

This is a kind of confusing variable name for this.

(Should we use the same code that do_socketcall in syscall.c
does to read the right number of arguments into an array
of abi_ulongs ?)

> +    const char *socketcallname;
> +
> +    switch (arg0) {
> +    case SOCKOP_bind: {
> +        abi_ulong sockfd, addr, addrlen;
> +
> +        socketcallname = "bind";
> +
> +print_sockaddr:
> +        get_user_ual(sockfd, arg1);
> +        get_user_ual(addr, arg1 + n);
> +        get_user_ual(addrlen, arg1 + 2 * n);
> +
> +        gemu_log("%s(", socketcallname);
> +        print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
> +        print_sockaddr(addr, addrlen);
> +        gemu_log(")");
> +        break;

I think a helper function so you just say
do_print_sockaddr("bind", arg1);
would be nicer than these gotos. Similarly with the other code
like this below.

> +    }
> +    case SOCKOP_connect:
> +        socketcallname = "connect";
> +        goto print_sockaddr;
> +    case SOCKOP_accept:
> +        socketcallname = "accept";
> +        goto print_sockaddr;
> +    case SOCKOP_getsockname:
> +        socketcallname = "getsockname";
> +        goto print_sockaddr;
> +    case SOCKOP_getpeername:
> +        socketcallname = "getpeername";
> +        goto print_sockaddr;
> +    case SOCKOP_socket: {
> +        abi_ulong domain, type, protocol;
> +
> +        get_user_ual(domain, arg1);
> +        get_user_ual(type, arg1 + n);
> +        get_user_ual(protocol, arg1 + 2 * n);
> +        gemu_log("socket(");
> +        print_socket_domain(domain);
> +        gemu_log(",");
> +        print_socket_type(type);
> +        gemu_log(",");
> +        if (domain == AF_PACKET ||
> +            type == TARGET_SOCK_PACKET) {
> +            protocol = tswapal(protocol); /* restore network endian long */
> +            protocol = abi_ntohl(protocol); /* a host endian long */

This doesn't seem to match the kind of byteswapping we do in the
syscall.c code, which just does a tswap16().

> +        }
> +        print_socket_protocol(domain, type, protocol);
> +        gemu_log(")");
> +        break;
> +    }

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace.
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace Laurent Vivier
@ 2016-06-10 12:53   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2016-06-10 12:53 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Riku Voipio, QEMU Developers

On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
> From: Laurent Vivier <Laurent@Vivier.EU>
>
> Parameter of SO_RCVTIMEO and SO_SNDTIMEO is timeval, not int.
>
> To test this, you can use :
>
> QEMU_STRACE= ping localhost 2>&1 |grep TIMEO
> 568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) = 0
> 568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) = 0
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index a7b24e2..398e56e 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1486,10 +1486,12 @@ print_optint:
>                  goto print_optint;
>              case TARGET_SO_RCVTIMEO:
>                  gemu_log("SO_RCVTIMEO,");
> -                goto print_optint;
> +                print_timeval(optval, 0);
> +                break;
>              case TARGET_SO_SNDTIMEO:
>                  gemu_log("SO_SNDTIMEO,");
> -                goto print_optint;
> +                print_timeval(optval, 0);
> +                break;
>              case TARGET_SO_ATTACH_FILTER: {
>                  struct target_sock_fprog *fprog;

You should just squash this into patch 1.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace Laurent Vivier
@ 2016-06-10 12:54   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2016-06-10 12:54 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Riku Voipio, QEMU Developers

On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.c    | 24 ++++++++++++++++++++++++
>  linux-user/strace.list |  2 +-
>  2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 398e56e..0c3675c 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1221,6 +1221,30 @@ print__llseek(const struct syscallname *name,
>  }
>  #endif
>
> +#if defined(TARGET_NR_socket)
> +static void
> +print_socket(const struct syscallname *name,
> +             abi_long arg0, abi_long arg1, abi_long arg2,
> +             abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    abi_ulong domain = arg0, type = arg1, protocol = arg2;
> +
> +    print_syscall_prologue(name);
> +    print_socket_domain(domain);
> +    gemu_log(",");
> +    print_socket_type(type);
> +    gemu_log(",");
> +    if (domain == AF_PACKET ||
> +        type == TARGET_SOCK_PACKET) {
> +        protocol = tswapal(protocol); /* restore network endian long */
> +        protocol = abi_ntohl(protocol); /* a host endian long */

Same remarks apply about this not being the same swapping
we do in syscall.c for do_socket().

> +    }
> +    print_socket_protocol(domain, type, protocol);
> +    print_syscall_epilogue(name);
> +}
> +
> +#endif
> +
>  #if defined(TARGET_NR_socketcall)
>  static void
>  print_socketcall(const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index b379497..7c54dc6 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -1291,7 +1291,7 @@
>  { TARGET_NR_sigsuspend, "sigsuspend" , NULL, NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_socket
> -{ TARGET_NR_socket, "socket" , NULL, NULL, NULL },
> +{ TARGET_NR_socket, "socket" , NULL, print_socket, NULL },
>  #endif
>  #ifdef TARGET_NR_socketcall
>  { TARGET_NR_socketcall, "socketcall" , NULL, print_socketcall, NULL },
> --
> 2.5.5
>
>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace Laurent Vivier
@ 2016-06-10 13:04   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2016-06-10 13:04 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Riku Voipio, QEMU Developers

On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
>        int get_thread_area(struct user_desc *u_info);
>        int set_thread_area(struct user_desc *u_info);
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.list | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 7c54dc6..9c0259c 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -337,7 +337,7 @@
>  { TARGET_NR_getsockopt, "getsockopt" , NULL, NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_get_thread_area
> -{ TARGET_NR_get_thread_area, "get_thread_area" , NULL, NULL, NULL },
> +{ TARGET_NR_get_thread_area, "get_thread_area", "%s(%p)", NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_gettid
>  { TARGET_NR_gettid, "gettid" , NULL, NULL, NULL },
> @@ -1234,7 +1234,7 @@
>  { TARGET_NR_setsockopt, "setsockopt" , NULL, NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_set_thread_area
> -{ TARGET_NR_set_thread_area, "set_thread_area" , NULL, NULL, NULL },
> +{ TARGET_NR_set_thread_area, "set_thread_area", "%s(%p)", NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_set_tid_address
>  { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL },

The problem with this is that %p is a format string for a host pointer,
but the argument we pass to gemu_log() in print_syscall() is an abi_long.
If host pointers are 64 bit but abi_long is 32 bit this is going to do
the wrong thing.

This is a bug present in some of our current format strings, but
we should probably not add to it. I think TARGET_ABI_FMT_lx should
do what you want?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace
  2016-06-08 20:24 ` [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace Laurent Vivier
@ 2016-06-10 13:13   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2016-06-10 13:13 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Riku Voipio, QEMU Developers

On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)

I think this change is correct, but it would be clearer to read
if we defined a do_print_clone() that did the actual printing and
took arguments in the same order as the do_fork() function in
syscall.c. Then it would be easy to compare the syscall.c and
this code to check they pass the arguments in the same order
to the function that does the work.
(Also, naming the arguments here arg1..arg6 rather than arg0..arg5
would make them match syscall.c.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-06-10 13:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08 20:24 [Qemu-devel] [PATCH 0/5] linux-user: some strace improvements Laurent Vivier
2016-06-08 20:24 ` [Qemu-devel] [PATCH 1/5] linux-user: add socketcall() strace Laurent Vivier
2016-06-10 12:51   ` Peter Maydell
2016-06-08 20:24 ` [Qemu-devel] [PATCH 2/5] linux-user: correct setsockopt() strace Laurent Vivier
2016-06-10 12:53   ` Peter Maydell
2016-06-08 20:24 ` [Qemu-devel] [PATCH 3/5] linux-user: add socket() strace Laurent Vivier
2016-06-10 12:54   ` Peter Maydell
2016-06-08 20:24 ` [Qemu-devel] [PATCH 4/5] linux-user: fix clone() strace Laurent Vivier
2016-06-10 13:13   ` Peter Maydell
2016-06-08 20:24 ` [Qemu-devel] [PATCH 5/5] linux-user: update get_thread_area/set_thread_area strace Laurent Vivier
2016-06-10 13:04   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.