0

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 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

4 Comments

You could disable single-stepping support in X86-64 to aid in your debugging of GDB. "show range-stepping" and "set range-stepping" -- Range stepping lets GDB step over 1 or more instructions without setting a break point. Without range-stepping, GDB must interpret the instruction stream and predict where execution will go - following any sort of branches. It will then set a breakpoint at each possible next instruction address.
Some time ago I also had some problem with breakpoints on aarch64, though I forget what the solution ended up being :-(. Try the "info signals SIGTRAP" command, and "handle SIGTRAP stop print pass"
There are a lot of internal debug settings too that might help see whats going wrong, like set debug aarch64
Thank you, for your response.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.