[PATCH] libdebugger/arm: Fix build for atsam.

Chris Johns chrisj at rtems.org
Thu Oct 17 10:49:44 UTC 2019


> On 17 Oct 2019, at 7:51 am, Christian Mauderer <Christian.Mauderer at embedded-brains.de> wrote:
> 
> Hello,
> 
> after a hint from Chris I took a more detailed look at the patch.
> There is at least one thing that I should change: The
> 
>    #if !ARM_THUMB_ONLY && defined(__thumb__)
> 
> case is most likely not necessary.

Yes. Sebastian gave me some hints and we can take a closer look while at the mentors summit. 

> 
> Some explanation:
> 
> In rtems-debugger-arm.c there are the following defines
> 
>    #if !ARM_THUMB_ONLY && defined(__thumb__)
>      #define ARM_SWITCH_REG       uint32_t arm_switch_reg
>      #define ARM_SWITCH_REG_ASM   [arm_switch_reg] "=&r" (arm_switch_reg)
>      #define ARM_SWITCH_REG_ASM_L ARM_SWITCH_REG_ASM,
>      #define ASM_ARM_MODE         ".align 2\nbx pc\n.arm\n"
>      #define ASM_THUMB_MODE       "add %[arm_switch_reg], pc, #1\nbx
> %[arm_switch_reg]\n.thumb\n"
>    #else
>      #define ARM_SWITCH_REG
>      #define ARM_SWITCH_REG_ASM
>      #define ARM_SWITCH_REG_ASM_L
>      #define ASM_ARM_MODE
>      #define ASM_THUMB_MODE
>    #endif
> 
> ARM_THUMB_ONLY is set to 1 for all ARM V7M targets (Cortex-M). With
> the current definition it is set to 1 in the same case when
> ARM_MULTILIB_ARCH_V7M is defined. So here the empty defines will be
> used. A bit later the following (unchanged) block can be found:
> 
>    /**
>     * ARM Variant support.
>     */
>    #if defined(ARM_MULTILIB_ARCH_V4)
>     #define EXCEPTION_ENTRY_EXC()               EXCEPTION_ENTRY_EXC_V4()
>     #define EXCEPTION_ENTRY_THREAD(_frame)
> EXCEPTION_ENTRY_THREAD_V4(_frame)
>     #define EXCEPTION_EXIT_THREAD(_frame)
> EXCEPTION_EXIT_THREAD_V4(_frame)
>     #define EXCEPTION_EXIT_EXC()                EXCEPTION_EXIT_EXC_V4()
>    #elif defined(ARM_MULTILIB_ARCH_V7M)
>     #define EXCEPTION_ENTRY_EXC()               (void) arm_switch_reg
>     #define EXCEPTION_ENTRY_THREAD(_frame)      (_frame) = NULL
>     #define EXCEPTION_EXIT_THREAD(_frame)       (_frame) = NULL
>     #define EXCEPTION_EXIT_EXC()                (void) arm_switch_reg
>    #else
>     #error ARM architecture is not supported.
>    #endif
> 
> Here the ARM_MULTILIB_ARCH_V7M case is the one that is true for
> Cortex-M targets.
> 
> From a quick look every Cortex-M target that we have has __thumb__
> defined. ARM V7M only supports thumb so it's not really surprising.
> 
> So ARM_SWITCH_REG is used to define a variable arm_switch_reg except
> on Cortex-M targets. But on the same time on Cortex-M targets the
> variable is read (without modification) with the EXCEPTION_ENTRY_EXC
> and EXCEPTION_EXIT_EXC.
> 
> I'm really not sure whether there should be some (global) volatile
> arm_switch_reg that has to be read on EXCEPTION_ENTRY_EXC and
> EXCEPTION_EXIT_EXC on Cortex-M targets?
> 
> Did the debugger support ever work on some Cortex-M target?

Not that I know of. It would be nice if the library built but gave a useful error message if run.  

Chris


More information about the devel mailing list