[Lldb-commits] [lldb] r117343 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp UnwindAssemblyProfiler-x86.cpp UnwindLLDB.cpp
Jason Molenda
jmolenda at apple.com
Mon Oct 25 17:47:17 PDT 2010
Author: jmolenda
Date: Mon Oct 25 19:47:17 2010
New Revision: 117343
URL: http://llvm.org/viewvc/llvm-project?rev=117343&view=rev
Log:
Get a disassembler based on the correct architecture for assembly
prologue profiling.
Change the log print statements to elide the thread number, make
some of them only print when IsLogVerbose().
Add a couple of sanity checks for impossible CFA values so backtraces
don't go too far off into the weeds.
Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=117343&r1=117342&r2=117343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Oct 25 19:47:17 2010
@@ -126,10 +126,23 @@
m_cfa = cfa_regval + cfa_offset;
Log *log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND);
+
+ // A couple of sanity checks..
+ if (m_cfa == (addr_t) -1 || m_cfa == 0 || m_cfa == 1)
+ {
+ if (log)
+ {
+ log->Printf("%*sFrame %d could not find a valid cfa address",
+ m_frame_number, "", m_frame_number);
+ }
+ m_frame_type = eNotAValidFrame;
+ return;
+ }
+
if (log)
{
- log->Printf("%*sThread %u Frame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
+ m_frame_number, "", m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()));
}
}
@@ -164,8 +177,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d could not get pc value",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number);
+ log->Printf("%*sFrame %d could not get pc value",
+ m_frame_number, "", m_frame_number);
}
m_frame_type = eNotAValidFrame;
return;
@@ -179,8 +192,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d using architectural default unwind method",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number);
+ log->Printf("%*sFrame %d using architectural default unwind method",
+ m_frame_number, "", m_frame_number);
}
ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch);
@@ -199,8 +212,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d failed to get cfa value",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number);
+ log->Printf("%*sFrame %d failed to get cfa value",
+ m_frame_number, "", m_frame_number);
}
m_frame_type = eNormalFrame;
return;
@@ -208,8 +221,8 @@
m_cfa = cfa_regval + cfa_offset;
if (log)
{
- log->Printf("%*sThread %u Frame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
+ m_frame_number, "", m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()));
}
return;
@@ -281,8 +294,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d failed to get cfa reg %d/%d",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d failed to get cfa reg %d/%d",
+ m_frame_number, "", m_frame_number,
row_register_kind, active_row->GetCFARegister());
}
m_frame_type = eNotAValidFrame;
@@ -292,10 +305,22 @@
m_cfa = cfa_regval + cfa_offset;
+ // A couple of sanity checks..
+ if (m_cfa == (addr_t) -1 || m_cfa == 0 || m_cfa == 1)
+ {
+ if (log)
+ {
+ log->Printf("%*sFrame %d could not find a valid cfa address",
+ m_frame_number, "", m_frame_number);
+ }
+ m_frame_type = eNotAValidFrame;
+ return;
+ }
+
if (log)
{
- log->Printf("%*sThread %u Frame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
+ m_frame_number, "", m_frame_number,
(uint64_t) m_cfa, (uint64_t) current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()));
}
}
@@ -448,13 +473,13 @@
}
Log *log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND);
- if (log)
+ if (log && IsLogVerbose())
{
const char *has_fast = "";
if (m_fast_unwind_plan)
has_fast = ", and has a fast UnwindPlan";
- log->Printf("%*sThread %u Frame %d frame uses %s for full UnwindPlan%s",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d frame uses %s for full UnwindPlan%s",
+ m_frame_number, "", m_frame_number,
m_full_unwind_plan->GetSourceName().GetCString(), has_fast);
}
@@ -630,8 +655,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -640,8 +665,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d supplying caller's saved reg %d's location using FastUnwindPlan",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d supplying caller's saved reg %d's location using FastUnwindPlan",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
have_unwindplan_regloc = true;
@@ -655,8 +680,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -665,10 +690,10 @@
if (active_row->GetRegisterInfo (row_regnum, unwindplan_regloc))
{
have_unwindplan_regloc = true;
- if (log)
+ if (log && IsLogVerbose ())
{
- log->Printf("%*sThread %u Frame %d supplying caller's saved reg %d's location using %s UnwindPlan",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d supplying caller's saved reg %d's location using %s UnwindPlan",
+ m_frame_number, "", m_frame_number,
lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString());
}
}
@@ -683,8 +708,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d did not supply reg location for %d because it is volatile",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d did not supply reg location for %d because it is volatile",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -702,18 +727,12 @@
new_regloc.location.register_number = lldb_regnum;
m_registers[lldb_regnum] = new_regloc;
regloc = new_regloc;
- if (log)
- {
- log->Printf("%*sThread %u Frame %d register %d is in the thread's live register context",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
- lldb_regnum);
- }
return true;
}
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -727,8 +746,8 @@
m_registers[lldb_regnum] = new_regloc;
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -744,8 +763,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -778,8 +797,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
return false;
@@ -792,8 +811,8 @@
if (log)
{
- log->Printf("%*sThread %u Frame %d could not supply caller's reg %d location",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d could not supply caller's reg %d location",
+ m_frame_number, "", m_frame_number,
lldb_regnum);
}
@@ -875,10 +894,10 @@
if (!IsValid())
return false;
- if (log)
+ if (log && IsLogVerbose ())
{
- log->Printf("%*sThread %u Frame %d looking for register saved location for reg %d",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d looking for register saved location for reg %d",
+ m_frame_number, "", m_frame_number,
lldb_reg);
}
@@ -887,8 +906,8 @@
{
if (log)
{
- log->Printf("%*sThread %u Frame %d passing along to the live register context for reg %d",
- m_frame_number, "", m_thread.GetIndexID(), m_frame_number,
+ log->Printf("%*sFrame %d passing along to the live register context for reg %d",
+ m_frame_number, "", m_frame_number,
lldb_reg);
}
return m_base_reg_ctx->ReadRegisterBytes (lldb_reg, data);
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=117343&r1=117342&r2=117343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Mon Oct 25 19:47:17 2010
@@ -480,14 +480,14 @@
const char *triple;
// FIXME should probably pass down the ArchSpec and work from that to make a portable triple
if (m_cpu == k_i386)
- triple = "i386-apple-darwin";
+ triple = "i386-unknown-unknown";
else
- triple = "x86_64-apple-darwin";
+ triple = "x86_64-unknown-unknown";
EDDisassemblerRef disasm;
EDInstRef cur_insn;
- if (EDGetDisassembler (&disasm, "i386-apple-darwin", kEDAssemblySyntaxX86ATT) != 0)
+ if (EDGetDisassembler (&disasm, triple, kEDAssemblySyntaxX86ATT) != 0)
{
return false;
}
@@ -565,7 +565,15 @@
unwind_plan.AppendRow (row);
goto loopnext;
}
-
+
+ if (mov_rsp_rbp_pattern_p ())
+ {
+ row.SetOffset (current_func_text_offset + insn_len);
+ row.SetCFARegister (m_lldb_fp_regnum);
+ unwind_plan.AppendRow (row);
+ goto loopnext;
+ }
+
// This is the start() function (or a pthread equivalent), it starts with a pushl $0x0 which puts the
// saved pc value of 0 on the stack. In this case we want to pretend we didn't see a stack movement at all --
// normally the saved pc value is already on the stack by the time the function starts executing.
@@ -617,14 +625,6 @@
goto loopnext;
}
- if (mov_rsp_rbp_pattern_p ())
- {
- row.SetOffset (current_func_text_offset + insn_len);
- row.SetCFARegister (m_lldb_fp_regnum);
- unwind_plan.AppendRow (row);
- goto loopnext;
- }
-
if (ret_pattern_p ())
{
// we know where the end of the function is; set the limit on the PlanValidAddressRange
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=117343&r1=117342&r2=117343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Mon Oct 25 19:47:17 2010
@@ -71,8 +71,8 @@
delete register_ctx;
if (log)
{
- log->Printf("%*sThread %u Frame %d invalid RegisterContext for this frame, stopping stack walk",
- cur_idx, "", m_thread.GetIndexID(), cur_idx);
+ log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
+ cur_idx, "", cur_idx);
}
break;
}
@@ -81,8 +81,18 @@
delete register_ctx;
if (log)
{
- log->Printf("%*sThread %u Frame %d did not get CFA for this frame, stopping stack walk",
- cur_idx, "", m_thread.GetIndexID(), cur_idx);
+ log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
+ cur_idx, "", cur_idx);
+ }
+ break;
+ }
+ if (cursor.cfa == (addr_t) -1 || cursor.cfa == 1 || cursor.cfa == 0)
+ {
+ delete register_ctx;
+ if (log)
+ {
+ log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
+ cur_idx, "", cur_idx);
}
break;
}
@@ -91,8 +101,8 @@
delete register_ctx;
if (log)
{
- log->Printf("%*sThread %u Frame %d did not get PC for this frame, stopping stack walk",
- cur_idx, "", m_thread.GetIndexID(), cur_idx);
+ log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
+ cur_idx, "", cur_idx);
}
break;
}
More information about the lldb-commits
mailing list