0
votes

I have troubles with gdb on aarch64. I can't describe a lot of details about platform, but it isn't needed. Problem is breakpoint handling. Only the first stop of breakpoint works well, after continuation breakpoint wasn't inserted again and program will run without following breakpoint stops. This lead to more errors, e.g. internal gdb breakpoints doesn't work as well and dynamic libraries isn't auto-loaded correctly.

As far as I understand gdb inserts special bp instructions in place of interest (something like INT 3 on x86-64), this generated SIGTRAP during execution, which handled by gdb (for bp stop, symbols loading etc.). When execution continues, gdb have to insert that instructions again.

I got that kind of error on both aarch64 and x86-64(used for understanding correct behaviour) instantly after continuation:

infrun: skipping breakpoint: stepping past insn at: <bp addr>

This is because gdb will pass bp place after continue (original instruction haven't executed yet), and it will lead to endless stops.

But on x86-64, I see that gdb handles another SIGTRAP after continuation from next instruction after bp, and at that moment bp could be inserted correctly (because bp address was allready passed). But on my aarch64 platform I got only 1 SIGTRAP from bp location and nothing more. This lead to non-inserting of bp again, as far as I understand.

I debugged GDB (yes, sir) and found no bp insertion for next instruction on x86-64. Because of that I can't investigate the same place for aarch64 and understand source of bug.

Did I understand bp implementation correctly? And which code affected "hidden" 2nd SIGTRAP generation?

UPD: I have found, that ptrace with request=PTRACE_SINGLESTEP doesn't work on aarch64 (program will continue until termination). Also, software single stepping is used for aarch64, but aarch64_software_single_step returns 0(abnormal completion), maybe this is the source.

1

1 Answers

0
votes

I still not found a bug. But at least I understand how continue handling in this case. For continue command gdb call ptrace with request=PTRACE_SINGLESTEP, which leads to execution 1 command in inferior process and stopping after that.