Skip to content

Conversation

@no1wudi
Copy link
Collaborator

@no1wudi no1wudi commented Nov 10, 2025

This commit adds comprehensive Call Frame Information (CFI) directives to the ARM Thumb invokeNative assembly function to enable proper stack unwinding in GDB debugging sessions.

Key changes:

  • Added .cfi_startproc and .cfi_endproc to define the function boundaries
  • Implemented .cfi_def_cfa directives to establish the canonical frame address
  • Added .cfi_offset directives for all callee-saved registers (lr, r7, r6, r5, r4)
  • Established proper frame pointer (r7) usage for reliable stack unwinding
  • Enhanced stack frame management with consistent alignment and cleanup

The CFI directives allow GDB to accurately track register values and unwind the call stack when debugging native function invocations, significantly improving the debugging experience for WAMR applications on ARM Thumb platforms.

@no1wudi
Copy link
Collaborator Author

no1wudi commented Nov 10, 2025

Before this patch:
image
After this patch:
屏幕截图 2025-11-09 225551

…DB debugging

This commit adds comprehensive Call Frame Information (CFI) directives to the ARM Thumb invokeNative assembly function to enable proper stack unwinding in GDB debugging sessions.

Key changes:
- Added .cfi_startproc and .cfi_endproc to define the function boundaries
- Implemented .cfi_def_cfa directives to establish the canonical frame address
- Added .cfi_offset directives for all callee-saved registers (lr, r7, r6, r5, r4)
- Established proper frame pointer (r7) usage for reliable stack unwinding
- Enhanced stack frame management with consistent alignment and cleanup

The CFI directives allow GDB to accurately track register values and unwind the call stack when debugging native function invocations, significantly improving the debugging experience for WAMR applications on ARM Thumb platforms.

Signed-off-by: Huang Qi <[email protected]>
@lum1n0us
Copy link
Collaborator

Great work. Do you have any plans to expand similar functionality to other architectures, like x86, x86-64, and so on?

@no1wudi
Copy link
Collaborator Author

no1wudi commented Nov 10, 2025

Great work. Do you have any plans to expand similar functionality to other architectures, like x86, x86-64, and so on?

I plan to implement it for arm/riscv first, and later for other platforms

@TianlongLiang
Copy link
Collaborator

This feature will greatly facilitate the debugging process. But do you think we should conditionally include it, controlled by CMake config or something? Since it will add overhead when invoking a native function?

@no1wudi
Copy link
Collaborator Author

no1wudi commented Nov 11, 2025

This feature will greatly facilitate the debugging process. But do you think we should conditionally include it, controlled by CMake config or something? Since it will add overhead when invoking a native function?

No "overhead" here, CFI directives is just annotation for debugger, will not generate actual code if don't touch the asm function itself

@no1wudi no1wudi marked this pull request as draft November 13, 2025 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants