Skip to content
Snippets Groups Projects
  1. Sep 28, 2022
  2. Sep 27, 2022
  3. Jun 02, 2022
  4. May 18, 2021
  5. May 15, 2021
  6. Aug 27, 2020
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of some clock and time functions · 1a674adf
      Filip Bozuta authored
      This patch implements strace argument printing functionality for following syscalls:
      
          * clock_getres, clock_gettime, clock_settime - clock and time functions
      
              int clock_getres(clockid_t clockid, struct timespec *res)
              int clock_gettime(clockid_t clockid, struct timespec *tp)
              int clock_settime(clockid_t clockid, const struct timespec *tp)
              man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
      
          * gettimeofday - get time
      
              int gettimeofday(struct timeval *tv, struct timezone *tz)
              man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
      
          * getitimer, setitimer - get or set value of an interval timer
      
              int getitimer(int which, struct itimerval *curr_value)
              int setitimer(int which, const struct itimerval *new_value,
                            struct itimerval *old_value)
              man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
      
      
      
      Implementation notes:
      
          All of the syscalls have some structue types as argument types and thus
          a separate printing function was stated in file "strace.list" for each
          of them. All of these functions use existing functions for their
          appropriate structure types ("print_timeval()" and "print_timezone()").
      
          Functions "print_timespec()" and "print_itimerval()" were added in this
          patch so that they can be used to print types "struct timespec" and
          "struct itimerval" used by some of the syscalls. Function "print_itimerval()"
          uses the existing function "print_timeval()" to print fields of the
          structure "struct itimerval" that are of type "struct timeval".
      
          Function "print_enums()", which was introduced in the previous patch, is used
          to print the interval timer type which is the first argument of "getitimer()"
          and "setitimer()". Also, this function is used to print the clock id which
          is the first argument of "clock_getres()" and "clock_gettime()". For that
          reason, the existing function "print_clockid()" was removed in this patch.
          Existing function "print_clock_adjtime()" was also changed for this reason
          to use "print_enums()".
      
          The existing function "print_timeval()" was changed a little so that it
          prints the field names beside the values.
      
          Syscalls "clock_getres()" and "clock_gettime()" have the same number
          and types of arguments and thus their print functions "print_clock_getres"
          and "print_clock_gettime" share a common definition in file "strace.c".
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      1a674adf
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory · 02e5d7d7
      Filip Bozuta authored
      This patch implements strace argument printing functionality for following syscalls:
      
          * mlock, munlock, mlockall, munlockall - lock and unlock memory
      
             int mlock(const void *addr, size_t len)
             int munlock(const void *addr, size_t len)
             int mlockall(int flags)
             int munlockall(void)
             man page: https://man7.org/linux/man-pages/man2/mlock.2.html
      
      
      
      Implementation notes:
      
          Syscall mlockall() takes an argument that is composed of predefined values
          which represent flags that determine the type of locking operation that is
          to be performed. For that reason, a printing function "print_mlockall" was
          stated in file "strace.list". This printing function uses an already existing
          function "print_flags()" to print the "flags" argument.  These flags are stated
          inside an array "mlockall_flags" that contains values of type "struct flags".
          These values are instantiated using an existing macro "FLAG_TARGET()" that
          crates aproppriate target flag values based on those defined in files
          '/target_syscall.h'. These target flag values were changed from
          "TARGET_MLOCKALL_MCL*" to "TARGET_MCL_*" so that they can be aproppriately set
          and recognised in "strace.c" with "FLAG_TARGET()". Value for "MCL_ONFAULT"
          was added in this patch. This value was also added in "syscall.c" in function
          "target_to_host_mlockall_arg()". Because this flag value was added in kernel
          version 4.4, it is enwrapped in an #ifdef directive (both in "syscall.c" and
          in "strace.c") as to support older kernel versions.
          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". Syscall mlock2() is not implemented in
          "syscall.c" and thus it's argument printing is not implemented in this patch.
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200811164553.27713-4-Filip.Bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      02e5d7d7
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid() · 7c89f343
      Filip Bozuta authored
      This patch implements strace argument printing functionality for following syscalls:
      
          * truncate, ftruncate - truncate a file to a specified length
      
              int truncate/truncate64(const char *path, off_t length)
              int ftruncate/ftruncate64(int fd, off_t length)
              man page: https://man7.org/linux/man-pages/man2/truncate.2.html
      
          * getsid - get session ID
      
              pid_t getsid(pid_t pid)
              man page: https://man7.org/linux/man-pages/man2/getsid.2.html
      
      
      
      Implementation notes:
      
          Syscalls truncate/truncate64 take string argument types and thus a
          separate print function "print_truncate/print_truncate64" 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()".
          For syscall ftruncate64, a separate printing function was also stated in
          "strace.c" as it requires a special kind of handling.
          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".
          Function "regpairs_aligned()" was cut & pasted from "syscall.c" to "qemu.h"
          as it is used by functions "print_truncate64()" and "print_ftruncate64()"
          to print the offset arguments of "truncate64()" and "ftruncate64()".
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200811164553.27713-3-Filip.Bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      7c89f343
  7. Jul 04, 2020
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of ioctl() · 79482e59
      Filip Bozuta authored
      
      This patch implements functionality for strace argument printing for ioctls.
      When running ioctls through qemu with "-strace", they get printed in format:
      
          "ioctl(fd_num,0x*,0x*) = ret_value"
      
      where the request code an the ioctl's third argument get printed in a hexadicemal
      format. This patch changes that by enabling strace to print both the request code
      name and the contents of the third argument. For example, when running ioctl
      RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
      this way:
      
          "ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
      
      In case of IOC_R type ioctls, the contents of the third argument get printed
      after the return value, and the argument inside the ioctl call gets printed
      as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
      "-strace", with changes from this patch, it gets printed in this way:
      
          "ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
      
      In case of IOC_RW type ioctls, the contents of the third argument get printed
      both inside the ioctl call and after the return value.
      
      Implementation notes:
      
          Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
          in "strace.c", are listed in file "strace.list" as "call" and "result"
          value for ioctl. Structure definition "IOCTLEntry" as well as predefined
          values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
          to file "qemu.h" so that they can be used by these functions to print the
          contents of the third ioctl argument. Also, the "static" identifier for array
          "ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
          so that it can also be used by these functions. To decode the structure type
          of the ioctl third argument, function "thunk_print()" was defined in file
          "thunk.c" and its definition is somewhat simillar to that of function
          "thunk_convert()".
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
      [lv: fix close-bracket]
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      79482e59
  8. Jun 29, 2020
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of fallocate() · f4d92c5e
      Filip Bozuta authored
      This patch implements strace argument printing functionality for following syscall:
      
          *fallocate - manipulate file space
      
              int fallocate(int fd, int mode, off_t offset, off_t len)
              man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html
      
      
      
      Implementation notes:
      
          This syscall's second argument "mode" is composed of predefined values
          which represent flags that determine the type of operation that is
          to be performed on the file space. For that reason, a printing
          function "print_fallocate" was stated in file "strace.list". This printing
          function uses an already existing function "print_flags()" to print flags of
          the "mode" argument. These flags are stated inside an array "falloc_flags"
          that contains values of type "struct flags". These values are instantiated
          using an existing macro "FLAG_GENERIC()". Most of these flags are defined
          after kernel version 3.0 which is why they are enwrapped in an #ifdef
          directive.
          The syscall's third ant fourth argument are of type "off_t" which can
          cause variations between 32/64-bit architectures. To handle this variation,
          function "target_offset64()" was copied from file "strace.c" and used in
          "print_fallocate" to print "off_t" arguments for 32-bit architectures.
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619123331.17387-7-filip.bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      f4d92c5e
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of chown()/lchown() · 5844f4bc
      Filip Bozuta authored
      This patch implements strace argument printing functionality for syscalls:
      
          *chown, lchown - change ownership of a file
      
              int chown(const char *pathname, uid_t owner, gid_t group)
              int lchown(const char *pathname, uid_t owner, gid_t group)
              man page: https://www.man7.org/linux/man-pages/man2/lchown.2.html
      
      
      
      Implementation notes:
      
          Both syscalls use strings as arguments and thus a separate
          printing function was stated in "strace.list" for them.
          Both syscalls share the same number and types of arguments
          and thus share a same definition in file "syscall.c".
          This defintion uses existing functions "print_string()" to
          print the string argument and "print_raw_param()" to print
          other two arguments that are of basic types.
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619123331.17387-6-filip.bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      5844f4bc
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments of lseek() · af861dea
      Filip Bozuta authored
      This patch implements strace argument printing functionality for syscall:
      
          *lseek - reposition read/write file offset
      
               off_t lseek(int fd, off_t offset, int whence)
               man page: https://www.man7.org/linux/man-pages/man2/lseek.2.html
      
      
      
      Implementation notes:
      
          The syscall's third argument "whence" has predefined values:
          "SEEK_SET","SEEK_CUR","SEEK_END","SEEK_DATA","SEEK_HOLE"
          and thus a separate printing function "print_lseek" was stated
          in file "strace.list". This function is defined in "strace.c"
          by using an existing function "print_raw_param()" to print
          the first and second argument and a switch(case) statement
          for the predefined values of the third argument.
          Values "SEEK_DATA" and "SEEK_HOLE" are defined in kernel version 3.1.
          That is the reason why case statements for these values are
          enwrapped in #ifdef directive.
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619123331.17387-5-filip.bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      af861dea
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing argument of syscalls used for extended attributes · 4fc3cdde
      Filip Bozuta authored
      This patch implements strace argument printing functionality for following syscalls:
      
          *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
      
              ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
              ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
              ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
              man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
      
          *listxattr, llistxattr, flistxattr - list extended attribute names
      
              ssize_t listxattr(const char *path, char *list, size_t size)
              ssize_t llistxattr(const char *path, char *list, size_t size)
              ssize_t flistxattr(int fd, char *list, size_t size)
              man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
      
          *removexattr, lremovexattr, fremovexattr - remove an extended attribute
      
               int removexattr(const char *path, const char *name)
               int lremovexattr(const char *path, const char *name)
               int fremovexattr(int fd, const char *name)
               man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
      
      
      
      Implementation notes:
      
          All of the syscalls have strings as argument types and thus a separate
          printing function was stated in file "strace.list" for every one of them.
          All of these printing functions were defined in "strace.c" using existing
          printing functions for appropriate argument types:
             "print_string()" - for (const char*) type
             "print_pointer()" - for (char*) and (void *) type
             "print_raw_param()" for (int) and (size_t) type
          Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
          arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
          share a same definition. The same statement applies to syscalls "listxattr()"
          and "llistxattr()".
          Function "print_syscall_ret_listxattr()" was added to print the returned list
          of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
          print_flistxattr()".
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      4fc3cdde
    • Filip Bozuta's avatar
      linux-user: Add strace support for a group of syscalls · c42569f6
      Filip Bozuta authored
      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: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200619123331.17387-3-filip.bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      c42569f6
  9. Jun 05, 2020
  10. Feb 19, 2020
  11. Oct 21, 2019
  12. Jul 02, 2019
  13. Mar 07, 2019
  14. Jul 03, 2018
  15. Jun 11, 2018
  16. May 29, 2017
    • Miloš Stojanović's avatar
      linux-user: add rt_tgsigqueueinfo() strace · 243e0fe5
      Miloš Stojanović authored
      
      This commit improves strace support for syscall rt_tgsigqueueinfo().
      
      Prior to this commit, typical strace output used to look like this:
      7775 rt_tgsigqueueinfo(7775,7775,50,1996483164,0,0) = 0
      
      After this commit, it looks like this:
      7775 rt_tgsigqueueinfo(7775,7775,50,0x76ffea5c) = 0
      
      Signed-off-by: default avatarMiloš Stojanović <Milos.Stojanovic@rt-rk.com>
      Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
      243e0fe5
    • Miloš Stojanović's avatar
      linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace · 5162264e
      Miloš Stojanović authored
      
      Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
      by implementing print functions that match arguments types of the system
      calls and add them to the corresponding starce.list entry.
      
      tkill:
      Prior to this commit, typical strace output used to look like this:
      4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
      After this commit, it looks like this:
      4886 tkill(4886,50) = 0
      
      tgkill:
      Prior to this commit, typical strace output used to look like this:
      4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
      After this commit, it looks like this:
      4890 tgkill(4890,4890,50) = 0
      
      rt_sigqueueinfo:
      Prior to this commit, typical strace output used to look like this:
      8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
      After this commit, it looks like this:
      8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
      
      Signed-off-by: default avatarMiloš Stojanović <Milos.Stojanovic@rt-rk.com>
      Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
      5162264e
    • Miloš Stojanović's avatar
      linux-user: add strace for getuid(), gettid(), getppid(), geteuid() · 65424cc4
      Miloš Stojanović authored
      
      Improve strace support for syscalls getuid(), gettid(), getppid()
      and geteuid(). Since these system calls don't have arguments, "%s()"
      is added in the corresponding strace.list entry so that no arguments
      are printed.
      
      getuid:
      Prior to this commit, typical strace output used to look like this:
      4894 getuid(4894,0,0,274886293296,-3689348814741910323,4832615904) = 1000
      After this commit, it looks like this:
      4894 getuid() = 1000
      
      gettid:
      Prior to this commit, typical strace output used to look like this:
      8307 gettid(0,0,64,0,4832630528,4832615840) = 8307
      After this commit, it looks like this:
      8307 gettid() = 8307
      
      getppid:
      Prior to this commit, typical strace output used to look like this:
      20588 getppid(20588,64,0,4832630528,4832615888,0) = 20625
      After this commit, it looks like this:
      20588 getppid() = 20625
      
      geteuid:
      Prior to this commit, typical strace output used to look like this:
      20588 geteuid(64,0,0,4832615888,0,-9151031864016699136) = 1000
      After this commit, it looks like this:
      20588 geteuid() = 1000
      
      Signed-off-by: default avatarMiloš Stojanović <Milos.Stojanovic@rt-rk.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
      65424cc4
  17. Oct 21, 2016
  18. Sep 23, 2016
  19. Jun 26, 2016
Loading