---

**[tickets:#441] arm: invalid register list when attaching in FIQ state**

**Status:** new
**Milestone:** 0.10.0
**Created:** Sun Nov 17, 2024 01:49 AM UTC by Alexey Karyakin
**Last Updated:** Sun Nov 17, 2024 01:49 AM UTC
**Owner:** OpenOCD-Gerrit


gdb-multiarch  10.1 cannot attach to an arm-v5 target when it's in the FIQ 
state. The "target.xml" architecture description sent from OpenOCD contains an 
invalid register list (see below). I did not debug gdb but it apparently 
expects a certain set of registers 
https://www.sourceware.org/gdb/current/onlinedocs/gdb.html/ARM-Features.html. 
At least, R8-R12 are missing from the "org.gnu.gdb.arm.core" feature. The 
"(r8-r12)fiq" are also duplicated in the "banked" feature.

This seems to happen because the register list is created using state-dependent 
mapping. 

Note that arm-v7m does not map registers at all, even it has banked MSP/PSP. I 
believe register mapping is not needed when registers are requested with 
REG_CLASS_ALL as it's only used by the get_gdb_reg_list_noread() function and 
there are other comments suggesting REG_CLASS_ALL is not used when reading 
register values.

I drafted a patch https://review.openocd.org/c/openocd/+/8588 that fixes this 
problem.

<?xml version="1.0"?>
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target version="1.0">
<architecture>arm</architecture>
<feature name="org.gnu.gdb.arm.core">
<reg name="r0" bitsize="32" regnum="0" save-restore="no" type="uint32" 
group="general"/>
<reg name="r1" bitsize="32" regnum="1" save-restore="no" type="uint32" 
group="general"/>
<reg name="r2" bitsize="32" regnum="2" save-restore="no" type="uint32" 
group="general"/>
<reg name="r3" bitsize="32" regnum="3" save-restore="no" type="uint32" 
group="general"/>
<reg name="r4" bitsize="32" regnum="4" save-restore="no" type="uint32" 
group="general"/>
<reg name="r5" bitsize="32" regnum="5" save-restore="no" type="uint32" 
group="general"/>
<reg name="r6" bitsize="32" regnum="6" save-restore="no" type="uint32" 
group="general"/>
<reg name="r7" bitsize="32" regnum="7" save-restore="no" type="uint32" 
group="general"/>
<reg name="sp" bitsize="32" regnum="13" save-restore="no" type="data_ptr" 
group="general"/>
<reg name="lr" bitsize="32" regnum="14" save-restore="no" type="code_ptr" 
group="general"/>
<reg name="pc" bitsize="32" regnum="15" save-restore="no" type="code_ptr" 
group="general"/>
<reg name="cpsr" bitsize="32" regnum="25" save-restore="no" type="uint32" 
group="general"/>
</feature>
<feature name="net.sourceforge.openocd.banked">
<reg name="r8_fiq" bitsize="32" regnum="28" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r9_fiq" bitsize="32" regnum="29" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r10_fiq" bitsize="32" regnum="30" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r11_fiq" bitsize="32" regnum="31" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r12_fiq" bitsize="32" regnum="32" save-restore="no" type="uint32" 
group="banked"/>
<reg name="sp_usr" bitsize="32" regnum="26" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_usr" bitsize="32" regnum="27" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="r8_fiq" bitsize="32" regnum="28" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r9_fiq" bitsize="32" regnum="29" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r10_fiq" bitsize="32" regnum="30" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r11_fiq" bitsize="32" regnum="31" save-restore="no" type="uint32" 
group="banked"/>
<reg name="r12_fiq" bitsize="32" regnum="32" save-restore="no" type="uint32" 
group="banked"/>
<reg name="sp_fiq" bitsize="32" regnum="33" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_fiq" bitsize="32" regnum="34" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="sp_irq" bitsize="32" regnum="35" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_irq" bitsize="32" regnum="36" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="sp_svc" bitsize="32" regnum="37" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_svc" bitsize="32" regnum="38" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="sp_abt" bitsize="32" regnum="39" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_abt" bitsize="32" regnum="40" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="sp_und" bitsize="32" regnum="41" save-restore="no" type="data_ptr" 
group="banked"/>
<reg name="lr_und" bitsize="32" regnum="42" save-restore="no" type="code_ptr" 
group="banked"/>
<reg name="spsr_fiq" bitsize="32" regnum="43" save-restore="no" type="uint32" 
group="banked"/>
<reg name="spsr_irq" bitsize="32" regnum="44" save-restore="no" type="uint32" 
group="banked"/>
<reg name="spsr_svc" bitsize="32" regnum="45" save-restore="no" type="uint32" 
group="banked"/>
<reg name="spsr_abt" bitsize="32" regnum="46" save-restore="no" type="uint32" 
group="banked"/>
<reg name="spsr_und" bitsize="32" regnum="47" save-restore="no" type="uint32" 
group="banked"/>
</feature>
</target>


---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.


Reply via email to