Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[gdb] - step after attach fails on current.




Hello,

I have NetBSD-current running on an RPi 3. When I attach to a program (which is waiting for the debugger in a loop) with gdb and try to step, or perform any activity that involves writing to the program text such as inserting a breakpoint, I see that the ptrace (PT_IO,...) call fails with errno EFAULT. EFAULT is not among the documented errnos set by ptrace.

I spent some time trying to find the root cause of this failure. The EFAULT is generated from a call to copyin() in src/sys/kern/subr_copy.c:copyin_vmspace(). I suspect that the call is failing because the page protection bits are not being set correctly on attach 
on the RPi.

I can reproduce this on NetBSD-current [8.99.3] on evbarm (RPi).

I dont have a spare machine/SD-card lying around to test this on -release. FWIW I cannot reproduce this with either -current or -release on amd64 though. Also FWIW, continuing without setting any breakpoints seems to work fine.

I am pasting a session transcript below for reference.

Script started on Sat Nov  4 00:35:43 2017
$ uname -a
NetBSD XXX 8.99.3 NetBSD 8.99.3 (RPI2) #0: Sun Oct  1 10:45:49 UTC 2017  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/evbarm/compile/RPI2 evbarm
$ ./loop &
[1] 630
$ gdb -pid=630
GNU gdb (GDB) 7.12
Copyright (C) 2016 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 "arm--netbsdelf-eabi".
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".
Attaching to process 630
Reading symbols from /usr/home/xxx/C/loop...done.
Reading symbols from /usr/lib/libc.so.12...(no debugging symbols found)...done.
Reading symbols from /usr/libexec/ld.elf_so...(no debugging symbols found)...done.
[Switching to LWP 1]
0x0001073c in loop () at loop.c:8
8               while (x) {
(gdb) n
0x0001073c in loop () at loop.c:8
8               while (x) {
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x10740

(gdb) 
0x0001073c in loop () at loop.c:8
8               while (x) {
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x10740

(gdb) q
A debugging session is active.

        Inferior 1 [LWP 0] will be detached.

Quit anyway? (y or n) y
Detaching from program: /usr/home/xxx/C/loop, process 630
$ exit

Script done on Sat Nov  4 00:36:25 2017

Thanks and regards,
--Gopikrishnan Sidhardhan


Home | Main Index | Thread Index | Old Index