From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: Re: ptid from core section
Date: Fri, 05 Jun 2009 17:54:00 -0000 [thread overview]
Message-ID: <h0bm40$db0$1@ger.gmane.org> (raw)
In-Reply-To: <200906051726.51861.pedro@codesourcery.com>
Pedro Alves wrote:
> On Friday 05 June 2009 15:53:00, Aleksandar Ristovski wrote:
>
>> Here is a new patch. I made sure it works even if
>> core_gdbarch is NULL.
>
> Sorry, we're going a bit in circles. The way you've now
> implemented it, there are three ways to get a ptid
> from a core reg section, but two of them are mostly
> the same --- the default gdbarch fallbacks, and the
> case of core_gdbarch being NULL handled in corelow.c itself.
On nto, we are not using lwp field at all. We use thread id.
In nto, I override core_open to add thread private data
once core_open has finished it's work. To identify threads,
I need to build ptid the way core does. I can do that, but
then I will have two functions for adding thread private
data (one for core ops, one for live target). Also, I would
have to either figure out which field is being used in
*_ptid_to_str or again provide two functions.
In summary: the motivation for this patch is to avoid having
to patch corelow.c. I am working on a larger nto patch that
I would like to have in before next official gdb release.
>
> On Friday 05 June 2009 14:44:37, Pedro Alves wrote:
>> change adds some unconditional accesses. The path of
>> least resistence to fix this, is to move the callback defaults
>> to corelow.c, make the new callbacks optional, and check
>> for 'core_gdbarch && gdbarch_foo_p (core_gdbarch)' predicates
>> before calling the optional callbacks.
>
> This meant:
>
> On Friday 05 June 2009 15:53:00, Aleksandar Ristovski wrote:
>> +static ptid_t
>> +default_ptid_from_core_section_name (struct gdbarch *gdbarch, const bfd *abfd,
>> + const char *name)
>> +{
>> + int thread_id;
>> + ptid_t ptid;
>> + const char *pos;
>> +
>> + pos = strchr (name, '/');
>> + if (pos == NULL)
>> + pos = name + strlen (name);
>> + else
>> + pos++;
>> + thread_id = atoi (pos);
>> + ptid = ptid_build (ptid_get_pid (inferior_ptid), thread_id, 0);
>> + return ptid;
>> +}
>> +
>> +static char *
>> +default_core_section_name_from_ptid (struct gdbarch *gdbarch,
>> + const bfd *abfd,
>> + const char *name,
>> + ptid_t ptid)
>> +{
>> + if (ptid_get_lwp (ptid))
>> + return xstrprintf ("%s/%ld", name, ptid_get_lwp (ptid));
>> + else
>> + return xstrdup (name);
>> +}
>
> Moving these functions to corelow.c, and making the gdbarch callbacks
> optional. Wouldn't that look cleaner? Something like the patch below.
Looking at core handling I think the whole thing is not
clean. I see your point, but I see no particular advantage
of your approach - we moved the default code to corelow but
now introduced check for gdbarch_..._p.
But don't get me wrong - I am not against your approach - as
long as I don't have to patch corelow in order to get gdb
working for neutrino.
>
> But, at this point, I'm now confused, and I have to re-ask:
> What is it that gets confused on nto when core files store
> the thread id in the lwp field of ptids instead of on the tid
> field? Your original patch only took care to adjust to
> read tids from the tid field in default_core_section_from_ptid,
> but didn't do anything to make ptids that stored the tid
> in the tid field in default_ptid_from_core_section? While
> your latest patch didn't even do that in
> default_ptid_from_core_section_name? I can't see how you
> avoid adding gdbarch callbacks for nto.
I don't, I provide my own callbacks similar to sol2-tdep.c,
only they build ptid something like this:
ptid_build (ptid_get_pid (ptid), 0, atoi (core_section_name
+ 5));
I reworked the latest patch to have exactly the same
behaviour as without the patch, except for one bit where I
check if both lwp and tid are 0 to set inferior_ptid.
>
>> I also fixed my previous patch for
>> target signal by checking if there is a core_gdbarch.
>
> Could you go ahead, and check in just that bit
> split out from the rest please? Thanks.
>
Sure.
--
Aleksandar Ristovski
QNX Software Systems
next prev parent reply other threads:[~2009-06-05 17:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-01 15:56 Aleksandar Ristovski
2009-06-03 14:41 ` Pedro Alves
2009-06-03 16:59 ` Aleksandar Ristovski
2009-06-03 18:41 ` Pedro Alves
2009-06-04 18:32 ` Aleksandar Ristovski
2009-06-05 13:43 ` Pedro Alves
2009-06-05 14:04 ` Aleksandar Ristovski
2009-06-05 14:39 ` Pedro Alves
2009-06-05 14:53 ` Aleksandar Ristovski
2009-06-05 16:26 ` Pedro Alves
2009-06-05 17:54 ` Aleksandar Ristovski [this message]
2009-06-05 19:00 ` Pedro Alves
2009-06-05 19:03 ` Aleksandar Ristovski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='h0bm40$db0$1@ger.gmane.org' \
--to=aristovski@qnx.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox