Skip to content

Commit c42569f

Browse files
bozutafvivier
authored andcommitted
linux-user: Add strace support for a group of syscalls
This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta <[email protected]> Reviewed-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent c84be71 commit c42569f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

linux-user/strace.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,18 @@ print_access(const struct syscallname *name,
13571357
}
13581358
#endif
13591359

1360+
#ifdef TARGET_NR_acct
1361+
static void
1362+
print_acct(const struct syscallname *name,
1363+
abi_long arg0, abi_long arg1, abi_long arg2,
1364+
abi_long arg3, abi_long arg4, abi_long arg5)
1365+
{
1366+
print_syscall_prologue(name);
1367+
print_string(arg0, 1);
1368+
print_syscall_epilogue(name);
1369+
}
1370+
#endif
1371+
13601372
#ifdef TARGET_NR_brk
13611373
static void
13621374
print_brk(const struct syscallname *name,
@@ -1621,7 +1633,6 @@ print_fcntl(const struct syscallname *name,
16211633
#define print_fcntl64 print_fcntl
16221634
#endif
16231635

1624-
16251636
#ifdef TARGET_NR_futimesat
16261637
static void
16271638
print_futimesat(const struct syscallname *name,

linux-user/strace.list

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{ TARGET_NR_access, "access" , NULL, print_access, NULL },
1414
#endif
1515
#ifdef TARGET_NR_acct
16-
{ TARGET_NR_acct, "acct" , NULL, NULL, NULL },
16+
{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL },
1717
#endif
1818
#ifdef TARGET_NR_add_key
1919
{ TARGET_NR_add_key, "add_key" , NULL, NULL, NULL },
@@ -215,7 +215,7 @@
215215
{ TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL },
216216
#endif
217217
#ifdef TARGET_NR_fdatasync
218-
{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL },
218+
{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL },
219219
#endif
220220
#ifdef TARGET_NR_fgetxattr
221221
{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL },
@@ -251,7 +251,7 @@
251251
{ TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL },
252252
#endif
253253
#ifdef TARGET_NR_fsync
254-
{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL },
254+
{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL },
255255
#endif
256256
#ifdef TARGET_NR_ftime
257257
{ TARGET_NR_ftime, "ftime" , NULL, NULL, NULL },
@@ -492,7 +492,7 @@
492492
{ TARGET_NR_Linux, "Linux" , NULL, NULL, NULL },
493493
#endif
494494
#ifdef TARGET_NR_listen
495-
{ TARGET_NR_listen, "listen" , NULL, NULL, NULL },
495+
{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL },
496496
#endif
497497
#ifdef TARGET_NR_listxattr
498498
{ TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL },

0 commit comments

Comments
 (0)