LLDB mainline
ProcessFreeBSDKernelCore.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_PROCESSFREEBSDKERNELCORE_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_PROCESSFREEBSDKERNELCORE_H
11
12#include "lldb/Core/Debugger.h"
13#include "lldb/Core/Module.h"
15
16#include <kvm.h>
17
19public:
21 const lldb_private::FileSpec &core_file);
22
24
25 static lldb::ProcessSP
27 const lldb_private::FileSpec *crash_file_path,
28 bool can_connect);
29
30 static void Initialize();
31
32 static void DebuggerInitialize(lldb_private::Debugger &debugger);
33
34 static void Terminate();
35
36 static llvm::StringRef GetPluginNameStatic() { return "freebsd-kernel-core"; }
37
38 static llvm::StringRef GetPluginDescriptionStatic() {
39 return "FreeBSD kernel core debugging plug-in.";
40 }
41
42 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
43
44 bool CanDebug(lldb::TargetSP target_sp,
45 bool plugin_specified_by_name) override;
46
48
50
52
54
55 void RefreshStateAfterStop() override;
56
57 size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size,
58 lldb_private::Status &error) override;
59
60protected:
62
63 bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list,
64 lldb_private::ThreadList &new_thread_list) override;
65
66 size_t DoReadMemory(const lldb_private::ProcessAddress &addr, void *buf,
67 size_t size, lldb_private::Status &error) override;
68
69 lldb::addr_t FindSymbol(const char *name);
70
71private:
72 static inline thread_local lldb_private::Module *g_kvm_kernel_module =
73 nullptr;
74
75 static int ResolveKVMSymbol(const char *name, kvaddr_t *value);
76
77 static kvm_t *OpenKVM(const lldb::ModuleSP &kernel_module,
78 const lldb_private::FileSpec &core_file, int flags,
79 char *errbuf);
80
82
83 void PrintUnreadMessage();
84
85 const char *GetError();
86
87 std::unique_ptr<lldb_private::CommandObjectMultiword> m_command_sp;
88
90
91 kvm_t *m_kvm;
92};
93
94#endif // LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_PROCESSFREEBSDKERNELCORE_H
static llvm::raw_ostream & error(Stream &strm)
lldb_private::Status DoDestroy() override
static llvm::StringRef GetPluginNameStatic()
ProcessFreeBSDKernelCore(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec &core_file)
lldb::addr_t FindSymbol(const char *name)
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec *crash_file_path, bool can_connect)
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
static void DebuggerInitialize(lldb_private::Debugger &debugger)
static llvm::StringRef GetPluginDescriptionStatic()
lldb_private::Status DoLoadCore() override
static int ResolveKVMSymbol(const char *name, kvaddr_t *value)
lldb_private::CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
static thread_local lldb_private::Module * g_kvm_kernel_module
friend class CommandObjectProcessFreeBSDKernelCoreRefreshThreads
lldb_private::DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, lldb_private::Status &error) override
Actually do the writing of memory to a process.
bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
llvm::StringRef GetPluginName() override
static kvm_t * OpenKVM(const lldb::ModuleSP &kernel_module, const lldb_private::FileSpec &core_file, int flags, char *errbuf)
size_t DoReadMemory(const lldb_private::ProcessAddress &addr, void *buf, size_t size, lldb_private::Status &error) override
Actually do the reading of memory from a process.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
std::unique_ptr< lldb_private::CommandObjectMultiword > m_command_sp
A class to manage flag bits.
Definition Debugger.h:101
A plug-in interface definition class for dynamic loaders.
A file utility class.
Definition FileSpec.h:56
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
Base class for all processes that don't represent a live process, such as coredumps or processes trac...
An address in a process, qualified by an address space.
An error handling class.
Definition Status.h:118
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP