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

Christian Mauderer christian.mauderer at embedded-brains.de
Thu Oct 17 05:51:46 UTC 2019


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.

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?

Best regards

Christian

On 15/10/2019 17:09, Christian Mauderer wrote:
> ---
>  cpukit/libdebugger/rtems-debugger-arm.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/libdebugger/rtems-debugger-arm.c
b/cpukit/libdebugger/rtems-debugger-arm.c
> index 3d5dea0ab7..a6aaca31f2 100644
> --- a/cpukit/libdebugger/rtems-debugger-arm.c
> +++ b/cpukit/libdebugger/rtems-debugger-arm.c
> @@ -1590,10 +1590,15 @@ target_exception(CPU_Exception_frame* 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
> + #if !ARM_THUMB_ONLY && defined(__thumb__)
> +  #define EXCEPTION_ENTRY_EXC()               (void) arm_switch_reg
> +  #define EXCEPTION_EXIT_EXC()                (void) arm_switch_reg
> + #else
> +  #define EXCEPTION_ENTRY_EXC()
> +  #define EXCEPTION_EXIT_EXC()
> + #endif
>   #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
>

-- 
--------------------------------------------
embedded brains GmbH
Herr Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.mauderer at embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list