Skip to content
Snippets Groups Projects
  1. Nov 15, 2020
  2. Aug 27, 2020
    • Filip Bozuta's avatar
      linux-user: Add strace support for printing arguments for ioctls used for... · 888468db
      Filip Bozuta authored
      linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines
      
      Functions "print_ioctl()" and "print_syscall_ret_ioctl()" are used
      to print arguments of "ioctl()" with "-strace". These functions
      use "thunk_print()", which is defined in "thunk.c", to print the
      contents of ioctl's third arguments that are not basic types.
      
      However, this function doesn't handle ioctls of group ioctl_tty which
      are used for terminals and serial lines. These ioctls use a type
      "struct termios" which thunk type is defined in a non standard
      way using "STRUCT_SPECIAL()". This means that this type is not decoded
      regularly using "thunk_convert()" and uses special converting functions
      "target_to_host_termios()" and "host_to_target_termios()", which are defined
      in "syscall.c" to decode it's values.
      
      For simillar reasons, this type is also not printed regularly using
      "thunk_print()". That is the reason why a separate printing function
      "print_termios()" is defined in file "strace.c". This function decodes
      and prints flag values of the "termios" structure.
      
      Implementation notes:
      
          Function "print_termios()" was implemented in "strace.c" using
          an existing function "print_flags()" to print flag values of
          "struct termios" fields. Also, recently implemented function
          "print_enums()" was also used to print enumareted values which
          are contained in the fields of 'struct termios'.
      
          These flag values were defined using an existing macro "FLAG_TARGET()"
          that generates aproppriate target flag values and string representations
          of these flags. Also, the recently defined macro "ENUM_TARGET()" was
          used to generate aproppriate enumarated values and their respective
          string representations.
      
          Function "print_termios()" was declared in "qemu.h" so that it can
          be accessed in "syscall.c". Type "StructEntry" defined in
          "exec/user/thunk.h" contains information that is used to decode
          structure values. Field "void print(void *arg)" was added in this
          structure as a special print function. Also, function "thunk_print()"
          was changed a little so that it uses this special print function
          in case it is defined. This printing function was instantiated with
          the defined "print_termios()" in "syscall.c" in "struct_termios_def".
      
      Signed-off-by: default avatarFilip Bozuta <Filip.Bozuta@syrmia.com>
      Reviewed-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20200723210233.349690-4-Filip.Bozuta@syrmia.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      888468db
  3. 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
  4. Mar 11, 2019
  5. Mar 06, 2019
  6. Jul 31, 2017
  7. Jun 07, 2016
  8. Feb 04, 2016
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  9. Jun 15, 2015
    • Alexander Graf's avatar
      linux-user: Allocate thunk size dynamically · 8be656b8
      Alexander Graf authored
      
      We store all struct types in an array of static size without ever
      checking whether we overrun it. Of course some day someone (like me
      in another, ancient ALSA enabling patch set) will run into the limit
      without realizing it.
      
      So let's make the allocation dynamic. We already know the number of
      structs that we want to allocate, so we only need to pass the variable
      into the respective piece of code.
      
      Also, to ensure we don't accidently overwrite random memory, add some
      asserts to sanity check whether a thunk is actually part of our array.
      
      Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
      Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
      8be656b8
  10. Dec 19, 2012
  11. Apr 06, 2012
  12. Jul 16, 2009
  13. Jan 04, 2009
  14. Oct 05, 2008
  15. Nov 19, 2007
  16. Nov 11, 2007
  17. Oct 14, 2007
  18. Sep 17, 2007
  19. Sep 16, 2007
  20. Jan 30, 2005
  21. Nov 09, 2004
  22. Jun 15, 2003
  23. Apr 07, 2003
  24. Mar 23, 2003
  25. Feb 18, 2003
Loading