* [patch] core: use core_pid
@ 2008-02-26 19:45 Aleksandar Ristovski
2008-02-26 19:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Aleksandar Ristovski @ 2008-02-26 19:45 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
Hello,
This patch fixes minor issue: in corelow.c (add_to_thread_list) we use thread_id
as pid and we ignore core_pid which is available. This gives confusing output
from "info threads" since threads appear to belong to different processes.
The patch rectifies this situation.
Thanks,
Aleksandar Ristovski
QNX Software Systems
2008-02-26 Aleksandar Ristovski <aristovski@qnx.com>
* Makefile.in (corelow.o): Add elf_bfd_h.
* corelow.c (elf-bfd.h): Add include.
(add_to_thread_list): Use core_pid instead of using tid as pid.
(get_core_register_section): Use tid from inferior_ptid instead of pid.
[-- Attachment #2: corelow.c.diff --]
[-- Type: text/plain, Size: 2501 bytes --]
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.984
diff -u -p -r1.984 Makefile.in
--- gdb/Makefile.in 20 Feb 2008 15:45:20 -0000 1.984
+++ gdb/Makefile.in 26 Feb 2008 19:20:38 -0000
@@ -1996,7 +1996,7 @@ corelow.o: corelow.c $(defs_h) $(arch_ut
$(inferior_h) $(symtab_h) $(command_h) $(bfd_h) $(target_h) \
$(gdbcore_h) $(gdbthread_h) $(regcache_h) $(regset_h) $(symfile_h) \
$(exec_h) $(readline_h) $(gdb_assert_h) \
- $(exceptions_h) $(solib_h) $(filenames_h)
+ $(exceptions_h) $(solib_h) $(filenames_h) $(elf_bfd_h)
core-regset.o: core-regset.c $(defs_h) $(command_h) $(gdbcore_h) \
$(inferior_h) $(target_h) $(regcache_h) $(gdb_string_h) $(gregset_h)
cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(command_h) $(gdbcmd_h) \
Index: gdb/corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.73
diff -u -p -r1.73 corelow.c
--- gdb/corelow.c 9 Feb 2008 13:45:33 -0000 1.73
+++ gdb/corelow.c 26 Feb 2008 19:20:43 -0000
@@ -45,6 +45,7 @@
#include "exceptions.h"
#include "solib.h"
#include "filenames.h"
+#include "elf-bfd.h"
#ifndef O_LARGEFILE
@@ -232,20 +233,22 @@ 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));
+ gdb_assert (abfd != NULL && elf_tdata (abfd) != NULL);
+ ptid = ptid_build (elf_tdata (abfd)->core_pid, 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. */
@@ -424,8 +427,8 @@ get_core_register_section (struct regcac
char *contents;
xfree (section_name);
- if (PIDGET (inferior_ptid))
- section_name = xstrprintf ("%s/%d", name, PIDGET (inferior_ptid));
+ if (ptid_get_tid (inferior_ptid))
+ section_name = xstrprintf ("%s/%ld", name, ptid_get_tid (inferior_ptid));
else
section_name = xstrdup (name);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] core: use core_pid
2008-02-26 19:45 [patch] core: use core_pid Aleksandar Ristovski
@ 2008-02-26 19:53 ` Daniel Jacobowitz
2008-02-26 20:15 ` Aleksandar Ristovski
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-02-26 19:53 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
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?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] core: use core_pid
2008-02-26 19:53 ` Daniel Jacobowitz
@ 2008-02-26 20:15 ` Aleksandar Ristovski
2008-04-10 15:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Aleksandar Ristovski @ 2008-02-26 20:15 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
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. */
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] core: use core_pid
2008-02-26 20:15 ` Aleksandar Ristovski
@ 2008-04-10 15:16 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-04-10 15:16 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
On Tue, Feb 26, 2008 at 02:52:47PM -0500, Aleksandar Ristovski wrote:
> 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?
Not quite. I recommend you take a look at bfd/elf.c and
bfd/elf64-x86-64.c to see some different ways ".reg/XXXX" sections are
created. For QNX, you get .reg/TID. But for other targets you get
(LWPID << 16) + PID and core_pid is updated as we go along.
It looks like the information GDB needs doesn't make it out of BFD.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-04-10 14:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 19:45 [patch] core: use core_pid Aleksandar Ristovski
2008-02-26 19:53 ` Daniel Jacobowitz
2008-02-26 20:15 ` Aleksandar Ristovski
2008-04-10 15:16 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox