[Lldb-commits] [lldb] r218808 - Add a new SBExecutionContext class that wraps an ExecutionContextRef. This class is a convenient way at the API level to package a target, process, thread and frame all together - or just a subset of those

Enrico Granata egranata at apple.com
Wed Oct 1 13:43:46 PDT 2014


Author: enrico
Date: Wed Oct  1 15:43:45 2014
New Revision: 218808

URL: http://llvm.org/viewvc/llvm-project?rev=218808&view=rev
Log:
Add a new SBExecutionContext class that wraps an ExecutionContextRef. This class is a convenient way at the API level to package a target,process,thread and frame all together - or just a subset of those

Added:
    lldb/trunk/include/lldb/API/SBExecutionContext.h
    lldb/trunk/scripts/Python/interface/SBExecutionContext.i
    lldb/trunk/source/API/SBExecutionContext.cpp
Modified:
    lldb/trunk/include/lldb/API/LLDB.h
    lldb/trunk/include/lldb/API/SBDefines.h
    lldb/trunk/include/lldb/API/SBFrame.h
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/lldb.swig

Modified: lldb/trunk/include/lldb/API/LLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/LLDB.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/LLDB.h (original)
+++ lldb/trunk/include/lldb/API/LLDB.h Wed Oct  1 15:43:45 2014
@@ -29,6 +29,7 @@
 #include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
+#include "lldb/API/SBExecutionContext.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Wed Oct  1 15:43:45 2014
@@ -45,6 +45,7 @@ class LLDB_API SBDeclaration;
 class LLDB_API SBError;
 class LLDB_API SBEvent;
 class LLDB_API SBEventList;
+class LLDB_API SBExecutionContext;
 class LLDB_API SBExpressionOptions;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;

Added: lldb/trunk/include/lldb/API/SBExecutionContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBExecutionContext.h?rev=218808&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SBExecutionContext.h (added)
+++ lldb/trunk/include/lldb/API/SBExecutionContext.h Wed Oct  1 15:43:45 2014
@@ -0,0 +1,70 @@
+//===-- SBExecutionContext.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_SBExecutionContext_h_
+#define LLDB_SBExecutionContext_h_
+
+#include "lldb/API/SBDefines.h"
+
+#include <stdio.h>
+#include <vector>
+
+
+namespace lldb {
+    
+class SBExecutionContext
+{
+public:
+    SBExecutionContext();
+    
+    SBExecutionContext (const lldb::SBExecutionContext &rhs);
+    
+    SBExecutionContext (const lldb::SBTarget &target);
+    
+    SBExecutionContext (const lldb::SBProcess &process);
+    
+    SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function
+    
+    SBExecutionContext (const lldb::SBFrame &frame);
+    
+    ~SBExecutionContext();
+    
+    const SBExecutionContext &
+    operator = (const lldb::SBExecutionContext &rhs);
+    
+    SBTarget
+    GetTarget () const;
+    
+    SBProcess
+    GetProcess () const;
+
+    SBThread
+    GetThread () const;
+
+    SBFrame
+    GetFrame () const;
+    
+protected:
+    ExecutionContextRefSP &
+    GetSP () const;
+    
+    void
+    reset (lldb::ExecutionContextRefSP &event_sp);
+    
+    lldb_private::ExecutionContextRef *
+    get () const;
+    
+private:
+    
+    mutable lldb::ExecutionContextRefSP m_exe_ctx_sp;
+};
+    
+} // namespace lldb
+
+#endif  // LLDB_SBExecutionContext_h_

Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Wed Oct  1 15:43:45 2014
@@ -206,6 +206,7 @@ public:
 protected:
 
     friend class SBBlock;
+    friend class SBExecutionContext;
     friend class SBInstruction;
     friend class SBThread;
     friend class SBValue;

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Wed Oct  1 15:43:45 2014
@@ -326,6 +326,7 @@ protected:
     friend class SBBreakpointLocation;
     friend class SBCommandInterpreter;
     friend class SBDebugger;
+    friend class SBExecutionContext;
     friend class SBFunction;
     friend class SBModule;
     friend class SBTarget;

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct  1 15:43:45 2014
@@ -933,6 +933,7 @@ protected:
     friend class SBAddress;
     friend class SBBlock;
     friend class SBDebugger;
+    friend class SBExecutionContext;
     friend class SBFunction;
     friend class SBInstruction;
     friend class SBModule;

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Wed Oct  1 15:43:45 2014
@@ -231,6 +231,7 @@ public:
 protected:
     friend class SBBreakpoint;
     friend class SBBreakpointLocation;
+    friend class SBExecutionContext;
     friend class SBFrame;
     friend class SBProcess;
     friend class SBDebugger;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Oct  1 15:43:45 2014
@@ -639,6 +639,7 @@
 		8CCB018219BA4E270009FD44 /* SBThreadCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CCB018119BA4E210009FD44 /* SBThreadCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8CCB018319BA51BF0009FD44 /* SBThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017F19BA4DD00009FD44 /* SBThreadCollection.cpp */; };
 		94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; };
+		940B02F619DC96E700AD0F52 /* SBExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940B02F519DC96E700AD0F52 /* SBExecutionContext.cpp */; };
 		94145431175E63B500284436 /* lldb-versioning.h in Headers */ = {isa = PBXBuildFile; fileRef = 94145430175D7FDE00284436 /* lldb-versioning.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568614E355F2003A195C /* SBTypeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568714E355F2003A195C /* SBTypeFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1970,6 +1971,9 @@
 		94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; };
 		94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
 		94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; };
+		940B02F419DC96CB00AD0F52 /* SBExecutionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBExecutionContext.h; path = include/lldb/API/SBExecutionContext.h; sourceTree = "<group>"; };
+		940B02F519DC96E700AD0F52 /* SBExecutionContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBExecutionContext.cpp; path = source/API/SBExecutionContext.cpp; sourceTree = "<group>"; };
+		940B02F719DC970900AD0F52 /* SBExecutionContext.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBExecutionContext.i; sourceTree = "<group>"; };
 		94145430175D7FDE00284436 /* lldb-versioning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-versioning.h"; path = "include/lldb/lldb-versioning.h"; sourceTree = "<group>"; };
 		94380B8019940B0300BFE4A8 /* StringLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringLexer.h; path = include/lldb/Utility/StringLexer.h; sourceTree = "<group>"; };
 		94380B8119940B0A00BFE4A8 /* StringLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringLexer.cpp; path = source/Utility/StringLexer.cpp; sourceTree = "<group>"; };
@@ -2653,6 +2657,7 @@
 				9452573616262CD000325455 /* SBDeclaration.i */,
 				2611FEFA142D83060017FEA3 /* SBError.i */,
 				2611FEFB142D83060017FEA3 /* SBEvent.i */,
+				940B02F719DC970900AD0F52 /* SBExecutionContext.i */,
 				2611FEFC142D83060017FEA3 /* SBFileSpec.i */,
 				2611FEFD142D83060017FEA3 /* SBFileSpecList.i */,
 				2611FEFE142D83060017FEA3 /* SBFrame.i */,
@@ -2744,6 +2749,8 @@
 				2682F284115EF3A700CCFF99 /* SBError.cpp */,
 				9A9830FE1125FC5800A56CB0 /* SBEvent.h */,
 				9A9830FD1125FC5800A56CB0 /* SBEvent.cpp */,
+				940B02F419DC96CB00AD0F52 /* SBExecutionContext.h */,
+				940B02F519DC96E700AD0F52 /* SBExecutionContext.cpp */,
 				4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */,
 				4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */,
 				26022531115F27FA00A601A2 /* SBFileSpec.h */,
@@ -4876,6 +4883,7 @@
 				9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */,
 				262F12B51835468600AEB384 /* SBPlatform.cpp in Sources */,
 				9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */,
+				940B02F619DC96E700AD0F52 /* SBExecutionContext.cpp in Sources */,
 				9461569D14E358A6003A195C /* SBTypeSynthetic.cpp in Sources */,
 				26680324116005D9008E1FE4 /* SBThread.cpp in Sources */,
 				26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */,

Modified: lldb/trunk/scripts/Python/build-swig-Python.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Wed Oct  1 15:43:45 2014
@@ -91,6 +91,7 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/l
 " ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\
 " ${SRC_ROOT}/include/lldb/API/SBError.h"\
 " ${SRC_ROOT}/include/lldb/API/SBEvent.h"\
+" ${SRC_ROOT}/include/lldb/API/SBExecutionContext.h"\
 " ${SRC_ROOT}/include/lldb/API/SBExpressionOptions.h"\
 " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\
 " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\
@@ -141,6 +142,7 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/Pyt
 " ${SRC_ROOT}/scripts/Python/interface/SBDeclaration.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBError.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBEvent.i"\
+" ${SRC_ROOT}/scripts/Python/interface/SBExecutionContext.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBExpressionOptions.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBFileSpec.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBFrame.i"\

Added: lldb/trunk/scripts/Python/interface/SBExecutionContext.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBExecutionContext.i?rev=218808&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBExecutionContext.i (added)
+++ lldb/trunk/scripts/Python/interface/SBExecutionContext.i Wed Oct  1 15:43:45 2014
@@ -0,0 +1,42 @@
+//===-- SWIG Interface for SBExecutionContext ---------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+    
+class SBExecutionContext
+{
+public:
+    SBExecutionContext();
+    
+    SBExecutionContext (const lldb::SBExecutionContext &rhs);
+    
+    SBExecutionContext (const lldb::SBTarget &target);
+    
+    SBExecutionContext (const lldb::SBProcess &process);
+    
+    SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function
+    
+    SBExecutionContext (const lldb::SBFrame &frame);
+    
+    ~SBExecutionContext();
+    
+    SBTarget
+    GetTarget () const;
+    
+    SBProcess
+    GetProcess () const;
+    
+    SBThread
+    GetThread () const;
+    
+    SBFrame
+    GetFrame () const;
+};
+    
+} // namespace lldb

Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=218808&r1=218807&r2=218808&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Oct  1 15:43:45 2014
@@ -66,6 +66,7 @@ import os
 #include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
+#include "lldb/API/SBExecutionContext.h"
 #include "lldb/API/SBExpressionOptions.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpecList.h"
@@ -139,6 +140,7 @@ import os
 %include "./Python/interface/SBDeclaration.i"
 %include "./Python/interface/SBError.i"
 %include "./Python/interface/SBEvent.i"
+%include "./Python/interface/SBExecutionContext.i"
 %include "./Python/interface/SBExpressionOptions.i"
 %include "./Python/interface/SBFileSpec.i"
 %include "./Python/interface/SBFileSpecList.i"

Added: lldb/trunk/source/API/SBExecutionContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBExecutionContext.cpp?rev=218808&view=auto
==============================================================================
--- lldb/trunk/source/API/SBExecutionContext.cpp (added)
+++ lldb/trunk/source/API/SBExecutionContext.cpp Wed Oct  1 15:43:45 2014
@@ -0,0 +1,118 @@
+//===-- SBExecutionContext.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/API/SBExecutionContext.h"
+
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBThread.h"
+#include "lldb/API/SBFrame.h"
+
+#include "lldb/Target/ExecutionContext.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBExecutionContext::SBExecutionContext() :
+m_exe_ctx_sp()
+{
+}
+
+SBExecutionContext::SBExecutionContext (const lldb::SBExecutionContext &rhs) :
+m_exe_ctx_sp(rhs.m_exe_ctx_sp)
+{
+}
+
+SBExecutionContext::SBExecutionContext (const lldb::SBTarget &target) :
+m_exe_ctx_sp(new ExecutionContextRef())
+{
+    m_exe_ctx_sp->SetTargetSP(target.GetSP());
+}
+
+SBExecutionContext::SBExecutionContext (const lldb::SBProcess &process) :
+m_exe_ctx_sp(new ExecutionContextRef())
+{
+    m_exe_ctx_sp->SetProcessSP(process.GetSP());
+}
+
+SBExecutionContext::SBExecutionContext (lldb::SBThread thread) :
+m_exe_ctx_sp(new ExecutionContextRef())
+{
+    m_exe_ctx_sp->SetThreadPtr(thread.get());
+}
+
+SBExecutionContext::SBExecutionContext (const lldb::SBFrame &frame) :
+m_exe_ctx_sp(new ExecutionContextRef())
+{
+    m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());
+}
+
+SBExecutionContext::~SBExecutionContext()
+{
+}
+
+const SBExecutionContext &
+SBExecutionContext::operator = (const lldb::SBExecutionContext &rhs)
+{
+    m_exe_ctx_sp = rhs.m_exe_ctx_sp;
+    return *this;
+}
+
+SBTarget
+SBExecutionContext::GetTarget () const
+{
+    SBTarget sb_target;
+    if (m_exe_ctx_sp)
+    {
+        TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());
+        if (target_sp)
+            sb_target.SetSP(target_sp);
+    }
+    return sb_target;
+}
+
+SBProcess
+SBExecutionContext::GetProcess () const
+{
+    SBProcess sb_process;
+    if (m_exe_ctx_sp)
+    {
+        ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());
+        if (process_sp)
+            sb_process.SetSP(process_sp);
+    }
+    return sb_process;
+}
+
+SBThread
+SBExecutionContext::GetThread () const
+{
+    SBThread sb_thread;
+    if (m_exe_ctx_sp)
+    {
+        ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());
+        if (thread_sp)
+            sb_thread.SetThread(thread_sp);
+    }
+    return sb_thread;
+}
+
+SBFrame
+SBExecutionContext::GetFrame () const
+{
+    SBFrame sb_frame;
+    if (m_exe_ctx_sp)
+    {
+        StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());
+        if (frame_sp)
+            sb_frame.SetFrameSP(frame_sp);
+    }
+    return sb_frame;
+}
+





More information about the lldb-commits mailing list