Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
@ 2015-08-28  5:16 Doug Evans
  2015-08-28 15:04 ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2015-08-28  5:16 UTC (permalink / raw)
  To: gdb-patches

Hi.

target_gdbarch is a magical thing, there are different kinds of arches:
for multiarch systems (e.g., call) which arch you use for certain
struct gdbarch API calls is important.

E.g.,
https://sourceware.org/ml/gdb-patches/2015-08/msg00789.html

Until this is cleaned up it'd be best to only use target_gdbarch
and not its underlying implementation.
Fortunately there is only one place that needed changing
(further reinforcing my sense that only target_gdbarch should be
used and never current_inferior ()->gdbarch).

Alas, short of an API reorg (which I think is reasonable), I can't think
of a way to prevent this from recurring.


2015-08-27  Doug Evans  <xdje42@gmail.com>

	* ravenscar-thread.c (ravenscar_inferior_created): Replace
	current_inferior ()->gdbarch with its wrapper target_gdbarch.

diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index ef82507..fe36c96 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -341,7 +341,7 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty)
   struct ravenscar_arch_ops *ops;
 
   if (!ravenscar_task_support
-      || gdbarch_ravenscar_ops (current_inferior ()->gdbarch) == NULL
+      || gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
       || !has_ravenscar_runtime ())
     return;
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
  2015-08-28  5:16 [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.* Doug Evans
@ 2015-08-28 15:04 ` Doug Evans
  2015-08-28 17:22   ` Ulrich Weigand
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2015-08-28 15:04 UTC (permalink / raw)
  To: gdb-patches

On Thu, Aug 27, 2015 at 10:15 PM, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> target_gdbarch is a magical thing, there are different kinds of arches:
> for multiarch systems (e.g., call) which arch you use for certain
> struct gdbarch API calls is important.
>
> E.g.,
> https://sourceware.org/ml/gdb-patches/2015-08/msg00789.html
>
> Until this is cleaned up it'd be best to only use target_gdbarch
> and not its underlying implementation.
> Fortunately there is only one place that needed changing
> (further reinforcing my sense that only target_gdbarch should be
> used and never current_inferior ()->gdbarch).
>
> Alas, short of an API reorg (which I think is reasonable), I can't think
> of a way to prevent this from recurring.
>
>
> 2015-08-27  Doug Evans  <xdje42@gmail.com>
>
>         * ravenscar-thread.c (ravenscar_inferior_created): Replace
>         current_inferior ()->gdbarch with its wrapper target_gdbarch.
>
> diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
> index ef82507..fe36c96 100644
> --- a/gdb/ravenscar-thread.c
> +++ b/gdb/ravenscar-thread.c
> @@ -341,7 +341,7 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty)
>    struct ravenscar_arch_ops *ops;
>
>    if (!ravenscar_task_support
> -      || gdbarch_ravenscar_ops (current_inferior ()->gdbarch) == NULL
> +      || gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
>        || !has_ravenscar_runtime ())
>      return;
>

Hmmm, forgot about ARI, bleah.
We could use that to at least catch recurrences.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
  2015-08-28 15:04 ` Doug Evans
@ 2015-08-28 17:22   ` Ulrich Weigand
  2015-08-28 19:16     ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Weigand @ 2015-08-28 17:22 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Doug Evans wrote:
> On Thu, Aug 27, 2015 at 10:15 PM, Doug Evans <xdje42@gmail.com> wrote:
> > 2015-08-27  Doug Evans  <xdje42@gmail.com>
> >
> >         * ravenscar-thread.c (ravenscar_inferior_created): Replace
> >         current_inferior ()->gdbarch with its wrapper target_gdbarch.

Just as a quick comment: this goes exactly into the opposite direction
from what we discussed in the other thread.  I think we should replace
target_gdbarch () with current_inferior ()->gdbarch *everywhere*,
instead of reverting that here ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
  2015-08-28 17:22   ` Ulrich Weigand
@ 2015-08-28 19:16     ` Doug Evans
  2015-08-31 14:02       ` Ulrich Weigand
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2015-08-28 19:16 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

On Fri, Aug 28, 2015 at 10:21 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> Doug Evans wrote:
>> On Thu, Aug 27, 2015 at 10:15 PM, Doug Evans <xdje42@gmail.com> wrote:
>> > 2015-08-27  Doug Evans  <xdje42@gmail.com>
>> >
>> >         * ravenscar-thread.c (ravenscar_inferior_created): Replace
>> >         current_inferior ()->gdbarch with its wrapper target_gdbarch.
>
> Just as a quick comment: this goes exactly into the opposite direction
> from what we discussed in the other thread.  I think we should replace
> target_gdbarch () with current_inferior ()->gdbarch *everywhere*,
> instead of reverting that here ...

This does nothing to fix the underlying problem, which is the
referencing of global state instead obtaining the needed state
(inferior, gdbarch, or whatever) from the passed in context.
That's what I was talking about in the other thread at any rate.
*In the mean time*, let's be consistent, and this patch is simpler.

When we do go to properly fix this (or at least take the next step
to properly fixing this), *then* we can go through and remove all
the target_gdbarch calls.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
  2015-08-28 19:16     ` Doug Evans
@ 2015-08-31 14:02       ` Ulrich Weigand
  2015-09-20 19:52         ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Weigand @ 2015-08-31 14:02 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Doug Evans wrote:
> On Fri, Aug 28, 2015 at 10:21 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> > Doug Evans wrote:
> >> On Thu, Aug 27, 2015 at 10:15 PM, Doug Evans <xdje42@gmail.com> wrote:
> >> > 2015-08-27  Doug Evans  <xdje42@gmail.com>
> >> >
> >> >         * ravenscar-thread.c (ravenscar_inferior_created): Replace
> >> >         current_inferior ()->gdbarch with its wrapper target_gdbarch.
> >
> > Just as a quick comment: this goes exactly into the opposite direction
> > from what we discussed in the other thread.  I think we should replace
> > target_gdbarch () with current_inferior ()->gdbarch *everywhere*,
> > instead of reverting that here ...
> 
> This does nothing to fix the underlying problem, which is the
> referencing of global state instead obtaining the needed state
> (inferior, gdbarch, or whatever) from the passed in context.
> That's what I was talking about in the other thread at any rate.
> *In the mean time*, let's be consistent, and this patch is simpler.
> 
> When we do go to properly fix this (or at least take the next step
> to properly fixing this), *then* we can go through and remove all
> the target_gdbarch calls.

Well, OK.  I guess I can see why we'd want to use target_gdbarch
consistently until it's eliminated completely ...  I don't really
object to this patch, in any case.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.*
  2015-08-31 14:02       ` Ulrich Weigand
@ 2015-09-20 19:52         ` Doug Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Evans @ 2015-09-20 19:52 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

"Ulrich Weigand" <uweigand@de.ibm.com> writes:
> Doug Evans wrote:
>> On Fri, Aug 28, 2015 at 10:21 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>> > Doug Evans wrote:
>> >> On Thu, Aug 27, 2015 at 10:15 PM, Doug Evans <xdje42@gmail.com> wrote:
>> >> > 2015-08-27  Doug Evans  <xdje42@gmail.com>
>> >> >
>> >> >         * ravenscar-thread.c (ravenscar_inferior_created): Replace
>> >> >         current_inferior ()->gdbarch with its wrapper target_gdbarch.
>> >
>> > Just as a quick comment: this goes exactly into the opposite direction
>> > from what we discussed in the other thread.  I think we should replace
>> > target_gdbarch () with current_inferior ()->gdbarch *everywhere*,
>> > instead of reverting that here ...
>> 
>> This does nothing to fix the underlying problem, which is the
>> referencing of global state instead obtaining the needed state
>> (inferior, gdbarch, or whatever) from the passed in context.
>> That's what I was talking about in the other thread at any rate.
>> *In the mean time*, let's be consistent, and this patch is simpler.
>> 
>> When we do go to properly fix this (or at least take the next step
>> to properly fixing this), *then* we can go through and remove all
>> the target_gdbarch calls.
>
> Well, OK.  I guess I can see why we'd want to use target_gdbarch
> consistently until it's eliminated completely ...  I don't really
> object to this patch, in any case.

Committed, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-20 19:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-28  5:16 [PATCH] Remove only use of current_inferior ()->gdbarch outside of gdbarch.* Doug Evans
2015-08-28 15:04 ` Doug Evans
2015-08-28 17:22   ` Ulrich Weigand
2015-08-28 19:16     ` Doug Evans
2015-08-31 14:02       ` Ulrich Weigand
2015-09-20 19:52         ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox