qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Nathan Froyd <froydnj@codesourcery.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] fix gdbstub support for multiple threads in usermode, v3
Date: Wed, 03 Jun 2009 21:40:48 +0200	[thread overview]
Message-ID: <4A26D1C0.80701@web.de> (raw)
In-Reply-To: <1244053988-14307-1-git-send-email-froydnj@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1658 bytes --]

Nathan Froyd wrote:
> When debugging multi-threaded programs, QEMU's gdb stub would report the
> correct number of threads (the qfThreadInfo and qsThreadInfo packets).
> However, the stub was unable to actually switch between threads (the T
> packet), since it would report every thread except the first as being
> dead.  Furthermore, the stub relied upon cpu_index as a reliable means
> of assigning IDs to the threads.  This was a bad idea; if you have this
> sequence of events:
> 
> initial thread created
> new thread #1
> new thread #2
> thread #1 exits
> new thread #3
> 
> thread #3 will have the same cpu_index as thread #1, which would confuse
> GDB.  (This problem is partly due to the remote protocol not having a
> good way to send thread creation/destruction events.)
> 
> We fix this by using the host thread ID for the identifier passed to GDB
> when debugging a multi-threaded userspace program.  The thread ID might
> wrap, but the same sort of problems with wrapping thread IDs would come
> up with debugging programs natively, so this doesn't represent a
> problem.
> ---
>  cpu-defs.h           |    1 +
>  exec.c               |    2 +-
>  gdbstub.c            |   69 +++++++++++++++++++++++++++++++------------------
>  linux-user/syscall.c |    4 ++-
>  4 files changed, 49 insertions(+), 27 deletions(-)
> 
> Changes from earlier versions: use the host thread ID as the unique ID
> to pass to GDB instead of inventing a new ID that tries to be robust
> against wrapping.

Looks good to me, has additionally some nice cleanup aspects, and
survived a quick regression test in system mode.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2009-06-03 19:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 18:33 [Qemu-devel] [PATCH] fix gdbstub support for multiple threads in usermode, v3 Nathan Froyd
2009-06-03 19:40 ` Jan Kiszka [this message]
2009-06-04 16:03 ` [Qemu-devel] [PATCH w/S-o-b] " Nathan Froyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A26D1C0.80701@web.de \
    --to=jan.kiszka@web.de \
    --cc=froydnj@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).