[Lldb-commits] Proposed small tweak to the Profile Until Ret Instruction patch

Tong Shen endlessroad at google.com
Mon Aug 25 15:13:25 PDT 2014


Hi Jason,

Patch confirmed, plan name changed as expected (and did not change for gcc
because gcc describes epilogue as well).

I made a small change though: now that you brought up "image dump
show-unwind", I found that I should make a copy of
m_unwind_plan_call_site_sp instead of modifying it directly.
Now "image show-unwind" output looks like:

Asynchronous (not restricted to call-sites) UnwindPlan for 1`f (start addr
0x8048420):
This UnwindPlan originally sourced from eh_frame CFI plus augmentation from
assembly parsing
Address range of this UnwindPlan: [1..text + 256-0x0000014b)
row[0]: 0x00000000: CFA=esp +4 => eip=[esp]
row[1]: 0x00000003: CFA=esp+24 => eip=[esp+20]
row[2]: 0x0000004a: CFA=esp +4 => eip=[esp]

Synchronous (restricted to call-sites) UnwindPlan for 1`f (start addr
0x8048420):
This UnwindPlan originally sourced from eh_frame CFI
Address range of this UnwindPlan: [1..text + 256-0x0000014b)
row[0]: 0x00000000: CFA=esp +4 => eip=[esp]
row[1]: 0x00000003: CFA=esp+24 => eip=[esp+20]

Architecture default UnwindPlan for 1`f (start addr 0x8048420):
This UnwindPlan originally sourced from i386 default unwind plan
row[0]: 0x00000000: CFA=ebp +8 => esp=ebp+8 ebp=[ebp] eip=[ebp+4]



On Mon, Aug 25, 2014 at 2:45 PM, Tong Shen <endlessroad at google.com> wrote:

> Of course :-)
> Keeping the old name may cause confusion in the future.
>
> I will test it now and make sure it works.
>
> Thanks!
>
>
> On Mon, Aug 25, 2014 at 2:43 PM, Jason Molenda <jmolenda at apple.com> wrote:
>
>> Hi Tong, I think it might be useful to note that the UnwindPlan has been
>> modified (in case one of us is looking at it with "image dump
>> show-unwind").  What do you think about this patch?  I don't have eh_frame
>> info on my system right now so I haven't tested this.
>>
>>
>
>
> --
> Best Regards, Tong Shen
>



-- 
Best Regards, Tong Shen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140825/e6e75499/attachment.html>
-------------- next part --------------
diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index d1836bf..78a4c19 100644
--- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -876,6 +876,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
     m_cur_insn = func.GetBaseAddress();
     uint64_t offset = 0;
     int row_id = 1;
+    bool unwind_plan_updated = false;
     UnwindPlan::RowSP row(new UnwindPlan::Row(*first_row));
     while (func.ContainsFileAddress (m_cur_insn))
     {
@@ -935,6 +936,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
 
@@ -946,6 +948,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
             if (pop_reg_p (regno)) {
@@ -959,6 +962,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
 
@@ -968,6 +972,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
                 row->SetCFAOffset (m_wordsize + row->GetCFAOffset());
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
 
@@ -979,6 +984,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
             if (sub_rsp_pattern_p (amount)) {
@@ -987,6 +993,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                 UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                 unwind_plan.InsertRow (new_row);
+                unwind_plan_updated = true;
                 continue;
             }
         }
@@ -1009,6 +1016,7 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
 
                     UnwindPlan::RowSP new_row(new UnwindPlan::Row(*row));
                     unwind_plan.InsertRow (new_row);
+                    unwind_plan_updated = true;
                     continue;
                 }
             }
@@ -1024,6 +1032,13 @@ AssemblyParse_x86::augment_unwind_plan_from_call_site (AddressRange& func, Unwin
     }
 
     unwind_plan.SetPlanValidAddressRange (func);
+    if (unwind_plan_updated)
+    {
+        std::string unwind_plan_source (unwind_plan.GetSourceName().AsCString());
+        unwind_plan_source += " plus augmentation from assembly parsing";
+        unwind_plan.SetSourceName (unwind_plan_source.c_str());
+        unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
+    }
     return true;
 }
 
diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp
index d6f89bc..95fc817 100644
--- a/source/Symbol/FuncUnwinders.cpp
+++ b/source/Symbol/FuncUnwinders.cpp
@@ -115,14 +115,19 @@ FuncUnwinders::GetUnwindPlanAtNonCallSite (Target& target, Thread& thread, int c
         if (assembly_profiler_sp)
         {
             if (target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_32_i386
-                || target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64)
+                || target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64
+                || target.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64h)
             {
                 // For 0th frame on i386 & x86_64, we fetch eh_frame and try using assembly profiler
                 // to augment it into asynchronous unwind table.
                 GetUnwindPlanAtCallSite(current_offset);
-                if (m_unwind_plan_call_site_sp
-                    && assembly_profiler_sp->AugmentUnwindPlanFromCallSite(m_range, thread, *m_unwind_plan_call_site_sp))
-                    return m_unwind_plan_call_site_sp;
+                if (m_unwind_plan_call_site_sp) {
+                    UnwindPlan* plan = new UnwindPlan (*m_unwind_plan_call_site_sp);
+                    if (assembly_profiler_sp->AugmentUnwindPlanFromCallSite (m_range, thread, *plan)) {
+                        m_unwind_plan_non_call_site_sp.reset (plan);
+                        return m_unwind_plan_non_call_site_sp;
+                    }
+                }
             }
 
             m_unwind_plan_non_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));


More information about the lldb-commits mailing list