blob: c75d1ca2e5f485f65fafc07248d3b97e904a21d9 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- OperatingSystem.h ----------------------------------------------*- C++
2//-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_OperatingSystem_h_
11#define liblldb_OperatingSystem_h_
12
13
14#include "lldb/Core/PluginInterface.h"
15#include "lldb/lldb-private.h"
16
17namespace lldb_private {
18
19/// \class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h"
20/// A plug-in interface definition class for halted OS helpers.
21///
22/// Halted OS plug-ins can be used by any process to locate and create
23/// OS objects, like threads, during the lifetime of a debug session.
24/// This is commonly used when attaching to an operating system that is
25/// halted, such as when debugging over JTAG or connecting to low level kernel
26/// debug services.
27
28class OperatingSystem : public PluginInterface {
29public:
30 /// Find a halted OS plugin for a given process.
31 ///
32 /// Scans the installed OperatingSystem plug-ins and tries to find an
33 /// instance that matches the current target triple and executable.
34 ///
35 /// \param[in] process
36 /// The process for which to try and locate a halted OS
37 /// plug-in instance.
38 ///
39 /// \param[in] plugin_name
40 /// An optional name of a specific halted OS plug-in that
41 /// should be used. If NULL, pick the best plug-in.
42 static OperatingSystem *FindPlugin(Process *process, const char *plugin_name);
43
44 // Class Methods
45 OperatingSystem(Process *process);
46
47 ~OperatingSystem() override;
48
49 // Plug-in Methods
50 virtual bool UpdateThreadList(ThreadList &old_thread_list,
51 ThreadList &real_thread_list,
52 ThreadList &new_thread_list) = 0;
53
54 virtual void ThreadWasSelected(Thread *thread) = 0;
55
56 virtual lldb::RegisterContextSP
57 CreateRegisterContextForThread(Thread *thread,
58 lldb::addr_t reg_data_addr) = 0;
59
60 virtual lldb::StopInfoSP CreateThreadStopReason(Thread *thread) = 0;
61
62 virtual lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) {
63 return lldb::ThreadSP();
64 }
65
66 virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp);
67
68protected:
69 // Member variables.
70 Process
71 *m_process; ///< The process that this dynamic loader plug-in is tracking.
72private:
73 DISALLOW_COPY_AND_ASSIGN(OperatingSystem);
74};
75
76} // namespace lldb_private
77
78#endif // liblldb_OperatingSystem_h_