i386: Fix debug frame unwinding for DRAP frames with red zones
Debug frame unwinding is corrected for stack-realigned frames when using red zones.
When using Dwarf’s DRAP (DWARF Register Allocation Path) for stack unwinding, frame pointer relative expressions were used to locate saved registers. A change to skip emitting CFA_RESTORE notes for registers in the red zone broke unwinding for DRAP frames, as these expressions became stale after the frame pointer was restored. This commit ensures CFA_RESTORE notes are emitted even for red zone registers in DRAP frames to maintain correct debugging information.
In Details
In DRAP (DWARF Register Allocation Path) frames, the Call Frame Information (CFI) uses frame-pointer-relative expressions (Rule 18 in dwarf2out_frame_debug_expr) to describe register locations. The function ix86_add_cfa_restore_note previously skipped emitting a note if the saved slot was within the red zone, assuming unwinders could find the value in the register or stack. However, this shortcut is invalid for DRAP frames where frame-pointer-relative expressions are used, as they become stale when %rbp is restored (e.g., by 'leave'). This change removes the shortcut when `stack_realign_dra…
- DRAP
- DWARF Register Allocation Path, a mechanism within the DWARF debugging format that describes how registers are allocated and can be restored during stack unwinding.
- CFI
- Call Frame Information, a part of the DWARF debugging standard that describes how to unwind the call stack, including the location of saved registers and previous frame pointers.
- red zone
- A small area of the stack below the current stack frame that can be used by the current function for temporary storage without needing to adjust the stack pointer. This is a common optimization in some calling conventions.
- frame pointer
- A register (commonly %rbp on x86-64) that points to the base of the current stack frame, used to access local variables and function arguments.
- DWARF
- A debugging data format used by many compilers, including GCC, to store information about variables, functions, and the structure of a program, enabling debuggers to provide detailed insights.