This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA]corelow.c: Add tid to add_to_thread_list


On Fri, Aug 6, 2010 at 02:44, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>
>>> I make a patch for kernel (http://lkml.org/lkml/2010/8/3/75) but they
>>> think it should be fixed in user space.
>>> So I add the tid to add_to_thread_list.
>
> I don't know about this area of gdb, so I can't really comment on the
> semantics of the change, but I do have a comment about how the change is
> written:
>
>>> - ?ptid = ptid_build (pid, lwpid, 0);
>>> + ?tid = 0;
>>> +get_ptid:
>>> + ?ptid = ptid_build (pid, lwpid, tid);
>>> + ?if (find_thread_ptid (ptid))
>>> + ? ?{
>>> + ? ? ?tid ++;
>>> + ? ? ?goto get_ptid;
>>> + ? ?}
>
> I think this would be more readably written without 'goto', as a loop.
>
> Tom
>

Thanks.  The prev one is too casual.  I make a new one that use the loop.

Best,
Hui

2010-08-06  Hui Zhu  <teawater@gmail.com>

	* corelow.c(add_to_thread_list): Add tid.

---
 corelow.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- a/corelow.c
+++ b/corelow.c
@@ -244,7 +244,7 @@ add_to_thread_list (bfd *abfd, asection
 {
   ptid_t ptid;
   int core_tid;
-  int pid, lwpid;
+  int pid, lwpid, tid;
   asection *reg_sect = (asection *) reg_sect_arg;

   if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
@@ -278,7 +278,13 @@ add_to_thread_list (bfd *abfd, asection
   if (current_inferior ()->pid == 0)
     inferior_appeared (current_inferior (), pid);

-  ptid = ptid_build (pid, lwpid, 0);
+  tid = 0;
+  do
+    {
+      ptid = ptid_build (pid, lwpid, tid);
+      tid ++;
+    }
+  while (find_thread_ptid (ptid));

   add_thread (ptid);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]