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.
29 eSignalDeliveredMessage,
41 // SIGSEGV crash reasons.
45 // SIGILL crash reasons.
48 eIllegalAddressingMode,
55 // SIGBUS crash reasons,
60 // SIGFPE crash reasons,
67 eFloatInvalidOperation,
72 : m_tid(LLDB_INVALID_PROCESS_ID),
73 m_kind(eInvalidMessage),
74 m_crash_reason(eInvalidCrashReason),
78 Kind GetKind() const { return m_kind; }
80 lldb::tid_t GetTID() const { return m_tid; }
82 /// Indicates that the thread @p tid is about to exit with status @p status.
83 static ProcessMessage Limbo(lldb::tid_t tid, int status) {
84 return ProcessMessage(tid, eLimboMessage, status);
87 /// Indicates that the thread @p tid had the signal @p signum delivered.
88 static ProcessMessage Signal(lldb::tid_t tid, int signum) {
89 return ProcessMessage(tid, eSignalMessage, signum);
92 /// Indicates that a signal @p signum generated by the debugging process was
93 /// delivered to the thread @p tid.
94 static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
95 return ProcessMessage(tid, eSignalDeliveredMessage, signum);
98 /// Indicates that the thread @p tid encountered a trace point.
99 static ProcessMessage Trace(lldb::tid_t tid) {
100 return ProcessMessage(tid, eTraceMessage);
103 /// Indicates that the thread @p tid encountered a break point.
104 static ProcessMessage Break(lldb::tid_t tid) {
105 return ProcessMessage(tid, eBreakpointMessage);
108 static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
109 return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
112 /// Indicates that the thread @p tid crashed.
113 static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason,
114 int signo, lldb::addr_t fault_addr) {
115 ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
116 message.m_crash_reason = reason;
120 /// Indicates that the thread @p child_tid was spawned.
121 static ProcessMessage NewThread(lldb::tid_t parent_tid, lldb::tid_t child_tid) {
122 return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
125 /// Indicates that the thread @p tid is about to exit with status @p status.
126 static ProcessMessage Exit(lldb::tid_t tid, int status) {
127 return ProcessMessage(tid, eExitMessage, status);
130 int GetExitStatus() const {
131 assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
135 int GetSignal() const {
136 assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
137 GetKind() == eSignalDeliveredMessage);
141 int GetStopStatus() const {
142 assert(GetKind() == eSignalMessage);
146 CrashReason GetCrashReason() const {
147 assert(GetKind() == eCrashMessage);
148 return m_crash_reason;
151 lldb::addr_t GetFaultAddress() const {
152 assert(GetKind() == eCrashMessage);
156 lldb::addr_t GetHWAddress() const {
157 assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
161 lldb::tid_t GetChildTID() const {
162 assert(GetKind() == eNewThreadMessage);
167 GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
170 PrintCrashReason() const;
173 PrintCrashReason(CrashReason reason);
182 ProcessMessage(lldb::tid_t tid, Kind kind,
183 int status = 0, lldb::addr_t addr = 0)
186 m_crash_reason(eInvalidCrashReason),
191 ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
194 m_crash_reason(eInvalidCrashReason),
197 m_child_tid(child_tid) { }
201 CrashReason m_crash_reason : 8;
204 lldb::tid_t m_child_tid;
207 #endif // #ifndef liblldb_ProcessMessage_H_