u-boot/arch
Heinrich Schuchardt f6431e8fb3 riscv: show code leading to exception
To make analyzing exceptions easier output the code that leads to it.
We already do the same on the ARM platform.

Here is an example:

    => exception ebreak
    Unhandled exception: Breakpoint
    EPC: 000000008ff5d50e RA: 000000008ff5d62c TVAL: 0000000000000000
    EPC: 000000008020b50e RA: 000000008020b62c reloc adjusted

    Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)

To disassemble the code we can use the decodecode script:

    $ echo 'Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)' | \
      CROSS_COMPILE=riscv64-linux-gnu- scripts/decodecode

    Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)
    All code
    ========
       0:   2785                    addiw   a5,a5,1
       2:   07a00693                li      a3,122
       6:   fef6dce3                bge     a3,a5,0xfffffffffffffffe
       a:   47a5                    li      a5,9
       c:   00e7d563                bge     a5,a4,0x16
      10:*  9002                    ebreak         <-- trapping instruction
            ...

    Code starting with the faulting instruction
    ===========================================
       0:   9002                    ebreak
            ...

As it is not always clear if the first 16 bits are at the start or in the
middle of a 32bit instruction it may become necessary to strip the first
u16 from the output before calling decodecode to get the correct
disassembled code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
2021-09-07 10:34:29 +08:00
..
arc global_data: Ensure we have <config.h> when symbols are not in Kconfig yet 2021-06-23 08:45:03 -04:00
arm stm32mp: Fix board_get_usable_ram_top() 2021-09-06 10:00:11 +02:00
m68k m68k: Remove M52277EVB board 2021-07-18 21:03:57 -04:00
microblaze lmb: move CONFIG_LMB in Kconfig 2021-04-22 14:09:45 -04:00
mips global: Convert simple_strtoul() with hex to hextoul() 2021-08-02 13:32:14 -04:00
nds32 pci: ppc: Drop ftpci100 driver 2021-08-06 08:26:48 -04:00
nios2 global: Convert simple_strtoul() with hex to hextoul() 2021-08-02 13:32:14 -04:00
powerpc pci: powerpc: Drop old code 2021-08-05 16:14:36 -04:00
riscv riscv: show code leading to exception 2021-09-07 10:34:29 +08:00
sandbox bootcount: add a new driver with syscon as backend 2021-08-22 11:04:52 +02:00
sh global: Convert simple_strtoul() with hex to hextoul() 2021-08-02 13:32:14 -04:00
x86 efi_loader rename enum efi_mem_type to efi_memory_type 2021-08-17 17:24:08 +02:00
xtensa treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
.gitignore
Kconfig Rename DRIVERS_MISC_SUPPORT to DRIVERS_MISC 2021-07-28 14:29:37 -04:00
u-boot-elf.lds