<div dir="ltr">Shouldn't it be possible to force clang to generate code like this? If so couldn't you write a test for this by stepping over a function call which has this kind of code in it?</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Feb 2, 2016 at 4:11 PM Jim Ingham via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jingham<br>
Date: Tue Feb 2 18:07:23 2016<br>
New Revision: 259611<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=259611&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=259611&view=rev</a><br>
Log:<br>
The compiler may use "line number 0" to indicate compiler generated goo that it can't<br>
track a source for. When we are pushing breakpoints and stepping past function prologues,<br>
also push past code from line 0 immediately following the prologue end.<br>
<br>
<rdar://problem/23730696><br>
<br>
Modified:<br>
lldb/trunk/include/lldb/Symbol/Function.h<br>
lldb/trunk/source/Symbol/Function.cpp<br>
<br>
Modified: lldb/trunk/include/lldb/Symbol/Function.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=259611&r1=259610&r2=259611&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=259611&r1=259610&r2=259611&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Symbol/Function.h (original)<br>
+++ lldb/trunk/include/lldb/Symbol/Function.h Tue Feb 2 18:07:23 2016<br>
@@ -574,6 +574,14 @@ public:<br>
CompilerType<br>
GetCompilerType ();<br>
<br>
+ //------------------------------------------------------------------<br>
+ /// Get the size of the prologue instructions for this function. The "prologue"<br>
+ /// instructions include any instructions given line number 0 immediately following<br>
+ /// the prologue end.<br>
+ ///<br>
+ /// @return<br>
+ /// The size of the prologue.<br>
+ //------------------------------------------------------------------<br>
uint32_t<br>
GetPrologueByteSize ();<br>
<br>
<br>
Modified: lldb/trunk/source/Symbol/Function.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=259611&r1=259610&r2=259611&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=259611&r1=259610&r2=259611&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Symbol/Function.cpp (original)<br>
+++ lldb/trunk/source/Symbol/Function.cpp Tue Feb 2 18:07:23 2016<br>
@@ -570,6 +570,8 @@ Function::GetPrologueByteSize ()<br>
{<br>
m_flags.Set(flagsCalculatedPrologueSize);<br>
LineTable* line_table = m_comp_unit->GetLineTable ();<br>
+ uint32_t prologue_end_line_idx = 0;<br>
+<br>
if (line_table)<br>
{<br>
LineEntry first_line_entry;<br>
@@ -578,9 +580,12 @@ Function::GetPrologueByteSize ()<br>
{<br>
// Make sure the first line entry isn't already the end of the prologue<br>
addr_t prologue_end_file_addr = LLDB_INVALID_ADDRESS;<br>
+ addr_t line_zero_end_file_addr = LLDB_INVALID_ADDRESS;<br>
+<br>
if (first_line_entry.is_prologue_end)<br>
{<br>
prologue_end_file_addr = first_line_entry.range.GetBaseAddress().GetFileAddress();<br>
+ prologue_end_line_idx = first_line_entry_idx;<br>
}<br>
else<br>
{<br>
@@ -595,6 +600,7 @@ Function::GetPrologueByteSize ()<br>
if (line_entry.is_prologue_end)<br>
{<br>
prologue_end_file_addr = line_entry.range.GetBaseAddress().GetFileAddress();<br>
+ prologue_end_line_idx = idx;<br>
break;<br>
}<br>
}<br>
@@ -607,7 +613,7 @@ Function::GetPrologueByteSize ()<br>
{<br>
// Check the first few instructions and look for one that has<br>
// a line number that's different than the first entry.<br>
- const uint32_t last_line_entry_idx = first_line_entry_idx + 6;<br>
+ uint32_t last_line_entry_idx = first_line_entry_idx + 6;<br>
for (uint32_t idx = first_line_entry_idx + 1; idx < last_line_entry_idx; ++idx)<br>
{<br>
LineEntry line_entry;<br>
@@ -616,6 +622,7 @@ Function::GetPrologueByteSize ()<br>
if (line_entry.line != first_line_entry.line)<br>
{<br>
prologue_end_file_addr = line_entry.range.GetBaseAddress().GetFileAddress();<br>
+ prologue_end_line_idx = idx;<br>
break;<br>
}<br>
}<br>
@@ -624,10 +631,37 @@ Function::GetPrologueByteSize ()<br>
if (prologue_end_file_addr == LLDB_INVALID_ADDRESS)<br>
{<br>
prologue_end_file_addr = first_line_entry.range.GetBaseAddress().GetFileAddress() + first_line_entry.range.GetByteSize();<br>
+ prologue_end_line_idx = first_line_entry_idx;<br>
}<br>
}<br>
+<br>
const addr_t func_start_file_addr = m_range.GetBaseAddress().GetFileAddress();<br>
const addr_t func_end_file_addr = func_start_file_addr + m_range.GetByteSize();<br>
+<br>
+ // Now calculate the offset to pass the subsequent line 0 entries.<br>
+ uint32_t first_non_zero_line = prologue_end_line_idx;<br>
+ while (1)<br>
+ {<br>
+ LineEntry line_entry;<br>
+ if (line_table->GetLineEntryAtIndex(first_non_zero_line, line_entry))<br>
+ {<br>
+ if (line_entry.line != 0)<br>
+ break;<br>
+ }<br>
+ if (line_entry.range.GetBaseAddress().GetFileAddress() >= func_end_file_addr)<br>
+ break;<br>
+<br>
+ first_non_zero_line++;<br>
+ }<br>
+<br>
+ if (first_non_zero_line > prologue_end_line_idx)<br>
+ {<br>
+ LineEntry first_non_zero_entry;<br>
+ if (line_table->GetLineEntryAtIndex(first_non_zero_line, first_non_zero_entry))<br>
+ {<br>
+ line_zero_end_file_addr = first_non_zero_entry.range.GetBaseAddress().GetFileAddress();<br>
+ }<br>
+ }<br>
<br>
// Verify that this prologue end file address in the function's<br>
// address range just to be sure<br>
@@ -635,10 +669,16 @@ Function::GetPrologueByteSize ()<br>
{<br>
m_prologue_byte_size = prologue_end_file_addr - func_start_file_addr;<br>
}<br>
+<br>
+ if (prologue_end_file_addr < line_zero_end_file_addr && line_zero_end_file_addr < func_end_file_addr)<br>
+ {<br>
+ m_prologue_byte_size += line_zero_end_file_addr - prologue_end_file_addr;<br>
+ }<br>
}<br>
}<br>
}<br>
- return m_prologue_byte_size;<br>
+<br>
+ return m_prologue_byte_size;<br>
}<br>
<br>
lldb::LanguageType<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>