* RE:Re: GDB 5.1/Core files and ptids
@ 2002-01-17 8:08 Takis Psarogiannakopoulos
2002-01-18 15:04 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Takis Psarogiannakopoulos @ 2002-01-17 8:08 UTC (permalink / raw)
To: kevinb; +Cc: gdb, binutils
Hi Kevin,
On Wed, 16 Jan 2002, Kevin Buettner wrote:
> The context here is that we're trying to fetch the appropriate
> .reg (.reg2, etc) section from bfd, right?
That is correct. We are trying to get a section with name "name".
> > Especially when, even in the new gdb-5.1/bfd we find:
> >
> > ======
> > static int
> > elfcore_make_pid (abfd)
> > bfd *abfd;
> > {
> > return ((elf_tdata (abfd)->core_lwpid << 16)
> > + (elf_tdata (abfd)->core_pid));
> > }
> > =======
>
> This will need to change. It is incorrect to attempt to represent
> both the pid and lwp as a single integer whose size isn't large
> enough to hold all of the bits.
>
I have no problem with the ptid especially when it is less confusing
from the old mixed pid's!
My problem is that a core DG/UX file has lot of info sections that
I would like to read and wasnt sure if gdb would be able now taking
in account that elfcore_make_pid had the above form.
> So, to fetch a .reg section in a multithreaded core dump where
> the pid is 14 and the lwp is 42, GDB would need to ask BFD for
> the .reg/14+42 (pseudo) section.
>
> else if (TIDGET (inferior_ptid))
> sprintf (section_name, "%s/%d+%d", name, PIDGET (inferior_ptid),
> TIDGET (inferior_ptid));
> else if (PIDGET (inferior_ptid))
> sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
> else
> strcpy (section_name, name);
>
OK. That is indeed a solution to what I was saying about reading sections
using ptid's. Thanks Kevin.
Regards,
Takis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: GDB 5.1/Core files and ptids
2002-01-17 8:08 RE:Re: GDB 5.1/Core files and ptids Takis Psarogiannakopoulos
@ 2002-01-18 15:04 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2002-01-18 15:04 UTC (permalink / raw)
To: Takis Psarogiannakopoulos, kevinb; +Cc: gdb, binutils
> else if (TIDGET (inferior_ptid))
>> sprintf (section_name, "%s/%d+%d", name, PIDGET (inferior_ptid),
>> TIDGET (inferior_ptid));
>> else if (PIDGET (inferior_ptid))
>> sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
For some reason, I've a preference for <name>/<PID>/<TID> but I can't
give a rational reason why. I suspect it is just that the ``+'' goes
against my thinking of how things are structured.
2c worth.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: GDB 5.1/Core files and ptids
[not found] <Pine.BSF.4.21.0201161102030.11703-100000@public.xfree86.org>
@ 2002-01-16 13:22 ` Kevin Buettner
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2002-01-16 13:22 UTC (permalink / raw)
To: Takis Psarogiannakopoulos, gdb; +Cc: binutils
On Jan 16, 11:16am, Takis Psarogiannakopoulos wrote:
> Trying to port DG/UX source files from gdb 5.0 to version
> 5.1 (and hopping to submit these at last to GNU) I have found
> that there is a serious inconsistency for the BFD core files.
>
> Before one could overload a process pid with a thread id
> using the macro:
>
> #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
>
> Note that this will give us again an integer!
> In 5.1 someone change this to a stucture called ptid.
Yes. That was me.
> However
> it seems to me that you forgot to implemnet something similar
> to BFD.
Okay...
> Problem:
>
> Suppose that one has a line co code of the type
>
> sprintf (section_name, "%s/%d", name, inferior_pid);
>
> OR of the type
>
> struct thread_info *tp;
> ...
> sprintf (section_name, "%s/%d", name, tp->pid);
>
> inside the gdb/core-dgux.c file. Note that this integer
> (tp->pid or inferior_pid) it should contains/be overloaded
> with the tid too!
>
> Clearly neven if in the 5.1 we have a tp->ptid one cannot
> write
>
> sprintf (section_name, "%s/%d", name, tp->ptid);
>
> because ptid is now a structure!
The context here is that we're trying to fetch the appropriate
.reg (.reg2, etc) section from bfd, right?
> Especially when, even in the new gdb-5.1/bfd we find:
>
> ======
> static int
> elfcore_make_pid (abfd)
> bfd *abfd;
> {
> return ((elf_tdata (abfd)->core_lwpid << 16)
> + (elf_tdata (abfd)->core_pid));
> }
> =======
This will need to change. It is incorrect to attempt to represent
both the pid and lwp as a single integer whose size isn't large
enough to hold all of the bits.
> Any suggestions? Eg can the guy that introduced these new
> ptids how specicfically to rewrite the line:
>
> sprintf (section_name, "%s/%d", name, tp->pid);
>
> (pid is from 5.0 ie. a mixed pid but still integer!)
>
> having given the tp->ptid and taking in account the
> elfcore_make_pid that is used by bfd!!!
>
> We want to rewrite the bit above so that gdb-5.1 will
> understand! that this section has info about the pid=
> PIDGET(tp->ptid) and the lwp=TIDGET(tp->ptid). And
> reflect these when asked.
Here are my suggestions:
1) In bfd, the parts requiring elfcore_make_pid() are all contained in
elf.c. I suggest that you rewrite elfcore_make_pid() to look something
like this:
static char *
elfcore_make_ptid_str (abfd)
bfd *abfd;
{
static char ptid_buf[40];
if (elf_tdata (abfd)->core_lwpid == 0)
{
/* Non-threaded */
sprintf (ptid_buf, "%d", elf_tdata (abfd)->core_pid);
}
else
{
/* Threaded */
sprintf (ptid_buf, "%d+%d", elf_tdata (abfd->core_pid),
elf_tdata (abfd->core_lwpid));
}
return ptid_buf;
}
2) Revise all callers in elf.c to use the above function. E.g, in
_bfd_elfcore_make_pseudosection(), the line:
sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd));
will become
sprintf (buf, "%s/%s", name, elfcore_make_ptid_str (abfd));
So, to fetch a .reg section in a multithreaded core dump where
the pid is 14 and the lwp is 42, GDB would need to ask BFD for
the .reg/14+42 (pseudo) section.
3) On the GDB side, specifically in corelow.c, as well as in the
DG/UX specific corefile reader that you're working on, change
the code which wants to fetch the bfd core section to understand
these new section names. E.g, in get_core_register_section()
in corelow.c, change:
if (PIDGET (inferior_ptid))
sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
else
strcpy (section_name, name);
to:
else if (TIDGET (inferior_ptid))
sprintf (section_name, "%s/%d+%d", name, PIDGET (inferior_ptid),
TIDGET (inferior_ptid));
else if (PIDGET (inferior_ptid))
sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
else
strcpy (section_name, name);
We ought to run this past the binutils folks too to make sure it's
okay with them. (I've cc'd them on this correspondence.)
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-01-18 20:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-17 8:08 RE:Re: GDB 5.1/Core files and ptids Takis Psarogiannakopoulos
2002-01-18 15:04 ` Andrew Cagney
[not found] <Pine.BSF.4.21.0201161102030.11703-100000@public.xfree86.org>
2002-01-16 13:22 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).