summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorPhilippe Ombredanne <pombredanne@nexb.com>2014-02-01 09:57:45 -0800
committerDmitry V. Levin <ldv@altlinux.org>2014-02-02 16:51:22 +0000
commit894c7e3858ede412e37a1752c716bed7f30a9605 (patch)
treeefaffb302587e9db4c8f524cb1f990c416e30dfd /net.c
parent123d401508a17403c9cafaa79a4bd771bce37c7e (diff)
downloadstrace-894c7e3858ede412e37a1752c716bed7f30a9605.tar.gz
strace-894c7e3858ede412e37a1752c716bed7f30a9605.tar.bz2
strace-894c7e3858ede412e37a1752c716bed7f30a9605.tar.xz
Add decoding of sockets descriptor 'paths' for network calls
* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto, sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg, sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode socket descriptor arguments using printfd. * pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls that take socket descriptor arguments. * tests/net-fd.test: New test for socket descriptor arguments decoding. * tests/Makefile.am (TESTS): Add net-fd.test. (net-fd.log): New dependency on net.log. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Diffstat (limited to 'net.c')
-rw-r--r--net.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/net.c b/net.c
index dd1e446..b6c8cc9 100644
--- a/net.c
+++ b/net.c
@@ -1711,7 +1711,8 @@ int
sys_bind(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu", tcp->u_arg[2]);
}
@@ -1728,7 +1729,9 @@ int
sys_listen(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
+ tprintf("%lu", tcp->u_arg[1]);
}
return 0;
}
@@ -1737,7 +1740,8 @@ static int
do_accept(struct tcb *tcp, int flags_arg)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
return 0;
}
if (!tcp->u_arg[2])
@@ -1777,7 +1781,8 @@ int
sys_send(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu, ", tcp->u_arg[2]);
/* flags */
@@ -1790,7 +1795,8 @@ int
sys_sendto(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu, ", tcp->u_arg[2]);
/* flags */
@@ -1810,7 +1816,8 @@ int
sys_sendmsg(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
/* flags */
tprints(", ");
@@ -1824,7 +1831,8 @@ sys_sendmmsg(struct tcb *tcp)
{
if (entering(tcp)) {
/* sockfd */
- tprintf("%d, ", (int) tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
if (!verbose(tcp)) {
tprintf("%#lx, %u, ",
tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
@@ -1843,7 +1851,8 @@ int
sys_recv(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
} else {
if (syserror(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -1862,7 +1871,8 @@ sys_recvfrom(struct tcb *tcp)
int fromlen;
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
} else {
if (syserror(tcp)) {
tprintf("%#lx, %lu, %lu, %#lx, %#lx",
@@ -1906,7 +1916,8 @@ int
sys_recvmsg(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
} else {
if (syserror(tcp) || !verbose(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -1926,7 +1937,8 @@ sys_recvmmsg(struct tcb *tcp)
static char str[5 + TIMESPEC_TEXT_BUFSIZE];
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
if (verbose(tcp)) {
sprint_timespec(str, tcp, tcp->u_arg[4]);
/* Abusing tcp->auxstr as temp storage.
@@ -1976,7 +1988,8 @@ int
sys_shutdown(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
}
return 0;
@@ -2077,7 +2090,8 @@ int
sys_getsockopt(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printxval(socketlayers, tcp->u_arg[1], "SOL_???");
tprints(", ");
switch (tcp->u_arg[1]) {
@@ -2343,7 +2357,8 @@ int
sys_setsockopt(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
tcp->u_arg[3], tcp->u_arg[4]);
tprintf(", %lu", tcp->u_arg[4]);