This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] core: use core_pid
Daniel Jacobowitz wrote:
On Tue, Feb 26, 2008 at 02:37:58PM -0500, Aleksandar Ristovski wrote:
+ gdb_assert (abfd != NULL && elf_tdata (abfd) != NULL);
What if it's not an ELF core file?
Didn't think about that (our core can only be ELF).
In that case, do you think something like this would work?
@@ -232,20 +233,24 @@ static void
add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
{
int thread_id;
+ ptid_t ptid;
asection *reg_sect = (asection *) reg_sect_arg;
if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
return;
thread_id = atoi (bfd_section_name (abfd, asect) + 5);
-
- add_thread (pid_to_ptid (thread_id));
+ if (abfd != NULL && elf_tdata (abfd) != NULL)
+ ptid = ptid_build (elf_tdata (abfd)->core_pid, 0, thread_id);
+ else
+ ptid = ptid_build (42, 0, thread_id);
+ add_thread (ptid);
/* Warning, Will Robinson, looking at BFD private data! */
if (reg_sect != NULL
&& asect->filepos == reg_sect->filepos) /* Did we find .reg? */
- inferior_ptid = pid_to_ptid (thread_id); /* Yes, make it current */
+ inferior_ptid = ptid; /* Yes, make it current */
}
/* This routine opens and sets up the core file bfd. */