LLDB  mainline
ProcessMessage.h
Go to the documentation of this file.
1 //===-- ProcessMessage.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_ProcessMessage_H_
10 #define liblldb_ProcessMessage_H_
11 
12 #include "CrashReason.h"
13 
14 #include <cassert>
15 #include <string>
16 
17 #include "lldb/lldb-defines.h"
18 #include "lldb/lldb-types.h"
19 
21 public:
22  /// The type of signal this message can correspond to.
23  enum Kind {
36  };
37 
41  m_addr(0) {}
42 
43  Kind GetKind() const { return m_kind; }
44 
45  lldb::tid_t GetTID() const { return m_tid; }
46 
47  /// Indicates that the process \p pid has successfully attached.
49  return ProcessMessage(pid, eAttachMessage);
50  }
51 
52  /// Indicates that the thread \p tid is about to exit with status \p status.
53  static ProcessMessage Limbo(lldb::tid_t tid, int status) {
54  return ProcessMessage(tid, eLimboMessage, status);
55  }
56 
57  /// Indicates that the thread \p tid had the signal \p signum delivered.
58  static ProcessMessage Signal(lldb::tid_t tid, int signum) {
59  return ProcessMessage(tid, eSignalMessage, signum);
60  }
61 
62  /// Indicates that a signal \p signum generated by the debugging process was
63  /// delivered to the thread \p tid.
64  static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
65  return ProcessMessage(tid, eSignalDeliveredMessage, signum);
66  }
67 
68  /// Indicates that the thread \p tid encountered a trace point.
70  return ProcessMessage(tid, eTraceMessage);
71  }
72 
73  /// Indicates that the thread \p tid encountered a break point.
76  }
77 
79  return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
80  }
81 
82  /// Indicates that the thread \p tid crashed.
83  static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason, int signo,
84  lldb::addr_t fault_addr) {
85  ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
86  message.m_crash_reason = reason;
87  return message;
88  }
89 
90  /// Indicates that the thread \p child_tid was spawned.
92  lldb::tid_t child_tid) {
93  return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
94  }
95 
96  /// Indicates that the thread \p tid is about to exit with status \p status.
97  static ProcessMessage Exit(lldb::tid_t tid, int status) {
98  return ProcessMessage(tid, eExitMessage, status);
99  }
100 
101  /// Indicates that the thread \p pid has exec'd.
103  return ProcessMessage(tid, eExecMessage);
104  }
105 
106  int GetExitStatus() const {
107  assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
108  return m_status;
109  }
110 
111  int GetSignal() const {
112  assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
114  return m_status;
115  }
116 
117  int GetStopStatus() const {
118  assert(GetKind() == eSignalMessage);
119  return m_status;
120  }
121 
123  assert(GetKind() == eCrashMessage);
124  return m_crash_reason;
125  }
126 
128  assert(GetKind() == eCrashMessage);
129  return m_addr;
130  }
131 
133  assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
134  return m_addr;
135  }
136 
138  assert(GetKind() == eNewThreadMessage);
139  return m_child_tid;
140  }
141 
142  const char *PrintCrashReason() const;
143 
144  const char *PrintKind() const;
145 
146  static const char *PrintKind(Kind);
147 
148 private:
149  ProcessMessage(lldb::tid_t tid, Kind kind, int status = 0,
150  lldb::addr_t addr = 0)
151  : m_tid(tid), m_kind(kind),
153  m_addr(addr), m_child_tid(0) {}
154 
156  : m_tid(tid), m_kind(kind),
158  m_addr(0), m_child_tid(child_tid) {}
159 
163  int m_status;
166 };
167 
168 #endif // #ifndef liblldb_ProcessMessage_H_
ProcessMessage::GetCrashReason
CrashReason GetCrashReason() const
Definition: ProcessMessage.h:122
ProcessMessage::eInvalidMessage
@ eInvalidMessage
Definition: ProcessMessage.h:24
ProcessMessage::Attach
static ProcessMessage Attach(lldb::pid_t pid)
Indicates that the process pid has successfully attached.
Definition: ProcessMessage.h:48
ProcessMessage::Trace
static ProcessMessage Trace(lldb::tid_t tid)
Indicates that the thread tid encountered a trace point.
Definition: ProcessMessage.h:69
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:92
ProcessMessage::ProcessMessage
ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
Definition: ProcessMessage.h:155
ProcessMessage::SignalDelivered
static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum)
Indicates that a signal signum generated by the debugging process was delivered to the thread tid.
Definition: ProcessMessage.h:64
ProcessMessage::m_tid
lldb::tid_t m_tid
Definition: ProcessMessage.h:160
lldb-defines.h
ProcessMessage::Limbo
static ProcessMessage Limbo(lldb::tid_t tid, int status)
Indicates that the thread tid is about to exit with status status.
Definition: ProcessMessage.h:53
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
ProcessMessage::eAttachMessage
@ eAttachMessage
Definition: ProcessMessage.h:25
ProcessMessage::eExitMessage
@ eExitMessage
Definition: ProcessMessage.h:26
ProcessMessage::eNewThreadMessage
@ eNewThreadMessage
Definition: ProcessMessage.h:34
ProcessMessage::Kind
Kind
The type of signal this message can correspond to.
Definition: ProcessMessage.h:23
ProcessMessage::eExecMessage
@ eExecMessage
Definition: ProcessMessage.h:35
ProcessMessage::eWatchpointMessage
@ eWatchpointMessage
Definition: ProcessMessage.h:32
ProcessMessage::eSignalDeliveredMessage
@ eSignalDeliveredMessage
Definition: ProcessMessage.h:29
CrashReason::eInvalidCrashReason
@ eInvalidCrashReason
ProcessMessage::eLimboMessage
@ eLimboMessage
Definition: ProcessMessage.h:27
ProcessMessage::PrintCrashReason
const char * PrintCrashReason() const
Definition: ProcessMessage.cpp:13
ProcessMessage::eCrashMessage
@ eCrashMessage
Definition: ProcessMessage.h:33
ProcessMessage::GetStopStatus
int GetStopStatus() const
Definition: ProcessMessage.h:117
ProcessMessage::m_status
int m_status
Definition: ProcessMessage.h:163
ProcessMessage::Exec
static ProcessMessage Exec(lldb::tid_t tid)
Indicates that the thread pid has exec'd.
Definition: ProcessMessage.h:102
ProcessMessage::eSignalMessage
@ eSignalMessage
Definition: ProcessMessage.h:28
ProcessMessage::NewThread
static ProcessMessage NewThread(lldb::tid_t parent_tid, lldb::tid_t child_tid)
Indicates that the thread child_tid was spawned.
Definition: ProcessMessage.h:91
ProcessMessage::GetHWAddress
lldb::addr_t GetHWAddress() const
Definition: ProcessMessage.h:132
ProcessMessage::eBreakpointMessage
@ eBreakpointMessage
Definition: ProcessMessage.h:31
ProcessMessage::GetKind
Kind GetKind() const
Definition: ProcessMessage.h:43
lldb-types.h
ProcessMessage::GetSignal
int GetSignal() const
Definition: ProcessMessage.h:111
ProcessMessage::GetExitStatus
int GetExitStatus() const
Definition: ProcessMessage.h:106
message
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
Definition: Plugins/Trace/intel-pt/CMakeLists.txt:6
ProcessMessage::PrintKind
const char * PrintKind() const
Definition: ProcessMessage.cpp:61
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
ProcessMessage::m_kind
Kind m_kind
Definition: ProcessMessage.h:161
ProcessMessage::Crash
static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason, int signo, lldb::addr_t fault_addr)
Indicates that the thread tid crashed.
Definition: ProcessMessage.h:83
ProcessMessage::m_child_tid
lldb::tid_t m_child_tid
Definition: ProcessMessage.h:165
ProcessMessage::Exit
static ProcessMessage Exit(lldb::tid_t tid, int status)
Indicates that the thread tid is about to exit with status status.
Definition: ProcessMessage.h:97
ProcessMessage::m_addr
lldb::addr_t m_addr
Definition: ProcessMessage.h:164
ProcessMessage
Definition: ProcessMessage.h:20
CrashReason
CrashReason
Definition: CrashReason.h:18
ProcessMessage::eTraceMessage
@ eTraceMessage
Definition: ProcessMessage.h:30
ProcessMessage::GetFaultAddress
lldb::addr_t GetFaultAddress() const
Definition: ProcessMessage.h:127
ProcessMessage::ProcessMessage
ProcessMessage()
Definition: ProcessMessage.h:38
ProcessMessage::ProcessMessage
ProcessMessage(lldb::tid_t tid, Kind kind, int status=0, lldb::addr_t addr=0)
Definition: ProcessMessage.h:149
ProcessMessage::GetTID
lldb::tid_t GetTID() const
Definition: ProcessMessage.h:45
ProcessMessage::Watch
static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr)
Definition: ProcessMessage.h:78
ProcessMessage::m_crash_reason
CrashReason m_crash_reason
Definition: ProcessMessage.h:162
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
CrashReason.h
ProcessMessage::Signal
static ProcessMessage Signal(lldb::tid_t tid, int signum)
Indicates that the thread tid had the signal signum delivered.
Definition: ProcessMessage.h:58
ProcessMessage::Break
static ProcessMessage Break(lldb::tid_t tid)
Indicates that the thread tid encountered a break point.
Definition: ProcessMessage.h:74
ProcessMessage::GetChildTID
lldb::tid_t GetChildTID() const
Definition: ProcessMessage.h:137