LLDB mainline
NativeThreadLinux.h
Go to the documentation of this file.
1//===-- NativeThreadLinux.h ----------------------------------- -*- C++ -*-===//
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 liblldb_NativeThreadLinux_H_
10#define liblldb_NativeThreadLinux_H_
11
16
17#include "llvm/ADT/StringRef.h"
18
19#include <csignal>
20#include <map>
21#include <memory>
22#include <string>
23
24namespace lldb_private {
25namespace process_linux {
26
27class NativeProcessLinux;
28
30 friend class NativeProcessLinux;
31
32public:
34
35 // NativeThreadProtocol Interface
36 std::string GetName() override;
37
38 lldb::StateType GetState() override;
39
40 bool GetStopReason(ThreadStopInfo &stop_info,
41 std::string &description) override;
42
44 return *m_reg_context_up;
45 }
46
47 Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
48 bool hardware) override;
49
51
52 Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
53
55
57
58 const NativeProcessLinux &GetProcess() const;
59
60 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
61 GetSiginfo() const override;
62
63private:
64 // Interface for friend classes
65
66 /// Resumes the thread. If \p signo is anything but
67 /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
68 Status Resume(uint32_t signo);
69
70 /// Single steps the thread. If \p signo is anything but
71 /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
72 Status SingleStep(uint32_t signo);
73
74 void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
75
76 /// Return true if the thread is stopped.
77 /// If stopped by a signal, indicate the signo in the signo argument.
78 /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
79 bool IsStopped(int *signo);
80
81 void SetStoppedByExec();
82
84
85 void SetStoppedByWatchpoint(uint32_t wp_index);
86
88
90
91 void SetStoppedByTrace();
92
93 void SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid);
94
96
98
99 void SetStoppedByProcessorTrace(llvm::StringRef description);
100
101 void SetExited();
102
104
105 // Private interface
106 void MaybeLogStateChange(lldb::StateType new_state);
107
108 void SetStopped();
109
110 /// Extend m_stop_description with logical and allocation tag values.
111 /// If there is an error along the way just add the information we were able
112 /// to get.
114
115 // Member Variables
118 std::unique_ptr<NativeRegisterContextLinux> m_reg_context_up;
120 using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
123 std::unique_ptr<SingleStepWorkaround> m_step_workaround;
124};
125} // namespace process_linux
126} // namespace lldb_private
127
128#endif // #ifndef liblldb_NativeThreadLinux_H_
An error handling class.
Definition: Status.h:44
Manages communication with the inferior (debugee) process.
void AnnotateSyncTagCheckFault(lldb::addr_t fault_addr)
Extend m_stop_description with logical and allocation tag values.
void MaybeLogStateChange(lldb::StateType new_state)
bool GetStopReason(ThreadStopInfo &stop_info, std::string &description) override
llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo() const override
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info=nullptr)
std::map< lldb::addr_t, uint32_t > WatchpointIndexMap
Status RemoveWatchpoint(lldb::addr_t addr) override
std::unique_ptr< NativeRegisterContextLinux > m_reg_context_up
Status SingleStep(uint32_t signo)
Single steps the thread.
std::unique_ptr< SingleStepWorkaround > m_step_workaround
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override
bool IsStopped(int *signo)
Return true if the thread is stopped.
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override
Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override
void SetStoppedByProcessorTrace(llvm::StringRef description)
NativeRegisterContextLinux & GetRegisterContext() override
Status Resume(uint32_t signo)
Resumes the thread.
void SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid)
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
StateType
Process and Thread States.
uint64_t pid_t
Definition: lldb-types.h:81
uint64_t addr_t
Definition: lldb-types.h:79
uint64_t tid_t
Definition: lldb-types.h:82