================
@@ -751,21 +751,15 @@ UnwindPlanSP 
ABIWindows_x86_64::CreateFunctionEntryUnwindPlan() {
 
 // Windows-x86_64 doesn't use %rbp
 // No available Unwind information for Windows-x86_64 (section .pdata)
-// Let's use SysV-x86_64 one for now
 UnwindPlanSP ABIWindows_x86_64::CreateDefaultUnwindPlan() {
-  uint32_t fp_reg_num = dwarf_rbp;
   uint32_t sp_reg_num = dwarf_rsp;
   uint32_t pc_reg_num = dwarf_rip;
 
   UnwindPlan::Row row;
-
-  const int32_t ptr_size = 8;
-  row.GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size);
   row.SetOffset(0);
   row.SetUnspecifiedRegistersAreUndefined(true);
-
-  row.SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
-  row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
+  row.GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 8);
+  row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -8, false);
   row.SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
----------------
charles-zablit wrote:

I copied the implementation from 
https://github.com/llvm/llvm-project/blob/a9e5bb572703780e3eea4a2759104a141ea73466/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp#L859-L862

As I understand, on Windows `CFA = rsp+8` and `pc = [CFA-8]` given the 
following:

1. 
https://llvm-mos.org/wiki/DWARF_implementation_guide#The_Canonical_Frame_Address:
> On most processors, the CFA is simply "the stack pointer value when this 
> function was called." Local variables are at negative offsets from the CFA 
> (below it on the stack), and the return address is at a fixed position 
> relative to the CFA.

2.https://learn.microsoft.com/en-us/cpp/build/prolog-and-epilog?view=msvc-170#prolog-code
> The code for a typical prolog might be:
> ```asm
> mov    [RSP + 8], RCX
>```


> Is it even right to say that rsp itself is spilled on the stack at row 0?

This is using the `Is` variant of the method, not the `At` variant. As I 
understand it, the register is not spilled on the stack (rightfully so). And 
that's why we don't see it in the diagram.

https://github.com/llvm/llvm-project/pull/210076
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to