Unable to step into an assembly file in forced disassembly mode

I’m working on an STM32 project, and I have an assembly (.S) file in it. Due to lots of repetitive code, it relies heavily on GNU Assembler macros (.macro.endm).

When stepping into a function defined in this assembly file, it shows me the source (i.e. the .S file itself). However, most of the code is wrapped in macros. So when the debugger is stopped on a given line, whether I click on “step into” or “step over”, it executes all the instructions in a macro (possibly dozens of them).

Of course there may be situations where I need to trace through this macro, look at the register values after executing each instruction, etc. So I thought to switch to forced disassembly mode. Unfortunately, when I do that, something very strange happens: it shows me disassembly of the caller (a C function), exactly one instruction after the bl my_asm_function instruction. Even adding a breakpoint at the bl my_asm_function itself, and trying to step into it, just jumps to the next instruction in the caller. I’ve tried absolutely everything I could think of, and I just can’t show the forced disassembly of a function written in assembly, only the source.

Note that there are no problems with C functions: I can switch between source and disassembly, can step into a function in forced disassembly mode and it shows the disassembly of the callee, etc. Zero issues when it’s a C function. The problem is with assembly files.

Perhaps this is a bug, in which case I’ll open an issue. But I’m just wondering if anyone ever came across this and found a magic command-line flag for the assembler/linker, or some assembly .directive I can add to the file to solve this issue.

Solved. It was missing a .size directive, e.g.:

.size my_asm_function, .-my_asm_function

at the end of the function. I swear I’d never needed that before on other gcc-based systems, but there you go. Hope it helps someone else going through the same issue.