1 //===-- SystemRuntime.h -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_SystemRuntime_h_
11 #define liblldb_SystemRuntime_h_
15 // Other libraries and framework includes
19 #include "lldb/lldb-public.h"
20 #include "lldb/Core/ConstString.h"
21 #include "lldb/Core/ModuleList.h"
22 #include "lldb/Core/PluginInterface.h"
23 #include "lldb/lldb-private.h"
26 namespace lldb_private {
28 //----------------------------------------------------------------------
29 /// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h"
30 /// @brief A plug-in interface definition class for system runtimes.
32 /// The system runtime plugins can collect information from the system
33 /// libraries during a Process' lifetime and provide information about
34 /// how objects/threads were originated.
36 /// For instance, a system runtime plugin use a breakpoint when threads
37 /// are created to record the backtrace of where that thread was created.
38 /// Later, when backtracing the created thread, it could extend the backtrace
39 /// to show where it was originally created from.
41 /// The plugin will insert its own breakpoint when Created and start collecting
42 /// information. Later when it comes time to augment a Thread, it can be
43 /// asked to provide that information.
45 //----------------------------------------------------------------------
48 public PluginInterface
51 //------------------------------------------------------------------
52 /// Find a system runtime plugin for a given process.
54 /// Scans the installed SystemRuntime plugins and tries to find
55 /// an instance that can be used to track image changes in \a
58 /// @param[in] process
59 /// The process for which to try and locate a system runtime
61 //------------------------------------------------------------------
63 FindPlugin (Process *process);
65 //------------------------------------------------------------------
66 /// Construct with a process.
67 // -----------------------------------------------------------------
68 SystemRuntime(lldb_private::Process *process);
70 //------------------------------------------------------------------
73 /// The destructor is virtual since this class is designed to be
74 /// inherited by the plug-in instance.
75 //------------------------------------------------------------------
79 //------------------------------------------------------------------
80 /// Called after attaching to a process.
82 /// Allow the SystemRuntime plugin to execute some code after attaching
84 //------------------------------------------------------------------
88 //------------------------------------------------------------------
89 /// Called after launching a process.
91 /// Allow the SystemRuntime plugin to execute some code after launching
93 //------------------------------------------------------------------
97 //------------------------------------------------------------------
98 /// Called when modules have been loaded in the process.
100 /// Allow the SystemRuntime plugin to enable logging features in the
101 /// system runtime libraries.
102 //------------------------------------------------------------------
104 ModulesDidLoad(lldb_private::ModuleList &module_list);
107 //------------------------------------------------------------------
108 /// Return a list of thread origin extended backtraces that may
111 /// A System Runtime may be able to provide a backtrace of when this
112 /// thread was originally created. Furthermore, it may be able to
113 /// provide that extended backtrace for different styles of creation.
114 /// On a system with both pthreads and libdispatch, aka Grand Central
115 /// Dispatch, queues, the system runtime may be able to provide the
116 /// pthread creation of the thread and it may also be able to provide
117 /// the backtrace of when this GCD queue work block was enqueued.
118 /// The caller may request these different origins by name.
120 /// The names will be provided in the order that they are most likely
121 /// to be requested. For instance, a most natural order may be to
122 /// request the GCD libdispatch queue origin. If there is none, then
123 /// request the pthread origin.
126 /// A vector of ConstStrings with names like "pthread" or "libdispatch".
127 /// An empty vector may be returned if no thread origin extended
128 /// backtrace capabilities are available.
129 //------------------------------------------------------------------
130 virtual const std::vector<ConstString> &
131 GetExtendedBacktraceTypes ();
133 //------------------------------------------------------------------
134 /// Return a Thread which shows the origin of this thread's creation.
136 /// This likely returns a HistoryThread which shows how thread was
137 /// originally created (e.g. "pthread" type), or how the work that
138 /// is currently executing on it was originally enqueued (e.g.
139 /// "libdispatch" type).
141 /// There may be a chain of thread-origins; it may be informative to
142 /// the end user to query the returned ThreadSP for its origins as
145 /// @param [in] thread
146 /// The thread to examine.
149 /// The type of thread origin being requested. The types supported
150 /// are returned from SystemRuntime::GetExtendedBacktraceTypes.
153 /// A ThreadSP which will have a StackList of frames. This Thread will
154 /// not appear in the Process' list of current threads. Normal thread
155 /// operations like stepping will not be available. This is a historical
156 /// view thread and may be only useful for showing a backtrace.
158 /// An empty ThreadSP will be returned if no thread origin is available.
159 //------------------------------------------------------------------
160 virtual lldb::ThreadSP
161 GetExtendedBacktraceThread (lldb::ThreadSP thread, ConstString type);
164 //------------------------------------------------------------------
166 //------------------------------------------------------------------
169 std::vector<ConstString> m_types;
172 DISALLOW_COPY_AND_ASSIGN (SystemRuntime);
175 } // namespace lldb_private
177 #endif // liblldb_SystemRuntime_h_