You are not logged in.

#1 Yesterday 19:59:54

gneg
Member
Registered: 2023-10-31
Posts: 3

gdb: Cannot insert breakpoint 1. Cannot access memory at address 0x

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 main

Then I tried to debug it with

gdb main

Here’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 0x1139

Interestingly, 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:

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

#2 Yesterday 21:09:12

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 515

Re: gdb: Cannot insert breakpoint 1. Cannot access memory at address 0x

$ gdb --nh main

Does this work? If it does, show your ~/.config/gdb/*

Offline

Board footer

Powered by FluxBB