Skip to contentSkip to conversation

GDB get wrong debug infos on TI DSP architecture extension

DISCUSSION casmac 4 participants 9 messages May 27, 2020 – May 29, 2020

lore
Share & tools
lore

casmac

author
#0 lore raw

Hi all,
   I am working on a TI DSP architecture extension for QEMU. Now, we are adding GDB debugging features.
   We have done the following, but not sure we are on the right track :
   - add a xml description file in gdb-xml, without understanding the purpose of the file, why some architectures don't provide such xml file?    - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register();
   - added  dsp_cpu_get_phys_page_attrs_debug(), but uncertain about what to return
     dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs)
     {
        return addr & TARGET_PAGE_MASK;  
     }
  
   We run QEMU with the these arguments
   qemu-system-dsp ... -kernel filename.out -S -s
  
   It turns out that gdb reads incorrect register values, and complains : "warning: Target-supplied registers are not supported by the current architecture".   
   Something is missing here, or we do it in a wrong way.  Any advise would be helpful to us.
  
   Thanks.
   
xiaolei

   ----- ti_dsp.xml  -----
  
&nbsp;&nbsp; <?xml version="1.0"?&gt;
<!DOCTYPE feature SYSTEM "gdb-target.dtd"&gt;
<feature name="org.gnu.gdb.tic3x.core"&gt; &nbsp;&nbsp;&nbsp; <reg name="r0"&nbsp; bitsize="32"&gt;</reg&gt; &nbsp;<reg name="r1"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="r2"&nbsp; bitsize="32"&gt;</reg&gt; &nbsp;<reg name="r3"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="r4"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="r5"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="r6"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="r7"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="ar0" bitsize="32"/&gt;
&nbsp;<reg name="ar1" bitsize="32"/&gt;
&nbsp;<reg name="ar2" bitsize="32"/&gt;
&nbsp;<reg name="ar3" bitsize="32"/&gt;
&nbsp;<reg name="ar4" bitsize="32"/&gt;
&nbsp;<reg name="ar5" bitsize="32"/&gt;
&nbsp;<reg name="ar6" bitsize="32"/&gt;
&nbsp;<reg name="ar7" bitsize="32"/&gt;
&nbsp;<reg name="dp"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="ir0" bitsize="32"/&gt;
&nbsp;<reg name="ir1" bitsize="32"/&gt;
&nbsp;<reg name="bk"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="sp"&nbsp; bitsize="32" type="data_ptr"/&gt; &nbsp;<reg name="st"&nbsp; bitsize="32"&gt;</reg&gt; &nbsp;<reg name="ie"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="if"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="iof" bitsize="32"/&gt;
&nbsp;<reg name="rs"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="re"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="rc"&nbsp; bitsize="32"/&gt;
&nbsp;<reg name="pc"&nbsp; bitsize="32" type="data_ptr"/&gt; &nbsp;<reg name="clk"&nbsp; bitsize="32"/&gt; </feature&gt;
&nbsp;&nbsp;

#1 lore raw

Hi Xiaolei,

Cc'ing more developers who might answer you.

Quoted 2 lines · casmac

Hi all,
   I am working on a TI DSP architecture extension for QEMU.

FYI you can find the TI TMS320C6x target implemented here:
https://github.com/philmd/qemu/releases/tag/target-c6x-2.4

I started rebasing it to QEMU 4.2 but then got distracted.

Quoted 65 lines

Now, we are
adding GDB debugging features.
   We have done the following, but not sure we are on the right track :
   - add a xml description file in gdb-xml, without understanding the purpose of the file, why some architectures don't provide such xml file?
   - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register();
   - added  dsp_cpu_get_phys_page_attrs_debug(), but uncertain about what to return
     dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs)
     {
        return addr & TARGET_PAGE_MASK;
     }

   We run QEMU with the these arguments
   qemu-system-dsp ... -kernel filename.out -S -s

   It turns out that gdb reads incorrect register values, and complains : "warning: Target-supplied registers are not supported by the current architecture".

   Something is missing here, or we do it in a wrong way.  Any advise would be helpful to us.

   Thanks.

xiaolei

   ----- ti_dsp.xml  -----

   <?xml version="1.0"?>
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.tic3x.core">
    <reg name="r0"  bitsize="32"></reg>
 <reg name="r1"  bitsize="32"/>
 <reg name="r2"  bitsize="32"></reg>
 <reg name="r3"  bitsize="32"/>
 <reg name="r4"  bitsize="32"/>
 <reg name="r5"  bitsize="32"/>
 <reg name="r6"  bitsize="32"/>
 <reg name="r7"  bitsize="32"/>
 <reg name="ar0" bitsize="32"/>
 <reg name="ar1" bitsize="32"/>
 <reg name="ar2" bitsize="32"/>
 <reg name="ar3" bitsize="32"/>
 <reg name="ar4" bitsize="32"/>
 <reg name="ar5" bitsize="32"/>
 <reg name="ar6" bitsize="32"/>
 <reg name="ar7" bitsize="32"/>
 <reg name="dp"  bitsize="32"/>
 <reg name="ir0" bitsize="32"/>
 <reg name="ir1" bitsize="32"/>
 <reg name="bk"  bitsize="32"/>
 <reg name="sp"  bitsize="32" type="data_ptr"/>
 <reg name="st"  bitsize="32"></reg>
 <reg name="ie"  bitsize="32"/>
 <reg name="if"  bitsize="32"/>
 <reg name="iof" bitsize="32"/>
 <reg name="rs"  bitsize="32"/>
 <reg name="re"  bitsize="32"/>
 <reg name="rc"  bitsize="32"/>
 <reg name="pc"  bitsize="32" type="data_ptr"/>
 <reg name="clk"  bitsize="32"/>
</feature>

#2 lore raw

For Hexagon, we have LLDB, not GDB. I tinkered with getting LLDB to talk to qemu but never got if fully functional. I'm planning to get back to it at some point.

With that caveat, I'll try to answer Xiaolei's questions
- The xml file is returned from qemu to gdb in response to the Xfer:features:read command. Providing it should be optional unless your debugger requires the target to support that command. If the target doesn't support this command, the debugger will generally use the qRegisterInfo command.
- I don't think get_phys_page_debug is used for gdb debugging. Which mode are you implementing? In linux-user mode, it's not needed. In softmmu mode, it is used when you use "-d in_asm" to find the memory to disassemble. If you have an MMU, you need to map the virtual address passed in to the physical address or return -1 if there is no mapping. If there isn't a MMU, return the virtual address.
- The error you are getting from gdb sounds like a mismatch between the version of the processor that qemu is emulating and gdb thinks it is debugging. In other words, qemu thinks there is a register that gdb know about. To see what's going on, try adding "-d trace:gdbstub_io_command,trace:gdbstub_io_reply" to your qemu command line. This will show you the commands from gdb and qemu's response. Look for the commands I described above and see if qemu is giving a register that doesn't exist.

HTH,
Taylor

Quoted 90 lines

-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]> On Behalf Of Philippe Mathieu-Daudé
Sent: Wednesday, May 27, 2020 2:20 AM
To: casmac <[email protected]>; qemu-devel <qemu- [email protected]>
Cc: Luc Michel <[email protected]>; Alex Bennée <[email protected]>; Taylor Simpson <[email protected]>
Subject: Re: GDB get wrong debug infos on TI DSP architecture extension

Hi Xiaolei,

Cc'ing more developers who might answer you.

Quoted 2 lines · casmac

Hi all,
I am working on a TI DSP architecture extension for QEMU.

FYI you can find the TI TMS320C6x target implemented here:
https://github.com/philmd/qemu/releases/tag/target-c6x-2.4

I started rebasing it to QEMU 4.2 but then got distracted.

Quoted 65 lines

Now, we are
adding GDB debugging features.
We have done the following, but not sure we are on the right track :
- add a xml description file in gdb-xml, without understanding the
purpose of the file, why some architectures don't provide such xml file?
- add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register();
- added dsp_cpu_get_phys_page_attrs_debug(), but uncertain about
what to return
dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
MemTxAttrs *attrs)

     {
        return addr & TARGET_PAGE_MASK;
     }

We run QEMU with the these arguments
qemu-system-dsp ... -kernel filename.out -S -s

It turns out that gdb reads incorrect register values, and complains
: "warning: Target-supplied registers are not supported by the current architecture".

Something is missing here, or we do it in a wrong way. Any advise
would be helpful to us.

Thanks.

xiaolei

   ----- ti_dsp.xml  -----

   <?xml version="1.0"?>
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.tic3x.core">
    <reg name="r0"  bitsize="32"></reg>
 <reg name="r1"  bitsize="32"/>
 <reg name="r2"  bitsize="32"></reg>
 <reg name="r3"  bitsize="32"/>
 <reg name="r4"  bitsize="32"/>
 <reg name="r5"  bitsize="32"/>
 <reg name="r6"  bitsize="32"/>
 <reg name="r7"  bitsize="32"/>
 <reg name="ar0" bitsize="32"/>
 <reg name="ar1" bitsize="32"/>
 <reg name="ar2" bitsize="32"/>
 <reg name="ar3" bitsize="32"/>
 <reg name="ar4" bitsize="32"/>
 <reg name="ar5" bitsize="32"/>
 <reg name="ar6" bitsize="32"/>
 <reg name="ar7" bitsize="32"/>
 <reg name="dp"  bitsize="32"/>
 <reg name="ir0" bitsize="32"/>
 <reg name="ir1" bitsize="32"/>
 <reg name="bk"  bitsize="32"/>
 <reg name="sp"  bitsize="32" type="data_ptr"/>
 <reg name="st"  bitsize="32"></reg>
 <reg name="ie"  bitsize="32"/>
 <reg name="if"  bitsize="32"/>
 <reg name="iof" bitsize="32"/>
 <reg name="rs"  bitsize="32"/>
 <reg name="re"  bitsize="32"/>
 <reg name="rc"  bitsize="32"/>
 <reg name="pc"  bitsize="32" type="data_ptr"/>

<reg name="clk" bitsize="32"/>
</feature>

author
#3 lore raw

Hi,&nbsp;
&nbsp; &nbsp;Thanks for the hints!! I put "-d trace:gdbstub_io_command,trace:gdbstub_io_reply" to command line, get the following from QEMU at the beginning when gdb starts, is there anything went wrong?

[email protected]:gdbstub_io_command Received: qSupported:xmlRegisters=tivc33;QNonStop;qRelocInsn+ [email protected]:gdbstub_io_reply Sent: PacketSize=1000;qXfer:features:read+;multiprocess+ [email protected]:gdbstub_io_command Received: Hg0 [email protected]:gdbstub_io_reply Sent: OK [email protected]:gdbstub_io_command Received: qXfer:features:read:target.xml:0,ffb [email protected]:gdbstub_io_command Received: qXfer:features:read:dsp-vc33-core.xml:0,ffb [email protected]:gdbstub_io_command Received: ? [email protected]:gdbstub_io_reply Sent: T05thread:01; [email protected]:gdbstub_io_command Received: Hc-1

&nbsp;[email protected]:gdbstub_io_command Received: qC [email protected]:gdbstub_io_reply Sent: QC01 [email protected]:gdbstub_io_command Received: qAttached [email protected]:gdbstub_io_reply Sent: 1 [email protected]:gdbstub_io_command Received: qOffsets
....

&nbsp;It looks like the .xml file is working , the "info reg" command returns the registers defined for TI DSP processor:
(szdb) info reg
r0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xc000000000&nbsp; &nbsp; &nbsp;-274877906944 r1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
r2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x2200000000&nbsp; &nbsp; &nbsp;146028888064 r3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
r4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
r5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x4100000000&nbsp; &nbsp; &nbsp;279172874240 r6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
r7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x6800000000&nbsp; &nbsp; &nbsp;446676598784 ar0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ar7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
dp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
ir0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
ir1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
bk&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
sp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
st&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x54&nbsp; &nbsp; &nbsp;84
ie&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
if&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
iof&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0
rs&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
re&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
rc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0&nbsp; &nbsp; &nbsp; 0
pc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xf&nbsp; &nbsp; &nbsp; 15
clk&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0&nbsp; &nbsp; &nbsp; 0&nbsp;&nbsp;

&nbsp; &nbsp; But GDB still complains&nbsp; "warning: Target-supplied registers are not supported by the current architecture" and an unkown symbol:&nbsp;
atexit (
&nbsp; &nbsp; fun=<error reading variable: Unknown argument list address for `fun'.&gt;)
&nbsp; &nbsp; at exit.c:44
44&nbsp; &nbsp; &nbsp; exit.c: No such file or directory.
&nbsp; &nbsp; &nbsp;Another problem is that DSP processor addresses memory by word(4 bytes), the starting entry address from the executable is 0xF, which will fail the 4-byte alignment assertion, so the instruction retrieved does not look right. We are going to fix it. &nbsp; &nbsp;thanks .
xiaolei&nbsp;
------------------&nbsp;Origina,l&nbsp;------------------
From:&nbsp;"Taylor Simpson"<[email protected]&gt;;
Date:&nbsp;Thu, May 28, 2020 05:41 AM
To:&nbsp;"Philippe Mathieu-Daud "<[email protected]&gt;;"casmac"<[email protected]&gt;;"qemu-devel"<[email protected]&gt;;
Cc:&nbsp;"Alex Benn e"<[email protected]&gt;;"Luc Michel"<[email protected]&gt;;
Subject:&nbsp;RE: GDB get wrong debug infos on TI DSP architecture extension

For Hexagon, we have LLDB, not GDB.&nbsp; I tinkered with getting LLDB to talk to qemu but never got if fully functional.&nbsp; I'm planning to get back to it at some point.

With that caveat, I'll try to answer Xiaolei's questions
- The xml file is returned from qemu to gdb in response to the Xfer:features:read command.&nbsp; Providing it should be optional unless your debugger requires the target to support that command.&nbsp; If the target doesn't support this command, the debugger will generally use the qRegisterInfo command.
- I don't think get_phys_page_debug is used for gdb debugging.&nbsp; Which mode are you implementing?&nbsp; In linux-user mode, it's not needed.&nbsp; In softmmu mode, it is used when you use "-d in_asm" to find the memory to disassemble.&nbsp; If you have an MMU, you need to map the virtual address passed in to the physical address or return -1 if there is no mapping.&nbsp; If there isn't a MMU, return the virtual address.
- The error you are getting from gdb sounds like a mismatch between the version of the processor that qemu is emulating and gdb thinks it is debugging.&nbsp; In other words, qemu thinks there is a register that gdb know about.&nbsp; To see what's going on, try adding "-d trace:gdbstub_io_command,trace:gdbstub_io_reply" to your qemu command line.&nbsp; This will show you the commands from gdb and qemu's response.&nbsp; Look for the commands I described above and see if qemu is giving a register that doesn't exist.

HTH,
Taylor

&gt; -----Original Message-----
&gt; From: Philippe Mathieu-Daudé <[email protected]&gt; On
&gt; Behalf Of Philippe Mathieu-Daudé
&gt; Sent: Wednesday, May 27, 2020 2:20 AM
&gt; To: casmac <[email protected]&gt;; qemu-devel <qemu-
&gt; [email protected]&gt;
&gt; Cc: Luc Michel <[email protected]&gt;; Alex Bennée
&gt; <[email protected]&gt;; Taylor Simpson <[email protected]&gt;
&gt; Subject: Re: GDB get wrong debug infos on TI DSP architecture extension
&gt;
&gt;
&gt; Hi Xiaolei,
&gt;
&gt; Cc'ing more developers who might answer you.
&gt;
&gt; On 5/27/20 8:48 AM, casmac wrote:
&gt; &gt; Hi all,
&gt; &gt;&nbsp;&nbsp;&nbsp; I am working on a TI DSP architecture extension for QEMU. &gt;
&gt; FYI you can find the TI TMS320C6x target implemented here:
&gt; https://github.com/philmd/qemu/releases/tag/target-c6x-2.4
&gt;
&gt; I started rebasing it to QEMU 4.2 but then got distracted.
&gt;
&gt; &gt; Now, we are
&gt; &gt; adding GDB debugging features.
&gt; &gt;&nbsp;&nbsp;&nbsp; We have done the following, but not sure we are on the right track :
&gt; &gt;&nbsp;&nbsp;&nbsp; - add a xml description file in gdb-xml, without understanding the &gt; &gt; purpose of the file, why some architectures don't provide such xml file? &gt; &gt;&nbsp;&nbsp;&nbsp; - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register(); &gt; &gt;&nbsp;&nbsp;&nbsp; - added&nbsp; dsp_cpu_get_phys_page_attrs_debug(), but uncertain about &gt; &gt; what to return
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, &gt; &gt; MemTxAttrs *attrs)
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return addr &amp; TARGET_PAGE_MASK; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; We run QEMU with the these arguments
&gt; &gt;&nbsp;&nbsp;&nbsp; qemu-system-dsp ... -kernel filename.out -S -s
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; It turns out that gdb reads incorrect register values, and complains &gt; &gt; : "warning: Target-supplied registers are not supported by the current &gt; &gt; architecture".
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; Something is missing here, or we do it in a wrong way.&nbsp; Any advise &gt; &gt; would be helpful to us.
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; Thanks.
&gt; &gt;
&gt; &gt; xiaolei
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; ----- ti_dsp.xml&nbsp; -----
&gt; &gt;
&gt; &gt;&nbsp;&nbsp;&nbsp; <?xml version="1.0"?&gt;
&gt; &gt; <!DOCTYPE feature SYSTEM "gdb-target.dtd"&gt;
&gt; &gt; <feature name="org.gnu.gdb.tic3x.core"&gt;
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; <reg name="r0"&nbsp; bitsize="32"&gt;</reg&gt; &gt; &gt;&nbsp; <reg name="r1"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="r2"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &gt;&nbsp; <reg name="r3"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="r4"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="r5"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="r6"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="r7"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar0" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar1" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar2" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar3" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar4" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar5" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar6" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ar7" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="dp"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ir0" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="ir1" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="bk"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="sp"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &gt;&nbsp; <reg name="st"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &gt;&nbsp; <reg name="ie"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="if"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="iof" bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="rs"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="re"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="rc"&nbsp; bitsize="32"/&gt;
&gt; &gt;&nbsp; <reg name="pc"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &gt;&nbsp; <reg name="clk"&nbsp; bitsize="32"/&gt;
&gt; &gt; </feature&gt;
&gt; &gt;
&gt;

#4 lore raw

To figure out which register gdb is complaining about, you could step through the code in gdb or selectively remove parts of the xml file until the error goes away.

The unaligned start address sounds like a problem with the executable you are trying to debug, not qemu or gdb.

Taylor

From: casmac <[email protected]>
Sent: Friday, May 29, 2020 2:28 AM
To: Taylor Simpson <[email protected]>; qemu-devel <[email protected]>
Subject: Re:RE: GDB get wrong debug infos on TI DSP architecture extension

Hi,
Thanks for the hints!! I put "-d trace:gdbstub_io_command,trace:gdbstub_io_reply" to command line, get the following from QEMU at the beginning when gdb starts, is there anything went wrong?

[email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qSupported:xmlRegisters=tivc33;QNonStop;qRelocInsn+ [email protected]:gdbstub_io_reply<mailto:[email protected]:gdbstub_io_reply> Sent: PacketSize=1000;qXfer:features:read+;multiprocess+ [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: Hg0 [email protected]:gdbstub_io_reply<mailto:[email protected]:gdbstub_io_reply> Sent: OK [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qXfer:features:read:target.xml:0,ffb [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qXfer:features:read:dsp-vc33-core.xml:0,ffb [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: ? [email protected]:gdbstub_io_reply<mailto:[email protected]:gdbstub_io_reply> Sent: T05thread:01; [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: Hc-1
[email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qC
[email protected]:gdbstub_io_reply<mailto:[email protected]:gdbstub_io_reply> Sent: QC01 [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qAttached [email protected]:gdbstub_io_reply<mailto:[email protected]:gdbstub_io_reply> Sent: 1 [email protected]:gdbstub_io_command<mailto:[email protected]:gdbstub_io_command> Received: qOffsets
....

It looks like the .xml file is working , the "info reg" command returns the registers defined for TI DSP processor:
(szdb) info reg

r0             0xc000000000     -274877906944
r1             0x0      0
r2             0x2200000000     146028888064
r3             0x0      0
r4             0x0      0
r5             0x4100000000     279172874240
r6             0x0      0
r7             0x6800000000     446676598784
ar0            0x0      0
ar1            0x0      0
ar2            0x0      0
ar3            0x0      0
ar4            0x0      0
ar5            0x0      0
ar6            0x0      0
ar7            0x0      0
dp             0x0      0
ir0            0x0      0
ir1            0x0      0
bk             0x0      0
sp             0x0      0
st             0x54     84
ie             0x0      0
if             0x0      0
iof            0x0      0
rs             0x0      0
re             0x0      0
rc             0x0      0
pc             0xf      15
clk            0x0      0

But GDB still complains "warning: Target-supplied registers are not supported by the current architecture" and an unkown symbol:
atexit (
fun=<error reading variable: Unknown argument list address for `fun'.>)
at exit.c:44
44 exit.c: No such file or directory.

     Another problem is that DSP processor addresses memory by word(4 bytes), the starting entry address from the executable is 0xF, which will fail the 4-byte alignment assertion, so the instruction retrieved does not look right. We are going to fix it.

thanks .
xiaolei
------------------ Origina,l ------------------
From: "Taylor Simpson"<[email protected]<mailto:[email protected]>>;
Date: Thu, May 28, 2020 05:41 AM
To: "Philippe Mathieu-Daud "<[email protected]<mailto:[email protected]>>;"casmac"<[email protected]<mailto:[email protected]>>;"qemu-devel"<[email protected]<mailto:[email protected]>>;
Cc: "Alex Benn e"<[email protected]<mailto:[email protected]>>;"Luc Michel"<[email protected]<mailto:[email protected]>>;
Subject: RE: GDB get wrong debug infos on TI DSP architecture extension

For Hexagon, we have LLDB, not GDB. I tinkered with getting LLDB to talk to qemu but never got if fully functional. I'm planning to get back to it at some point.

With that caveat, I'll try to answer Xiaolei's questions
- The xml file is returned from qemu to gdb in response to the Xfer:features:read command. Providing it should be optional unless your debugger requires the target to support that command. If the target doesn't support this command, the debugger will generally use the qRegisterInfo command.
- I don't think get_phys_page_debug is used for gdb debugging. Which mode are you implementing? In linux-user mode, it's not needed. In softmmu mode, it is used when you use "-d in_asm" to find the memory to disassemble. If you have an MMU, you need to map the virtual address passed in to the physical address or return -1 if there is no mapping. If there isn't a MMU, return the virtual address.
- The error you are getting from gdb sounds like a mismatch between the version of the processor that qemu is emulating and gdb thinks it is debugging. In other words, qemu thinks there is a register that gdb know about. To see what's going on, try adding "-d trace:gdbstub_io_command,trace:gdbstub_io_reply" to your qemu command line. This will show you the commands from gdb and qemu's response. Look for the commands I described above and see if qemu is giving a register that doesn't exist.

HTH,
Taylor

Quoted 90 lines

-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]<mailto:[email protected]>> On Behalf Of Philippe Mathieu-Daudé
Sent: Wednesday, May 27, 2020 2:20 AM
To: casmac <[email protected]<mailto:[email protected]>>; qemu-devel <qemu- [email protected]<mailto:[email protected]>>
Cc: Luc Michel <[email protected]<mailto:[email protected]>>; Alex Bennée <[email protected]<mailto:[email protected]>>; Taylor Simpson <[email protected]<mailto:[email protected]>>
Subject: Re: GDB get wrong debug infos on TI DSP architecture extension

Hi Xiaolei,

Cc'ing more developers who might answer you.

Quoted 2 lines · casmac

Hi all,
I am working on a TI DSP architecture extension for QEMU.

FYI you can find the TI TMS320C6x target implemented here:
https://github.com/philmd/qemu/releases/tag/target-c6x-2.4

I started rebasing it to QEMU 4.2 but then got distracted.

Quoted 65 lines

Now, we are
adding GDB debugging features.
We have done the following, but not sure we are on the right track :
- add a xml description file in gdb-xml, without understanding the
purpose of the file, why some architectures don't provide such xml file?
- add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register();
- added dsp_cpu_get_phys_page_attrs_debug(), but uncertain about
what to return
dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
MemTxAttrs *attrs)

     {
        return addr & TARGET_PAGE_MASK;
     }

We run QEMU with the these arguments
qemu-system-dsp ... -kernel filename.out -S -s

It turns out that gdb reads incorrect register values, and complains
: "warning: Target-supplied registers are not supported by the current architecture".

Something is missing here, or we do it in a wrong way. Any advise
would be helpful to us.

Thanks.

xiaolei

   ----- ti_dsp.xml  -----

   <?xml version="1.0"?>
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.tic3x.core">
    <reg name="r0"  bitsize="32"></reg>
 <reg name="r1"  bitsize="32"/>
 <reg name="r2"  bitsize="32"></reg>
 <reg name="r3"  bitsize="32"/>
 <reg name="r4"  bitsize="32"/>
 <reg name="r5"  bitsize="32"/>
 <reg name="r6"  bitsize="32"/>
 <reg name="r7"  bitsize="32"/>
 <reg name="ar0" bitsize="32"/>
 <reg name="ar1" bitsize="32"/>
 <reg name="ar2" bitsize="32"/>
 <reg name="ar3" bitsize="32"/>
 <reg name="ar4" bitsize="32"/>
 <reg name="ar5" bitsize="32"/>
 <reg name="ar6" bitsize="32"/>
 <reg name="ar7" bitsize="32"/>
 <reg name="dp"  bitsize="32"/>
 <reg name="ir0" bitsize="32"/>
 <reg name="ir1" bitsize="32"/>
 <reg name="bk"  bitsize="32"/>
 <reg name="sp"  bitsize="32" type="data_ptr"/>
 <reg name="st"  bitsize="32"></reg>
 <reg name="ie"  bitsize="32"/>
 <reg name="if"  bitsize="32"/>
 <reg name="iof" bitsize="32"/>
 <reg name="rs"  bitsize="32"/>
 <reg name="re"  bitsize="32"/>
 <reg name="rc"  bitsize="32"/>
 <reg name="pc"  bitsize="32" type="data_ptr"/>

<reg name="clk" bitsize="32"/>
</feature>

author
#5 lore raw
In reply to Philippe Mathieu-Daudé

Hi,
&nbsp;&nbsp; Thank you for forwarding my question to developers and sharing the C6x implementation.
&nbsp;&nbsp; Perhaps I should follow up with another problem I encountered. The senerio is the&nbsp; emulator keeps running eventhough the program it emulates has already exited. And it keeps retrieving instructions which are all zero "instruction"(0x00000000).

&nbsp;&nbsp; It looks to me that in function cpu_exec(CPUState *cpu), the following loop never terminate:
&nbsp;&nbsp; while (!cpu_handle_exception(cpu, &amp;ret)) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TranslationBlock *last_tb = NULL; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int tb_exit = 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!cpu_handle_interrupt(cpu, &amp;last_tb)) { ... } &nbsp;&nbsp; Is it because cpu-&gt;exit_request remains 0 ?

&nbsp;&nbsp; At what point should we make cpu-&gt;exit_request=1 ? &nbsp;&nbsp; Thanks again!!

regards
xiaolei

------------------&nbsp;Original&nbsp;------------------
From:&nbsp;"Philippe Mathieu-Daudé"<[email protected]&gt;;
Date:&nbsp;Wed, May 27, 2020 03:19 PM To:&nbsp;"casmac"<[email protected]&gt;;"qemu-devel"<[email protected]&gt;;
Cc:&nbsp;"Taylor Simpson"<[email protected]&gt;;"Alex Bennée"<[email protected]&gt;;"Luc Michel"<[email protected]&gt;; Subject:&nbsp;Re: GDB get wrong debug infos on TI DSP architecture extension

Hi Xiaolei,

Cc'ing more developers who might answer you.

On 5/27/20 8:48 AM, casmac wrote:
&gt; Hi all,
&gt; &nbsp;&nbsp; I am working on a TI DSP architecture extension for QEMU.

FYI you can find the TI TMS320C6x target implemented here:
https://github.com/philmd/qemu/releases/tag/target-c6x-2.4

I started rebasing it to QEMU 4.2 but then got distracted.

&gt; Now, we are
&gt; adding GDB debugging features.
&gt; &nbsp;&nbsp; We have done the following, but not sure we are on the right track :
&gt; &nbsp;&nbsp; - add a xml description file in gdb-xml, without understanding the &gt; purpose of the file, why some architectures don't provide such xml file? &gt; &nbsp;&nbsp; - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register(); &gt; &nbsp;&nbsp; - added&nbsp; dsp_cpu_get_phys_page_attrs_debug(), but uncertain about &gt; what to return
&gt; &nbsp; &nbsp;&nbsp; dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, &gt; MemTxAttrs *attrs)
&gt; &nbsp; &nbsp;&nbsp; {
&gt; &nbsp; &nbsp; &nbsp; &nbsp; return addr &amp; TARGET_PAGE_MASK;&nbsp;&nbsp; &gt; &nbsp; &nbsp;&nbsp; }
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; We run QEMU with the these arguments
&gt; &nbsp;&nbsp; qemu-system-dsp ... -kernel filename.out -S -s
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; It turns out that gdb reads incorrect register values, and complains &gt; : "warning: Target-supplied registers are not supported by the current &gt; architecture".
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; Something is missing here, or we do it in a wrong way.&nbsp; Any advise &gt; would be helpful to us.
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; Thanks.
&gt; &nbsp; &nbsp;
&gt; xiaolei
&gt;
&gt; &nbsp;&nbsp; ----- ti_dsp.xml&nbsp; -----
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; <?xml version="1.0"?&gt;
&gt; <!DOCTYPE feature SYSTEM "gdb-target.dtd"&gt;
&gt; <feature name="org.gnu.gdb.tic3x.core"&gt;
&gt; &nbsp;&nbsp;&nbsp; <reg name="r0"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="r1"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r2"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="r3"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r4"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r5"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r6"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r7"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar0" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar1" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar2" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar3" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar4" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar5" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar6" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar7" bitsize="32"/&gt;
&gt; &nbsp;<reg name="dp"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="ir0" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ir1" bitsize="32"/&gt;
&gt; &nbsp;<reg name="bk"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="sp"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &nbsp;<reg name="st"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="ie"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="if"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="iof" bitsize="32"/&gt;
&gt; &nbsp;<reg name="rs"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="re"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="rc"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="pc"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &nbsp;<reg name="clk"&nbsp; bitsize="32"/&gt;
&gt; </feature&gt;
&gt; &nbsp;&nbsp;

#6 lore raw
Quoted 4 lines · casmac

Hi,
&nbsp;&nbsp; Thank you for forwarding my question to developers and sharing the C6x implementation.
&nbsp;&nbsp; Perhaps I should follow up with another problem I encountered. The senerio is the&nbsp; emulator keeps running eventhough the program it emulates has already exited. And it keeps retrieving instructions which are all zero "instruction"(0x00000000).

Quoted 8 lines

&nbsp;&nbsp; It looks to me that in function cpu_exec(CPUState *cpu), the following loop never terminate:
&nbsp;&nbsp; while (!cpu_handle_exception(cpu, &amp;ret)) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TranslationBlock *last_tb = NULL; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int tb_exit = 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!cpu_handle_interrupt(cpu, &amp;last_tb)) { ... } &nbsp;&nbsp; Is it because cpu-&gt;exit_request remains 0 ?

&nbsp;&nbsp; At what point should we make cpu-&gt;exit_request=1 ?

cpu->exit_request is set for asynchronus conditions (e.g. timer IRQs or IO events). A number of helpers will "kick" the cpu by calling cpu_exit().

Quoted 95 lines

&nbsp;&nbsp; Thanks again!!

regards
xiaolei

------------------&nbsp;Original&nbsp;------------------
From:&nbsp;"Philippe Mathieu-Daudé"<[email protected]&gt;;
Date:&nbsp;Wed, May 27, 2020 03:19 PM To:&nbsp;"casmac"<[email protected]&gt;;"qemu-devel"<[email protected]&gt;;
Cc:&nbsp;"Taylor Simpson"<[email protected]&gt;;"Alex Bennée"<[email protected]&gt;;"Luc Michel"<[email protected]&gt;; Subject:&nbsp;Re: GDB get wrong debug infos on TI DSP architecture extension

Hi Xiaolei,

Cc'ing more developers who might answer you.

On 5/27/20 8:48 AM, casmac wrote:
&gt; Hi all,
&gt; &nbsp;&nbsp; I am working on a TI DSP architecture extension for QEMU.

FYI you can find the TI TMS320C6x target implemented here:
https://github.com/philmd/qemu/releases/tag/target-c6x-2.4

I started rebasing it to QEMU 4.2 but then got distracted.

&gt; Now, we are
&gt; adding GDB debugging features.
&gt; &nbsp;&nbsp; We have done the following, but not sure we are on the right track :
&gt; &nbsp;&nbsp; - add a xml description file in gdb-xml, without understanding the &gt; purpose of the file, why some architectures don't provide such xml file? &gt; &nbsp;&nbsp; - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register(); &gt; &nbsp;&nbsp; - added&nbsp; dsp_cpu_get_phys_page_attrs_debug(), but uncertain about &gt; what to return
&gt; &nbsp; &nbsp;&nbsp; dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, &gt; MemTxAttrs *attrs)
&gt; &nbsp; &nbsp;&nbsp; {
&gt; &nbsp; &nbsp; &nbsp; &nbsp; return addr &amp; TARGET_PAGE_MASK;&nbsp;&nbsp; &gt; &nbsp; &nbsp;&nbsp; }
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; We run QEMU with the these arguments
&gt; &nbsp;&nbsp; qemu-system-dsp ... -kernel filename.out -S -s
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; It turns out that gdb reads incorrect register values, and complains &gt; : "warning: Target-supplied registers are not supported by the current &gt; architecture".
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; Something is missing here, or we do it in a wrong way.&nbsp; Any advise &gt; would be helpful to us.
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; Thanks.
&gt; &nbsp; &nbsp;
&gt; xiaolei
&gt;
&gt; &nbsp;&nbsp; ----- ti_dsp.xml&nbsp; -----
&gt; &nbsp;&nbsp;
&gt; &nbsp;&nbsp; <?xml version="1.0"?&gt;
&gt; <!DOCTYPE feature SYSTEM "gdb-target.dtd"&gt;
&gt; <feature name="org.gnu.gdb.tic3x.core"&gt;
&gt; &nbsp;&nbsp;&nbsp; <reg name="r0"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="r1"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r2"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="r3"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r4"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r5"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r6"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="r7"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar0" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar1" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar2" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar3" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar4" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar5" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar6" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ar7" bitsize="32"/&gt;
&gt; &nbsp;<reg name="dp"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="ir0" bitsize="32"/&gt;
&gt; &nbsp;<reg name="ir1" bitsize="32"/&gt;
&gt; &nbsp;<reg name="bk"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="sp"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &nbsp;<reg name="st"&nbsp; bitsize="32"&gt;</reg&gt;
&gt; &nbsp;<reg name="ie"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="if"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="iof" bitsize="32"/&gt;
&gt; &nbsp;<reg name="rs"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="re"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="rc"&nbsp; bitsize="32"/&gt;
&gt; &nbsp;<reg name="pc"&nbsp; bitsize="32" type="data_ptr"/&gt;
&gt; &nbsp;<reg name="clk"&nbsp; bitsize="32"/&gt;
&gt; </feature&gt;
&gt; &nbsp;&nbsp;

Signature · 1 line
Alex Bennée
author
#7 lore raw

Hi ,
Thanks for the hint.
I have been looking for how QEMU determine the target program terminates by checking the host implementation (eg i386). I thought the target program termination is connected to the initial FP pushed to stack, I am not sure this is how QEMU does. Could you be more specific on the termination check ? is it target architecture dependent( an added DSP target architecture should deal with it explicitly)? Thanks again

xiaolei

------------------ 原始邮件 ------------------
发件人: "Alex Bennée"<[email protected]>;
发送时间: 2020年5月28日(星期四) 下午4:34
收件人: "casmac"<[email protected]>;
抄送: "Philippe Mathieu-Daudé"<[email protected]>;"qemu-devel"<[email protected]>; 主题: Re: GDB get wrong debug infos on TI DSP architecture extension

Quoted 1 line · casmac

Hi,

Thank you for forwarding my question to developers and sharing the C6x implementation.

Quoted 10 lines

&nbsp;&nbsp; Perhaps I should follow up with another problem I encountered. The senerio is the&nbsp; emulator keeps running eventhough the program it emulates has already exited. And it keeps retrieving instructions which are all zero "instruction"(0x00000000).

It looks to me that in function cpu_exec(CPUState *cpu), the following loop never terminate:
while (!cpu_handle_exception(cpu, &amp;ret)) {
TranslationBlock *last_tb = NULL;
int tb_exit = 0;
while (!cpu_handle_interrupt(cpu, &amp;last_tb)) { ... }
Is it because cpu-&gt;exit_request remains 0 ?

At what point should we make cpu-&gt;exit_request=1 ?

cpu->exit_request is set for asynchronus conditions (e.g. timer IRQs or IO events). A number of helpers will "kick" the cpu by calling cpu_exit().

Quoted 8 lines

&nbsp;&nbsp; Thanks again!!

regards
xiaolei

#8 lore raw
In reply to casmac
Quoted 6 lines · casmac

Hi all,
&nbsp;&nbsp; I am working on a TI DSP architecture extension for QEMU. Now, we are adding GDB debugging features. &nbsp;&nbsp; We have done the following, but not sure we are on the right track :
&nbsp;&nbsp; - add a xml description file in gdb-xml, without
understanding the purpose of the file, why some architectures don't
provide such xml file?

XML descriptions are an extension to the GDB protocol which avoids having to have knowledge baked into GDB itself. The older well supported architectures don't need to send them for their base config as GDB already knows what they should have. However most extensions are reported as XML.

You may well need to have logic in your target code which decides which XML variant to send.

Quoted 14 lines

&nbsp;&nbsp; - add ***_cpu_gdb_read_register(), ***_cpu_gdb_write_register(); &nbsp;&nbsp; - added&nbsp; dsp_cpu_get_phys_page_attrs_debug(), but uncertain about what to return &nbsp; &nbsp;&nbsp; dsp_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) &nbsp; &nbsp;&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; return addr &amp; TARGET_PAGE_MASK;&nbsp;&nbsp;
&nbsp; &nbsp;&nbsp; }
&nbsp;&nbsp;
&nbsp;&nbsp; We run QEMU with the these arguments
&nbsp;&nbsp; qemu-system-dsp ... -kernel filename.out -S -s
&nbsp;&nbsp;
&nbsp;&nbsp; It turns out that gdb reads incorrect register values,
and complains : "warning: Target-supplied registers are not supported
by the current architecture".

Quoted 1 line

<feature name="org.gnu.gdb.tic3x.core"&gt;

Does this match something in gdb?

Signature · 1 line
Alex Bennée