You are not logged in.
Hi! I can’t debug C code, because GDB can’t access memory at address 0x1139.
This happens in all programs I’m trying to debug. For example, I’ve made a super
simple C program:
#include <stdio.h>
int main(void) {
for (;;) {
puts("hi");
}
}I compiled it with
gcc -ggdb3 main.c -o mainThen I tried to debug it with
gdb mainHere’s what happened next:
GNU gdb (GDB) 17.1
Copyright <...>
Reading symbols from main...
(gdb) list
1 #include <stdio.h>
2
3 int main(void) {
4 for (;;) {
5 puts("hi");
6 }
7 }
(gdb) break main
Breakpoint 1 at 0x113d: file main.c, line 5.
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x000000000000113d in main at main.c:5
(gdb) run
Starting program: /tmp/main
❌️ Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x1139Interestingly, the address of the break point is 0x113d, but GDB can’t access 0x1139.
I’ve searched the internet about this, but haven’t found anything helpful. What I’ve seen:
Gentoo: gdb accepts no breakpoint. They talk about “CONFIG_PROC_
MEM_FORCE_PTRACE.” I don’t know what it is.
Gentoo: GDB "Cannot Insert Breakpoint." This guy’s GDB doesn’t work
because his kernel is hardened. As far as I know, my kernel is not hardened.
I use regular linux-lts.
Arch: GDB can't insert breakpoint. This guy has a problem with /proc/sys/
kernel/yama/ptrace_scope. I can set it to 0, but it doesn’t help.
Other questions I’ve seen about this problem are unrelated, I think.
By the way, Delve, a Go debugger, works fine.
Help me fix my GDB!
Offline
$ gdb --nh mainDoes this work? If it does, show your ~/.config/gdb/*
Offline