[Lldb-commits] [lldb] r194245 - Add History subclasses for Thread, Unwind, RegisterContext.

Jason Molenda jmolenda at apple.com
Thu Nov 7 20:59:55 PST 2013


Author: jmolenda
Date: Thu Nov  7 22:59:54 2013
New Revision: 194245

URL: http://llvm.org/viewvc/llvm-project?rev=194245&view=rev
Log:
Add History subclasses for Thread, Unwind, RegisterContext.
Still working out some of the details of these classes but 
I wanted to get the overall structure checked in.
<rdar://problem/15314068> 

Added:
    lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp
    lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h
    lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp
    lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.h
Modified:
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=194245&r1=194244&r2=194245&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Nov  7 22:59:54 2013
@@ -599,6 +599,12 @@
 		9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; };
 		9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; };
 		A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A36FF33B17D8E94600244D40 /* OptionParser.cpp */; };
+		AF061F87182C97ED00B6A19C /* RegisterContextHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF061F85182C97ED00B6A19C /* RegisterContextHistory.cpp */; };
+		AF061F88182C97ED00B6A19C /* RegisterContextHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = AF061F86182C97ED00B6A19C /* RegisterContextHistory.h */; };
+		AF061F8B182C980000B6A19C /* HistoryThread.h in Headers */ = {isa = PBXBuildFile; fileRef = AF061F89182C980000B6A19C /* HistoryThread.h */; };
+		AF061F8C182C980000B6A19C /* HistoryUnwind.h in Headers */ = {isa = PBXBuildFile; fileRef = AF061F8A182C980000B6A19C /* HistoryUnwind.h */; };
+		AF1729D6182C907200E0AB97 /* HistoryThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1729D4182C907200E0AB97 /* HistoryThread.cpp */; };
+		AF1729D7182C907200E0AB97 /* HistoryUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */; };
 		AF254E31170CCC33007AE5C9 /* PlatformDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF254E2F170CCC33007AE5C9 /* PlatformDarwinKernel.cpp */; };
 		AF254E32170CCC33007AE5C9 /* PlatformDarwinKernel.h in Headers */ = {isa = PBXBuildFile; fileRef = AF254E30170CCC33007AE5C9 /* PlatformDarwinKernel.h */; };
 		AF37E10A17C861F20061E18E /* ProcessRunLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF37E10917C861F20061E18E /* ProcessRunLock.cpp */; };
@@ -1737,6 +1743,12 @@
 		9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBreakpointLocation.cpp; path = source/API/SBBreakpointLocation.cpp; sourceTree = "<group>"; };
 		A36FF33B17D8E94600244D40 /* OptionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionParser.cpp; sourceTree = "<group>"; };
 		A36FF33D17D8E98800244D40 /* OptionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionParser.h; path = include/lldb/Host/OptionParser.h; sourceTree = "<group>"; };
+		AF061F85182C97ED00B6A19C /* RegisterContextHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextHistory.cpp; path = Utility/RegisterContextHistory.cpp; sourceTree = "<group>"; };
+		AF061F86182C97ED00B6A19C /* RegisterContextHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextHistory.h; path = Utility/RegisterContextHistory.h; sourceTree = "<group>"; };
+		AF061F89182C980000B6A19C /* HistoryThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryThread.h; path = Utility/HistoryThread.h; sourceTree = "<group>"; };
+		AF061F8A182C980000B6A19C /* HistoryUnwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryUnwind.h; path = Utility/HistoryUnwind.h; sourceTree = "<group>"; };
+		AF1729D4182C907200E0AB97 /* HistoryThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HistoryThread.cpp; path = Utility/HistoryThread.cpp; sourceTree = "<group>"; };
+		AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HistoryUnwind.cpp; path = Utility/HistoryUnwind.cpp; sourceTree = "<group>"; };
 		AF254E2F170CCC33007AE5C9 /* PlatformDarwinKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformDarwinKernel.cpp; sourceTree = "<group>"; };
 		AF254E30170CCC33007AE5C9 /* PlatformDarwinKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDarwinKernel.h; sourceTree = "<group>"; };
 		AF37E10917C861F20061E18E /* ProcessRunLock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessRunLock.cpp; sourceTree = "<group>"; };
@@ -2544,6 +2556,10 @@
 				26954EBD1401EE8B00294D09 /* DynamicRegisterInfo.h */,
 				B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */,
 				B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */,
+				AF1729D4182C907200E0AB97 /* HistoryThread.cpp */,
+				AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */,
+				AF061F89182C980000B6A19C /* HistoryThread.h */,
+				AF061F8A182C980000B6A19C /* HistoryUnwind.h */,
 				AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */,
 				AF68D3301255A110002FF25B /* UnwindLLDB.h */,
 				26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */,
@@ -2554,6 +2570,8 @@
 				26957D9713D381C900670048 /* RegisterContextDarwin_x86_64.h */,
 				944372DA171F6B4300E57C32 /* RegisterContextDummy.cpp */,
 				944372DB171F6B4300E57C32 /* RegisterContextDummy.h */,
+				AF061F85182C97ED00B6A19C /* RegisterContextHistory.cpp */,
+				AF061F86182C97ED00B6A19C /* RegisterContextHistory.h */,
 				AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */,
 				AF68D2551255416E002FF25B /* RegisterContextLLDB.h */,
 				262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */,
@@ -3610,10 +3628,12 @@
 				260CC63615D04377002BF2E0 /* OptionValueFormat.h in Headers */,
 				26D1804516CEE12500EDFB5B /* KQueue.h in Headers */,
 				260CC63715D04377002BF2E0 /* OptionValueSInt64.h in Headers */,
+				AF061F8C182C980000B6A19C /* HistoryUnwind.h in Headers */,
 				260CC63815D04377002BF2E0 /* OptionValueString.h in Headers */,
 				260CC63915D04377002BF2E0 /* OptionValueUInt64.h in Headers */,
 				260CC63A15D04377002BF2E0 /* OptionValueUUID.h in Headers */,
 				260A248E15D06C50009981B0 /* OptionValues.h in Headers */,
+				AF061F88182C97ED00B6A19C /* RegisterContextHistory.h in Headers */,
 				26DAED6015D327A200E15819 /* OptionValuePathMappings.h in Headers */,
 				26ACEC2815E077AE00E94760 /* Property.h in Headers */,
 				26491E3B15E1DB8600CBFFC2 /* OptionValueRegex.h in Headers */,
@@ -3623,6 +3643,7 @@
 				947A1D651616476B0017C8D1 /* CommandObjectPlugin.h in Headers */,
 				262ED0051631FA2800879631 /* OptionGroupString.h in Headers */,
 				944372DD171F6B4300E57C32 /* RegisterContextDummy.h in Headers */,
+				AF061F8B182C980000B6A19C /* HistoryThread.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -4050,6 +4071,7 @@
 				2689003813353E0400698AC0 /* DataExtractor.cpp in Sources */,
 				2689003913353E0400698AC0 /* Debugger.cpp in Sources */,
 				2689003A13353E0400698AC0 /* Disassembler.cpp in Sources */,
+				AF1729D7182C907200E0AB97 /* HistoryUnwind.cpp in Sources */,
 				2689003B13353E0400698AC0 /* EmulateInstruction.cpp in Sources */,
 				2689003C13353E0400698AC0 /* Error.cpp in Sources */,
 				2689003D13353E0400698AC0 /* Event.cpp in Sources */,
@@ -4146,6 +4168,7 @@
 				2689009F13353E4200698AC0 /* ProcessGDBRemote.cpp in Sources */,
 				268900A013353E4200698AC0 /* ProcessGDBRemoteLog.cpp in Sources */,
 				268900A113353E4200698AC0 /* ThreadGDBRemote.cpp in Sources */,
+				AF1729D6182C907200E0AB97 /* HistoryThread.cpp in Sources */,
 				268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */,
 				268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */,
 				268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,
@@ -4267,6 +4290,7 @@
 				263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */,
 				264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */,
 				26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */,
+				AF061F87182C97ED00B6A19C /* RegisterContextHistory.cpp in Sources */,
 				267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */,
 				26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */,
 				AF81DEFA1828A23F0042CF19 /* SystemRuntime.cpp in Sources */,

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=194245&r1=194244&r2=194245&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Thu Nov  7 22:59:54 2013
@@ -1303,7 +1303,8 @@ SBThread::GetExtendedBacktrace (const ch
                 if (runtime)
                 {
                     ThreadSP origin_thread = runtime->GetExtendedBacktrace (real_thread, type_const);
-                    sb_origin_thread.SetThread (origin_thread);
+                    if (origin_thread && origin_thread->IsValid())
+                        sb_origin_thread.SetThread (origin_thread);
                 }
             }
         }

Modified: lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt?rev=194245&r1=194244&r2=194245&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt Thu Nov  7 22:59:54 2013
@@ -4,16 +4,19 @@ set(LLVM_NO_RTTI 1)
 
 add_lldb_library(lldbPluginProcessUtility
   DynamicRegisterInfo.cpp
+  HistoryThread.cpp
+  HistoryUnwind.cpp
   InferiorCallPOSIX.cpp
   RegisterContextDarwin_arm.cpp
   RegisterContextDarwin_i386.cpp
   RegisterContextDarwin_x86_64.cpp
   RegisterContextDummy.cpp
+  RegisterContextHistory.cpp
   RegisterContextLLDB.cpp
+  RegisterContextMacOSXFrameBackchain.cpp
   RegisterContextMach_arm.cpp
   RegisterContextMach_i386.cpp
   RegisterContextMach_x86_64.cpp
-  RegisterContextMacOSXFrameBackchain.cpp
   RegisterContextMemory.cpp
   RegisterContextThreadMemory.cpp
   StopInfoMachException.cpp

Added: lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp Thu Nov  7 22:59:54 2013
@@ -0,0 +1,68 @@
+//===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-private.h"
+
+#include "Plugins/Process/Utility/HistoryUnwind.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
+#include "Plugins/Process/Utility/RegisterContextHistory.h"
+
+#include "lldb/Target/StackFrameList.h"
+#include "lldb/Target/Process.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+HistoryThread::HistoryThread (lldb_private::Process &process, 
+                              std::vector<lldb::addr_t> pcs, 
+                              uint32_t stop_id, 
+                              bool stop_id_is_valid) : 
+        Thread (process, LLDB_INVALID_THREAD_ID),
+        m_framelist_mutex(),
+        m_framelist(),
+        m_pcs (pcs),
+        m_stop_id (stop_id),
+        m_stop_id_is_valid (stop_id_is_valid)
+{
+    m_unwinder_ap.reset (new HistoryUnwind (*this, pcs, stop_id, stop_id_is_valid));
+}
+
+HistoryThread::~HistoryThread ()
+{
+}
+
+lldb::RegisterContextSP
+HistoryThread::GetRegisterContext ()
+{
+    RegisterContextSP rctx ;
+    if (m_pcs.size() > 0)
+    {
+        rctx.reset (new RegisterContextHistory (*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
+    }
+    return rctx;
+
+}
+
+lldb::RegisterContextSP
+HistoryThread::CreateRegisterContextForFrame (StackFrame *frame)
+{
+    return m_unwinder_ap->CreateRegisterContextForFrame (frame);
+}
+
+lldb::StackFrameListSP
+HistoryThread::GetStackFrameList ()
+{
+    Mutex::Locker (m_framelist_mutex);
+    if (m_framelist.get() == NULL)
+    {
+        m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true));
+    }
+
+    return m_framelist;
+}

Added: lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h Thu Nov  7 22:59:54 2013
@@ -0,0 +1,57 @@
+//===-- HistoryThread.h -----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_HistoryThread_h_
+#define liblldb_HistoryThread_h_
+
+#include "lldb/lldb-private.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Core/Broadcaster.h"
+#include "lldb/Core/Event.h"
+#include "lldb/Core/UserID.h"
+#include "lldb/Core/UserSettingsController.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Target/StackFrameList.h"
+#include "lldb/Target/Thread.h"
+
+namespace lldb_private {
+
+class HistoryThread : public lldb_private::Thread
+{
+public:
+    HistoryThread (lldb_private::Process &process, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid);
+
+    virtual ~HistoryThread ();
+
+    virtual lldb::RegisterContextSP
+    GetRegisterContext ();
+
+    virtual lldb::RegisterContextSP
+    CreateRegisterContextForFrame (StackFrame *frame);
+
+    virtual void
+    RefreshStateAfterStop() { }
+
+    bool
+    CalculateStopInfo () { return false; }
+
+protected:
+    virtual lldb::StackFrameListSP
+    GetStackFrameList ();
+
+    mutable Mutex               m_framelist_mutex;
+    lldb::StackFrameListSP      m_framelist;
+    std::vector<lldb::addr_t>   m_pcs;
+    uint32_t                    m_stop_id;
+    bool                        m_stop_id_is_valid;
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_HistoryThread_h_

Added: lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp Thu Nov  7 22:59:54 2013
@@ -0,0 +1,79 @@
+//===-- HistoryUnwind.cpp ---------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-private.h"
+
+#include "Plugins/Process/Utility/RegisterContextHistory.h"
+#include "Plugins/Process/Utility/HistoryUnwind.h"
+
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+HistoryUnwind::HistoryUnwind (Thread &thread,
+                              std::vector<lldb::addr_t> pcs,
+                              uint32_t stop_id,
+                              bool stop_id_is_valid) :
+        Unwind (thread),
+        m_pcs (pcs),
+        m_stop_id (stop_id),
+        m_stop_id_is_valid (stop_id_is_valid)
+{
+}
+
+HistoryUnwind::~HistoryUnwind ()
+{
+}
+
+void
+HistoryUnwind::DoClear ()
+{
+    Mutex::Locker locker(m_unwind_mutex);
+    m_pcs.clear();
+    m_stop_id_is_valid = false;
+}
+
+lldb::RegisterContextSP
+HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame)
+{
+    RegisterContextSP rctx;
+    if (frame)
+    {
+        addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress (&frame->GetThread()->GetProcess()->GetTarget());
+        if (pc != LLDB_INVALID_ADDRESS)
+        {
+            rctx.reset (new RegisterContextHistory (*frame->GetThread().get(), frame->GetConcreteFrameIndex(), 
+                        frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
+        }
+    }
+    return rctx;
+}
+
+bool
+HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc)
+{
+    Mutex::Locker (m_unwind_mutex);
+    if (frame_idx < m_pcs.size())
+    {
+        cfa = frame_idx;
+        pc = m_pcs[frame_idx];
+        return true;
+    }
+    return false;
+}
+
+uint32_t
+HistoryUnwind::DoGetFrameCount ()
+{
+    return m_pcs.size();
+}

Added: lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h Thu Nov  7 22:59:54 2013
@@ -0,0 +1,51 @@
+//===-- HistoryUnwind.h -----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_HistoryUnwind_h_
+#define liblldb_HistoryUnwind_h_
+
+#include <vector>
+
+#include "lldb/lldb-private.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Target/Unwind.h"
+
+namespace lldb_private {
+
+class HistoryUnwind : public lldb_private::Unwind
+{
+public:
+    HistoryUnwind (Thread &thread, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid);
+
+    virtual ~HistoryUnwind ();
+
+protected:
+    void
+    DoClear();
+
+    lldb::RegisterContextSP
+    DoCreateRegisterContextForFrame (StackFrame *frame);
+
+    bool
+    DoGetFrameInfoAtIndex (uint32_t frame_idx,
+                           lldb::addr_t& cfa, 
+                           lldb::addr_t& pc);
+    uint32_t
+    DoGetFrameCount ();
+
+private:
+
+    std::vector<lldb::addr_t>   m_pcs;
+    uint32_t                    m_stop_id;
+    bool                        m_stop_id_is_valid;
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_HistoryUnwind_h_

Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp Thu Nov  7 22:59:54 2013
@@ -0,0 +1,138 @@
+//===-- RegisterContextHistory.cpp ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/DynamicLoader.h"
+
+#include "RegisterContextHistory.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+RegisterContextHistory::RegisterContextHistory (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size, addr_t pc_value) :
+RegisterContext (thread, concrete_frame_idx),
+    m_pc_value (pc_value)
+{
+    m_reg_set0.name = "General Purpose Registers";
+    m_reg_set0.short_name = "GPR";
+    m_reg_set0.num_registers = 1;
+    m_reg_set0.registers = new uint32_t(0);
+    
+    m_pc_reg_info.name = "pc";
+    m_pc_reg_info.alt_name = "pc";
+    m_pc_reg_info.byte_offset = 0;
+    m_pc_reg_info.byte_size = address_byte_size;
+    m_pc_reg_info.encoding = eEncodingUint;
+    m_pc_reg_info.format = eFormatPointer;
+    m_pc_reg_info.invalidate_regs = NULL;
+    m_pc_reg_info.value_regs = NULL;
+    m_pc_reg_info.kinds[eRegisterKindGCC] = LLDB_INVALID_REGNUM;
+    m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
+    m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+    m_pc_reg_info.kinds[eRegisterKindGDB] = LLDB_INVALID_REGNUM;
+    m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
+}
+
+RegisterContextHistory::~RegisterContextHistory ()
+{
+    delete m_reg_set0.registers;
+    delete m_pc_reg_info.invalidate_regs;
+    delete m_pc_reg_info.value_regs;
+}
+
+void
+RegisterContextHistory::InvalidateAllRegisters () {}
+
+size_t
+RegisterContextHistory::GetRegisterCount ()
+{
+    return 1;
+}
+
+const lldb_private::RegisterInfo *
+RegisterContextHistory::GetRegisterInfoAtIndex (size_t reg)
+{
+    if (reg)
+        return NULL;
+    return &m_pc_reg_info;
+}
+
+size_t
+RegisterContextHistory::GetRegisterSetCount ()
+{
+    return 1;
+}
+
+const lldb_private::RegisterSet *
+RegisterContextHistory::GetRegisterSet (size_t reg_set)
+{
+    if (reg_set)
+        return NULL;
+    return &m_reg_set0;
+}
+
+bool
+RegisterContextHistory::ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
+{
+    if (!reg_info)
+        return false;
+    uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
+    if (reg_number == LLDB_REGNUM_GENERIC_PC)
+    {
+        value.SetUInt(m_pc_value, reg_info->byte_size);
+        return true;
+    }
+    return false;
+}
+
+bool
+RegisterContextHistory::WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
+{
+    return false;
+}
+
+bool
+RegisterContextHistory::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+{
+    return false;
+}
+
+bool
+RegisterContextHistory::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
+{
+    return false;
+}
+
+uint32_t
+RegisterContextHistory::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num)
+{
+    if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
+        return 0;
+    return LLDB_INVALID_REGNUM;
+}

Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.h?rev=194245&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.h Thu Nov  7 22:59:54 2013
@@ -0,0 +1,79 @@
+//===-- RegisterContextHistory.h ----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_RegisterContextHistory_h_
+#define lldb_RegisterContextHistory_h_
+
+#include <vector>
+
+#include "lldb/lldb-private.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+namespace lldb_private {
+    
+class RegisterContextHistory : public lldb_private::RegisterContext
+{
+public:
+    typedef std::shared_ptr<RegisterContextHistory> SharedPtr;
+    
+    RegisterContextHistory (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size, lldb::addr_t pc_value);
+    
+    ///
+    // pure virtual functions from the base class that we must implement
+    ///
+
+    virtual
+    ~RegisterContextHistory ();
+
+    virtual void
+    InvalidateAllRegisters ();
+
+    virtual size_t
+    GetRegisterCount ();
+
+    virtual const lldb_private::RegisterInfo *
+    GetRegisterInfoAtIndex (size_t reg);
+
+    virtual size_t
+    GetRegisterSetCount ();
+
+    virtual const lldb_private::RegisterSet *
+    GetRegisterSet (size_t reg_set);
+
+    virtual bool
+    ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
+
+    virtual bool
+    WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
+    virtual bool
+    ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
+
+    virtual bool
+    WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
+
+    virtual uint32_t
+    ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
+    
+private:
+    //------------------------------------------------------------------
+    // For RegisterContextLLDB only
+    //------------------------------------------------------------------
+    
+    lldb_private::RegisterSet m_reg_set0; // register set 0 (PC only)
+    lldb_private::RegisterInfo m_pc_reg_info;
+
+    lldb::addr_t m_pc_value;
+    
+    DISALLOW_COPY_AND_ASSIGN (RegisterContextHistory);
+};
+} // namespace lldb_private
+
+#endif  // lldb_RegisterContextHistory_h_





More information about the lldb-commits mailing list