NetBSD Problem Report #55703

From www@netbsd.org  Thu Oct  8 09:00:47 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 C13251A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  8 Oct 2020 09:00:47 +0000 (UTC)
Message-Id: <20201008090046.BEF8C1A923A@mollari.NetBSD.org>
Date: Thu,  8 Oct 2020 09:00:46 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: GDB single step fails for arm in shared library
X-Send-Pr-Version: www-1.0

>Number:         55703
>Category:       port-arm
>Synopsis:       GDB single step fails for arm in shared library
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 08 09:05:00 +0000 2020
>Originator:     Rin Okuyama
>Release:        9.99.73
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD cubietruck 9.99.73 NetBSD 9.99.73 (GENERICEB) #8: Mon Oct  5 17:26:07 JST 2020  rin@latipes:/sys/arch/evbarm/compile/GENERICEB evbarm earmv7hfeb
(occurs also for little endian)
>Description:
For arm, GDB fails to single-step into shared library on system built with
MKDEBUG=yes:

----
# gdb ./hello
GNU gdb (GDB) 8.3
...
Reading symbols from ./hello...
(gdb) b main
Breakpoint 1 at 0x106a4: file hello.c, line 7.
(gdb) r
Starting program: /root/hello

Breakpoint 1, main () at hello.c:7
7               printf("Hello, World!\n");
(gdb) s
puts (s=0x10774 "Hello, World!") at /usr/src/lib/libc/stdio/puts.c:61
61      /usr/src/lib/libc/stdio/puts.c: No such file or directory.
(gdb)
68      in /usr/src/lib/libc/stdio/puts.c
(gdb)
...
_mmap (addr=0x0, len=69632, prot=3, flags=4098, fd=-1, offset=0)
    at /usr/src/lib/libc/sys/mmap.c:61
61      /usr/src/lib/libc/sys/mmap.c: No such file or directory.
(gdb)


0x6dc72144 in __mmap () from /usr/lib/libc.so.12
(gdb)
Single stepping until exit from function __mmap,
which has no line number information.
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x0


(gdb)
Single stepping until exit from function __mmap,
which has no line number information.
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x0

(gdb)
...
----

For armv5hf{,eb}, GDB crashes after trying to insert breakpoint to 0
with ``gdb_exception_RETURN_MASK_ERROR'', if compiled by GCC 9.3.
This crash can be avoided if breakpoint.c and ifrun.c are compiled with
-O0, or -O2 by GCC8, but it still fails to single-step further anyway.

Also, if breakpoint is inserted directly to __mmap, GDB freezes
indefinitely, without capable of terminated by ^C or ^\. It accepts
only SIGKILL:

----
# gdb ./hello
GNU gdb (GDB) 8.3
...
Reading symbols from ./hello...
(gdb) b __mmap
Function "__mmap" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (__mmap) pending.
(gdb) r
Starting program: /root/hello

Breakpoint 1, 0x7973bf58 in __mmap () from /usr/libexec/ld.elf_so
(gdb) s
Single stepping until exit from function __mmap,
which has no line number information.
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x0

(gdb)
Single stepping until exit from function __mmap,
which has no line number information.
^C^C^C^\^\^\[ 260553.7405450] sorry, pid 10026 was killed: orphaned traced process
[1]   Killed                  gdb ./hello
#
----
>How-To-Repeat:
Described above.
>Fix:
N/A

NetBSD Home
NetBSD PR Database Search

(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.