<rdar://problem/11852100>

The "stop-line-count-after" and "stop-line-count-before" settings are broken. This fixes them.

llvm-svn: 160071
This commit is contained in:
Greg Clayton 2012-07-11 20:33:48 +00:00
parent 1fa2acaed4
commit 53eb7ad2f7
8 changed files with 61 additions and 81 deletions

View File

@ -167,9 +167,7 @@ public:
bool bool
GetStatus (Stream &strm, GetStatus (Stream &strm,
bool show_frame_info, bool show_frame_info,
bool show_source, bool show_source);
uint32_t source_lines_before,
uint32_t source_lines_after);
protected: protected:
friend class StackFrameList; friend class StackFrameList;

View File

@ -76,9 +76,7 @@ public:
uint32_t first_frame, uint32_t first_frame,
uint32_t num_frames, uint32_t num_frames,
bool show_frame_info, bool show_frame_info,
uint32_t num_frames_with_source, uint32_t num_frames_with_source);
uint32_t source_lines_before,
uint32_t source_lines_after);
protected: protected:

View File

@ -762,9 +762,7 @@ public:
uint32_t first_frame, uint32_t first_frame,
uint32_t num_frames, uint32_t num_frames,
bool show_frame_info, bool show_frame_info,
uint32_t num_frames_with_source, uint32_t num_frames_with_source);
uint32_t source_lines_before,
uint32_t source_lines_after);
// We need a way to verify that even though we have a thread in a shared // We need a way to verify that even though we have a thread in a shared
// pointer that the object itself is still valid. Currently this won't be // pointer that the object itself is still valid. Currently this won't be

View File

@ -282,14 +282,7 @@ protected:
bool show_frame_info = true; bool show_frame_info = true;
bool show_source = !already_shown; bool show_source = !already_shown;
Debugger &debugger = m_interpreter.GetDebugger(); if (frame->GetStatus (result.GetOutputStream(), show_frame_info, show_source))
const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
if (frame->GetStatus (result.GetOutputStream(),
show_frame_info,
show_source,
source_lines_before,
source_lines_after))
{ {
result.SetStatus (eReturnStatusSuccessFinishResult); result.SetStatus (eReturnStatusSuccessFinishResult);
return result.Succeeded(); return result.Succeeded();

View File

@ -2630,7 +2630,7 @@ DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var
if (new_value != UINT32_MAX) if (new_value != UINT32_MAX)
m_stop_source_before_count = new_value; m_stop_source_before_count = new_value;
else else
err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextAfterName ().GetCString()); err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextBeforeName ().GetCString());
} }
else if (var_name == StopSourceContextAfterName ()) else if (var_name == StopSourceContextAfterName ())
{ {
@ -2638,7 +2638,7 @@ DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var
if (new_value != UINT32_MAX) if (new_value != UINT32_MAX)
m_stop_source_after_count = new_value; m_stop_source_after_count = new_value;
else else
err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextBeforeName ().GetCString()); err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextAfterName ().GetCString());
} }
else if (var_name == StopDisassemblyCountName ()) else if (var_name == StopDisassemblyCountName ())
{ {
@ -2703,13 +2703,13 @@ DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
else if (var_name == StopSourceContextAfterName ()) else if (var_name == StopSourceContextAfterName ())
{ {
StreamString strm; StreamString strm;
strm.Printf ("%u", m_stop_source_before_count); strm.Printf ("%u", m_stop_source_after_count);
value.AppendString (strm.GetData()); value.AppendString (strm.GetData());
} }
else if (var_name == StopSourceContextBeforeName ()) else if (var_name == StopSourceContextBeforeName ())
{ {
StreamString strm; StreamString strm;
strm.Printf ("%u", m_stop_source_after_count); strm.Printf ("%u", m_stop_source_before_count);
value.AppendString (strm.GetData()); value.AppendString (strm.GetData());
} }
else if (var_name == StopDisassemblyCountName ()) else if (var_name == StopDisassemblyCountName ())

View File

@ -1296,10 +1296,9 @@ StackFrame::HasCachedData () const
bool bool
StackFrame::GetStatus (Stream& strm, StackFrame::GetStatus (Stream& strm,
bool show_frame_info, bool show_frame_info,
bool show_source, bool show_source)
uint32_t source_lines_before,
uint32_t source_lines_after)
{ {
if (show_frame_info) if (show_frame_info)
{ {
strm.Indent(); strm.Indent();
@ -1312,56 +1311,62 @@ StackFrame::GetStatus (Stream& strm,
bool have_source = false; bool have_source = false;
DebuggerInstanceSettings::StopDisassemblyType disasm_display = DebuggerInstanceSettings::eStopDisassemblyTypeNever; DebuggerInstanceSettings::StopDisassemblyType disasm_display = DebuggerInstanceSettings::eStopDisassemblyTypeNever;
Target *target = exe_ctx.GetTargetPtr(); Target *target = exe_ctx.GetTargetPtr();
if (target && (source_lines_before || source_lines_after)) if (target)
{ {
GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); Debugger &debugger = target->GetDebugger();
const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
disasm_display = debugger.GetStopDisassemblyDisplay ();
if (m_sc.comp_unit && m_sc.line_entry.IsValid()) if (source_lines_before > 0 || source_lines_after > 0)
{ {
if (target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file, GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
m_sc.line_entry.line,
source_lines_before, if (m_sc.comp_unit && m_sc.line_entry.IsValid())
source_lines_after,
"->",
&strm))
{ {
have_source = true; if (target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
m_sc.line_entry.line,
source_lines_before,
source_lines_after,
"->",
&strm))
{
have_source = true;
}
} }
} }
disasm_display = target->GetDebugger().GetStopDisassemblyDisplay (); switch (disasm_display)
} {
case DebuggerInstanceSettings::eStopDisassemblyTypeNever:
switch (disasm_display)
{
case DebuggerInstanceSettings::eStopDisassemblyTypeNever:
break;
case DebuggerInstanceSettings::eStopDisassemblyTypeNoSource:
if (have_source)
break; break;
// Fall through to next case
case DebuggerInstanceSettings::eStopDisassemblyTypeAlways: case DebuggerInstanceSettings::eStopDisassemblyTypeNoSource:
if (target) if (have_source)
{ break;
const uint32_t disasm_lines = target->GetDebugger().GetDisassemblyLineCount(); // Fall through to next case
if (disasm_lines > 0) case DebuggerInstanceSettings::eStopDisassemblyTypeAlways:
if (target)
{ {
const ArchSpec &target_arch = target->GetArchitecture(); const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
AddressRange pc_range; if (disasm_lines > 0)
pc_range.GetBaseAddress() = GetFrameCodeAddress(); {
pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize()); const ArchSpec &target_arch = target->GetArchitecture();
Disassembler::Disassemble (target->GetDebugger(), AddressRange pc_range;
target_arch, pc_range.GetBaseAddress() = GetFrameCodeAddress();
NULL, pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
exe_ctx, Disassembler::Disassemble (target->GetDebugger(),
pc_range, target_arch,
disasm_lines, NULL,
0, exe_ctx,
Disassembler::eOptionMarkPCAddress, pc_range,
strm); disasm_lines,
0,
Disassembler::eOptionMarkPCAddress,
strm);
}
} }
break;
} }
break;
} }
} }
return true; return true;

View File

@ -587,9 +587,7 @@ StackFrameList::GetStatus (Stream& strm,
uint32_t first_frame, uint32_t first_frame,
uint32_t num_frames, uint32_t num_frames,
bool show_frame_info, bool show_frame_info,
uint32_t num_frames_with_source, uint32_t num_frames_with_source)
uint32_t source_lines_before,
uint32_t source_lines_after)
{ {
size_t num_frames_displayed = 0; size_t num_frames_displayed = 0;
@ -614,9 +612,7 @@ StackFrameList::GetStatus (Stream& strm,
if (!frame_sp->GetStatus (strm, if (!frame_sp->GetStatus (strm,
show_frame_info, show_frame_info,
num_frames_with_source > first_frame - frame_idx, num_frames_with_source > (first_frame - frame_idx)))
source_lines_before,
source_lines_after))
break; break;
++num_frames_displayed; ++num_frames_displayed;
} }

View File

@ -1321,16 +1321,12 @@ Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint
strm.IndentMore(); strm.IndentMore();
const bool show_frame_info = true; const bool show_frame_info = true;
const uint32_t source_lines_before = 3;
const uint32_t source_lines_after = 3;
strm.IndentMore (); strm.IndentMore ();
num_frames_shown = GetStackFrameList ()->GetStatus (strm, num_frames_shown = GetStackFrameList ()->GetStatus (strm,
start_frame, start_frame,
num_frames, num_frames,
show_frame_info, show_frame_info,
num_frames_with_source, num_frames_with_source);
source_lines_before,
source_lines_after);
strm.IndentLess(); strm.IndentLess();
strm.IndentLess(); strm.IndentLess();
} }
@ -1342,17 +1338,13 @@ Thread::GetStackFrameStatus (Stream& strm,
uint32_t first_frame, uint32_t first_frame,
uint32_t num_frames, uint32_t num_frames,
bool show_frame_info, bool show_frame_info,
uint32_t num_frames_with_source, uint32_t num_frames_with_source)
uint32_t source_lines_before,
uint32_t source_lines_after)
{ {
return GetStackFrameList()->GetStatus (strm, return GetStackFrameList()->GetStatus (strm,
first_frame, first_frame,
num_frames, num_frames,
show_frame_info, show_frame_info,
num_frames_with_source, num_frames_with_source);
source_lines_before,
source_lines_after);
} }
bool bool