From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] Avoid find_thread_ptid with null_ptid
Date: Tue, 02 Oct 2018 17:08:00 -0000 [thread overview]
Message-ID: <4a78c0f6-9d0a-2ee0-30cb-39f950f5fec5@redhat.com> (raw)
In-Reply-To: <87d0stll3u.fsf@tromey.com>
On 10/01/2018 04:53 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> This patch prepares for the change, by avoiding passing down null_ptid
> Pedro> to find_thread_ptid or to functions that naturally use it
>
> Should find_thread_ptid assert this?
I didn't think it's useful, since the code will end up like this:
struct thread_info *
find_thread_ptid (ptid_t ptid)
{
inferior *inf = find_inferior_ptid (ptid);
if (inf == NULL)
return NULL;
return find_thread_ptid (inf, ptid);
}
and null_ptid hits that assertion in:
struct inferior *
find_inferior_pid (int pid)
{
/* Looking for inferior pid == 0 is always wrong, and indicative of
a bug somewhere else. There may be more than one with pid == 0,
for instance. */
gdb_assert (pid != 0);
But I can add it if you prefer.
>
> Pedro> if (print_inferior_events)
> Pedro> - printf_unfiltered (_("[New inferior %d (%s)]\n"),
> Pedro> - inf->num,
> Pedro> - target_pid_to_str (ptid_t (pid)));
> Pedro> + {
> Pedro> + if (pid != 0)
> Pedro> + printf_unfiltered (_("[New inferior %d (%s)]\n"),
> Pedro> + inf->num,
> Pedro> + target_pid_to_str (ptid_t (pid)));
> Pedro> + else
> Pedro> + printf_unfiltered (_("[New inferior %d]\n"), inf->num);
>
> I wonder if it is possible for an RSP implementation to say that the
> inferior has PID 0.
GDB would break down badly. Throughout we assume pid == 0 means the
inferior/process is not started.
The RSP docs say:
"In addition, the remote protocol supports a multiprocess feature in
which the @var{thread-id} syntax is extended to optionally include both
process and thread ID fields, as @samp{p@var{pid}.@var{tid}}.
The @var{pid} (process) and @var{tid} (thread) components each have the
format described above: a positive number with target-specific
^^^^^^^^^^^^^^^^^
interpretation formatted as a big-endian hex string, literal @samp{-1}
to indicate all processes or threads (respectively), or @samp{0} to
^^^^^^^^^^^^^^
indicate an arbitrary process or thread. Specifying just a process, as
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks,
Pedro Alves
next prev parent reply other threads:[~2018-10-02 17:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 10:32 [PATCH 0/3] Per-inferior thread list, multi-target prep Pedro Alves
2018-10-01 10:32 ` [PATCH 1/3] Avoid find_thread_ptid with null_ptid Pedro Alves
2018-10-01 15:54 ` Tom Tromey
2018-10-02 17:08 ` Pedro Alves [this message]
2018-10-02 21:14 ` Tom Tromey
2018-10-01 10:33 ` [PATCH 2/3] Fix follow_exec latent problem Pedro Alves
2018-10-01 10:33 ` [PATCH 3/3] Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc Pedro Alves
2018-10-01 16:33 ` John Baldwin
2018-10-02 13:21 ` Pedro Alves
2018-10-03 17:34 ` John Baldwin
2018-10-04 19:16 ` Pedro Alves
2018-10-01 17:12 ` Tom Tromey
2018-10-03 12:12 ` Pedro Alves
2018-11-22 16:28 ` [PATCH 0/3] Per-inferior thread list, multi-target prep Pedro Alves
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=4a78c0f6-9d0a-2ee0-30cb-39f950f5fec5@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).