I notice now that the code from systat is mapped to very low memory
addresses unlike my own programs. I think that's why I am getting
errors. Curious how this is happening.

>From: Anindya Mukherjee
>Sent: February 4, 2021 3:59 PM
>To: misc@openbsd.org <misc@openbsd.org>
>Subject: gdb issue 
> 
>Hi,
>
>I'm trying to debug the systat utility for learning purposes. I enabled
>-g -O0 in the Makefile, and built it in /usr/src/usr.bin/systat. It
>builds and runs fine. However, gdb cannot insert any breakspoints. I'm
>on a very recent snapshot and everything is fully patched.
>
>I set kern.global_ptrace=1 and gdb can attach. Trying to insert a
>breakpoint causes the following error:
>
>$ gdb
>GNU gdb 6.3
>Copyright 2004 Free Software Foundation, Inc.
>GDB is free software, covered by the GNU General Public License, and you are
>welcome to change it and/or distribute copies of it under certain conditions.
>Type "show copying" to see the conditions.
>There is absolutely no warranty for GDB.  Type "show warranty" for details.
>This GDB was configured as "amd64-unknown-openbsd6.8"
>
>(gdb) file systat
>Reading symbols from /usr/src/usr.bin/systat/systat...done.
>(gdb) attach 51616
>Attaching to program: /usr/src/usr.bin/systat/systat, process 51616
>[Switching to thread 588561]
>0x00000b5f3d6c5c8a in ?? ()
>(gdb) b engine.c:1156
>Breakpoint 1 at 0x13aca: file engine.c, line 1156.
>(gdb) info b
>Num Type           Disp Enb Address            What
>1   breakpoint     keep y   0x0000000000013aca in message_set at engine.c:1156
>(gdb) c
>Continuing.
>Warning:
>Cannot insert breakpoint 1.
>Error accessing memory address 0x13aca: Input/output error.
>
>If I build a simple C program debugging works fine. I can even debug
>tmux built from git fine with either gdb or egdb. Any ideas? How
>would one proceed if one was investigating a bug?
>
>Thanks,
>Anindya

Reply via email to