Skip to content
Snippets Groups Projects
  1. Jun 27, 2022
  2. Jun 10, 2022
    • Peter Maydell's avatar
      gdbstub: Don't use GDB syscalls if no GDB is attached · ebf1b4cb
      Peter Maydell authored
      
      In two places in gdbstub.c we look at gdbserver_state.init to decide
      whether we're going to do a semihosting syscall via the gdb remote
      protocol:
       * when setting up, if the user didn't explicitly select either
         native semihosting or gdb semihosting, we autoselect, with the
         intended behaviour "use gdb if gdb is connected"
       * when the semihosting layer attempts to do a syscall via gdb, we
         silently ignore it if the gdbstub wasn't actually set up
      
      However, if the user's commandline sets up the gdbstub but tells QEMU
      to start rather than waiting for a GDB to connect (eg using '-s' but
      not '-S'), then we will have gdbserver_state.init true but no actual
      connection; an attempt to use gdb syscalls will then crash because we
      try to use gdbserver_state.c_cpu when it hasn't been set up:
      
      #0  0x00007ffff6803ba8 in qemu_cpu_kick (cpu=0x0) at ../../softmmu/cpus.c:457
      #1  0x00007ffff6c03913 in gdb_do_syscallv (cb=0x7ffff6c19944 <common_semi_cb>,
          fmt=0x7ffff7573b7e "", va=0x7ffff56294c0) at ../../gdbstub.c:2946
      #2  0x00007ffff6c19c3a in common_semi_gdb_syscall (cs=0x7ffff83fe060,
          cb=0x7ffff6c19944 <common_semi_cb>, fmt=0x7ffff7573b75 "isatty,%x")
          at ../../semihosting/arm-compat-semi.c:494
      #3  0x00007ffff6c1a064 in gdb_isattyfn (cs=0x7ffff83fe060, gf=0x7ffff86a3690)
          at ../../semihosting/arm-compat-semi.c:636
      #4  0x00007ffff6c1b20f in do_common_semihosting (cs=0x7ffff83fe060)
          at ../../semihosting/arm-compat-semi.c:967
      #5  0x00007ffff693a037 in handle_semihosting (cs=0x7ffff83fe060)
          at ../../target/arm/helper.c:10316
      
      You can probably also get into this state via some odd
      corner cases involving connecting a GDB and then telling it
      to detach from all the vCPUs.
      
      Abstract out the test into a new gdb_attached() function
      which returns true only if there's actually a GDB connected
      to the debug stub and attached to at least one vCPU.
      
      Reported-by: default avatarLiviu Ionescu <ilg@livius.net>
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarLuc Michel <luc@lmichel.fr>
      Message-id: 20220526190053.521505-2-peter.maydell@linaro.org
      ebf1b4cb
  3. Apr 06, 2022
  4. Mar 22, 2022
  5. Dec 10, 2021
  6. Nov 29, 2021
    • Alex Bennée's avatar
      gdbstub: handle a potentially racing TaskState · a8e537fa
      Alex Bennée authored
      
      When dealing with multi-threaded userspace programs there is a race
      condition with the addition of cpu->opaque (aka TaskState). This is
      due to cpu_copy calling cpu_create which updates the global vCPU list.
      However the task state isn't set until later. This shouldn't be a
      problem because the new thread can't have executed anything yet but
      the gdbstub code does liberally iterate through the CPU list in
      various places.
      
      This sticking plaster ensure the not yet fully realized vCPU is given
      an pid of -1 which should be enough to ensure it doesn't show up
      anywhere else.
      
      In the longer term I think the code that manages the association
      between vCPUs and attached GDB processes could do with a clean-up and
      re-factor.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Tested-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Cc: Richard Henderson <richard.henderson@linaro.org>
      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/730
      Message-Id: <20211129140932.4115115-6-alex.bennee@linaro.org>
      a8e537fa
  7. Nov 04, 2021
  8. Sep 13, 2021
  9. Aug 26, 2021
  10. May 25, 2021
  11. May 02, 2021
  12. Mar 10, 2021
  13. Mar 09, 2021
  14. Mar 06, 2021
    • Paolo Bonzini's avatar
      chardev: add nodelay option · a9b1315f
      Paolo Bonzini authored
      
      The "delay" option was introduced as a way to enable Nagle's algorithm
      with ",nodelay".  Since the short form for boolean options has now been
      deprecated, introduce a more properly named "nodelay" option.  The "delay"
      option remains as an undocumented option.
      
      "delay" and "nodelay" are mutually exclusive.  Because the check is
      done at consumption time, the code also rejects them if one of the
      two is specified via -set.
      
      Based-on: <20210226080526.651705-1-pbonzini@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a9b1315f
  15. Feb 25, 2021
  16. Feb 08, 2021
  17. Jan 18, 2021
  18. Dec 15, 2020
    • Peter Maydell's avatar
      gdbstub: Correct misparsing of vCont C/S requests · 3ddd9036
      Peter Maydell authored
      In the vCont packet, two of the command actions (C and S) take an
      argument specifying the signal to be sent to the process/thread, which is
      sent as an ASCII string of two hex digits which immediately follow the
      'C' or 'S' character.
      
      Our code for parsing this packet accidentally skipped the first of the
      two bytes of the signal value, because it started parsing the hex string
      at 'p + 1' when the preceding code had already moved past the 'C' or
      'S' with "cur_action = *p++".
      
      This meant that we would only do the right thing for signals below
      10, and would misinterpret the rest.  For instance, when the debugger
      wants to send the process a SIGPROF (27 on x86-64) we mangle this into
      a SIGSEGV (11).
      
      Remove the accidental double increment.
      
      Fixes: https://bugs.launchpad.net/qemu/+bug/1773743
      
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-id: 20201121210342.10089-1-peter.maydell@linaro.org
      3ddd9036
  19. Oct 06, 2020
    • Pavel Dovgalyuk's avatar
      replay: create temporary snapshot at debugger connection · 56357d80
      Pavel Dovgalyuk authored
      
      When record/replay does not uses overlays for storing the snapshots,
      user is not capable of issuing reverse debugging commands.
      This patch adds creation of the VM snapshot on the temporary
      overlay image, when the debugger connects to QEMU.
      Therefore the execution can be rewind to the moment
      of the debugger connection while debugging the virtual machine.
      
      Signed-off-by: default avatarPavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
      
      --
      
      v6:
       - dropped unused error processing (suggested by Philippe Mathieu-Daudé)
      Message-Id: <160174524096.12451.11651270339216758643.stgit@pasha-ThinkPad-X280>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      56357d80
    • Pavel Dovgaluk's avatar
      gdbstub: add reverse continue support in replay mode · cda38259
      Pavel Dovgaluk authored
      
      This patch adds support of the reverse continue operation for gdbstub.
      Reverse continue finds the last breakpoint that would happen in normal
      execution from the beginning to the current moment.
      Implementation of the reverse continue replays the execution twice:
      to find the breakpoints that were hit and to seek to the last breakpoint.
      Reverse continue loads the previous snapshot and tries to find the breakpoint
      since that moment. If there are no such breakpoints, it proceeds to
      the earlier snapshot, and so on. When no breakpoints or watchpoints were
      hit at all, execution stops at the beginning of the replay log.
      
      Signed-off-by: default avatarPavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
      Message-Id: <160174522930.12451.6994758004725016836.stgit@pasha-ThinkPad-X280>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cda38259
    • Pavel Dovgaluk's avatar
      gdbstub: add reverse step support in replay mode · fda8458b
      Pavel Dovgaluk authored
      
      GDB remote protocol supports two reverse debugging commands:
      reverse step and reverse continue.
      This patch adds support of the first one to the gdbstub.
      Reverse step is intended to step one instruction in the backwards
      direction. This is not possible in regular execution.
      But replayed execution is deterministic, therefore we can load one of
      the prior snapshots and proceed to the desired step. It is equivalent
      to stepping one instruction back.
      There should be at least one snapshot preceding the debugged part of
      the replay log.
      
      Signed-off-by: default avatarPavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      
      --
      
      v4 changes:
       - inverted condition in cpu_handle_guest_debug (suggested by Alex Bennée)
      Message-Id: <160174522341.12451.1498758422543765253.stgit@pasha-ThinkPad-X280>
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      fda8458b
  20. Aug 21, 2020
    • Paolo Bonzini's avatar
      trace: switch position of headers to what Meson requires · 243af022
      Paolo Bonzini authored
      
      Meson doesn't enjoy the same flexibility we have with Make in choosing
      the include path.  In particular the tracing headers are using
      $(build_root)/$(<D).
      
      In order to keep the include directives unchanged,
      the simplest solution is to generate headers with patterns like
      "trace/trace-audio.h" and place forwarding headers in the source tree
      such that for example "audio/trace.h" includes "trace/trace-audio.h".
      
      This patch is too ugly to be applied to the Makefiles now.  It's only
      a way to separate the changes to the tracing header files from the
      Meson rewrite of the tracing logic.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      243af022
  21. Jul 21, 2020
  22. May 06, 2020
  23. Apr 07, 2020
  24. Mar 17, 2020
Loading