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 
24 namespace lldb_private {
25 namespace process_linux {
26 
27 class NativeProcessLinux;
28 
30  friend class NativeProcessLinux;
31 
32 public:
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 
50  Status RemoveWatchpoint(lldb::addr_t addr) override;
51 
52  Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
53 
55 
57 
58 private:
59  // Interface for friend classes
60 
61  /// Resumes the thread. If \p signo is anything but
62  /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
63  Status Resume(uint32_t signo);
64 
65  /// Single steps the thread. If \p signo is anything but
66  /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
67  Status SingleStep(uint32_t signo);
68 
69  void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
70 
71  /// Return true if the thread is stopped.
72  /// If stopped by a signal, indicate the signo in the signo argument.
73  /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
74  bool IsStopped(int *signo);
75 
76  void SetStoppedByExec();
77 
79 
80  void SetStoppedByWatchpoint(uint32_t wp_index);
81 
82  bool IsStoppedAtBreakpoint();
83 
84  bool IsStoppedAtWatchpoint();
85 
86  void SetStoppedByTrace();
87 
88  void SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid);
89 
90  void SetStoppedByVForkDone();
91 
93 
94  void SetStoppedByProcessorTrace(llvm::StringRef description);
95 
96  void SetExited();
97 
99 
100  // Private interface
101  void MaybeLogStateChange(lldb::StateType new_state);
102 
103  void SetStopped();
104 
105  /// Extend m_stop_description with logical and allocation tag values.
106  /// If there is an error along the way just add the information we were able
107  /// to get.
108  void AnnotateSyncTagCheckFault(const siginfo_t *info);
109 
110  // Member Variables
113  std::unique_ptr<NativeRegisterContextLinux> m_reg_context_up;
115  using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
118  std::unique_ptr<SingleStepWorkaround> m_step_workaround;
119 };
120 } // namespace process_linux
121 } // namespace lldb_private
122 
123 #endif // #ifndef liblldb_NativeThreadLinux_H_
lldb_private::process_linux::NativeThreadLinux::SetStoppedByVForkDone
void SetStoppedByVForkDone()
Definition: NativeThreadLinux.cpp:465
lldb_private::process_linux::NativeThreadLinux::IsStopped
bool IsStopped(int *signo)
Return true if the thread is stopped.
Definition: NativeThreadLinux.cpp:366
lldb_private::NativeThreadProtocol
Definition: NativeThreadProtocol.h:20
lldb_private::process_linux::NativeThreadLinux::GetProcess
NativeProcessLinux & GetProcess()
Definition: NativeThreadLinux.cpp:536
lldb_private::process_linux::NativeThreadLinux::Resume
Status Resume(uint32_t signo)
Resumes the thread.
Definition: NativeThreadLinux.cpp:210
lldb_private::process_linux::NativeRegisterContextLinux
Definition: NativeRegisterContextLinux.h:22
lldb_private::process_linux::NativeThreadLinux::SetStoppedByProcessorTrace
void SetStoppedByProcessorTrace(llvm::StringRef description)
Definition: NativeThreadLinux.cpp:478
lldb_private::process_linux::NativeThreadLinux::m_stop_info
ThreadStopInfo m_stop_info
Definition: NativeThreadLinux.h:112
lldb_private::process_linux::NativeThreadLinux::m_watchpoint_index_map
WatchpointIndexMap m_watchpoint_index_map
Definition: NativeThreadLinux.h:116
lldb_private::process_linux::NativeThreadLinux
Definition: NativeThreadLinux.h:29
lldb_private::process_linux::NativeThreadLinux::m_step_workaround
std::unique_ptr< SingleStepWorkaround > m_step_workaround
Definition: NativeThreadLinux.h:118
lldb_private::process_linux::NativeThreadLinux::m_state
lldb::StateType m_state
Definition: NativeThreadLinux.h:111
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::process_linux::NativeThreadLinux::SetStoppedByFork
void SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid)
Definition: NativeThreadLinux.cpp:456
lldb-private-forward.h
lldb_private::process_linux::NativeThreadLinux::RemoveHardwareBreakpoint
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override
Definition: NativeThreadLinux.cpp:196
lldb_private::process_linux::NativeThreadLinux::SetStoppedByExec
void SetStoppedByExec()
Definition: NativeThreadLinux.cpp:393
lldb_private::process_linux::NativeThreadLinux::GetName
std::string GetName() override
Definition: NativeThreadLinux.cpp:100
lldb_private::process_linux::NativeThreadLinux::WatchpointIndexMap
std::map< lldb::addr_t, uint32_t > WatchpointIndexMap
Definition: NativeThreadLinux.h:115
lldb_private::process_linux::NativeThreadLinux::m_stop_description
std::string m_stop_description
Definition: NativeThreadLinux.h:114
lldb_private::process_linux::NativeThreadLinux::SingleStep
Status SingleStep(uint32_t signo)
Single steps the thread.
Definition: NativeThreadLinux.cpp:252
lldb_private::process_linux::NativeThreadLinux::RemoveWatchpoint
Status RemoveWatchpoint(lldb::addr_t addr) override
Definition: NativeThreadLinux.cpp:167
lldb_private::process_linux::NativeProcessLinux
Definition: NativeProcessLinux.h:40
SingleStepCheck.h
lldb_private::process_linux::NativeThreadLinux::SetStopped
void SetStopped()
Definition: NativeThreadLinux.cpp:380
lldb_private::process_linux::NativeThreadLinux::GetState
lldb::StateType GetState() override
Definition: NativeThreadLinux.cpp:109
lldb_private::process_linux::NativeThreadLinux::SetStoppedByTrace
void SetStoppedByTrace()
Definition: NativeThreadLinux.cpp:449
lldb_private::process_linux::NativeThreadLinux::MaybeLogStateChange
void MaybeLogStateChange(lldb::StateType new_state)
Definition: NativeThreadLinux.cpp:521
lldb_private::process_linux::NativeThreadLinux::IsStoppedAtBreakpoint
bool IsStoppedAtBreakpoint()
Definition: NativeThreadLinux.cpp:439
lldb_private::process_linux::NativeThreadLinux::SetWatchpoint
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override
Definition: NativeThreadLinux.cpp:150
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::process_linux::NativeThreadLinux::RequestStop
Status RequestStop()
Definition: NativeThreadLinux.cpp:495
lldb_private::process_linux::NativeThreadLinux::SetHardwareBreakpoint
Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override
Definition: NativeThreadLinux.cpp:178
lldb_private::process_linux::NativeThreadLinux::m_hw_break_index_map
WatchpointIndexMap m_hw_break_index_map
Definition: NativeThreadLinux.h:117
lldb_private::process_linux::NativeThreadLinux::SetStoppedByBreakpoint
void SetStoppedByBreakpoint()
Definition: NativeThreadLinux.cpp:403
lldb_private::ThreadStopInfo
Definition: Debug.h:133
lldb_private::process_linux::NativeThreadLinux::SetExited
void SetExited()
Definition: NativeThreadLinux.cpp:487
lldb_private::process_linux::NativeThreadLinux::SetStoppedBySignal
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info=nullptr)
Definition: NativeThreadLinux.cpp:278
lldb_private::process_linux::NativeThreadLinux::NativeThreadLinux
NativeThreadLinux(NativeProcessLinux &process, lldb::tid_t tid)
Definition: NativeThreadLinux.cpp:91
lldb_private::Status
Definition: Status.h:44
lldb_private::process_linux::NativeThreadLinux::SetStoppedByWatchpoint
void SetStoppedByWatchpoint(uint32_t wp_index)
Definition: NativeThreadLinux.cpp:411
uint32_t
NativeThreadProtocol.h
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::process_linux::NativeThreadLinux::AnnotateSyncTagCheckFault
void AnnotateSyncTagCheckFault(const siginfo_t *info)
Extend m_stop_description with logical and allocation tag values.
Definition: NativeThreadLinux.cpp:313
lldb_private::process_linux::NativeThreadLinux::m_reg_context_up
std::unique_ptr< NativeRegisterContextLinux > m_reg_context_up
Definition: NativeThreadLinux.h:113
lldb_private::process_linux::NativeThreadLinux::SetStoppedWithNoReason
void SetStoppedWithNoReason()
Definition: NativeThreadLinux.cpp:471
NativeRegisterContextLinux.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::process_linux::NativeThreadLinux::GetRegisterContext
NativeRegisterContextLinux & GetRegisterContext() override
Definition: NativeThreadLinux.h:43
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb_private::process_linux::NativeThreadLinux::IsStoppedAtWatchpoint
bool IsStoppedAtWatchpoint()
Definition: NativeThreadLinux.cpp:444
lldb_private::process_linux::NativeThreadLinux::GetStopReason
bool GetStopReason(ThreadStopInfo &stop_info, std::string &description) override
Definition: NativeThreadLinux.cpp:111
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86