diff options
12 files changed, 91 insertions, 24 deletions
diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 035a92e6486..c9f6083f6f7 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -70,7 +70,9 @@ private: uint8_t ptr_encoding; lldb_private::UnwindPlan::Row initial_row; - CIE(dw_offset_t offset) : cie_offset(offset), initial_row() {} + CIE(dw_offset_t offset) : cie_offset(offset), initial_row(), version (-1), + code_align (0), data_align (0), return_addr_reg_num (-1), + inst_offset (0), inst_length (0), ptr_encoding (0) {} }; typedef lldb::SharedPtr<CIE>::Type CIESP; @@ -80,6 +82,8 @@ private: AddressRange bounds; // function bounds dw_offset_t offset; // offset to this FDE within the Section + FDEEntry () : offset (0), bounds () { } + inline bool operator<(const DWARFCallFrameInfo::FDEEntry& b) const { diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h index 21833b58901..ea4e100858c 100644 --- a/lldb/include/lldb/Symbol/FuncUnwinders.h +++ b/lldb/include/lldb/Symbol/FuncUnwinders.h @@ -74,6 +74,8 @@ protected: Address m_first_non_prologue_insn; + DISALLOW_COPY_AND_ASSIGN (FuncUnwinders); + }; // class FuncUnwinders inline bool diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index e6b19477934..f021c550b78 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -59,7 +59,7 @@ public: isDWARFExpression // reg = eval(dwarf_expr) }; - RegisterLocation() : m_type(unspecified) { } + RegisterLocation() : m_type(unspecified), m_location() { } bool operator == (const RegisterLocation& rhs) const; @@ -175,8 +175,8 @@ public: } // Return the number of registers we have locations for - int - GetRegisterCount () const + int + GetRegisterCount () const { return m_register_locations.size(); } diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 63d893708a2..f5d7edd10fb 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -21,11 +21,19 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Interpreter/Options.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Core/Stream.h" #include "lldb/Target/StackFrame.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "lldb/Target/StackFrame.h" +#include "lldb/Target/Thread.h" +#include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Symbol/DWARFCallFrameInfo.h" +#include "lldb/Utility/ArchVolatileRegs.h" + #define DEFAULT_DISASM_BYTE_SIZE 32 using namespace lldb; @@ -252,7 +260,46 @@ CommandObjectDisassemble::Execute // The default action is to disassemble the current frame function. if (exe_ctx.frame) { - SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); +// SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + SymbolContext sc(exe_ctx.frame->GetSymbolContext (eSymbolContextEverything)); + + ArchVolatileRegs *vr = ArchVolatileRegs::FindPlugin (exe_ctx.target->GetArchitecture()); + Address pc = exe_ctx.frame->GetFrameCodeAddress(); + FuncUnwindersSP fu = pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (pc, sc); + if (fu != NULL) + { + + Address first_non_prologue_insn = fu->GetFirstNonPrologueInsn (*exe_ctx.target); + UnwindPlan *up = fu->GetUnwindPlanAtCallSite(); + Stream *s = &result.GetOutputStream(); + if (up) + { + s->Printf ("\nJSMDEBUG: unwind plan at call site (from eh_frame)\n"); + up->Dump (result.GetOutputStream(), &exe_ctx.frame->GetThread()); + } + else + { + result.GetOutputStream().Printf("No UnwindPlanAtCallSite available.\n"); + } + up = fu->GetUnwindPlanAtNonCallSite(exe_ctx.frame->GetThread()); + s->Printf ("\nJSMDEBUG: unwind plan at non-call site (from disassembly)\n"); + up->Dump (result.GetOutputStream(), &exe_ctx.frame->GetThread()); + + up = fu->GetUnwindPlanFastUnwind(exe_ctx.frame->GetThread()); + if (up) + { + s->Printf ("\nJSMDEBUG: fast unwind plan\n"); + up->Dump (result.GetOutputStream(), &exe_ctx.frame->GetThread()); + } + + up = fu->GetUnwindPlanArchitectureDefault(exe_ctx.frame->GetThread()); + if (up) + { + s->Printf ("\nJSMDEBUG: architectural default unwind plan\n"); + up->Dump (result.GetOutputStream(), &exe_ctx.frame->GetThread()); + } + } + if (sc.function) range = sc.function->GetAddressRange(); else if (sc.symbol && sc.symbol->GetAddressRangePtr()) diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp index e0fc02c3bec..f112a95dfc4 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp @@ -362,6 +362,7 @@ SyntaxForArchSpec (const ArchSpec &arch) ((strcasestr (arch_name, "i386") == arch_name) || (strcasestr (arch_name, "x86_64") == arch_name))) return kEDAssemblySyntaxX86ATT; +printf ("JSMDEBUG: Warning returning 'default' as the assembly syntax style\n"); return (EDAssemblySyntax_t)0; // default } @@ -382,6 +383,10 @@ DisassemblerLLVM::DisassemblerLLVM(const ArchSpec &arch) : char triple[256]; if (TripleForArchSpec (arch, triple, sizeof(triple))) { +printf ("JSMDEBUG: Getting disassembler for triple %s\n", triple); +if (strcmp (triple, "x86_64-unknown-unknown") == 0) + strcpy (triple, "x86_64-apple-darwin"); +printf ("JSMDEBUG: Getting disassembler for triple fixed %s\n", triple); assert(!EDGetDisassembler(&m_disassembler, triple, SyntaxForArchSpec (arch)) && "No disassembler created!"); } } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 5b7ea7203ce..28ef513f49b 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -34,7 +34,8 @@ RegisterContextLLDB::RegisterContextLLDB (Thread& thread, RegisterContext (thread), m_thread(thread), m_next_frame(next_frame), m_sym_ctx(sym_ctx), m_all_registers_available(false), m_registers(), m_cfa (LLDB_INVALID_ADDRESS), m_start_pc (), m_current_pc (), m_frame_number (frame_number), - m_full_unwind_plan(NULL), m_fast_unwind_plan(NULL) + m_full_unwind_plan(NULL), m_fast_unwind_plan(NULL), m_base_reg_ctx (), m_frame_type (-1), + m_current_offset (0), m_sym_ctx_valid (false) { m_sym_ctx.Clear(); m_sym_ctx_valid = false; @@ -498,7 +499,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame () if (m_frame_type == eSigtrampFrame) { m_fast_unwind_plan = NULL; - UnwindPlan *up = fu->GetUnwindPlanAtCallSite (); + up = fu->GetUnwindPlanAtCallSite (); if (up->PlanValidAtAddress (m_current_pc)) { return up; diff --git a/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp index e0f99d9255c..8521231e6e6 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp @@ -162,10 +162,15 @@ private: int m_wordsize; int m_cpu; + + DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86); }; AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_cpu(cpu), m_func_bounds(func) + m_target (target), m_thread (thread), m_cpu(cpu), m_func_bounds(func), + m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), + m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), + m_wordsize (-1), m_cur_insn () { int *initialized_flag = NULL; m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; @@ -519,7 +524,7 @@ AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) m_cur_insn = m_func_bounds.GetBaseAddress (); int current_func_text_offset = 0; int current_sp_bytes_offset_from_cfa = 0; - UnwindPlan::Row::RegisterLocation regloc; + UnwindPlan::Row::RegisterLocation initial_regloc; if (!m_cur_insn.IsValid()) { @@ -535,13 +540,13 @@ AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) row.SetCFAOffset (m_wordsize); // caller's stack pointer value before the call insn is the CFA address - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (m_lldb_sp_regnum, regloc); + initial_regloc.SetIsCFAPlusOffset (0); + row.SetRegisterInfo (m_lldb_sp_regnum, initial_regloc); // saved instruction pointer can be found at CFA - wordsize. current_sp_bytes_offset_from_cfa = m_wordsize; - regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); - row.SetRegisterInfo (m_lldb_ip_regnum, regloc); + initial_regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); + row.SetRegisterInfo (m_lldb_ip_regnum, initial_regloc); unwind_plan.AppendRow (row); diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp index 9fdd05d9563..8fb7763b287 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -35,7 +35,7 @@ UnwindLLDB::GetFrameCount() if (m_frames.empty()) { // First, set up the 0th (initial) frame - CursorSP first_cursor_sp(new Cursor); + CursorSP first_cursor_sp(new Cursor ()); RegisterContextSP no_frame; // an empty shared pointer RegisterContextLLDB *first_register_ctx = new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0); if (!first_register_ctx->IsValid()) @@ -55,16 +55,16 @@ UnwindLLDB::GetFrameCount() } // Reuse the StackFrame provided by the processor native machine context for the first frame first_register_ctx->SetStackFrame (m_thread.GetStackFrameAtIndex(0).get()); - RegisterContextSP temp_rcs(first_register_ctx); - first_cursor_sp->reg_ctx = temp_rcs; + RegisterContextSP first_register_ctx_sp(first_register_ctx); + first_cursor_sp->reg_ctx = first_register_ctx_sp; m_frames.push_back (first_cursor_sp); // Now walk up the rest of the stack while (1) { - CursorSP cursor_sp(new Cursor); + CursorSP cursor_sp(new Cursor ()); RegisterContextLLDB *register_ctx; - int cur_idx = m_frames.size (); + uint32_t cur_idx = m_frames.size (); register_ctx = new RegisterContextLLDB (m_thread, m_frames[cur_idx - 1]->reg_ctx, cursor_sp->sctx, cur_idx); if (!register_ctx->IsValid()) { @@ -106,10 +106,10 @@ UnwindLLDB::GetFrameCount() } break; } - RegisterContextSP temp_rcs(register_ctx); - StackFrame *frame = new StackFrame(cur_idx, cur_idx, m_thread, temp_rcs, cursor_sp->cfa, cursor_sp->start_pc, &(cursor_sp->sctx)); + RegisterContextSP register_ctx_sp(register_ctx); + StackFrame *frame = new StackFrame(cur_idx, cur_idx, m_thread, register_ctx_sp, cursor_sp->cfa, cursor_sp->start_pc, &(cursor_sp->sctx)); register_ctx->SetStackFrame (frame); - cursor_sp->reg_ctx = temp_rcs; + cursor_sp->reg_ctx = register_ctx_sp; m_frames.push_back (cursor_sp); } } diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h index f281269690d..128a4a7d20f 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h @@ -56,6 +56,7 @@ private: lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } + DISALLOW_COPY_AND_ASSIGN (Cursor); }; typedef lldb::SharedPtr<Cursor>::Type CursorSP; diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index d6667340e3e..7e06e78cfed 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -26,6 +26,8 @@ #include "Utility/StringExtractorGDBRemote.h" #include "UnwindLibUnwind.h" #include "UnwindMacOSXFrameBackchain.h" +#include "UnwindLLDB.h" +#include "RegisterContextLLDB.h" using namespace lldb; using namespace lldb_private; @@ -128,7 +130,7 @@ ThreadGDBRemote::GetUnwinder () const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ()); if (target_arch == ArchSpec("x86_64") || target_arch == ArchSpec("i386")) { - m_unwinder_ap.reset (new UnwindLibUnwind (*this, GetGDBProcess().GetLibUnwindAddressSpace())); + m_unwinder_ap.reset (new UnwindLLDB (*this)); } else { diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index ee2c68baa48..849d0668912 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -35,7 +35,8 @@ DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile& objfile, SectionSP& section, m_cfi_data_initialized (false), m_fde_index (), m_fde_index_initialized (false), - m_is_eh_frame (is_eh_frame) + m_is_eh_frame (is_eh_frame), + m_flags () { } diff --git a/lldb/source/Symbol/FuncUnwinders.cpp b/lldb/source/Symbol/FuncUnwinders.cpp index 5ce4d25fc0a..e813d05d5b8 100644 --- a/lldb/source/Symbol/FuncUnwinders.cpp +++ b/lldb/source/Symbol/FuncUnwinders.cpp @@ -105,7 +105,6 @@ FuncUnwinders::GetUnwindPlanArchitectureDefault (Thread& thread) Address current_pc; Target *target = thread.CalculateTarget(); - ArchSpec arch; if (target) { ArchSpec arch = target->GetArchitecture (); |