1 //===-- ProcessMessage.h ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ProcessMessage_H_
11 #define liblldb_ProcessMessage_H_
15 #include "lldb/lldb-defines.h"
16 #include "lldb/lldb-types.h"
22 /// The type of signal this message can correspond to.
30 eSignalDeliveredMessage,
43 // SIGSEGV crash reasons.
47 // SIGILL crash reasons.
50 eIllegalAddressingMode,
57 // SIGBUS crash reasons,
62 // SIGFPE crash reasons,
69 eFloatInvalidOperation,
74 : m_tid(LLDB_INVALID_PROCESS_ID),
75 m_kind(eInvalidMessage),
76 m_crash_reason(eInvalidCrashReason),
80 Kind GetKind() const { return m_kind; }
82 lldb::tid_t GetTID() const { return m_tid; }
84 /// Indicates that the process @p pid has successfully attached.
85 static ProcessMessage Attach(lldb::pid_t pid) {
86 return ProcessMessage(pid, eAttachMessage);
89 /// Indicates that the thread @p tid is about to exit with status @p status.
90 static ProcessMessage Limbo(lldb::tid_t tid, int status) {
91 return ProcessMessage(tid, eLimboMessage, status);
94 /// Indicates that the thread @p tid had the signal @p signum delivered.
95 static ProcessMessage Signal(lldb::tid_t tid, int signum) {
96 return ProcessMessage(tid, eSignalMessage, signum);
99 /// Indicates that a signal @p signum generated by the debugging process was
100 /// delivered to the thread @p tid.
101 static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
102 return ProcessMessage(tid, eSignalDeliveredMessage, signum);
105 /// Indicates that the thread @p tid encountered a trace point.
106 static ProcessMessage Trace(lldb::tid_t tid) {
107 return ProcessMessage(tid, eTraceMessage);
110 /// Indicates that the thread @p tid encountered a break point.
111 static ProcessMessage Break(lldb::tid_t tid) {
112 return ProcessMessage(tid, eBreakpointMessage);
115 static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
116 return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
119 /// Indicates that the thread @p tid crashed.
120 static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason,
121 int signo, lldb::addr_t fault_addr) {
122 ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
123 message.m_crash_reason = reason;
127 /// Indicates that the thread @p child_tid was spawned.
128 static ProcessMessage NewThread(lldb::tid_t parent_tid, lldb::tid_t child_tid) {
129 return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
132 /// Indicates that the thread @p tid is about to exit with status @p status.
133 static ProcessMessage Exit(lldb::tid_t tid, int status) {
134 return ProcessMessage(tid, eExitMessage, status);
137 /// Indicates that the thread @p pid has exec'd.
138 static ProcessMessage Exec(lldb::tid_t tid) {
139 return ProcessMessage(tid, eExecMessage);
142 int GetExitStatus() const {
143 assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
147 int GetSignal() const {
148 assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
149 GetKind() == eSignalDeliveredMessage);
153 int GetStopStatus() const {
154 assert(GetKind() == eSignalMessage);
158 CrashReason GetCrashReason() const {
159 assert(GetKind() == eCrashMessage);
160 return m_crash_reason;
163 lldb::addr_t GetFaultAddress() const {
164 assert(GetKind() == eCrashMessage);
168 lldb::addr_t GetHWAddress() const {
169 assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
173 lldb::tid_t GetChildTID() const {
174 assert(GetKind() == eNewThreadMessage);
179 GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
182 PrintCrashReason() const;
185 PrintCrashReason(CrashReason reason);
194 ProcessMessage(lldb::tid_t tid, Kind kind,
195 int status = 0, lldb::addr_t addr = 0)
198 m_crash_reason(eInvalidCrashReason),
203 ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
206 m_crash_reason(eInvalidCrashReason),
209 m_child_tid(child_tid) { }
213 CrashReason m_crash_reason : 8;
216 lldb::tid_t m_child_tid;
219 #endif // #ifndef liblldb_ProcessMessage_H_