Re: [rfc, arm] Always use correct execution state for single-step breakpoints

Ulrich Weigand
2011-03-25T16:23:37Z

Tom Tromey wrote:
> >>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
>
> Ulrich> This is done by means of a new global "arm_override_mode" which
> Ulrich> is respected in arm_pc_is_thumb unconditionally (similar to
> Ulrich> arm_force_mode_string),
>
> Ulrich> (The global is a bit ugly, but the concept still seems right to me:
> Ulrich> if at some point in the future, we actually do use two different
> Ulrich> gdbarch's to represent Thumb vs. ARM, the single-step routines would
> Ulrich> determine the proper gdbarch to set the breakpoint in and simply
> Ulrich> use insert_single_step_breakpoint with that arch.)
>
> I wonder whether such globals should actually be per-inferior?
> I really don't know whether it would be possible to get in trouble with
> this.

Well, the way the patch is using the global, there is no possibility
of any trouble (as long as GDB itself it not multi-threaded):

+ struct cleanup *old_chain
+ = make_cleanup_restore_integer (&arm_override_mode);
+
+ arm_override_mode = IS_THUMB_ADDR (pc);
+ pc = gdbarch_addr_bits_remove (gdbarch, pc);
+
+ insert_single_step_breakpoint (gdbarch, aspace, pc);
+
+ do_cleanups (old_chain);

Note how the setting only remains in effect across the one call to
insert_single_step_breakpoint. The intent is basically to pass an
extra argument through to a routine called within the call chain
of that one function invocation.