+2002-08-23  Mark Kettenis  <kettenis@gnu.org>
+
+       * linux-proc.c (struct linux_corefile_thread_data): Add num_notes
+       member.
+       (linux_corefile_thread_callback): Increase args->num_notes.
+       (linux_make_note_section): Initialize thread_args.num_notes, and
+       use it to determine whether notes for any threads were created.
+
 2002-08-23  Donn Terry  <dterry@microsoft.com>
 
        * proc-api.c (rw_table): Do not include a row for PCDSTOP if the
 
   return note_data;
 }
 
-struct linux_corefile_thread_data {
-  bfd  *obfd;
+struct linux_corefile_thread_data
+{
+  bfd *obfd;
   char *note_data;
-  int  *note_size;
+  int *note_size;
+  int num_notes;
 };
 
 /* Function: linux_corefile_thread_callback
                                               ti->ptid, 
                                               args->note_data, 
                                               args->note_size);
+  args->num_notes++;
   inferior_ptid = saved_ptid;
   registers_changed ();
   target_fetch_registers (-1); /* FIXME should not be necessary; 
   thread_args.obfd = obfd;
   thread_args.note_data = note_data;
   thread_args.note_size = note_size;
+  thread_args.num_notes = 0;
   iterate_over_threads (linux_corefile_thread_callback, &thread_args);
-  if (thread_args.note_data == note_data)
+  if (thread_args.num_notes == 0)
     {
       /* iterate_over_threads didn't come up with any threads;
-        just use inferior_ptid. */
+        just use inferior_ptid.  */
       note_data = linux_do_thread_registers (obfd, inferior_ptid, 
                                             note_data, note_size);
     }