This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Fix MT gcore bug on GNU/Linux
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 23 Aug 2002 21:11:23 +0200 (CEST)
- Subject: [PATCH] Fix MT gcore bug on GNU/Linux
This patch fixes a bug in linux-proc.c:linux_make_note_section(). The
old code compared the otigional note_data pointer to its "new" value
to decide whether we've added any note sections in the
iterate_over_threads() call. Since the memory for the notes is
realloc'ed it is very well possible that the location of the memory
doesn't change when we add new notes. This happened on my system.
This patch solves the problem.
Checked in.
Mark
Index: ChangeLog
from 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.
Index: linux-proc.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-proc.c,v
retrieving revision 1.10
diff -u -p -r1.10 linux-proc.c
--- linux-proc.c 1 Aug 2002 22:55:36 -0000 1.10
+++ linux-proc.c 23 Aug 2002 19:01:38 -0000
@@ -198,10 +198,12 @@ linux_do_thread_registers (bfd *obfd, pt
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
@@ -224,6 +226,7 @@ linux_corefile_thread_callback (struct t
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;
@@ -271,11 +274,12 @@ linux_make_note_section (bfd *obfd, int
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);
}