diff --git a/components/esp_gdbstub/src/port/riscv/rv_decode.c b/components/esp_gdbstub/src/port/riscv/rv_decode.c index b555621086..defe48aa46 100644 --- a/components/esp_gdbstub/src/port/riscv/rv_decode.c +++ b/components/esp_gdbstub/src/port/riscv/rv_decode.c @@ -1,10 +1,12 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include "rv_decode.h" +#include "riscv/csr_hwlp.h" +#include "soc/soc_caps.h" static inline uint32_t rv_inst_len(uint32_t inst) { @@ -154,5 +156,26 @@ uintptr_t rv_compute_next_pc(esp_gdbstub_frame_t *frame, uintptr_t inst_addr) } } #endif /* __riscv_c */ +#if SOC_CPU_HAS_HWLOOP + /* This block of code could be done with a loop, but the RV_READ_CSR macro + * is not designed to pass values as variables. + */ + /* Check if LOOP0 is executing */ + const uintptr_t loop0_end_addr = RV_READ_CSR(CSR_LOOP0_END_ADDR); + if (loop0_end_addr == inst_addr) { + const uint32_t loop0_count = RV_READ_CSR(CSR_LOOP0_COUNT); + if (loop0_count > 1) { + return RV_READ_CSR(CSR_LOOP0_START_ADDR); + } + } + /* Check if LOOP1 is executing */ + const uintptr_t loop1_end_addr = RV_READ_CSR(CSR_LOOP1_END_ADDR); + if (loop1_end_addr == inst_addr) { + const uint32_t loop1_count = RV_READ_CSR(CSR_LOOP1_COUNT); + if (loop1_count > 1) { + return RV_READ_CSR(CSR_LOOP1_START_ADDR); + } + } +#endif // SOC_CPU_HAS_HWLOOP return inst_addr + inst_len; } diff --git a/components/esp_gdbstub/test_gdbstub_host/rv_decode/test_rv_decode.cpp b/components/esp_gdbstub/test_gdbstub_host/rv_decode/test_rv_decode.cpp index 1f624eac4d..50c9ccc386 100644 --- a/components/esp_gdbstub/test_gdbstub_host/rv_decode/test_rv_decode.cpp +++ b/components/esp_gdbstub/test_gdbstub_host/rv_decode/test_rv_decode.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -103,6 +103,368 @@ struct inst_list_s rv32c_nojump[] = { {0x9459, "c.srai"}, {0x8481, "c.srai64"}}; +struct inst_list_s xesppie_nojump[] = { + {0x0287805f, "esp.vcmulas.s16.qacc.h"}, + {0x03c0633b, "esp.vcmulas.s16.qacc.h.ld.ip"}, + {0x0300207f, "esp.vcmulas.s16.qacc.h.ld.xp"}, + {0x0283805f, "esp.vcmulas.s16.qacc.l"}, + {0x01c0633b, "esp.vcmulas.s16.qacc.l.ld.ip"}, + {0x0100207f, "esp.vcmulas.s16.qacc.l.ld.xp"}, + {0x0285805f, "esp.vcmulas.s8.qacc.h"}, + {0x02c0633b, "esp.vcmulas.s8.qacc.h.ld.ip"}, + {0x0200207f, "esp.vcmulas.s8.qacc.h.ld.xp"}, + {0x0281805f, "esp.vcmulas.s8.qacc.l"}, + {0x00c0633b, "esp.vcmulas.s8.qacc.l.ld.ip"}, + {0x0000207f, "esp.vcmulas.s8.qacc.l.ld.xp"}, + {0x02c7005f, "esp.vmulas.s16.qacc"}, + {0x02e060bb, "esp.vmulas.s16.qacc.ld.ip"}, + {0x020822ff, "esp.vmulas.s16.qacc.ld.xp"}, + {0x03e060bb, "esp.vmulas.s16.qacc.st.ip"}, + {0x030822ff, "esp.vmulas.s16.qacc.st.xp"}, + {0x02c3005f, "esp.vmulas.s16.xacc"}, + {0x00e060bb, "esp.vmulas.s16.xacc.ld.ip"}, + {0x000822ff, "esp.vmulas.s16.xacc.ld.xp"}, + {0x01e060bb, "esp.vmulas.s16.xacc.st.ip"}, + {0x010822ff, "esp.vmulas.s16.xacc.st.xp"}, + {0x02c5005f, "esp.vmulas.s8.qacc"}, + {0x026060bb, "esp.vmulas.s8.qacc.ld.ip"}, + {0x020022ff, "esp.vmulas.s8.qacc.ld.xp"}, + {0x036060bb, "esp.vmulas.s8.qacc.st.ip"}, + {0x030022ff, "esp.vmulas.s8.qacc.st.xp"}, + {0x02c1005f, "esp.vmulas.s8.xacc"}, + {0x006060bb, "esp.vmulas.s8.xacc.ld.ip"}, + {0x000022ff, "esp.vmulas.s8.xacc.ld.xp"}, + {0x016060bb, "esp.vmulas.s8.xacc.st.ip"}, + {0x010022ff, "esp.vmulas.s8.xacc.st.xp"}, + {0x02c6005f, "esp.vmulas.u16.qacc"}, + {0x02a060bb, "esp.vmulas.u16.qacc.ld.ip"}, + {0x020820ff, "esp.vmulas.u16.qacc.ld.xp"}, + {0x03a060bb, "esp.vmulas.u16.qacc.st.ip"}, + {0x030820ff, "esp.vmulas.u16.qacc.st.xp"}, + {0x02c2005f, "esp.vmulas.u16.xacc"}, + {0x00a060bb, "esp.vmulas.u16.xacc.ld.ip"}, + {0x000820ff, "esp.vmulas.u16.xacc.ld.xp"}, + {0x01a060bb, "esp.vmulas.u16.xacc.st.ip"}, + {0x010820ff, "esp.vmulas.u16.xacc.st.xp"}, + {0x02c4005f, "esp.vmulas.u8.qacc"}, + {0x022060bb, "esp.vmulas.u8.qacc.ld.ip"}, + {0x020020ff, "esp.vmulas.u8.qacc.ld.xp"}, + {0x032060bb, "esp.vmulas.u8.qacc.st.ip"}, + {0x030020ff, "esp.vmulas.u8.qacc.st.xp"}, + {0x02c0005f, "esp.vmulas.u8.xacc"}, + {0x002060bb, "esp.vmulas.u8.xacc.ld.ip"}, + {0x000020ff, "esp.vmulas.u8.xacc.ld.xp"}, + {0x012060bb, "esp.vmulas.u8.xacc.st.ip"}, + {0x010020ff, "esp.vmulas.u8.xacc.st.xp"}, + {0x006061bb, "esp.vmulas.s16.qacc.ldbc.incp"}, + {0x002061bb, "esp.vmulas.s8.qacc.ldbc.incp"}, + {0x004061bb, "esp.vmulas.u16.qacc.ldbc.incp"}, + {0x000061bb, "esp.vmulas.u8.qacc.ldbc.incp"}, + {0x02f0005f, "esp.vsmulas.s16.qacc"}, + {0x038063bb, "esp.vsmulas.s16.qacc.ld.incp"}, + {0x02b0005f, "esp.vsmulas.s8.qacc"}, + {0x018063bb, "esp.vsmulas.s8.qacc.ld.incp"}, + {0x02d0005f, "esp.vsmulas.u16.qacc"}, + {0x028063bb, "esp.vsmulas.u16.qacc.ld.incp"}, + {0x0290005f, "esp.vsmulas.u8.qacc"}, + {0x008063bb, "esp.vsmulas.u8.qacc.ld.incp"}, + {0x0006245f, "esp.cmul.s16"}, + {0x00c0403f, "esp.cmul.s16.ld.incp"}, + {0x02c0403f, "esp.cmul.s16.st.incp"}, + {0x0002245f, "esp.cmul.s8"}, + {0x0040403f, "esp.cmul.s8.ld.incp"}, + {0x0240403f, "esp.cmul.s8.st.incp"}, + {0x0004245f, "esp.cmul.u16"}, + {0x0080403f, "esp.cmul.u16.ld.incp"}, + {0x0280403f, "esp.cmul.u16.st.incp"}, + {0x0000245f, "esp.cmul.u8"}, + {0x0000403f, "esp.cmul.u8.ld.incp"}, + {0x0200403f, "esp.cmul.u8.st.incp"}, + {0x90c0505b, "esp.max.s16.a"}, + {0x90a0505b, "esp.max.s32.a"}, + {0x9040505b, "esp.max.s8.a"}, + {0x9080505b, "esp.max.u16.a"}, + {0x9020505b, "esp.max.u32.a"}, + {0x9000505b, "esp.max.u8.a"}, + {0x90d0505b, "esp.min.s16.a"}, + {0x90b0505b, "esp.min.s32.a"}, + {0x9050505b, "esp.min.s8.a"}, + {0x9090505b, "esp.min.u16.a"}, + {0x9030505b, "esp.min.u32.a"}, + {0x9010505b, "esp.min.u8.a"}, + {0x8000105b, "esp.vabs.16"}, + {0x8000085b, "esp.vabs.32"}, + {0x8000005b, "esp.vabs.8"}, + {0x0284065f, "esp.vadd.s16"}, + {0x0108603b, "esp.vadd.s16.ld.incp"}, + {0x0308603b, "esp.vadd.s16.st.incp"}, + {0x0284055f, "esp.vadd.s32"}, + {0x0100613b, "esp.vadd.s32.ld.incp"}, + {0x0300613b, "esp.vadd.s32.st.incp"}, + {0x0280065f, "esp.vadd.s8"}, + {0x0008603b, "esp.vadd.s8.ld.incp"}, + {0x0208603b, "esp.vadd.s8.st.incp"}, + {0x0284045f, "esp.vadd.u16"}, + {0x0100603b, "esp.vadd.u16.ld.incp"}, + {0x0300603b, "esp.vadd.u16.st.incp"}, + {0x0280055f, "esp.vadd.u32"}, + {0x0000613b, "esp.vadd.u32.ld.incp"}, + {0x0200613b, "esp.vadd.u32.st.incp"}, + {0x0280045f, "esp.vadd.u8"}, + {0x0000603b, "esp.vadd.u8.ld.incp"}, + {0x0200603b, "esp.vadd.u8.st.incp"}, + {0x0000505b, "esp.vclamp.s16"}, + {0x0006ac5f, "esp.vmax.s16"}, + {0x0068403f, "esp.vmax.s16.ld.incp"}, + {0x00e8403f, "esp.vmax.s16.st.incp"}, + {0x0005ac5f, "esp.vmax.s32"}, + {0x0058403f, "esp.vmax.s32.ld.incp"}, + {0x00d8403f, "esp.vmax.s32.st.incp"}, + {0x0002ac5f, "esp.vmax.s8"}, + {0x0028403f, "esp.vmax.s8.ld.incp"}, + {0x00a8403f, "esp.vmax.s8.st.incp"}, + {0x0004ac5f, "esp.vmax.u16"}, + {0x0048403f, "esp.vmax.u16.ld.incp"}, + {0x00c8403f, "esp.vmax.u16.st.incp"}, + {0x0001ac5f, "esp.vmax.u32"}, + {0x0018403f, "esp.vmax.u32.ld.incp"}, + {0x0098403f, "esp.vmax.u32.st.incp"}, + {0x0000ac5f, "esp.vmax.u8"}, + {0x0008403f, "esp.vmax.u8.ld.incp"}, + {0x0088403f, "esp.vmax.u8.st.incp"}, + {0x00063c5f, "esp.vmin.s16"}, + {0x0168403f, "esp.vmin.s16.ld.incp"}, + {0x01e8403f, "esp.vmin.s16.st.incp"}, + {0x00053c5f, "esp.vmin.s32"}, + {0x0158403f, "esp.vmin.s32.ld.incp"}, + {0x01d8403f, "esp.vmin.s32.st.incp"}, + {0x00023c5f, "esp.vmin.s8"}, + {0x0128403f, "esp.vmin.s8.ld.incp"}, + {0x01a8403f, "esp.vmin.s8.st.incp"}, + {0x00043c5f, "esp.vmin.u16"}, + {0x0148403f, "esp.vmin.u16.ld.incp"}, + {0x01c8403f, "esp.vmin.u16.st.incp"}, + {0x00013c5f, "esp.vmin.u32"}, + {0x0118403f, "esp.vmin.u32.ld.incp"}, + {0x0198403f, "esp.vmin.u32.st.incp"}, + {0x00003c5f, "esp.vmin.u8"}, + {0x0108403f, "esp.vmin.u8.ld.incp"}, + {0x0188403f, "esp.vmin.u8.st.incp"}, + {0x0006bc5f, "esp.vmul.s16"}, + {0x0368403f, "esp.vmul.s16.ld.incp"}, + {0x0283045f, "esp.vmul.s16.s8xs8"}, + {0x03e8403f, "esp.vmul.s16.st.incp"}, + {0x0287045f, "esp.vmul.s32.s16xs16"}, + {0x0002bc5f, "esp.vmul.s8"}, + {0x0328403f, "esp.vmul.s8.ld.incp"}, + {0x03a8403f, "esp.vmul.s8.st.incp"}, + {0x0004bc5f, "esp.vmul.u16"}, + {0x0348403f, "esp.vmul.u16.ld.incp"}, + {0x03c8403f, "esp.vmul.u16.st.incp"}, + {0x0000bc5f, "esp.vmul.u8"}, + {0x0308403f, "esp.vmul.u8.ld.incp"}, + {0x0388403f, "esp.vmul.u8.st.incp"}, + {0x02a0605f, "esp.vprelu.s16"}, + {0x0220605f, "esp.vprelu.s8"}, + {0x82005c5b, "esp.vrelu.s16"}, + {0x8200585b, "esp.vrelu.s8"}, + {0x1a80025f, "esp.vsadds.s16"}, + {0x0a80025f, "esp.vsadds.s8"}, + {0x1280025f, "esp.vsadds.u16"}, + {0x0280025f, "esp.vsadds.u8"}, + {0x1800583b, "esp.vsat.s16"}, + {0x1800543b, "esp.vsat.s32"}, + {0x1800483b, "esp.vsat.s8"}, + {0x1800503b, "esp.vsat.u16"}, + {0x1800443b, "esp.vsat.u32"}, + {0x1800403b, "esp.vsat.u8"}, + {0x1e80025f, "esp.vssubs.s16"}, + {0x0e80025f, "esp.vssubs.s8"}, + {0x1680025f, "esp.vssubs.u16"}, + {0x0680025f, "esp.vssubs.u8"}, + {0x028406df, "esp.vsub.s16"}, + {0x0188613b, "esp.vsub.s16.ld.incp"}, + {0x0388613b, "esp.vsub.s16.st.incp"}, + {0x028405df, "esp.vsub.s32"}, + {0x0100633b, "esp.vsub.s32.ld.incp"}, + {0x0300633b, "esp.vsub.s32.st.incp"}, + {0x028006df, "esp.vsub.s8"}, + {0x0088613b, "esp.vsub.s8.ld.incp"}, + {0x0288613b, "esp.vsub.s8.st.incp"}, + {0x028404df, "esp.vsub.u16"}, + {0x0180613b, "esp.vsub.u16.ld.incp"}, + {0x0380613b, "esp.vsub.u16.st.incp"}, + {0x028005df, "esp.vsub.u32"}, + {0x0000633b, "esp.vsub.u32.ld.incp"}, + {0x0200633b, "esp.vsub.u32.st.incp"}, + {0x028004df, "esp.vsub.u8"}, + {0x0080613b, "esp.vsub.u8.ld.incp"}, + {0x0280613b, "esp.vsub.u8.st.incp"}, + {0x04840433, "esp.addx2"}, + {0x08840433, "esp.addx4"}, + {0x40842433, "esp.sat"}, + {0x44840433, "esp.subx2"}, + {0x48840433, "esp.subx4"}, + {0x0004205f, "esp.andq"}, + {0x0006205f, "esp.notq"}, + {0x0000205f, "esp.orq"}, + {0x0002205f, "esp.xorq"}, + {0x0001b45f, "esp.vcmp.eq.s16"}, + {0x00012c5f, "esp.vcmp.eq.s32"}, + {0x0000b45f, "esp.vcmp.eq.s8"}, + {0x0001345f, "esp.vcmp.eq.u16"}, + {0x00002c5f, "esp.vcmp.eq.u32"}, + {0x0000345f, "esp.vcmp.eq.u8"}, + {0x0005b45f, "esp.vcmp.gt.s16"}, + {0x00052c5f, "esp.vcmp.gt.s32"}, + {0x0004b45f, "esp.vcmp.gt.s8"}, + {0x0005345f, "esp.vcmp.gt.u16"}, + {0x00042c5f, "esp.vcmp.gt.u32"}, + {0x0004345f, "esp.vcmp.gt.u8"}, + {0x0003b45f, "esp.vcmp.lt.s16"}, + {0x00032c5f, "esp.vcmp.lt.s32"}, + {0x0002b45f, "esp.vcmp.lt.s8"}, + {0x0003345f, "esp.vcmp.lt.u16"}, + {0x00022c5f, "esp.vcmp.lt.u32"}, + {0x0002345f, "esp.vcmp.lt.u8"}, + {0x1060005b, "esp.mov.s16.qacc"}, + {0x1020005b, "esp.mov.s8.qacc"}, + {0x1040005b, "esp.mov.u16.qacc"}, + {0x1000005b, "esp.mov.u8.qacc"}, + {0x00c0005f, "esp.movi.16.a"}, + {0x80e0005f, "esp.movi.16.q"}, + {0x8080005f, "esp.movi.32.a"}, + {0x8090005f, "esp.movi.32.q"}, + {0x0080005f, "esp.movi.8.a"}, + {0x80a0005f, "esp.movi.8.q"}, + {0x80d0005f, "esp.movx.r.cfg"}, + {0x84d0005f, "esp.movx.r.fft.bit.width"}, + {0x8cd0005f, "esp.movx.r.perf"}, + {0x80b0005f, "esp.movx.r.sar"}, + {0x88b0005f, "esp.movx.r.sar.bytes"}, + {0x8cb0005f, "esp.movx.r.xacc.h"}, + {0x84b0005f, "esp.movx.r.xacc.l"}, + {0x90d0005f, "esp.movx.w.cfg"}, + {0x94d0005f, "esp.movx.w.fft.bit.width"}, + {0x9cd0005f, "esp.movx.w.perf"}, + {0x90b0005f, "esp.movx.w.sar"}, + {0x98b0005f, "esp.movx.w.sar.bytes"}, + {0x9cb0005f, "esp.movx.w.xacc.h"}, + {0x94b0005f, "esp.movx.w.xacc.l"}, + {0x1800585b, "esp.vext.s16"}, + {0x0800585b, "esp.vext.s8"}, + {0x1000585b, "esp.vext.u16"}, + {0x0000585b, "esp.vext.u8"}, + {0x0286005f, "esp.vunzip.16"}, + {0x0284805f, "esp.vunzip.32"}, + {0x0284005f, "esp.vunzip.8"}, + {0x00c04c5b, "esp.vunzipt.16"}, + {0x00804c5b, "esp.vunzipt.8"}, + {0x0282005f, "esp.vzip.16"}, + {0x0280805f, "esp.vzip.32"}, + {0x0280005f, "esp.vzip.8"}, + {0x00404c5b, "esp.vzipt.16"}, + {0x00004c5b, "esp.vzipt.8"}, + {0x0040005b, "esp.zero.q"}, + {0x0000025b, "esp.zero.qacc"}, + {0x0000005b, "esp.zero.xacc"}, + {0x0000007b, "esp.fft.ams.s16.ld.incp"}, + {0x0000207b, "esp.fft.ams.s16.ld.incp.uaup"}, + {0x0000607b, "esp.fft.ams.s16.ld.r32.decp"}, + {0x0000203f, "esp.fft.ams.s16.st.incp"}, + {0x1000025b, "esp.fft.bitrev"}, + {0x0000003f, "esp.fft.cmul.s16.ld.xp"}, + {0x0000007f, "esp.fft.cmul.s16.st.xp"}, + {0x0281045f, "esp.fft.r2bf.s16"}, + {0x0200605f, "esp.fft.r2bf.s16.st.incp"}, + {0x0000203b, "esp.fft.vst.r32.decp"}, + {0x8800203b, "esp.ld.128.usar.ip"}, + {0x8000405f, "esp.ld.128.usar.xp"}, + {0xa000433b, "esp.ld.xacc.ip"}, + {0xe08040bb, "esp.ldqa.s16.128.ip"}, + {0x1300535b, "esp.ldqa.s16.128.xp"}, + {0x608040bb, "esp.ldqa.s8.128.ip"}, + {0x1300515b, "esp.ldqa.s8.128.xp"}, + {0xa08040bb, "esp.ldqa.u16.128.ip"}, + {0x1300525b, "esp.ldqa.u16.128.xp"}, + {0x208040bb, "esp.ldqa.u8.128.ip"}, + {0x1300505b, "esp.ldqa.u8.128.xp"}, + {0xc600203b, "esp.vldbc.16.ip"}, + {0x9600405f, "esp.vldbc.16.xp"}, + {0x8e00203b, "esp.vldbc.32.ip"}, + {0x8e00405f, "esp.vldbc.32.xp"}, + {0x4600203b, "esp.vldbc.8.ip"}, + {0x8600405f, "esp.vldbc.8.xp"}, + {0xc880403b, "esp.vldext.s16.ip"}, + {0xf000605f, "esp.vldext.s16.xp"}, + {0x4880403b, "esp.vldext.s8.ip"}, + {0x7000605f, "esp.vldext.s8.xp"}, + {0x8880403b, "esp.vldext.u16.ip"}, + {0xb000605f, "esp.vldext.u16.xp"}, + {0x0880403b, "esp.vldext.u8.ip"}, + {0x3000605f, "esp.vldext.u8.xp"}, + {0x2800403b, "esp.vldhbc.16.incp"}, + {0x4080403b, "esp.ld.qacc.h.h.128.ip"}, + {0x6080403b, "esp.ld.qacc.h.l.128.ip"}, + {0x0080403b, "esp.ld.qacc.l.h.128.ip"}, + {0x2080403b, "esp.ld.qacc.l.l.128.ip"}, + {0x6000413b, "esp.ld.ua.state.ip"}, + {0x0080205f, "esp.ldxq.32"}, + {0xc080403b, "esp.st.qacc.h.h.128.ip"}, + {0xe080403b, "esp.st.qacc.h.l.128.ip"}, + {0x8080403b, "esp.st.qacc.l.h.128.ip"}, + {0xa080403b, "esp.st.qacc.l.l.128.ip"}, + {0xe000413b, "esp.st.ua.state.ip"}, + {0x8080205f, "esp.stxq.32"}, + {0x4200203b, "esp.vld.128.ip"}, + {0x8200405f, "esp.vld.128.xp"}, + {0x6400203b, "esp.vld.h.64.ip"}, + {0x8c00405f, "esp.vld.h.64.xp"}, + {0x2400203b, "esp.vld.l.64.ip"}, + {0x8400405f, "esp.vld.l.64.xp"}, + {0xc200203b, "esp.vst.128.ip"}, + {0x9200405f, "esp.vst.128.xp"}, + {0xe400203b, "esp.vst.h.64.ip"}, + {0x9c00405f, "esp.vst.h.64.xp"}, + {0xa400203b, "esp.vst.l.64.ip"}, + {0x9400405f, "esp.vst.l.64.xp"}, + {0x0000485b, "esp.slci.2q"}, + {0x0000405f, "esp.slcxxp.2q"}, + {0x8024005b, "esp.src.q"}, + {0x8000213b, "esp.src.q.ld.ip"}, + {0x0000003b, "esp.src.q.ld.xp"}, + {0x8024105b, "esp.src.q.qup"}, + {0x0080485b, "esp.srci.2q"}, + {0x9864005b, "esp.srcmb.s16.q.qacc"}, + {0xd800203b, "esp.srcmb.s16.qacc"}, + {0x8864005b, "esp.srcmb.s8.q.qacc"}, + {0x5800203b, "esp.srcmb.s8.qacc"}, + {0x9064005b, "esp.srcmb.u16.q.qacc"}, + {0x9800203b, "esp.srcmb.u16.qacc"}, + {0x8064005b, "esp.srcmb.u8.q.qacc"}, + {0x1800203b, "esp.srcmb.u8.qacc"}, + {0x0000405b, "esp.srcq.128.st.incp"}, + {0x0000445f, "esp.srcxxp.2q"}, + {0x94f0005f, "esp.srs.s.xacc"}, + {0x84f0005f, "esp.srs.u.xacc"}, + {0x8004005b, "esp.vsl.32"}, + {0x0020005f, "esp.vsld.16"}, + {0x0010005f, "esp.vsld.32"}, + {0x0000005f, "esp.vsld.8"}, + {0x8004035b, "esp.vsr.s32"}, + {0x8004015b, "esp.vsr.u32"}, + {0x0060005f, "esp.vsrd.16"}, + {0x0050005f, "esp.vsrd.32"}, + {0x0040005f, "esp.vsrd.8"}, + {0xe00041bb, "esp.st.s.xacc.ip"}, + {0x600041bb, "esp.st.u.xacc.ip"}, + {0x0000502b, "esp.lp.setupi"}, + {0x0004402b, "esp.lp.setup"}, + {0x0000002b, "esp.lp.starti"}, + {0x0000102b, "esp.lp.endi"}, + {0x0000302b, "esp.lp.counti"}, + {0x0004202b, "esp.lp.count"}}; + TEST_CASE("decode rv32i instructions") { @@ -336,3 +698,16 @@ TEST_CASE("decode rv32m instructions") CHECK(rv_compute_next_pc(temp_regs_frame, inst_addr) == inst_addr + 4); } } + +TEST_CASE("decode xesppie instructions") +{ + uintptr_t pc; + uint32_t inst; + uintptr_t inst_addr = (uintptr_t)&inst; + + for (size_t i = 0; i < sizeof(xesppie_nojump)/sizeof(xesppie_nojump[0]); i++) { + inst = xesppie_nojump[i].inst; + DEBUG_PRINTF("testing instruction %s\n", xesppie_nojump[i].name); + CHECK(rv_compute_next_pc(temp_regs_frame, inst_addr) == inst_addr + 4); + } +} diff --git a/components/esp_gdbstub/test_gdbstub_host/rv_decode/xesppie.S b/components/esp_gdbstub/test_gdbstub_host/rv_decode/xesppie.S new file mode 100644 index 0000000000..8f662369d4 --- /dev/null +++ b/components/esp_gdbstub/test_gdbstub_host/rv_decode/xesppie.S @@ -0,0 +1,369 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is used to generate "xesppie_nojump" array. +// It's manually passed to gcc + objdump: +// riscv32-esp-elf-gcc -march=rv32ixesppie -c rv_decode/xesppie.S +// riscv32-esp-elf-objdump -D -j .text xesppie.o | tail -n +8 | sed -E 's/^\s+[0-9a-f]+:\s+([0-9a-f]+)\s+([a-zA-Z0-9_.]+).*/{0x\1, "\2"},/' +esp.vcmulas.s16.qacc.h q0,q0 +esp.vcmulas.s16.qacc.h.ld.ip q0,x8,-128,q0,q0 +esp.vcmulas.s16.qacc.h.ld.xp q0,x8,x8,q0,q0 +esp.vcmulas.s16.qacc.l q0,q0 +esp.vcmulas.s16.qacc.l.ld.ip q0,x8,-128,q0,q0 +esp.vcmulas.s16.qacc.l.ld.xp q0,x8,x8,q0,q0 +esp.vcmulas.s8.qacc.h q0,q0 +esp.vcmulas.s8.qacc.h.ld.ip q0,x8,-128,q0,q0 +esp.vcmulas.s8.qacc.h.ld.xp q0,x8,x8,q0,q0 +esp.vcmulas.s8.qacc.l q0,q0 +esp.vcmulas.s8.qacc.l.ld.ip q0,x8,-128,q0,q0 +esp.vcmulas.s8.qacc.l.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.s16.qacc q0,q0 +esp.vmulas.s16.qacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.s16.qacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.s16.qacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.s16.qacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.s16.xacc q0,q0 +esp.vmulas.s16.xacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.s16.xacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.s16.xacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.s16.xacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.s8.qacc q0,q0 +esp.vmulas.s8.qacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.s8.qacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.s8.qacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.s8.qacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.s8.xacc q0,q0 +esp.vmulas.s8.xacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.s8.xacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.s8.xacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.s8.xacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.u16.qacc q0,q0 +esp.vmulas.u16.qacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.u16.qacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.u16.qacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.u16.qacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.u16.xacc q0,q0 +esp.vmulas.u16.xacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.u16.xacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.u16.xacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.u16.xacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.u8.qacc q0,q0 +esp.vmulas.u8.qacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.u8.qacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.u8.qacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.u8.qacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.u8.xacc q0,q0 +esp.vmulas.u8.xacc.ld.ip q0,x8,-128,q0,q0 +esp.vmulas.u8.xacc.ld.xp q0,x8,x8,q0,q0 +esp.vmulas.u8.xacc.st.ip q0,x8,-128,q0,q0 +esp.vmulas.u8.xacc.st.xp q0,x8,x8,q0,q0 +esp.vmulas.s16.qacc.ldbc.incp q0,x8,q0,q0 +esp.vmulas.s8.qacc.ldbc.incp q0,x8,q0,q0 +esp.vmulas.u16.qacc.ldbc.incp q0,x8,q0,q0 +esp.vmulas.u8.qacc.ldbc.incp q0,x8,q0,q0 +esp.vsmulas.s16.qacc q0,q0,0 +esp.vsmulas.s16.qacc.ld.incp q0,x8,q0,q0,0 +esp.vsmulas.s8.qacc q0,q0,0 +esp.vsmulas.s8.qacc.ld.incp q0,x8,q0,q0,0 +esp.vsmulas.u16.qacc q0,q0,0 +esp.vsmulas.u16.qacc.ld.incp q0,x8,q0,q0,0 +esp.vsmulas.u8.qacc q0,q0,0 +esp.vsmulas.u8.qacc.ld.incp q0,x8,q0,q0,0 +esp.cmul.s16 q0,q0,q0,0 +esp.cmul.s16.ld.incp q0,x8,q0,q0,q0,0 +esp.cmul.s16.st.incp q0,x8,q0,q0,q0,0 +esp.cmul.s8 q0,q0,q0,0 +esp.cmul.s8.ld.incp q0,x8,q0,q0,q0,0 +esp.cmul.s8.st.incp q0,x8,q0,q0,q0,0 +esp.cmul.u16 q0,q0,q0,0 +esp.cmul.u16.ld.incp q0,x8,q0,q0,q0,0 +esp.cmul.u16.st.incp q0,x8,q0,q0,q0,0 +esp.cmul.u8 q0,q0,q0,0 +esp.cmul.u8.ld.incp q0,x8,q0,q0,q0,0 +esp.cmul.u8.st.incp q0,x8,q0,q0,q0,0 +esp.max.s16.a q0,x8 +esp.max.s32.a q0,x8 +esp.max.s8.a q0,x8 +esp.max.u16.a q0,x8 +esp.max.u32.a q0,x8 +esp.max.u8.a q0,x8 +esp.min.s16.a q0,x8 +esp.min.s32.a q0,x8 +esp.min.s8.a q0,x8 +esp.min.u16.a q0,x8 +esp.min.u32.a q0,x8 +esp.min.u8.a q0,x8 +esp.vabs.16 q0,q0 +esp.vabs.32 q0,q0 +esp.vabs.8 q0,q0 +esp.vadd.s16 q0,q0,q0 +esp.vadd.s16.ld.incp q0,x8,q0,q0,q0 +esp.vadd.s16.st.incp q0,x8,q0,q0,q0 +esp.vadd.s32 q0,q0,q0 +esp.vadd.s32.ld.incp q0,x8,q0,q0,q0 +esp.vadd.s32.st.incp q0,x8,q0,q0,q0 +esp.vadd.s8 q0,q0,q0 +esp.vadd.s8.ld.incp q0,x8,q0,q0,q0 +esp.vadd.s8.st.incp q0,x8,q0,q0,q0 +esp.vadd.u16 q0,q0,q0 +esp.vadd.u16.ld.incp q0,x8,q0,q0,q0 +esp.vadd.u16.st.incp q0,x8,q0,q0,q0 +esp.vadd.u32 q0,q0,q0 +esp.vadd.u32.ld.incp q0,x8,q0,q0,q0 +esp.vadd.u32.st.incp q0,x8,q0,q0,q0 +esp.vadd.u8 q0,q0,q0 +esp.vadd.u8.ld.incp q0,x8,q0,q0,q0 +esp.vadd.u8.st.incp q0,x8,q0,q0,q0 +esp.vclamp.s16 q0,q0,0 +esp.vmax.s16 q0,q0,q0 +esp.vmax.s16.ld.incp q0,x8,q0,q0,q0 +esp.vmax.s16.st.incp q0,x8,q0,q0,q0 +esp.vmax.s32 q0,q0,q0 +esp.vmax.s32.ld.incp q0,x8,q0,q0,q0 +esp.vmax.s32.st.incp q0,x8,q0,q0,q0 +esp.vmax.s8 q0,q0,q0 +esp.vmax.s8.ld.incp q0,x8,q0,q0,q0 +esp.vmax.s8.st.incp q0,x8,q0,q0,q0 +esp.vmax.u16 q0,q0,q0 +esp.vmax.u16.ld.incp q0,x8,q0,q0,q0 +esp.vmax.u16.st.incp q0,x8,q0,q0,q0 +esp.vmax.u32 q0,q0,q0 +esp.vmax.u32.ld.incp q0,x8,q0,q0,q0 +esp.vmax.u32.st.incp q0,x8,q0,q0,q0 +esp.vmax.u8 q0,q0,q0 +esp.vmax.u8.ld.incp q0,x8,q0,q0,q0 +esp.vmax.u8.st.incp q0,x8,q0,q0,q0 +esp.vmin.s16 q0,q0,q0 +esp.vmin.s16.ld.incp q0,x8,q0,q0,q0 +esp.vmin.s16.st.incp q0,x8,q0,q0,q0 +esp.vmin.s32 q0,q0,q0 +esp.vmin.s32.ld.incp q0,x8,q0,q0,q0 +esp.vmin.s32.st.incp q0,x8,q0,q0,q0 +esp.vmin.s8 q0,q0,q0 +esp.vmin.s8.ld.incp q0,x8,q0,q0,q0 +esp.vmin.s8.st.incp q0,x8,q0,q0,q0 +esp.vmin.u16 q0,q0,q0 +esp.vmin.u16.ld.incp q0,x8,q0,q0,q0 +esp.vmin.u16.st.incp q0,x8,q0,q0,q0 +esp.vmin.u32 q0,q0,q0 +esp.vmin.u32.ld.incp q0,x8,q0,q0,q0 +esp.vmin.u32.st.incp q0,x8,q0,q0,q0 +esp.vmin.u8 q0,q0,q0 +esp.vmin.u8.ld.incp q0,x8,q0,q0,q0 +esp.vmin.u8.st.incp q0,x8,q0,q0,q0 +esp.vmul.s16 q0,q0,q0 +esp.vmul.s16.ld.incp q0,x8,q0,q0,q0 +esp.vmul.s16.s8xs8 q0,q0,q0,q0 +esp.vmul.s16.st.incp q0,x8,q0,q0,q0 +esp.vmul.s32.s16xs16 q0,q0,q0,q0 +esp.vmul.s8 q0,q0,q0 +esp.vmul.s8.ld.incp q0,x8,q0,q0,q0 +esp.vmul.s8.st.incp q0,x8,q0,q0,q0 +esp.vmul.u16 q0,q0,q0 +esp.vmul.u16.ld.incp q0,x8,q0,q0,q0 +esp.vmul.u16.st.incp q0,x8,q0,q0,q0 +esp.vmul.u8 q0,q0,q0 +esp.vmul.u8.ld.incp q0,x8,q0,q0,q0 +esp.vmul.u8.st.incp q0,x8,q0,q0,q0 +esp.vprelu.s16 q0,q0,q0,x8 +esp.vprelu.s8 q0,q0,q0,x8 +esp.vrelu.s16 q0,x8,x8 +esp.vrelu.s8 q0,x8,x8 +esp.vsadds.s16 q0,q0,x8 +esp.vsadds.s8 q0,q0,x8 +esp.vsadds.u16 q0,q0,x8 +esp.vsadds.u8 q0,q0,x8 +esp.vsat.s16 q0,q0,x8,x8 +esp.vsat.s32 q0,q0,x8,x8 +esp.vsat.s8 q0,q0,x8,x8 +esp.vsat.u16 q0,q0,x8,x8 +esp.vsat.u32 q0,q0,x8,x8 +esp.vsat.u8 q0,q0,x8,x8 +esp.vssubs.s16 q0,q0,x8 +esp.vssubs.s8 q0,q0,x8 +esp.vssubs.u16 q0,q0,x8 +esp.vssubs.u8 q0,q0,x8 +esp.vsub.s16 q0,q0,q0 +esp.vsub.s16.ld.incp q0,x8,q0,q0,q0 +esp.vsub.s16.st.incp q0,x8,q0,q0,q0 +esp.vsub.s32 q0,q0,q0 +esp.vsub.s32.ld.incp q0,x8,q0,q0,q0 +esp.vsub.s32.st.incp q0,x8,q0,q0,q0 +esp.vsub.s8 q0,q0,q0 +esp.vsub.s8.ld.incp q0,x8,q0,q0,q0 +esp.vsub.s8.st.incp q0,x8,q0,q0,q0 +esp.vsub.u16 q0,q0,q0 +esp.vsub.u16.ld.incp q0,x8,q0,q0,q0 +esp.vsub.u16.st.incp q0,x8,q0,q0,q0 +esp.vsub.u32 q0,q0,q0 +esp.vsub.u32.ld.incp q0,x8,q0,q0,q0 +esp.vsub.u32.st.incp q0,x8,q0,q0,q0 +esp.vsub.u8 q0,q0,q0 +esp.vsub.u8.ld.incp q0,x8,q0,q0,q0 +esp.vsub.u8.st.incp q0,x8,q0,q0,q0 +esp.addx2 x8,x8,x8 +esp.addx4 x8,x8,x8 +esp.sat x8,x8,x8 +esp.subx2 x8,x8,x8 +esp.subx4 x8,x8,x8 +esp.andq q0,q0,q0 +esp.notq q0,q0 +esp.orq q0,q0,q0 +esp.xorq q0,q0,q0 +esp.vcmp.eq.s16 q0,q0,q0 +esp.vcmp.eq.s32 q0,q0,q0 +esp.vcmp.eq.s8 q0,q0,q0 +esp.vcmp.eq.u16 q0,q0,q0 +esp.vcmp.eq.u32 q0,q0,q0 +esp.vcmp.eq.u8 q0,q0,q0 +esp.vcmp.gt.s16 q0,q0,q0 +esp.vcmp.gt.s32 q0,q0,q0 +esp.vcmp.gt.s8 q0,q0,q0 +esp.vcmp.gt.u16 q0,q0,q0 +esp.vcmp.gt.u32 q0,q0,q0 +esp.vcmp.gt.u8 q0,q0,q0 +esp.vcmp.lt.s16 q0,q0,q0 +esp.vcmp.lt.s32 q0,q0,q0 +esp.vcmp.lt.s8 q0,q0,q0 +esp.vcmp.lt.u16 q0,q0,q0 +esp.vcmp.lt.u32 q0,q0,q0 +esp.vcmp.lt.u8 q0,q0,q0 +esp.mov.s16.qacc q0 +esp.mov.s8.qacc q0 +esp.mov.u16.qacc q0 +esp.mov.u8.qacc q0 +esp.movi.16.a q0,x8,0 +esp.movi.16.q q0,x8,0 +esp.movi.32.a q0,x8,0 +esp.movi.32.q q0,x8,0 +esp.movi.8.a q0,x8,0 +esp.movi.8.q q0,x8,0 +esp.movx.r.cfg x8 +esp.movx.r.fft.bit.width x8 +esp.movx.r.perf x8,x8 +esp.movx.r.sar x8 +esp.movx.r.sar.bytes x8 +esp.movx.r.xacc.h x8 +esp.movx.r.xacc.l x8 +esp.movx.w.cfg x8 +esp.movx.w.fft.bit.width x8 +esp.movx.w.perf x8 +esp.movx.w.sar x8 +esp.movx.w.sar.bytes x8 +esp.movx.w.xacc.h x8 +esp.movx.w.xacc.l x8 +esp.vext.s16 q0,q0,q0 +esp.vext.s8 q0,q0,q0 +esp.vext.u16 q0,q0,q0 +esp.vext.u8 q0,q0,q0 +esp.vunzip.16 q0,q0 +esp.vunzip.32 q0,q0 +esp.vunzip.8 q0,q0 +esp.vunzipt.16 q0,q0,q0 +esp.vunzipt.8 q0,q0,q0 +esp.vzip.16 q0,q0 +esp.vzip.32 q0,q0 +esp.vzip.8 q0,q0 +esp.vzipt.16 q0,q0,q0 +esp.vzipt.8 q0,q0,q0 +esp.zero.q q0 +esp.zero.qacc +esp.zero.xacc +esp.fft.ams.s16.ld.incp q0,x8,q0,q0,q0,q0,q0,0 +esp.fft.ams.s16.ld.incp.uaup q0,x8,q0,q0,q0,q0,q0,0 +esp.fft.ams.s16.ld.r32.decp q0,x8,q0,q0,q0,q0,q0,0 +esp.fft.ams.s16.st.incp q0,q0,x8,x8,q0,q0,q0,0 +esp.fft.bitrev q0,x8 +esp.fft.cmul.s16.ld.xp q0,x8,x8,q0,q0,q0,0 +esp.fft.cmul.s16.st.xp q0,q0,q0,x8,x8,0,0,0 +esp.fft.r2bf.s16 q0,q0,q0,q0,0 +esp.fft.r2bf.s16.st.incp q0,q0,q0,x8,0 +esp.fft.vst.r32.decp q0,x8,0 +esp.ld.128.usar.ip q0,x8,-2048 +esp.ld.128.usar.xp q0,x8,x8 +esp.ld.xacc.ip x8,-1024 +esp.ldqa.s16.128.ip x8,-2048 +esp.ldqa.s16.128.xp x8,x8 +esp.ldqa.s8.128.ip x8,-2048 +esp.ldqa.s8.128.xp x8,x8 +esp.ldqa.u16.128.ip x8,-2048 +esp.ldqa.u16.128.xp x8,x8 +esp.ldqa.u8.128.ip x8,-2048 +esp.ldqa.u8.128.xp x8,x8 +esp.vldbc.16.ip q0,x8,-512 +esp.vldbc.16.xp q0,x8,x8 +esp.vldbc.32.ip q0,x8,-512 +esp.vldbc.32.xp q0,x8,x8 +esp.vldbc.8.ip q0,x8,-512 +esp.vldbc.8.xp q0,x8,x8 +esp.vldext.s16.ip q0,q0,x8,-128 +esp.vldext.s16.xp q0,q0,x8,x8 +esp.vldext.s8.ip q0,q0,x8,-128 +esp.vldext.s8.xp q0,q0,x8,x8 +esp.vldext.u16.ip q0,q0,x8,-128 +esp.vldext.u16.xp q0,q0,x8,x8 +esp.vldext.u8.ip q0,q0,x8,-128 +esp.vldext.u8.xp q0,q0,x8,x8 +esp.vldhbc.16.incp q0,q0,x8 +esp.ld.qacc.h.h.128.ip x8,-2048 +esp.ld.qacc.h.l.128.ip x8,-2048 +esp.ld.qacc.l.h.128.ip x8,-2048 +esp.ld.qacc.l.l.128.ip x8,-2048 +esp.ld.ua.state.ip x8,-2048 +esp.ldxq.32 q0,q0,x8,0,0 +esp.st.qacc.h.h.128.ip x8,-2048 +esp.st.qacc.h.l.128.ip x8,-2048 +esp.st.qacc.l.h.128.ip x8,-2048 +esp.st.qacc.l.l.128.ip x8,-2048 +esp.st.ua.state.ip x8,-2048 +esp.stxq.32 q0,q0,x8,0,0 +esp.vld.128.ip q0,x8,-2048 +esp.vld.128.xp q0,x8,x8 +esp.vld.h.64.ip q0,x8,-1024 +esp.vld.h.64.xp q0,x8,x8 +esp.vld.l.64.ip q0,x8,-1024 +esp.vld.l.64.xp q0,x8,x8 +esp.vst.128.ip q0,x8,-2048 +esp.vst.128.xp q0,x8,x8 +esp.vst.h.64.ip q0,x8,-1024 +esp.vst.h.64.xp q0,x8,x8 +esp.vst.l.64.ip q0,x8,-1024 +esp.vst.l.64.xp q0,x8,x8 +esp.slci.2q q0,q0,0 +esp.slcxxp.2q q0,q0,x8,x8 +esp.src.q q0,q0,q0 +esp.src.q.ld.ip q0,x8,-2048,q0,q0 +esp.src.q.ld.xp q0,x8,x8,q0,q0 +esp.src.q.qup q0,q0,q0 +esp.srci.2q q0,q0,0 +esp.srcmb.s16.q.qacc q0,q0,0 +esp.srcmb.s16.qacc q0,x8,0 +esp.srcmb.s8.q.qacc q0,q0,0 +esp.srcmb.s8.qacc q0,x8,0 +esp.srcmb.u16.q.qacc q0,q0,0 +esp.srcmb.u16.qacc q0,x8,0 +esp.srcmb.u8.q.qacc q0,q0,0 +esp.srcmb.u8.qacc q0,x8,0 +esp.srcq.128.st.incp q0,q0,x8 +esp.srcxxp.2q q0,q0,x8,x8 +esp.srs.s.xacc x8,x8 +esp.srs.u.xacc x8,x8 +esp.vsl.32 q0,q0 +esp.vsld.16 q0,q0,q0 +esp.vsld.32 q0,q0,q0 +esp.vsld.8 q0,q0,q0 +esp.vsr.s32 q0,q0 +esp.vsr.u32 q0,q0 +esp.vsrd.16 q0,q0,q0 +esp.vsrd.32 q0,q0,q0 +esp.vsrd.8 q0,q0,q0 +esp.st.s.xacc.ip x8,-1024 +esp.st.u.xacc.ip x8,-1024 +esp.lp.setupi 0,0,0 +esp.lp.setup 0,x8,0 +esp.lp.starti 0,0 +esp.lp.endi 0,0 +esp.lp.counti 0,0 +esp.lp.count 0,x8 diff --git a/tools/test_apps/system/gdbstub_runtime/main/CMakeLists.txt b/tools/test_apps/system/gdbstub_runtime/main/CMakeLists.txt index 9d9aaefa8f..efe217bc94 100644 --- a/tools/test_apps/system/gdbstub_runtime/main/CMakeLists.txt +++ b/tools/test_apps/system/gdbstub_runtime/main/CMakeLists.txt @@ -1,4 +1,9 @@ -idf_component_register(SRCS "test_app_main.c" +set(srcs "test_app_main.c") +if(CONFIG_IDF_TARGET_ARCH_RISCV AND CONFIG_SOC_CPU_HAS_HWLOOP) + list(APPEND srcs "xesppie_loops.S") +endif() + +idf_component_register(SRCS ${srcs} INCLUDE_DIRS "" REQUIRES esp_gdbstub) diff --git a/tools/test_apps/system/gdbstub_runtime/main/test_app_main.c b/tools/test_apps/system/gdbstub_runtime/main/test_app_main.c index 7f3980e3a9..554d6fc09c 100644 --- a/tools/test_apps/system/gdbstub_runtime/main/test_app_main.c +++ b/tools/test_apps/system/gdbstub_runtime/main/test_app_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "sdkconfig.h" int var_1; int var_2; @@ -19,12 +20,17 @@ void foo(void) var_2--; } +void test_xesppie_loops(void); void app_main(void) { printf("tested app is running.\n"); vTaskDelay(5000 / portTICK_PERIOD_MS); +#if SOC_CPU_HAS_HWLOOP + test_xesppie_loops(); +#endif + while(1) { var_1++; if (var_1 % 10 == 0) { diff --git a/tools/test_apps/system/gdbstub_runtime/main/xesppie_loops.S b/tools/test_apps/system/gdbstub_runtime/main/xesppie_loops.S new file mode 100644 index 0000000000..dfb1a8a968 --- /dev/null +++ b/tools/test_apps/system/gdbstub_runtime/main/xesppie_loops.S @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ + +#define DEBUG_OUTPUT 0 +#define LOOP_COUNT 3 + +#if DEBUG_OUTPUT +.section .data +loop_counter_str: .string "loop counter is %d\n" +#endif + +.section .text +.type test_xesppie_loops, @function +.global test_xesppie_loops + +/* This workaround is intended to help the MI2 interpreter find labels in + * assembly code. */ +.globl test_loop_start +.type test_loop_start, @function + +test_xesppie_loops: + addi sp, sp, -16 + sw ra, 12(sp) +#if DEBUG_OUTPUT + sw s0, 8(sp) + + la s0, loop_counter_str +#endif + li t0, LOOP_COUNT + +test_loop_start: + esp.lp.setup 0, t0, test_loop_end + csrr a1, 0x7C8 +#if DEBUG_OUTPUT + mv a0, s0 + call ets_printf +#endif +test_loop_end: + nop + +#if DEBUG_OUTPUT + lw s0, 8(sp) +#endif + lw ra, 12(sp) + addi sp, sp, 16 + ret +.size test_xesppie_loops, .-test_xesppie_loops diff --git a/tools/test_apps/system/gdbstub_runtime/pytest_runtime.py b/tools/test_apps/system/gdbstub_runtime/pytest_gdbstub_runtime.py similarity index 64% rename from tools/test_apps/system/gdbstub_runtime/pytest_runtime.py rename to tools/test_apps/system/gdbstub_runtime/pytest_gdbstub_runtime.py index f2c3fa2c08..dc51c3681a 100644 --- a/tools/test_apps/system/gdbstub_runtime/pytest_runtime.py +++ b/tools/test_apps/system/gdbstub_runtime/pytest_gdbstub_runtime.py @@ -3,6 +3,7 @@ import os import os.path as path import sys +from typing import Any import pytest @@ -19,25 +20,93 @@ def get_line_number(lookup: str, offset: int = 0) -> int: return -1 -@pytest.mark.supported_targets -@pytest.mark.generic -def test_gdbstub_runtime(dut: PanicTestDut) -> None: +def start_gdb(dut: PanicTestDut) -> None: dut.expect_exact('tested app is running.') dut.write(b'\x03') # send Ctrl-C dut.start_gdb_for_gdbstub() + +def run_and_break(dut: PanicTestDut, cmd: str) -> dict[Any, Any]: + responses = dut.gdb_write(cmd) + assert dut.find_gdb_response('running', 'result', responses) is not None + if not dut.find_gdb_response('stopped', 'notify', responses): # have not stopped on breakpoint yet + responses = dut.gdbmi.get_gdb_response(timeout_sec=3) + assert dut.find_gdb_response('stopped', 'notify', responses) is not None + payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + assert isinstance(payload, dict) + return payload + + +@pytest.mark.esp32p4 +@pytest.mark.generic +def test_hwloop_jump(dut: PanicTestDut) -> None: + start_gdb(dut) + + cmd = '-break-insert --source xesppie_loops.S --function test_loop_start' + response = dut.find_gdb_response('done', 'result', dut.gdb_write(cmd)) + assert response is not None + + # go to the beginning of the loop + cmd = '-exec-continue' + payload = run_and_break(dut, cmd) + assert payload['reason'] == 'breakpoint-hit' + assert payload['bkptno'] == '1' + assert payload['frame']['func'] == 'test_xesppie_loops' + assert payload['stopped-threads'] == 'all' + + cmd = '-break-delete 1' + responses = dut.gdb_write(cmd) + assert dut.find_gdb_response('done', 'result', responses) is not None + + # go through the loop + loop_count = 3 + while loop_count: + inst_count = 2 + while inst_count: + cmd = '-exec-step' + payload = run_and_break(dut, cmd) + assert payload['reason'] == 'end-stepping-range' + assert payload['frame']['func'] == 'test_xesppie_loops' + assert payload['stopped-threads'] == 'all' + inst_count -= 1 + cmd = '-data-list-register-values d 11' + responses = dut.gdb_write(cmd) + response = dut.find_gdb_response('done', 'result', responses) + assert response is not None + payload = response['payload'] + assert payload['register-values'][0]['number'] == '11' + assert payload['register-values'][0]['value'] == f'{loop_count}' + loop_count -= 1 + + # go through the func prologue + remaining_instructions = 3 + while remaining_instructions: + cmd = '-exec-step' + payload = run_and_break(dut, cmd) + assert payload['reason'] == 'end-stepping-range' + assert payload['frame']['func'] == 'test_xesppie_loops' + assert payload['stopped-threads'] == 'all' + remaining_instructions -= 1 + + # Now we stepping back to app_main + cmd = '-exec-step' + payload = run_and_break(dut, cmd) + assert payload['reason'] == 'end-stepping-range' + assert payload['frame']['func'] == 'app_main' + assert payload['stopped-threads'] == 'all' + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_gdbstub_runtime(dut: PanicTestDut) -> None: + start_gdb(dut) + # Test breakpoint cmd = '-break-insert --source test_app_main.c --function app_main --label label_1' response = dut.find_gdb_response('done', 'result', dut.gdb_write(cmd)) assert response is not None cmd = '-exec-continue' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'breakpoint-hit' assert payload['bkptno'] == '1' assert payload['frame']['func'] == 'app_main' @@ -46,13 +115,7 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: # Test step command cmd = '-exec-step' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'end-stepping-range' assert payload['frame']['func'] == 'foo' assert payload['frame']['line'] == str(get_line_number('var_2+=2;')) @@ -60,13 +123,7 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: # Test finish command cmd = '-exec-finish' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'function-finished' # On riscv we may have situation when returned from a function but stay on exactly the same line # foo(); @@ -84,13 +141,7 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: # Test next command cmd = '-exec-next' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'end-stepping-range' assert payload['frame']['line'] == str(get_line_number('label_3:', 1)) assert payload['frame']['func'] == 'app_main' @@ -117,12 +168,7 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: responses = dut.gdb_write(cmd) assert dut.find_gdb_response('done', 'result', responses) is not None cmd = '-exec-continue' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'signal-received' assert payload['frame']['func'] == 'foo' assert payload['stopped-threads'] == 'all' @@ -143,12 +189,7 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: # test panic handling cmd = '-exec-continue' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'signal-received' assert payload['signal-name'] == 'SIGSEGV' assert payload['frame']['func'] == 'app_main' @@ -162,22 +203,14 @@ def test_gdbstub_runtime(dut: PanicTestDut) -> None: @pytest.mark.generic @pytest.mark.temp_skip_ci(targets=['esp32', 'esp32s2', 'esp32s3'], reason='fix IDF-7927') def test_gdbstub_runtime_xtensa_stepping_bug(dut: PanicTestDut) -> None: - dut.expect_exact('tested app is running.') - dut.write(b'\x03') # send Ctrl-C - dut.start_gdb_for_gdbstub() + start_gdb(dut) # Test breakpoint cmd = '-break-insert --source test_app_main.c --function app_main --label label_1' response = dut.find_gdb_response('done', 'result', dut.gdb_write(cmd)) assert response is not None cmd = '-exec-continue' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'breakpoint-hit' assert payload['bkptno'] == '1' assert payload['frame']['func'] == 'app_main' @@ -186,13 +219,7 @@ def test_gdbstub_runtime_xtensa_stepping_bug(dut: PanicTestDut) -> None: # Test step command cmd = '-exec-step' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'end-stepping-range' assert payload['frame']['func'] == 'foo' assert payload['frame']['line'] == str(get_line_number('var_2+=2;')) @@ -200,13 +227,7 @@ def test_gdbstub_runtime_xtensa_stepping_bug(dut: PanicTestDut) -> None: # Test next command cmd = '-exec-next' - responses = dut.gdb_write(cmd) - assert dut.find_gdb_response('running', 'result', responses) is not None - if not dut.find_gdb_response('stopped', 'notify', responses): - # have not stopped on breakpoint yet - responses = dut.gdbmi.get_gdb_response(timeout_sec=3) - assert dut.find_gdb_response('stopped', 'notify', responses) is not None - payload = dut.find_gdb_response('stopped', 'notify', responses)['payload'] + payload = run_and_break(dut, cmd) assert payload['reason'] == 'end-stepping-range' assert payload['frame']['line'] == str(get_line_number('var_2--;', 0)) assert payload['frame']['func'] == 'foo'