NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-arm/55791: software breakpoint skipped on ARMv6
>Number: 55791
>Category: port-arm
>Synopsis: software breakpoint skipped on ARMv6
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-arm-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Nov 07 00:15:00 +0000 2020
>Originator: Rin Okuyama
>Release: 9.99.75
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD rpi0w 9.99.75 NetBSD 9.99.75 (RPI) #68: Sat Nov 7 07:24:01 JST 2020 rin@latipes:/sys/arch/evbarm/compile/RPI evbarm earmv6hf
>Description:
At least on ARM1176 in RPI[01], software breakpoints inserted by GDB in
shared libraries are skipped with a high probability:
----
$ gdb echo
GNU gdb (GDB) 8.3
...
Reading symbols from echo...
Reading symbols from /usr/libdata/debug//bin/echo.debug...
(gdb) b main
Breakpoint 1 at 0x950: file /usr/src/bin/echo/echo.c, line 58.
(gdb) r
Starting program: /bin/echo
Breakpoint 1, main (argc=1, argv=0x7feff32c) at /usr/src/bin/echo/echo.c:58
58 /usr/src/bin/echo/echo.c: No such file or directory.
(gdb) s
[Inferior 1 (process 2354) exited normally]
(gdb)
----
This is odd since this userland is built with MKDEBUGLIB=yes. On the other
hand, on Cortex-A53 in RPI2 rev1.2, breakpoints seem to work as expected:
----
$ gdb echo
GNU gdb (GDB) 8.3
...
Reading symbols from echo...
Reading symbols from /usr/libdata/debug//bin/echo.debug...
(gdb) b main
Breakpoint 1 at 0x950: file /usr/src/bin/echo/echo.c, line 58.
(gdb) r
Starting program: /bin/echo
Breakpoint 1, main (argc=1, argv=0x7ff19804) at /usr/src/bin/echo/echo.c:58
58 /usr/src/bin/echo/echo.c: No such file or directory.
(gdb) s
setprogname (progname=0x7ff19cc0 "/bin/echo")
at /usr/src/lib/libc/gen/setprogname.c:65
65 /usr/src/lib/libc/gen/setprogname.c: No such file or directory.
(gdb)
main (argc=<optimized out>, argv=0x7ff19804) at /usr/src/bin/echo/echo.c:59
59 /usr/src/bin/echo/echo.c: No such file or directory.
(gdb)
__setlocale50 (category=0, locale=0xc110adc "")
at /usr/src/lib/libc/locale/setlocale.c:193
193 /usr/src/lib/libc/locale/setlocale.c: No such file or directory.
(gdb)
194 in /usr/src/lib/libc/locale/setlocale.c
(gdb)
__setlocale (category=0, name=0xc110adc "")
at /usr/src/lib/libc/locale/setlocale.c:175
175 in /usr/src/lib/libc/locale/setlocale.c
...
----
Even on ARM1176, one or two breakpoints sometimes work. Therefore,
I suspect this is due to pmap_procwr():
https://nxr.netbsd.org/xref/src/sys/arch/arm/arm32/pmap.c#4793
4793 void
4794 pmap_procwr(struct proc *p, vaddr_t va, int len)
4795 {
4796 #ifndef ARM_MMU_EXTENDED
4797
4798 /* We only need to do anything if it is the current process. */
4799 if (p == curproc)
4800 cpu_icache_sync_range(va, len);
4801 #endif
4802 }
When GDB inserts a software breakpoint, p != curproc. So, we may need to
sync icache even for p != curproc (ARM_MMU_EXTENDED is not defined for
ARM1176). Note that a similar fix had been applied to aarch64:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/aarch64/aarch64/pmap.c#rev1.82
>How-To-Repeat:
Described above; ``gdb echo'' with userland built with MKDEBUGLIB=yes on
Raspberry Pi 1 or Zero.
>Fix:
For !ARM_MMU_EXTENDED case at least, sync icache even for p != curproc.
However, unfortunately, I don't know realizations for arm at the moment...
Home |
Main Index |
Thread Index |
Old Index