NetBSD Problem Report #55791
From www@netbsd.org Sat Nov 7 00:10:34 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 815911A9246
for <gnats-bugs@gnats.NetBSD.org>; Sat, 7 Nov 2020 00:10:34 +0000 (UTC)
Message-Id: <20201107001033.41D011A925D@mollari.NetBSD.org>
Date: Sat, 7 Nov 2020 00:10:33 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: software breakpoint skipped on ARMv6
X-Send-Pr-Version: www-1.0
>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...
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.