It appears that debugging armv7 binaries on arm64 is broken. I've created an armv7 jail on an arm64 FreeBSD 13.0-RELEASE system, entered it, and install gdb from ports. Then I executed an arbitrary program under gdb, set a breakpoint and let the program run (a simple way to do this is to type "start"). The breakpoint is reached and gdb informs me that a SIGBUS was delivered to the program; attempting to continue after this breakpoint is impossible. I suppose there's something wrong here as debugging on a native armv7 system seems to work fine.
Any idea if this is a regression with respect to older FreeBSD versions?
(In reply to Mark Johnston from comment #1) Older FreeBSD versions do not support execution of armv7 binaries on arm64. So I suppose it is not.
I have noticed that with current gdb-10.2_1 installed from ports, this issue only occurs when the break point is set into thumb code. So to reproduce, write some random C program, e.g. #include <stdio.h> int main(void) { puts("hello world"); return (0); } and compile with cc -mthumb -o hello hello.c then debug with gdb: break main run This should trigger the issue.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2734050154927eaa63d3b65de5d46d05569b3a5b commit 2734050154927eaa63d3b65de5d46d05569b3a5b Author: Olivier Houchard <cognet@FreeBSD.org> AuthorDate: 2021-09-21 13:49:45 +0000 Commit: Olivier Houchard <cognet@FreeBSD.org> CommitDate: 2021-09-21 13:52:42 +0000 arm64: Handle 32bits breakpoint exception. A different exception is raised when we hit a 32bits breakpoint, rather than a 64bits one, so handle those as well when COMPAT_FREEBSD32 is defined. This should fix SIGBUS at least when using breakpoints with thumb2 code. PR: 256468 MFC After: 1 week sys/arm64/arm64/trap.c | 3 +++ sys/arm64/include/armreg.h | 1 + 2 files changed, 4 insertions(+)
Hi Oliver, Thanks for the commit! Will test the changes once my ports builds for bug #257419 are done (so in a couple of days) and then close the PR if that did the trick.
That did the trick! You can close this after the MFC.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d055e974c4eeb7237cd18c3fe84a87fbd09ae43b commit d055e974c4eeb7237cd18c3fe84a87fbd09ae43b Author: Olivier Houchard <cognet@FreeBSD.org> AuthorDate: 2021-09-21 13:49:45 +0000 Commit: Olivier Houchard <cognet@FreeBSD.org> CommitDate: 2022-05-10 09:14:40 +0000 arm64: Handle 32bits breakpoint exception. A different exception is raised when we hit a 32bits breakpoint, rather than a 64bits one, so handle those as well when COMPAT_FREEBSD32 is defined. This should fix SIGBUS at least when using breakpoints with thumb2 code. PR: 256468 MFC After: 1 week (cherry picked from commit 2734050154927eaa63d3b65de5d46d05569b3a5b) sys/arm64/arm64/trap.c | 3 +++ sys/arm64/include/armreg.h | 1 + 2 files changed, 4 insertions(+)
Seems like we are done here!