Re: [RFC] Implement -list-thread-groups.

Michael Snyder
2008-11-14T18:55:48Z

Vladimir Prus wrote:
> On Friday 14 November 2008 20:39:47 you wrote:
>>> diff --git a/gdb/thread.c b/gdb/thread.c
>>> index b1e318d..a32dff4 100644
>>> --- a/gdb/thread.c
>>> +++ b/gdb/thread.c
>>> @@ -636,9 +636,10 @@ set_stop_requested (ptid_t ptid, int stop)
>>> use from MI.
>>> If REQUESTED_THREAD is not -1, it's the GDB id of the thread
>>> that should be printed. Otherwise, all threads are
>>> - printed. */
>>> + printed.
>>> + If PID is not -1, only prints threads from the process PID. */
>> For completeness and consistency, how about adding
>> "Otherwise, threads from all attached PIDs are printed."
>
> Ok.
>
>>> void
>>> -print_thread_info (struct ui_out *uiout, int requested_thread)
>>> +print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
>>> {
>>> struct thread_info *tp;
>>> ptid_t current_ptid;
>>> @@ -646,6 +647,8 @@ print_thread_info (struct ui_out *uiout, int requested_thread)
>>> char *extra_info;
>>> int current_thread = -1;
>>>
>>> + gdb_assert (requested_thead == -1 || pid == -1);
>> I'm puzzled by this assert.
>> You don't think we'll ever want to specify both the pid and the thread?
>
> I think that makes no sense. If a thread is specified, then there's no possible
> use of 'pid'. Threads are globally numbered.

Even if it makes no sense in the sense that
it's not required, that doesn't necessarily make it
an error. Suppose somebody specifies both the pid and
the thread? What's the harm? If they're inconsistent
(this pid does not contain this thread), THEN we'll
return an error.