ok, there are 2 issues: "stop at begin" and "access violation"
The "stop at begin" is "by design".
That is from all I know, gdb behaves like this by intention.
I am not sure, how much (if at all), the IDE is currently aware of this. And if/what could be added to improve this.
Currently unfortunately this does not make my todo list, as there are to many other items of higher priority.
There may be an issue report for it already, if not it can be created....
Mind that to a degree it is considered useful, if the breakpoint is just one or two lines above.
"access violation"
You may have to open the "debug output" before starting the debugger. Otherwise not all info is captured.
Or you can unset, and again set the breakpoint while the window is open.
Looking for lines like this:
<info line "B:\tmp\dbg\unit1.pas":46>
&"info line \"B:\\tmp\\dbg\\unit1.pas\":46\n"
~"Line 46 of \"unit1.pas\" starts at address 0x10003a629 <$fin$00000139+9> and ends at 0x10003a63a <DEBUGSTART_$UNIT1+26>.\n"
^done
(gdb)
<-break-insert "\"B:/tmp/dbg/unit1.pas\":46">
^done,bkpt={number="8",type="breakpoint",disp="keep",enabled="y",addr="<MULTIPLE>",times="0",original-location="B:/tmp/dbg/unit1.pas:46",locations=[{number="8.1",enabled="y",addr="0x000000010003a629",func="$fin$00000139",file="unit1.pas",fullname="B:\\tmp\\dbg\\unit1.pas",line="46",thread-groups=["i1"]},{number="8.2",enabled="y",addr="0x000000010003a654",func="Button1Click",file="unit1.pas",fullname="B:\\tmp\\dbg\\unit1.pas",line="46",thread-groups=["i1"]}]}
(gdb)
<-break-enable 8>
^done
There are 2 addresses for this line
addr="0x000000010003a629" that is inside the hidden finally block that fpc generated for the procedure.
addr="0x000000010003a654" the "begin" line.
=> But the question is this: Are both address actually at the start of an assembler instruction?
< Background >
Assembler instruction can be multiple bytes. Breakpoints, replace the instruction with "int 3", that will be caught by the debugger.
If the address is in the middle of an assembler instruction, then instead of a breakpoint, its a random code modification, and that would likely crash.
< /Background >
If it is in the middle, then the question is: Did FPC write a wrong address in the debug info? Or did GDB get something wrong.
- If its fpc, then it needs to be fixed there.
- If its gdb, well you can try to report it to them, but you would need some way for them to reproduce it. (and check against the latest gdb first). I currently do not have the time, to prepare a gdb report....
So once you have the address, you need to step (potentially assembler-single step-into) each of those functions, and show the disassembler for them.
Or you may be able to disassemble with objdump.
Then you can look for the address, and see if it is at the start of a statement or not.
objdump (lineinfo) can also show you, what addresses fpc actually included.