[0/3] gdb/arm: Fixes for Cortex-M stack unwinding

Message ID 20221104144438.2786801-1-torbjorn.svensson@foss.st.com
Headers
Series gdb/arm: Fixes for Cortex-M stack unwinding |

Message

Torbjorn SVENSSON Nov. 4, 2022, 2:44 p.m. UTC
  Hi,

This patchset attempts to attack the issues reported in pr/29716 and
pr/29738.

Based on my testing on a STM32L552 with TrustZone, it appears to work as
expected, but I'd love to have another set of eyes on this!

Most of the items reported can be seen using the GTZC example from ST:
https://github.com/STMicroelectronics/STM32CubeL5/tree/master/Projects/NUCLEO-L552ZE-Q/Examples/GTZC/GTZC_TZSC_MPCBB_TrustZone

I've manually verfied the register content by setting break points in
* main
* Error_Handler
* SecureFault_Handler


For the dwarf2 problem in pr/29738, I added 7-chained functions like
below and placed a breakpoint at myfunc7:

  void myfunc7()
    {
      HAL_Delay(1);
    }
  ...
  void myfunc1()
    {
      HAL_Delay(1);
      myfunc2();
    }

For each breakpoint, I then used the below macros to print the
registers. For each of the printed frames, I then manually checked if
the values maked sense.

define show_reg
  shell printf "%-8s " '$arg0'
  p/x $arg0
end
define show_stacks
  shell echo
  shell echo -e "\x1b[35mContent at $arg0\x1b[0m"
  bt
  set $i = 0
  while $i <= $arg1
    f $i
    show_reg $lr
    show_reg $pc
    show_reg $sp
    show_reg $msp
    show_reg $msp_s
    show_reg $msp_ns
    show_reg $psp
    show_reg $psp_s
    show_reg $psp_ns

    shell echo
    set $i = $i + 1
  end
  shell echo
  shell echo
end


The show_stacks macro takes 2 arguments, a description and the number of
frames to print registers for.
To show the registers for all the frames when at the Error_Handler
breakpoint, I used:
show_stacks "Error_Handler" 7


With this series applied, I've not been able to reproduce the stack
trace shown in comment 0 in pr/29716. I'm not sure if the series fixes
the issue, or if it still there but I'm doing something wrong.


Kind regards,
Torbjörn