From: Pedro Alves <palves@redhat.com>
To: Michael Eager <eager@eagerm.com>
Cc: "Maciej W. Rozycki" <macro@codesourcery.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: MIPS Linux signals
Date: Tue, 22 May 2012 16:02:00 -0000 [thread overview]
Message-ID: <4FBBB877.8010109@redhat.com> (raw)
In-Reply-To: <4FBBB352.6080009@eagerm.com>
On 05/22/2012 04:40 PM, Michael Eager wrote:
> On 05/22/2012 03:17 AM, Pedro Alves wrote:
>
>> I agree that the current naming is confusing, but I'll point out why I think
>> target_signal_from_host is actually correct, and then conclude with renaming
>> suggestions to avoid the confusion, and fix the naming of the gdbarch hook, which
>> I think is not correct. We have
>>
>> enum target_signal
>> {
>> ...
>> TARGET_SIGNAL_FOO,
>> TARGET_SIGNAL_BAR,
>> ...
>> };
>>
>> which represents GDB's internal signal numbers.AFAIK, the "target_" prefix
>> naming in this case is just a natural choice, given that that's how we name
>> everything behind the target_ops abstraction -- target_read_memory,
>> target_resume, etc., etc. (target.h) -- the mechanism that is mostly about
>> abstracting the details of handling the target's debug interface API.
>
> As you say, these are GDB's internal values. They are not the values used on
> (some) targets. They are not the values used by (some) host systems either.
>
> There's a difference between target_read_memory() which actually reads a
> value from the memory on the target, and target_signal which is not the
> value from the target, but a translated internal value.
>
>> So this explains the "target_signal_from_" part of the function's signature.
>
> Not for me. :-)
Could it be you mean "I agree, but I think the naming
of the enum could be clearer/better"? The enum is called "enum target_signal".
So the function that converts an enum target_signal from something else
is called "target_signal_from_...". That much seems clear enough to me.
>
>> The "from_host" part is really correct: this really is a host function -- think in
>> terms of autoconf's notion of build vs host vs target. It only makes sense to call
>> it in native code (native == host). And in fact, that's what happens.
>
> GDB tends to muddle host and target. Or perhaps the confusion is between the
> host environment and GDB's internal data structures.
Not sure what you're alluding to.
> There is no need to translate signal numbers from the host system environment
> to the target system environment. There is a need to translate from GDB's internal
> numbering to the target numbering, and vice versa. There is nothing significant
> about the host's signal numbering that should affect how GDB works with the target,
> whether the target is a native process, remote system, or core file.
Correct. Is that in disagreement with anything I said? It's just that GDB's
internal signal numbering is called "enum target_signal".
>
> When target=host, translating from the target's signal numbering to GDB's
> internal numbering should be identical to the case when target!=host.
>
> target_signal_from_host() makes no sense to me.
It makes sense in the native/host-only parts of GDB. linux-nat.c and friends, etc.
> I don't have a host core file; it's a target core file.
Yes, that's why in corelow.c the conversion goes through the gdbarch method.
corelow.c is not a native/host-only file (ideally anyway). We have the
target_signal_from_host fallback for old ports that haven't yet bothered
to convert to modern mechanisms, and can't cross-debug cores.
>
>> gdbserver is always native, so always host.
>
> That's the exception.
So is all the native-debugger code within GDB; code which we want
to actually split out of gdb and share/merge with gdbserver.
> But that should still use the target to/from internal
> translation function.
Correct.
>
>> enum target_signal => enum gdb_signal
>>
>> target_signal_from_host => gdb_signal_from_host (or gdb_signal_from_host_signal)
>> target_signal_to_host => gdb_signal_to_host (or gdb_signal_to_host_signal)
>>
>> gdbarch_target_signal_from_host => gdbarch_gdb_signal_from_target (or gdbarch_gdb_signal_from_target_signal)
>> gdbarch_target_signal_to_host => gdbarch_gdb_signal_to_target (or gdbarch_gdb_signal_to_target_signal)
>
> OK, but I'd recommend
> target_signal_from_host => gdb_signal_from_target
> target_signal_to_host => gdb_signal_to_target
>
> This is symmetric with the gdbarch_ functions and clear that the function
> translates to/from target system values, not the host system.
But it's not what the functions do... They really convert from the host
system signals, not the target's. I think the symmetry will only lead to
people getting confused (which one to call in common/target-independent code?).
--
Pedro Alves
next prev parent reply other threads:[~2012-05-22 16:02 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-20 2:03 Michael Eager
2012-05-21 11:04 ` Pedro Alves
2012-05-21 14:51 ` Michael Eager
2012-05-21 17:37 ` Pedro Alves
2012-05-21 18:06 ` Michael Eager
2012-05-21 18:19 ` Maciej W. Rozycki
[not found] ` <alpine.DEB.1.10.1205211232260.11227@tp.orcam.me.uk>
2012-05-21 18:21 ` Michael Eager
2012-05-21 22:34 ` Maciej W. Rozycki
2012-05-22 9:38 ` Pedro Alves
2012-05-21 21:35 ` Pedro Alves
2012-05-21 21:53 ` Michael Eager
2012-05-21 22:48 ` Maciej W. Rozycki
2012-05-22 0:16 ` Michael Eager
2012-05-22 10:17 ` Pedro Alves
2012-05-22 13:16 ` Maciej W. Rozycki
2012-05-22 13:32 ` Pedro Alves
2012-05-22 15:10 ` Move store_waitstatus to inf-child.c (was: Re: MIPS Linux signals) Pedro Alves
2012-05-22 15:40 ` MIPS Linux signals Michael Eager
2012-05-22 16:02 ` Pedro Alves [this message]
2012-05-22 18:14 ` Michael Eager
2012-05-22 18:31 ` Pedro Alves
2012-05-22 19:32 ` Michael Eager
2012-05-22 22:06 ` Pedro Alves
2012-05-22 16:26 ` Pedro Alves
2012-05-22 10:58 ` Pedro Alves
2012-05-22 19:31 ` Aleksandar Ristovski
2012-05-22 21:55 ` Pedro Alves
2012-05-22 23:29 ` Aleksandar Ristovski
2012-05-23 11:39 ` Pedro Alves
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=4FBBB877.8010109@redhat.com \
--to=palves@redhat.com \
--cc=eager@eagerm.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@codesourcery.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