#3733 closed enhancement (fixed)

Add general reg support to libdebugger

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 5.1
Component: lib/debugger Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

Testing master on a Zynq reports:

(gdb) target remote 10.10.5.45:1122                        
Remote debugging using 10.10.5.45:1122             
Truncated register 19 in remote 'g' packet

It looks to me like gdb is now smart enough to know this ARM arch has a NEON and floating point registers:

(gdb) maint print registers
Name         Nr  Rel Offset    Size  Type
 r0            0    0      0       4 uint32_t
 r1            1    1      4       4 uint32_t
 r2            2    2      8       4 uint32_t
 r3            3    3     12       4 uint32_t
 r4            4    4     16       4 uint32_t
 r5            5    5     20       4 uint32_t
 r6            6    6     24       4 uint32_t
 r7            7    7     28       4 uint32_t
 r8            8    8     32       4 uint32_t
 r9            9    9     36       4 uint32_t
 r10          10   10     40       4 uint32_t
 r11          11   11     44       4 uint32_t
 r12          12   12     48       4 uint32_t
 sp           13   13     52       4 *1
 lr           14   14     56       4 uint32_t
 pc           15   15     60       4 *1
 f0           16   16     64      12 _arm_ext
 f1           17   17     76      12 _arm_ext
 f2           18   18     88      12 _arm_ext
 f3           19   19    100      12 _arm_ext
 f4           20   20    112      12 _arm_ext
 f5           21   21    124      12 _arm_ext
 f6           22   22    136      12 _arm_ext
 f7           23   23    148      12 _arm_ext
 fps          24   24    160       4 uint32_t
 cpsr         25   25    164       4 uint32_t

The target support in libdebugger is a simple array of 32bit ints. This needs to change to handle registers at various offsets. The lack of fp regs was a simplification at the time I first implement this server. Loos like I need to sort this out.

Change History (3)

comment:1 Changed on Apr 6, 2019 at 12:39:37 AM by Chris Johns

Status: newaccepted

I suspect the more recent gdb we are using is checking the g register data length and libdebugger was not returning the correct amount for the ARM processor.

comment:2 Changed on Apr 6, 2019 at 12:43:24 AM by Chris Johns

Adding support for offsets to the ARM backend has things working. The following is with master RSB, kernel and libbsd:

 $ /opt/work/rtems/5/bin/arm-rtems5-gdb ./build/arm-rtems5-xilinx_zynq_zedboard-default/debugger01.exe
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-freebsd11.2 --target=arm-rtems5".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build/arm-rtems5-xilinx_zynq_zedboard-default/debugger01.exe...done.
(gdb) target remote 10.10.5.45:1122
Remote debugging using 10.10.5.45:1122
0x00000030 in ?? ()
(gdb) info threads
  Id   Target Id                                                                                                    Frame
* 1    Thread 1.167837697 (UI1  (0a010001), priority(c:508 r:508), stack(s: 32768 a:0x44dda0), state(TIME:SUSP:IS)) 0x00000030 in ?? ()
  2    Thread 1.167837698 (SHLL (0a010002), priority(c:  2 r:  2), stack(s: 32768 a:0x456590), state(SEM:SUSP))     arm_interrupt_disable () at /opt/work/chris/rtems/kernel/rtems.git/cpukit/score/cpu/arm/include/rtems/score/cpu.h:299                                                                          
(gdb) info reg
r0             0x2c7184            2912644
r1             0x2c7184            2912644
r2             0x2c7184            2912644
r3             0x2c7184            2912644
r4             0x30be70            3194480
r5             0x40e660            4253280
r6             0x7184be70          1904524912
r7             0x7184002c          1904476204
r8             0x7184002c          1904476204
r9             0x7184002c          1904476204
r10            0xbe70002c          3195011116
r11            0xea680030          3932684336
r12            0xbe700040          3195011136
sp             0xc5000030          0xc5000030
lr             0xbe6c0044          3194748996
pc             0x30                0x30
cpsr           0x0                 0
(gdb) thread 2
[Switching to thread 2 (Thread 1.167837698)]
#0  arm_interrupt_disable () at /opt/work/chris/rtems/kernel/rtems.git/cpukit/score/cpu/arm/include/rtems/score/cpu.h:299
299       __asm__ volatile (
(gdb) bt
#0  arm_interrupt_disable () at /opt/work/chris/rtems/kernel/rtems.git/cpukit/score/cpu/arm/include/rtems/score/cpu.h:299
#1  _Thread_Do_dispatch (cpu_self=<optimized out>, level=<optimized out>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threaddispatch.c:309                                                                                                                                              
#2  0x0022d09a in _Semaphore_Wait_timed_ticks (_sem=_sem@entry=0x455e38, ticks=ticks@entry=0) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/semaphore.c:100                                                                                                                               
#3  0x002254fa in rtems_binary_semaphore_wait_timed_ticks (ticks=0, binary_semaphore=0x455e38) at /opt/work/chris/rtems/kernel/rtems.git/cpukit/include/rtems/thread.h:263                                                                                                                                         
#4  fillBufferQueue (tty=0x455da8) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libcsupport/src/termios.c:1509
#5  rtems_termios_read_tty (tty=tty@entry=0x455da8, buffer=buffer@entry=0x44c94b <__sf+67> "\r", initial_count=initial_count@entry=1) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libcsupport/src/termios.c:1538                                                                                  
#6  0x0022562c in rtems_termios_imfs_read (iop=0x41aec8 <rtems_libio_iops>, buffer=0x44c94b <__sf+67>, count=1) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libcsupport/src/termios.c:2052                                                                                                        
#7  0x00223be8 in read (fd=<optimized out>, buffer=<optimized out>, count=<optimized out>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libcsupport/src/read.c:44                                                                                                                                  
#8  0x00241c12 in __sread (ptr=<optimized out>, cookie=0x44c908 <__sf>, buf=<optimized out>, n=<optimized out>) at ../../../../../../../../../gcc-7.4.0/newlib/libc/stdio/stdio.c:47                                                                                                                               
#9  0x00241782 in __srefill_r (ptr=ptr@entry=0x40ed18 <_RTEMS_tasks_Objects+1720>, fp=fp@entry=0x44c908 <__sf>) at ../../../../../../../../../gcc-7.4.0/newlib/libc/stdio/refill.c:117                                                                                                                             
#10 0x0024188c in __srget_r (ptr=ptr@entry=0x40ed18 <_RTEMS_tasks_Objects+1720>, fp=fp@entry=0x44c908 <__sf>) at ../../../../../../../../../gcc-7.4.0/newlib/libc/stdio/rget.c:42                                                                                                                                  
#11 0x0023abfc in fgetc (fp=fp@entry=0x44c908 <__sf>) at ../../../../../../../../../gcc-7.4.0/newlib/libc/stdio/fgetc.c:110
#12 0x00232858 in rtems_shell_getchar (in=in@entry=0x44c908 <__sf>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libmisc/shell/shell_getchar.c:123                                                                                                                                                 
#13 0x00231704 in rtems_shell_line_editor (size=128, out=0x44c988 <__sf+128>, in=0x44c908 <__sf>, prompt=<optimized out>, count=<optimized out>, cmds=0x45e360) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libmisc/shell/shell.c:225                                                             
#14 rtems_shell_main_loop (shell_env_arg=<optimized out>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libmisc/shell/shell.c:880
#15 0x0023255e in rtems_shell_task (task_argument=<optimized out>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/libmisc/shell/shell.c:679
#16 0x0022ad3a in _Thread_Handler () at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threadhandler.c:135
#17 0x0022abbc in _Thread_Do_dispatch (cpu_self=<optimized out>, level=<optimized out>) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threaddispatch.c:299                                                                                                                                
#18 0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

comment:3 Changed on Apr 9, 2019 at 5:05:23 AM by Chris Johns <chrisj@…>

Resolution: fixed
Status: acceptedclosed

In 2c09b71/rtems:

libdebugger: Use an offset table to format GDB g packets.

Adding support for a register offset table lets FPU registers
be supported if added to the backend.

Closes #3733.

Note: See TracTickets for help on using tickets.