Don't indent log lines by frame # spaces if the frame # exceeds 100 - the indentation

gets to be a problem if you have a unbounded stack walk.

Fix the CFA sanity checks.  Add one to the arch default UnwindPlan run which was giving
one extra stack frame on the main thread.  Fix a couple of logging lines that had their
argument order incorrect.

llvm-svn: 117350
This commit is contained in:
Jason Molenda 2010-10-26 04:14:12 +00:00
parent ceb6b1393d
commit 49ea23e266
2 changed files with 46 additions and 33 deletions

View File

@ -128,12 +128,12 @@ RegisterContextLLDB::InitializeZerothFrame()
Log *log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND); Log *log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND);
// A couple of sanity checks.. // A couple of sanity checks..
if (m_cfa == (addr_t) -1 || m_cfa == 0 || m_cfa == 1) if (cfa_regval == LLDB_INVALID_ADDRESS || cfa_regval == 0 || cfa_regval == 1)
{ {
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not find a valid cfa address", log->Printf("%*sFrame %d could not find a valid cfa address",
m_frame_number, "", m_frame_number); m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
} }
m_frame_type = eNotAValidFrame; m_frame_type = eNotAValidFrame;
return; return;
@ -141,9 +141,9 @@ RegisterContextLLDB::InitializeZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx", log->Printf("%*sThread %d Frame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_thread.GetIndexID(), m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget())); (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()), (uint64_t) m_cfa);
} }
} }
@ -178,7 +178,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not get pc value", log->Printf("%*sFrame %d could not get pc value",
m_frame_number, "", m_frame_number); m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
} }
m_frame_type = eNotAValidFrame; m_frame_type = eNotAValidFrame;
return; return;
@ -193,7 +193,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d using architectural default unwind method", log->Printf("%*sFrame %d using architectural default unwind method",
m_frame_number, "", m_frame_number); m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
} }
ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch);
@ -213,17 +213,30 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d failed to get cfa value", log->Printf("%*sFrame %d failed to get cfa value",
m_frame_number, "", m_frame_number); m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
} }
m_frame_type = eNormalFrame; m_frame_type = eNormalFrame;
return; return;
} }
m_cfa = cfa_regval + cfa_offset; m_cfa = cfa_regval + cfa_offset;
// A couple of sanity checks..
if (cfa_regval == LLDB_INVALID_ADDRESS || cfa_regval == 0 || cfa_regval == 1)
{
if (log)
{
log->Printf("%*sFrame %d could not find a valid cfa address",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
}
m_frame_type = eNotAValidFrame;
return;
}
if (log) if (log)
{ {
log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx", log->Printf("%*sFrame %d initialized frame cfa is 0x%llx",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget())); (uint64_t) m_cfa);
} }
return; return;
} }
@ -295,7 +308,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d failed to get cfa reg %d/%d", log->Printf("%*sFrame %d failed to get cfa reg %d/%d",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
row_register_kind, active_row->GetCFARegister()); row_register_kind, active_row->GetCFARegister());
} }
m_frame_type = eNotAValidFrame; m_frame_type = eNotAValidFrame;
@ -306,12 +319,12 @@ RegisterContextLLDB::InitializeNonZerothFrame()
m_cfa = cfa_regval + cfa_offset; m_cfa = cfa_regval + cfa_offset;
// A couple of sanity checks.. // A couple of sanity checks..
if (m_cfa == (addr_t) -1 || m_cfa == 0 || m_cfa == 1) if (cfa_regval == LLDB_INVALID_ADDRESS || cfa_regval == 0 || cfa_regval == 1)
{ {
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not find a valid cfa address", log->Printf("%*sFrame %d could not find a valid cfa address",
m_frame_number, "", m_frame_number); m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
} }
m_frame_type = eNotAValidFrame; m_frame_type = eNotAValidFrame;
return; return;
@ -320,8 +333,8 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log) if (log)
{ {
log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx", log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget())); (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()), (uint64_t) m_cfa);
} }
} }
@ -479,7 +492,7 @@ RegisterContextLLDB::GetUnwindPlansForFrame (Address current_pc)
if (m_fast_unwind_plan) if (m_fast_unwind_plan)
has_fast = ", and has a fast UnwindPlan"; has_fast = ", and has a fast UnwindPlan";
log->Printf("%*sFrame %d frame uses %s for full UnwindPlan%s", log->Printf("%*sFrame %d frame uses %s for full UnwindPlan%s",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
m_full_unwind_plan->GetSourceName().GetCString(), has_fast); m_full_unwind_plan->GetSourceName().GetCString(), has_fast);
} }
@ -656,7 +669,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -666,7 +679,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d supplying caller's saved reg %d's location using FastUnwindPlan", log->Printf("%*sFrame %d supplying caller's saved reg %d's location using FastUnwindPlan",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
have_unwindplan_regloc = true; have_unwindplan_regloc = true;
@ -681,7 +694,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -693,7 +706,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log && IsLogVerbose ()) if (log && IsLogVerbose ())
{ {
log->Printf("%*sFrame %d supplying caller's saved reg %d's location using %s UnwindPlan", log->Printf("%*sFrame %d supplying caller's saved reg %d's location using %s UnwindPlan",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString()); lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString());
} }
} }
@ -709,7 +722,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d did not supply reg location for %d because it is volatile", log->Printf("%*sFrame %d did not supply reg location for %d because it is volatile",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -732,7 +745,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -747,7 +760,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -764,7 +777,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -798,7 +811,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
return false; return false;
@ -812,7 +825,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
if (log) if (log)
{ {
log->Printf("%*sFrame %d could not supply caller's reg %d location", log->Printf("%*sFrame %d could not supply caller's reg %d location",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_regnum); lldb_regnum);
} }
@ -897,7 +910,7 @@ RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data)
if (log && IsLogVerbose ()) if (log && IsLogVerbose ())
{ {
log->Printf("%*sFrame %d looking for register saved location for reg %d", log->Printf("%*sFrame %d looking for register saved location for reg %d",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_reg); lldb_reg);
} }
@ -907,7 +920,7 @@ RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data)
if (log) if (log)
{ {
log->Printf("%*sFrame %d passing along to the live register context for reg %d", log->Printf("%*sFrame %d passing along to the live register context for reg %d",
m_frame_number, "", m_frame_number, m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
lldb_reg); lldb_reg);
} }
return m_base_reg_ctx->ReadRegisterBytes (lldb_reg, data); return m_base_reg_ctx->ReadRegisterBytes (lldb_reg, data);

View File

@ -72,7 +72,7 @@ UnwindLLDB::GetFrameCount()
if (log) if (log)
{ {
log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk", log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
cur_idx, "", cur_idx); cur_idx < 100 ? cur_idx : 100, "", cur_idx);
} }
break; break;
} }
@ -82,7 +82,7 @@ UnwindLLDB::GetFrameCount()
if (log) if (log)
{ {
log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk", log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
cur_idx, "", cur_idx); cur_idx < 100 ? cur_idx : 100, "", cur_idx);
} }
break; break;
} }
@ -92,7 +92,7 @@ UnwindLLDB::GetFrameCount()
if (log) if (log)
{ {
log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk", log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
cur_idx, "", cur_idx); cur_idx < 100 ? cur_idx : 100, "", cur_idx);
} }
break; break;
} }
@ -102,7 +102,7 @@ UnwindLLDB::GetFrameCount()
if (log) if (log)
{ {
log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk", log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
cur_idx, "", cur_idx); cur_idx < 100 ? cur_idx : 100, "", cur_idx);
} }
break; break;
} }