EDIT Changed my code to just a hello world example, I've provided an object dump and read elf output. I tried building gdb version 13.1 from source but I'm still seeing the same behavior. This makes me believe it's an issue based on something gdb is using
OBJECT DUMP https://pastebin.com/sJNtWm6K
READELF -a OUTPUT https://pastebin.com/xynjJVPn
#include <stdio.h>
int main(int argsc, char* argv[])
{
printf("Hello World\n");
return 0;
}
OLD Question I'm trying to learn C++. I'm running the code on my Raspberry Pi 4 running Raspberry PI OS. I type these commands into the terminal.
g++ -g brainfuck.cpp -o brainfuck -O0
gdb brainfuck
// inside of gdb
break main
Breakpoint 1 at 0xd74: file brainfuck.cpp, line 49.
run
// output of gdb
Starting program: /home/deca/Programming/Cpp/brainfuck
Now SP is 3During startup program exited normally.
I check that gdb actual set my break point
(gdb) info breakpoint
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000000d74 in main(int, char**) at brainfuck.cpp:49
but for some reason it skips past it all the way to the end of my program. Does anyone know why this is happening? And is someone able to recreate this behavior on their PI 4 as well?
So far I've tried
- removing and redownloading gdb using the package manager
- using set breakpoint auto-hw off based on the suggestion of another user
- using the flags -O0 -g -ggdb -fno-omit-frame-pointer -gcolumn-info
- Creating a Hello World program and seeing if break points work there
- Running gdb as root as outlined in this stackoverflow post from 9 years ago
- Setting a breakpoint a _start with
b _start
- Compiling a new version of GDB from source
The output of strace -f -o syscall.txt gdb ./helloworld
on my hello world example
warning: Could not trace the inferior process.
warning: ptrace: Operation not permitted
During startup program exited with code 127.
Versions
g++ (Debian 10.2.1-6) 10.2.1 20210110
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Linux raspberrypi 5.15.84-v8+
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"