aboutsummaryrefslogtreecommitdiffstats
path: root/source/Plugins/Process/POSIX
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /source/Plugins/Process/POSIX
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'source/Plugins/Process/POSIX')
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.cpp577
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.h74
-rw-r--r--source/Plugins/Process/POSIX/ProcessMessage.cpp103
-rw-r--r--source/Plugins/Process/POSIX/ProcessMessage.h299
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp311
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.h169
6 files changed, 753 insertions, 780 deletions
diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp
index 44409a4ce552..debdd7808e63 100644
--- a/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -9,308 +9,333 @@
#include "CrashReason.h"
+#include "llvm/Support/raw_ostream.h"
+
#include <sstream>
namespace {
-void
-AppendFaultAddr (std::string& str, lldb::addr_t addr)
-{
- std::stringstream ss;
- ss << " (fault address: 0x" << std::hex << addr << ")";
- str += ss.str();
+void AppendFaultAddr(std::string &str, lldb::addr_t addr) {
+ std::stringstream ss;
+ ss << " (fault address: 0x" << std::hex << addr << ")";
+ str += ss.str();
+}
+
+void AppendBounds(std::string &str, lldb::addr_t lower_bound,
+ lldb::addr_t upper_bound, lldb::addr_t addr) {
+ llvm::raw_string_ostream stream(str);
+ if ((unsigned long)addr < lower_bound)
+ stream << ": lower bound violation ";
+ else
+ stream << ": upper bound violation ";
+ stream << "(fault address: 0x";
+ stream.write_hex(addr);
+ stream << ", lower bound: 0x";
+ stream.write_hex(lower_bound);
+ stream << ", upper bound: 0x";
+ stream.write_hex(upper_bound);
+ stream << ")";
+ stream.flush();
}
-CrashReason
-GetCrashReasonForSIGSEGV(const siginfo_t& info)
-{
- assert(info.si_signo == SIGSEGV);
+CrashReason GetCrashReasonForSIGSEGV(const siginfo_t &info) {
+ assert(info.si_signo == SIGSEGV);
- switch (info.si_code)
- {
+ switch (info.si_code) {
#ifdef SI_KERNEL
- case SI_KERNEL:
- // Some platforms will occasionally send nonstandard spurious SI_KERNEL codes.
- // One way to get this is via unaligned SIMD loads.
- return CrashReason::eInvalidAddress; // for lack of anything better
+ case SI_KERNEL:
+ // Some platforms will occasionally send nonstandard spurious SI_KERNEL
+ // codes.
+ // One way to get this is via unaligned SIMD loads.
+ return CrashReason::eInvalidAddress; // for lack of anything better
#endif
- case SEGV_MAPERR:
- return CrashReason::eInvalidAddress;
- case SEGV_ACCERR:
- return CrashReason::ePrivilegedAddress;
- }
-
- assert(false && "unexpected si_code for SIGSEGV");
- return CrashReason::eInvalidCrashReason;
-}
+ case SEGV_MAPERR:
+ return CrashReason::eInvalidAddress;
+ case SEGV_ACCERR:
+ return CrashReason::ePrivilegedAddress;
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif
+ case SEGV_BNDERR:
+ return CrashReason::eBoundViolation;
+ }
-CrashReason
-GetCrashReasonForSIGILL(const siginfo_t& info)
-{
- assert(info.si_signo == SIGILL);
-
- switch (info.si_code)
- {
- case ILL_ILLOPC:
- return CrashReason::eIllegalOpcode;
- case ILL_ILLOPN:
- return CrashReason::eIllegalOperand;
- case ILL_ILLADR:
- return CrashReason::eIllegalAddressingMode;
- case ILL_ILLTRP:
- return CrashReason::eIllegalTrap;
- case ILL_PRVOPC:
- return CrashReason::ePrivilegedOpcode;
- case ILL_PRVREG:
- return CrashReason::ePrivilegedRegister;
- case ILL_COPROC:
- return CrashReason::eCoprocessorError;
- case ILL_BADSTK:
- return CrashReason::eInternalStackError;
- }
-
- assert(false && "unexpected si_code for SIGILL");
- return CrashReason::eInvalidCrashReason;
+ assert(false && "unexpected si_code for SIGSEGV");
+ return CrashReason::eInvalidCrashReason;
}
-CrashReason
-GetCrashReasonForSIGFPE(const siginfo_t& info)
-{
- assert(info.si_signo == SIGFPE);
-
- switch (info.si_code)
- {
- case FPE_INTDIV:
- return CrashReason::eIntegerDivideByZero;
- case FPE_INTOVF:
- return CrashReason::eIntegerOverflow;
- case FPE_FLTDIV:
- return CrashReason::eFloatDivideByZero;
- case FPE_FLTOVF:
- return CrashReason::eFloatOverflow;
- case FPE_FLTUND:
- return CrashReason::eFloatUnderflow;
- case FPE_FLTRES:
- return CrashReason::eFloatInexactResult;
- case FPE_FLTINV:
- return CrashReason::eFloatInvalidOperation;
- case FPE_FLTSUB:
- return CrashReason::eFloatSubscriptRange;
- }
-
- assert(false && "unexpected si_code for SIGFPE");
- return CrashReason::eInvalidCrashReason;
+CrashReason GetCrashReasonForSIGILL(const siginfo_t &info) {
+ assert(info.si_signo == SIGILL);
+
+ switch (info.si_code) {
+ case ILL_ILLOPC:
+ return CrashReason::eIllegalOpcode;
+ case ILL_ILLOPN:
+ return CrashReason::eIllegalOperand;
+ case ILL_ILLADR:
+ return CrashReason::eIllegalAddressingMode;
+ case ILL_ILLTRP:
+ return CrashReason::eIllegalTrap;
+ case ILL_PRVOPC:
+ return CrashReason::ePrivilegedOpcode;
+ case ILL_PRVREG:
+ return CrashReason::ePrivilegedRegister;
+ case ILL_COPROC:
+ return CrashReason::eCoprocessorError;
+ case ILL_BADSTK:
+ return CrashReason::eInternalStackError;
+ }
+
+ assert(false && "unexpected si_code for SIGILL");
+ return CrashReason::eInvalidCrashReason;
}
-CrashReason
-GetCrashReasonForSIGBUS(const siginfo_t& info)
-{
- assert(info.si_signo == SIGBUS);
-
- switch (info.si_code)
- {
- case BUS_ADRALN:
- return CrashReason::eIllegalAlignment;
- case BUS_ADRERR:
- return CrashReason::eIllegalAddress;
- case BUS_OBJERR:
- return CrashReason::eHardwareError;
- }
-
- assert(false && "unexpected si_code for SIGBUS");
- return CrashReason::eInvalidCrashReason;
+CrashReason GetCrashReasonForSIGFPE(const siginfo_t &info) {
+ assert(info.si_signo == SIGFPE);
+
+ switch (info.si_code) {
+ case FPE_INTDIV:
+ return CrashReason::eIntegerDivideByZero;
+ case FPE_INTOVF:
+ return CrashReason::eIntegerOverflow;
+ case FPE_FLTDIV:
+ return CrashReason::eFloatDivideByZero;
+ case FPE_FLTOVF:
+ return CrashReason::eFloatOverflow;
+ case FPE_FLTUND:
+ return CrashReason::eFloatUnderflow;
+ case FPE_FLTRES:
+ return CrashReason::eFloatInexactResult;
+ case FPE_FLTINV:
+ return CrashReason::eFloatInvalidOperation;
+ case FPE_FLTSUB:
+ return CrashReason::eFloatSubscriptRange;
+ }
+
+ assert(false && "unexpected si_code for SIGFPE");
+ return CrashReason::eInvalidCrashReason;
}
+CrashReason GetCrashReasonForSIGBUS(const siginfo_t &info) {
+ assert(info.si_signo == SIGBUS);
+
+ switch (info.si_code) {
+ case BUS_ADRALN:
+ return CrashReason::eIllegalAlignment;
+ case BUS_ADRERR:
+ return CrashReason::eIllegalAddress;
+ case BUS_OBJERR:
+ return CrashReason::eHardwareError;
+ }
+
+ assert(false && "unexpected si_code for SIGBUS");
+ return CrashReason::eInvalidCrashReason;
+}
}
-std::string
-GetCrashReasonString (CrashReason reason, lldb::addr_t fault_addr)
-{
- std::string str;
-
- switch (reason)
- {
- default:
- assert(false && "invalid CrashReason");
- break;
-
- case CrashReason::eInvalidAddress:
- str = "signal SIGSEGV: invalid address";
- AppendFaultAddr (str, fault_addr);
- break;
- case CrashReason::ePrivilegedAddress:
- str = "signal SIGSEGV: address access protected";
- AppendFaultAddr (str, fault_addr);
- break;
- case CrashReason::eIllegalOpcode:
- str = "signal SIGILL: illegal instruction";
- break;
- case CrashReason::eIllegalOperand:
- str = "signal SIGILL: illegal instruction operand";
- break;
- case CrashReason::eIllegalAddressingMode:
- str = "signal SIGILL: illegal addressing mode";
- break;
- case CrashReason::eIllegalTrap:
- str = "signal SIGILL: illegal trap";
- break;
- case CrashReason::ePrivilegedOpcode:
- str = "signal SIGILL: privileged instruction";
- break;
- case CrashReason::ePrivilegedRegister:
- str = "signal SIGILL: privileged register";
- break;
- case CrashReason::eCoprocessorError:
- str = "signal SIGILL: coprocessor error";
- break;
- case CrashReason::eInternalStackError:
- str = "signal SIGILL: internal stack error";
- break;
- case CrashReason::eIllegalAlignment:
- str = "signal SIGBUS: illegal alignment";
- break;
- case CrashReason::eIllegalAddress:
- str = "signal SIGBUS: illegal address";
- break;
- case CrashReason::eHardwareError:
- str = "signal SIGBUS: hardware error";
- break;
- case CrashReason::eIntegerDivideByZero:
- str = "signal SIGFPE: integer divide by zero";
- break;
- case CrashReason::eIntegerOverflow:
- str = "signal SIGFPE: integer overflow";
- break;
- case CrashReason::eFloatDivideByZero:
- str = "signal SIGFPE: floating point divide by zero";
- break;
- case CrashReason::eFloatOverflow:
- str = "signal SIGFPE: floating point overflow";
- break;
- case CrashReason::eFloatUnderflow:
- str = "signal SIGFPE: floating point underflow";
- break;
- case CrashReason::eFloatInexactResult:
- str = "signal SIGFPE: inexact floating point result";
- break;
- case CrashReason::eFloatInvalidOperation:
- str = "signal SIGFPE: invalid floating point operation";
- break;
- case CrashReason::eFloatSubscriptRange:
- str = "signal SIGFPE: invalid floating point subscript range";
- break;
- }
+std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info) {
+ std::string str;
+// make sure that siginfo_t has the bound fields available.
+#if defined(si_lower) && defined(si_upper)
+ if (reason == CrashReason::eBoundViolation) {
+ str = "signal SIGSEGV";
+ AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower),
+ reinterpret_cast<lldb::addr_t>(info.si_upper),
+ reinterpret_cast<lldb::addr_t>(info.si_addr));
return str;
+ }
+#endif
+
+ return GetCrashReasonString(reason,
+ reinterpret_cast<lldb::addr_t>(info.si_addr));
}
-const char *
-CrashReasonAsString (CrashReason reason)
-{
+std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
+ std::string str;
+
+ switch (reason) {
+ default:
+ assert(false && "invalid CrashReason");
+ break;
+
+ case CrashReason::eInvalidAddress:
+ str = "signal SIGSEGV: invalid address";
+ AppendFaultAddr(str, fault_addr);
+ break;
+ case CrashReason::ePrivilegedAddress:
+ str = "signal SIGSEGV: address access protected";
+ AppendFaultAddr(str, fault_addr);
+ break;
+ case CrashReason::eBoundViolation:
+ str = "signal SIGSEGV: bound violation";
+ break;
+ case CrashReason::eIllegalOpcode:
+ str = "signal SIGILL: illegal instruction";
+ break;
+ case CrashReason::eIllegalOperand:
+ str = "signal SIGILL: illegal instruction operand";
+ break;
+ case CrashReason::eIllegalAddressingMode:
+ str = "signal SIGILL: illegal addressing mode";
+ break;
+ case CrashReason::eIllegalTrap:
+ str = "signal SIGILL: illegal trap";
+ break;
+ case CrashReason::ePrivilegedOpcode:
+ str = "signal SIGILL: privileged instruction";
+ break;
+ case CrashReason::ePrivilegedRegister:
+ str = "signal SIGILL: privileged register";
+ break;
+ case CrashReason::eCoprocessorError:
+ str = "signal SIGILL: coprocessor error";
+ break;
+ case CrashReason::eInternalStackError:
+ str = "signal SIGILL: internal stack error";
+ break;
+ case CrashReason::eIllegalAlignment:
+ str = "signal SIGBUS: illegal alignment";
+ break;
+ case CrashReason::eIllegalAddress:
+ str = "signal SIGBUS: illegal address";
+ break;
+ case CrashReason::eHardwareError:
+ str = "signal SIGBUS: hardware error";
+ break;
+ case CrashReason::eIntegerDivideByZero:
+ str = "signal SIGFPE: integer divide by zero";
+ break;
+ case CrashReason::eIntegerOverflow:
+ str = "signal SIGFPE: integer overflow";
+ break;
+ case CrashReason::eFloatDivideByZero:
+ str = "signal SIGFPE: floating point divide by zero";
+ break;
+ case CrashReason::eFloatOverflow:
+ str = "signal SIGFPE: floating point overflow";
+ break;
+ case CrashReason::eFloatUnderflow:
+ str = "signal SIGFPE: floating point underflow";
+ break;
+ case CrashReason::eFloatInexactResult:
+ str = "signal SIGFPE: inexact floating point result";
+ break;
+ case CrashReason::eFloatInvalidOperation:
+ str = "signal SIGFPE: invalid floating point operation";
+ break;
+ case CrashReason::eFloatSubscriptRange:
+ str = "signal SIGFPE: invalid floating point subscript range";
+ break;
+ }
+
+ return str;
+}
+
+const char *CrashReasonAsString(CrashReason reason) {
#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- // Just return the code in ascii for integration builds.
- chcar str[8];
- sprintf(str, "%d", reason);
+ // Just return the code in ascii for integration builds.
+ chcar str[8];
+ sprintf(str, "%d", reason);
#else
- const char *str = nullptr;
-
- switch (reason)
- {
- case CrashReason::eInvalidCrashReason:
- str = "eInvalidCrashReason";
- break;
-
- // SIGSEGV crash reasons.
- case CrashReason::eInvalidAddress:
- str = "eInvalidAddress";
- break;
- case CrashReason::ePrivilegedAddress:
- str = "ePrivilegedAddress";
- break;
-
- // SIGILL crash reasons.
- case CrashReason::eIllegalOpcode:
- str = "eIllegalOpcode";
- break;
- case CrashReason::eIllegalOperand:
- str = "eIllegalOperand";
- break;
- case CrashReason::eIllegalAddressingMode:
- str = "eIllegalAddressingMode";
- break;
- case CrashReason::eIllegalTrap:
- str = "eIllegalTrap";
- break;
- case CrashReason::ePrivilegedOpcode:
- str = "ePrivilegedOpcode";
- break;
- case CrashReason::ePrivilegedRegister:
- str = "ePrivilegedRegister";
- break;
- case CrashReason::eCoprocessorError:
- str = "eCoprocessorError";
- break;
- case CrashReason::eInternalStackError:
- str = "eInternalStackError";
- break;
-
- // SIGBUS crash reasons:
- case CrashReason::eIllegalAlignment:
- str = "eIllegalAlignment";
- break;
- case CrashReason::eIllegalAddress:
- str = "eIllegalAddress";
- break;
- case CrashReason::eHardwareError:
- str = "eHardwareError";
- break;
-
- // SIGFPE crash reasons:
- case CrashReason::eIntegerDivideByZero:
- str = "eIntegerDivideByZero";
- break;
- case CrashReason::eIntegerOverflow:
- str = "eIntegerOverflow";
- break;
- case CrashReason::eFloatDivideByZero:
- str = "eFloatDivideByZero";
- break;
- case CrashReason::eFloatOverflow:
- str = "eFloatOverflow";
- break;
- case CrashReason::eFloatUnderflow:
- str = "eFloatUnderflow";
- break;
- case CrashReason::eFloatInexactResult:
- str = "eFloatInexactResult";
- break;
- case CrashReason::eFloatInvalidOperation:
- str = "eFloatInvalidOperation";
- break;
- case CrashReason::eFloatSubscriptRange:
- str = "eFloatSubscriptRange";
- break;
- }
+ const char *str = nullptr;
+
+ switch (reason) {
+ case CrashReason::eInvalidCrashReason:
+ str = "eInvalidCrashReason";
+ break;
+
+ // SIGSEGV crash reasons.
+ case CrashReason::eInvalidAddress:
+ str = "eInvalidAddress";
+ break;
+ case CrashReason::ePrivilegedAddress:
+ str = "ePrivilegedAddress";
+ break;
+ case CrashReason::eBoundViolation:
+ str = "eBoundViolation";
+ break;
+
+ // SIGILL crash reasons.
+ case CrashReason::eIllegalOpcode:
+ str = "eIllegalOpcode";
+ break;
+ case CrashReason::eIllegalOperand:
+ str = "eIllegalOperand";
+ break;
+ case CrashReason::eIllegalAddressingMode:
+ str = "eIllegalAddressingMode";
+ break;
+ case CrashReason::eIllegalTrap:
+ str = "eIllegalTrap";
+ break;
+ case CrashReason::ePrivilegedOpcode:
+ str = "ePrivilegedOpcode";
+ break;
+ case CrashReason::ePrivilegedRegister:
+ str = "ePrivilegedRegister";
+ break;
+ case CrashReason::eCoprocessorError:
+ str = "eCoprocessorError";
+ break;
+ case CrashReason::eInternalStackError:
+ str = "eInternalStackError";
+ break;
+
+ // SIGBUS crash reasons:
+ case CrashReason::eIllegalAlignment:
+ str = "eIllegalAlignment";
+ break;
+ case CrashReason::eIllegalAddress:
+ str = "eIllegalAddress";
+ break;
+ case CrashReason::eHardwareError:
+ str = "eHardwareError";
+ break;
+
+ // SIGFPE crash reasons:
+ case CrashReason::eIntegerDivideByZero:
+ str = "eIntegerDivideByZero";
+ break;
+ case CrashReason::eIntegerOverflow:
+ str = "eIntegerOverflow";
+ break;
+ case CrashReason::eFloatDivideByZero:
+ str = "eFloatDivideByZero";
+ break;
+ case CrashReason::eFloatOverflow:
+ str = "eFloatOverflow";
+ break;
+ case CrashReason::eFloatUnderflow:
+ str = "eFloatUnderflow";
+ break;
+ case CrashReason::eFloatInexactResult:
+ str = "eFloatInexactResult";
+ break;
+ case CrashReason::eFloatInvalidOperation:
+ str = "eFloatInvalidOperation";
+ break;
+ case CrashReason::eFloatSubscriptRange:
+ str = "eFloatSubscriptRange";
+ break;
+ }
#endif
- return str;
+ return str;
}
-CrashReason
-GetCrashReason(const siginfo_t& info)
-{
- switch(info.si_signo)
- {
- case SIGSEGV:
- return GetCrashReasonForSIGSEGV(info);
- case SIGBUS:
- return GetCrashReasonForSIGBUS(info);
- case SIGFPE:
- return GetCrashReasonForSIGFPE(info);
- case SIGILL:
- return GetCrashReasonForSIGILL(info);
- }
-
- assert(false && "unexpected signal");
- return CrashReason::eInvalidCrashReason;
+CrashReason GetCrashReason(const siginfo_t &info) {
+ switch (info.si_signo) {
+ case SIGSEGV:
+ return GetCrashReasonForSIGSEGV(info);
+ case SIGBUS:
+ return GetCrashReasonForSIGBUS(info);
+ case SIGFPE:
+ return GetCrashReasonForSIGFPE(info);
+ case SIGILL:
+ return GetCrashReasonForSIGILL(info);
+ }
+
+ assert(false && "unexpected signal");
+ return CrashReason::eInvalidCrashReason;
}
diff --git a/source/Plugins/Process/POSIX/CrashReason.h b/source/Plugins/Process/POSIX/CrashReason.h
index f6d9ba553e4a..57abe47b46b2 100644
--- a/source/Plugins/Process/POSIX/CrashReason.h
+++ b/source/Plugins/Process/POSIX/CrashReason.h
@@ -16,47 +16,45 @@
#include <string>
-enum class CrashReason
-{
- eInvalidCrashReason,
-
- // SIGSEGV crash reasons.
- eInvalidAddress,
- ePrivilegedAddress,
-
- // SIGILL crash reasons.
- eIllegalOpcode,
- eIllegalOperand,
- eIllegalAddressingMode,
- eIllegalTrap,
- ePrivilegedOpcode,
- ePrivilegedRegister,
- eCoprocessorError,
- eInternalStackError,
-
- // SIGBUS crash reasons,
- eIllegalAlignment,
- eIllegalAddress,
- eHardwareError,
-
- // SIGFPE crash reasons,
- eIntegerDivideByZero,
- eIntegerOverflow,
- eFloatDivideByZero,
- eFloatOverflow,
- eFloatUnderflow,
- eFloatInexactResult,
- eFloatInvalidOperation,
- eFloatSubscriptRange
+enum class CrashReason {
+ eInvalidCrashReason,
+
+ // SIGSEGV crash reasons.
+ eInvalidAddress,
+ ePrivilegedAddress,
+ eBoundViolation,
+
+ // SIGILL crash reasons.
+ eIllegalOpcode,
+ eIllegalOperand,
+ eIllegalAddressingMode,
+ eIllegalTrap,
+ ePrivilegedOpcode,
+ ePrivilegedRegister,
+ eCoprocessorError,
+ eInternalStackError,
+
+ // SIGBUS crash reasons,
+ eIllegalAlignment,
+ eIllegalAddress,
+ eHardwareError,
+
+ // SIGFPE crash reasons,
+ eIntegerDivideByZero,
+ eIntegerOverflow,
+ eFloatDivideByZero,
+ eFloatOverflow,
+ eFloatUnderflow,
+ eFloatInexactResult,
+ eFloatInvalidOperation,
+ eFloatSubscriptRange
};
-std::string
-GetCrashReasonString (CrashReason reason, lldb::addr_t fault_addr);
+std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
+std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info);
-const char *
-CrashReasonAsString (CrashReason reason);
+const char *CrashReasonAsString(CrashReason reason);
-CrashReason
-GetCrashReason(const siginfo_t& info);
+CrashReason GetCrashReason(const siginfo_t &info);
#endif // #ifndef liblldb_CrashReason_H_
diff --git a/source/Plugins/Process/POSIX/ProcessMessage.cpp b/source/Plugins/Process/POSIX/ProcessMessage.cpp
index 02049a2af953..48f2a7844cf7 100644
--- a/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ b/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -11,68 +11,59 @@
using namespace lldb_private;
-const char *
-ProcessMessage::PrintCrashReason() const
-{
- return CrashReasonAsString(m_crash_reason);
+const char *ProcessMessage::PrintCrashReason() const {
+ return CrashReasonAsString(m_crash_reason);
}
-const char *
-ProcessMessage::PrintKind(Kind kind)
-{
+const char *ProcessMessage::PrintKind(Kind kind) {
#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- // Just return the code in ascii for integration builds.
- chcar str[8];
- sprintf(str, "%d", reason);
+ // Just return the code in ascii for integration builds.
+ chcar str[8];
+ sprintf(str, "%d", reason);
#else
- const char *str = NULL;
+ const char *str = NULL;
- switch (kind)
- {
- case eInvalidMessage:
- str = "eInvalidMessage";
- break;
- case eAttachMessage:
- str = "eAttachMessage";
- break;
- case eExitMessage:
- str = "eExitMessage";
- break;
- case eLimboMessage:
- str = "eLimboMessage";
- break;
- case eSignalMessage:
- str = "eSignalMessage";
- break;
- case eSignalDeliveredMessage:
- str = "eSignalDeliveredMessage";
- break;
- case eTraceMessage:
- str = "eTraceMessage";
- break;
- case eBreakpointMessage:
- str = "eBreakpointMessage";
- break;
- case eWatchpointMessage:
- str = "eWatchpointMessage";
- break;
- case eCrashMessage:
- str = "eCrashMessage";
- break;
- case eNewThreadMessage:
- str = "eNewThreadMessage";
- break;
- case eExecMessage:
- str = "eExecMessage";
- break;
- }
+ switch (kind) {
+ case eInvalidMessage:
+ str = "eInvalidMessage";
+ break;
+ case eAttachMessage:
+ str = "eAttachMessage";
+ break;
+ case eExitMessage:
+ str = "eExitMessage";
+ break;
+ case eLimboMessage:
+ str = "eLimboMessage";
+ break;
+ case eSignalMessage:
+ str = "eSignalMessage";
+ break;
+ case eSignalDeliveredMessage:
+ str = "eSignalDeliveredMessage";
+ break;
+ case eTraceMessage:
+ str = "eTraceMessage";
+ break;
+ case eBreakpointMessage:
+ str = "eBreakpointMessage";
+ break;
+ case eWatchpointMessage:
+ str = "eWatchpointMessage";
+ break;
+ case eCrashMessage:
+ str = "eCrashMessage";
+ break;
+ case eNewThreadMessage:
+ str = "eNewThreadMessage";
+ break;
+ case eExecMessage:
+ str = "eExecMessage";
+ break;
+ }
#endif
- return str;
+ return str;
}
-const char *
-ProcessMessage::PrintKind() const
-{
- return PrintKind(m_kind);
-}
+const char *ProcessMessage::PrintKind() const { return PrintKind(m_kind); }
diff --git a/source/Plugins/Process/POSIX/ProcessMessage.h b/source/Plugins/Process/POSIX/ProcessMessage.h
index f932e9fff278..3c596ca68549 100644
--- a/source/Plugins/Process/POSIX/ProcessMessage.h
+++ b/source/Plugins/Process/POSIX/ProcessMessage.h
@@ -18,165 +18,152 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-class ProcessMessage
-{
+class ProcessMessage {
public:
-
- /// The type of signal this message can correspond to.
- enum Kind
- {
- eInvalidMessage,
- eAttachMessage,
- eExitMessage,
- eLimboMessage,
- eSignalMessage,
- eSignalDeliveredMessage,
- eTraceMessage,
- eBreakpointMessage,
- eWatchpointMessage,
- eCrashMessage,
- eNewThreadMessage,
- eExecMessage
- };
-
- ProcessMessage()
- : m_tid(LLDB_INVALID_PROCESS_ID),
- m_kind(eInvalidMessage),
- m_crash_reason(CrashReason::eInvalidCrashReason),
- m_status(0),
- m_addr(0) { }
-
- Kind GetKind() const { return m_kind; }
-
- lldb::tid_t GetTID() const { return m_tid; }
-
- /// Indicates that the process @p pid has successfully attached.
- static ProcessMessage Attach(lldb::pid_t pid) {
- return ProcessMessage(pid, eAttachMessage);
- }
-
- /// Indicates that the thread @p tid is about to exit with status @p status.
- static ProcessMessage Limbo(lldb::tid_t tid, int status) {
- return ProcessMessage(tid, eLimboMessage, status);
- }
-
- /// Indicates that the thread @p tid had the signal @p signum delivered.
- static ProcessMessage Signal(lldb::tid_t tid, int signum) {
- return ProcessMessage(tid, eSignalMessage, signum);
- }
-
- /// Indicates that a signal @p signum generated by the debugging process was
- /// delivered to the thread @p tid.
- static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
- return ProcessMessage(tid, eSignalDeliveredMessage, signum);
- }
-
- /// Indicates that the thread @p tid encountered a trace point.
- static ProcessMessage Trace(lldb::tid_t tid) {
- return ProcessMessage(tid, eTraceMessage);
- }
-
- /// Indicates that the thread @p tid encountered a break point.
- static ProcessMessage Break(lldb::tid_t tid) {
- return ProcessMessage(tid, eBreakpointMessage);
- }
-
- static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
- return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
- }
-
- /// Indicates that the thread @p tid crashed.
- static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason,
- int signo, lldb::addr_t fault_addr) {
- ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
- message.m_crash_reason = reason;
- return message;
- }
-
- /// Indicates that the thread @p child_tid was spawned.
- static ProcessMessage NewThread(lldb::tid_t parent_tid, lldb::tid_t child_tid) {
- return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
- }
-
- /// Indicates that the thread @p tid is about to exit with status @p status.
- static ProcessMessage Exit(lldb::tid_t tid, int status) {
- return ProcessMessage(tid, eExitMessage, status);
- }
-
- /// Indicates that the thread @p pid has exec'd.
- static ProcessMessage Exec(lldb::tid_t tid) {
- return ProcessMessage(tid, eExecMessage);
- }
-
- int GetExitStatus() const {
- assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
- return m_status;
- }
-
- int GetSignal() const {
- assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
- GetKind() == eSignalDeliveredMessage);
- return m_status;
- }
-
- int GetStopStatus() const {
- assert(GetKind() == eSignalMessage);
- return m_status;
- }
-
- CrashReason GetCrashReason() const {
- assert(GetKind() == eCrashMessage);
- return m_crash_reason;
- }
-
- lldb::addr_t GetFaultAddress() const {
- assert(GetKind() == eCrashMessage);
- return m_addr;
- }
-
- lldb::addr_t GetHWAddress() const {
- assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
- return m_addr;
- }
-
- lldb::tid_t GetChildTID() const {
- assert(GetKind() == eNewThreadMessage);
- return m_child_tid;
- }
-
- const char *
- PrintCrashReason() const;
-
- const char *
- PrintKind() const;
-
- static const char *
- PrintKind(Kind);
+ /// The type of signal this message can correspond to.
+ enum Kind {
+ eInvalidMessage,
+ eAttachMessage,
+ eExitMessage,
+ eLimboMessage,
+ eSignalMessage,
+ eSignalDeliveredMessage,
+ eTraceMessage,
+ eBreakpointMessage,
+ eWatchpointMessage,
+ eCrashMessage,
+ eNewThreadMessage,
+ eExecMessage
+ };
+
+ ProcessMessage()
+ : m_tid(LLDB_INVALID_PROCESS_ID), m_kind(eInvalidMessage),
+ m_crash_reason(CrashReason::eInvalidCrashReason), m_status(0),
+ m_addr(0) {}
+
+ Kind GetKind() const { return m_kind; }
+
+ lldb::tid_t GetTID() const { return m_tid; }
+
+ /// Indicates that the process @p pid has successfully attached.
+ static ProcessMessage Attach(lldb::pid_t pid) {
+ return ProcessMessage(pid, eAttachMessage);
+ }
+
+ /// Indicates that the thread @p tid is about to exit with status @p status.
+ static ProcessMessage Limbo(lldb::tid_t tid, int status) {
+ return ProcessMessage(tid, eLimboMessage, status);
+ }
+
+ /// Indicates that the thread @p tid had the signal @p signum delivered.
+ static ProcessMessage Signal(lldb::tid_t tid, int signum) {
+ return ProcessMessage(tid, eSignalMessage, signum);
+ }
+
+ /// Indicates that a signal @p signum generated by the debugging process was
+ /// delivered to the thread @p tid.
+ static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
+ return ProcessMessage(tid, eSignalDeliveredMessage, signum);
+ }
+
+ /// Indicates that the thread @p tid encountered a trace point.
+ static ProcessMessage Trace(lldb::tid_t tid) {
+ return ProcessMessage(tid, eTraceMessage);
+ }
+
+ /// Indicates that the thread @p tid encountered a break point.
+ static ProcessMessage Break(lldb::tid_t tid) {
+ return ProcessMessage(tid, eBreakpointMessage);
+ }
+
+ static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
+ return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
+ }
+
+ /// Indicates that the thread @p tid crashed.
+ static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason, int signo,
+ lldb::addr_t fault_addr) {
+ ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
+ message.m_crash_reason = reason;
+ return message;
+ }
+
+ /// Indicates that the thread @p child_tid was spawned.
+ static ProcessMessage NewThread(lldb::tid_t parent_tid,
+ lldb::tid_t child_tid) {
+ return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
+ }
+
+ /// Indicates that the thread @p tid is about to exit with status @p status.
+ static ProcessMessage Exit(lldb::tid_t tid, int status) {
+ return ProcessMessage(tid, eExitMessage, status);
+ }
+
+ /// Indicates that the thread @p pid has exec'd.
+ static ProcessMessage Exec(lldb::tid_t tid) {
+ return ProcessMessage(tid, eExecMessage);
+ }
+
+ int GetExitStatus() const {
+ assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
+ return m_status;
+ }
+
+ int GetSignal() const {
+ assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
+ GetKind() == eSignalDeliveredMessage);
+ return m_status;
+ }
+
+ int GetStopStatus() const {
+ assert(GetKind() == eSignalMessage);
+ return m_status;
+ }
+
+ CrashReason GetCrashReason() const {
+ assert(GetKind() == eCrashMessage);
+ return m_crash_reason;
+ }
+
+ lldb::addr_t GetFaultAddress() const {
+ assert(GetKind() == eCrashMessage);
+ return m_addr;
+ }
+
+ lldb::addr_t GetHWAddress() const {
+ assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
+ return m_addr;
+ }
+
+ lldb::tid_t GetChildTID() const {
+ assert(GetKind() == eNewThreadMessage);
+ return m_child_tid;
+ }
+
+ const char *PrintCrashReason() const;
+
+ const char *PrintKind() const;
+
+ static const char *PrintKind(Kind);
private:
- ProcessMessage(lldb::tid_t tid, Kind kind,
- int status = 0, lldb::addr_t addr = 0)
- : m_tid(tid),
- m_kind(kind),
- m_crash_reason(CrashReason::eInvalidCrashReason),
- m_status(status),
- m_addr(addr),
- m_child_tid(0) { }
-
- ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
- : m_tid(tid),
- m_kind(kind),
- m_crash_reason(CrashReason::eInvalidCrashReason),
- m_status(0),
- m_addr(0),
- m_child_tid(child_tid) { }
-
- lldb::tid_t m_tid;
- Kind m_kind : 8;
- CrashReason m_crash_reason;
- int m_status;
- lldb::addr_t m_addr;
- lldb::tid_t m_child_tid;
+ ProcessMessage(lldb::tid_t tid, Kind kind, int status = 0,
+ lldb::addr_t addr = 0)
+ : m_tid(tid), m_kind(kind),
+ m_crash_reason(CrashReason::eInvalidCrashReason), m_status(status),
+ m_addr(addr), m_child_tid(0) {}
+
+ ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
+ : m_tid(tid), m_kind(kind),
+ m_crash_reason(CrashReason::eInvalidCrashReason), m_status(0),
+ m_addr(0), m_child_tid(child_tid) {}
+
+ lldb::tid_t m_tid;
+ Kind m_kind : 8;
+ CrashReason m_crash_reason;
+ int m_status;
+ lldb::addr_t m_addr;
+ lldb::tid_t m_child_tid;
};
#endif // #ifndef liblldb_ProcessMessage_H_
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
index b259804a3a27..9ced11c7ca2a 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
@@ -1,4 +1,5 @@
-//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++ -*-===//
+//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,199 +12,185 @@
#include <mutex>
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
#include "ProcessPOSIXLog.h"
using namespace lldb;
using namespace lldb_private;
-
// We want to avoid global constructors where code needs to be run so here we
// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is
+// that will construct the static g_log_sp the first time this function is
// called.
static bool g_log_enabled = false;
-static Log * g_log = NULL;
-static Log *
-GetLog ()
-{
- if (!g_log_enabled)
- return NULL;
- return g_log;
+static Log *g_log = NULL;
+static Log *GetLog() {
+ if (!g_log_enabled)
+ return NULL;
+ return g_log;
}
-void
-ProcessPOSIXLog::Initialize(ConstString name)
-{
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, [name](){
- Log::Callbacks log_callbacks = {
- DisableLog,
- EnableLog,
- ListLogCategories
- };
-
- Log::RegisterLogChannel (name, log_callbacks);
- RegisterPluginName(name);
- });
-}
+void ProcessPOSIXLog::Initialize(ConstString name) {
+ static std::once_flag g_once_flag;
-Log *
-ProcessPOSIXLog::GetLogIfAllCategoriesSet (uint32_t mask)
-{
- Log *log(GetLog ());
- if (log && mask)
- {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
+ std::call_once(g_once_flag, [name]() {
+ Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
+
+ Log::RegisterLogChannel(name, log_callbacks);
+ RegisterPluginName(name);
+ });
}
-static uint32_t
-GetFlagBits (const char *arg)
-{
- if (::strcasecmp (arg, "all") == 0 ) return POSIX_LOG_ALL;
- else if (::strcasecmp (arg, "async") == 0 ) return POSIX_LOG_ASYNC;
- else if (::strncasecmp (arg, "break", 5) == 0 ) return POSIX_LOG_BREAKPOINTS;
- else if (::strncasecmp (arg, "comm", 4) == 0 ) return POSIX_LOG_COMM;
- else if (::strcasecmp (arg, "default") == 0 ) return POSIX_LOG_DEFAULT;
- else if (::strcasecmp (arg, "packets") == 0 ) return POSIX_LOG_PACKETS;
- else if (::strcasecmp (arg, "memory") == 0 ) return POSIX_LOG_MEMORY;
- else if (::strcasecmp (arg, "data-short") == 0 ) return POSIX_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp (arg, "data-long") == 0 ) return POSIX_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp (arg, "process") == 0 ) return POSIX_LOG_PROCESS;
- else if (::strcasecmp (arg, "ptrace") == 0 ) return POSIX_LOG_PTRACE;
- else if (::strcasecmp (arg, "registers") == 0 ) return POSIX_LOG_REGISTERS;
- else if (::strcasecmp (arg, "step") == 0 ) return POSIX_LOG_STEP;
- else if (::strcasecmp (arg, "thread") == 0 ) return POSIX_LOG_THREAD;
- else if (::strcasecmp (arg, "verbose") == 0 ) return POSIX_LOG_VERBOSE;
- else if (::strncasecmp (arg, "watch", 5) == 0 ) return POSIX_LOG_WATCHPOINTS;
- return 0;
+Log *ProcessPOSIXLog::GetLogIfAllCategoriesSet(uint32_t mask) {
+ Log *log(GetLog());
+ if (log && mask) {
+ uint32_t log_mask = log->GetMask().Get();
+ if ((log_mask & mask) != mask)
+ return NULL;
+ }
+ return log;
}
-void
-ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm)
-{
- Log *log (GetLog ());
- if (log)
- {
- uint32_t flag_bits = 0;
-
- flag_bits = log->GetMask().Get();
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits &= ~bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories (feedback_strm);
- }
- }
-
- log->GetMask().Reset (flag_bits);
- if (flag_bits == 0)
- g_log_enabled = false;
- }
-
- return;
+static uint32_t GetFlagBits(const char *arg) {
+ if (::strcasecmp(arg, "all") == 0)
+ return POSIX_LOG_ALL;
+ else if (::strcasecmp(arg, "async") == 0)
+ return POSIX_LOG_ASYNC;
+ else if (::strncasecmp(arg, "break", 5) == 0)
+ return POSIX_LOG_BREAKPOINTS;
+ else if (::strncasecmp(arg, "comm", 4) == 0)
+ return POSIX_LOG_COMM;
+ else if (::strcasecmp(arg, "default") == 0)
+ return POSIX_LOG_DEFAULT;
+ else if (::strcasecmp(arg, "packets") == 0)
+ return POSIX_LOG_PACKETS;
+ else if (::strcasecmp(arg, "memory") == 0)
+ return POSIX_LOG_MEMORY;
+ else if (::strcasecmp(arg, "data-short") == 0)
+ return POSIX_LOG_MEMORY_DATA_SHORT;
+ else if (::strcasecmp(arg, "data-long") == 0)
+ return POSIX_LOG_MEMORY_DATA_LONG;
+ else if (::strcasecmp(arg, "process") == 0)
+ return POSIX_LOG_PROCESS;
+ else if (::strcasecmp(arg, "ptrace") == 0)
+ return POSIX_LOG_PTRACE;
+ else if (::strcasecmp(arg, "registers") == 0)
+ return POSIX_LOG_REGISTERS;
+ else if (::strcasecmp(arg, "step") == 0)
+ return POSIX_LOG_STEP;
+ else if (::strcasecmp(arg, "thread") == 0)
+ return POSIX_LOG_THREAD;
+ else if (::strcasecmp(arg, "verbose") == 0)
+ return POSIX_LOG_VERBOSE;
+ else if (::strncasecmp(arg, "watch", 5) == 0)
+ return POSIX_LOG_WATCHPOINTS;
+ return 0;
}
-Log *
-ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **args, Stream *feedback_strm)
-{
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the same.
+void ProcessPOSIXLog::DisableLog(const char **args, Stream *feedback_strm) {
+ Log *log(GetLog());
+ if (log) {
uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp)
- {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
+
+ flag_bits = log->GetMask().Get();
+ for (; args && args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits &= ~bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories(feedback_strm);
+ }
}
+ log->GetMask().Reset(flag_bits);
+ if (flag_bits == 0)
+ g_log_enabled = false;
+ }
+
+ return;
+}
+
+Log *ProcessPOSIXLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
+ const char **args, Stream *feedback_strm) {
+ // Try see if there already is a log - that way we can reuse its settings.
+ // We could reuse the log in toto, but we don't know that the stream is the
+ // same.
+ uint32_t flag_bits = 0;
+ if (g_log)
+ flag_bits = g_log->GetMask().Get();
+
+ // Now make a new log with this stream if one was provided
+ if (log_stream_sp) {
if (g_log)
- {
- bool got_unknown_category = false;
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits |= bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false)
- {
- got_unknown_category = true;
- ListLogCategories (feedback_strm);
- }
- }
+ g_log->SetStream(log_stream_sp);
+ else
+ g_log = new Log(log_stream_sp);
+ }
+
+ if (g_log) {
+ bool got_unknown_category = false;
+ for (; args && args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits |= bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ if (got_unknown_category == false) {
+ got_unknown_category = true;
+ ListLogCategories(feedback_strm);
}
- if (flag_bits == 0)
- flag_bits = POSIX_LOG_DEFAULT;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- g_log_enabled = true;
+ }
}
- return g_log;
+ if (flag_bits == 0)
+ flag_bits = POSIX_LOG_DEFAULT;
+ g_log->GetMask().Reset(flag_bits);
+ g_log->GetOptions().Reset(log_options);
+ g_log_enabled = true;
+ }
+ return g_log;
}
-void
-ProcessPOSIXLog::ListLogCategories (Stream *strm)
-{
- strm->Printf ("Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " async - log asynchronous activity\n"
- " break - log breakpoints\n"
- " communication - log communication activity\n"
- " default - enable the default set of logging categories for liblldb\n"
- " packets - log gdb remote packets\n"
- " memory - log memory reads and writes\n"
- " data-short - log memory bytes for memory reads and writes for short transactions only\n"
- " data-long - log memory bytes for memory reads and writes for all transactions\n"
- " process - log process events and activities\n"
+void ProcessPOSIXLog::ListLogCategories(Stream *strm) {
+ strm->Printf(
+ "Logging categories for '%s':\n"
+ " all - turn on all available logging categories\n"
+ " async - log asynchronous activity\n"
+ " break - log breakpoints\n"
+ " communication - log communication activity\n"
+ " default - enable the default set of logging categories for liblldb\n"
+ " packets - log gdb remote packets\n"
+ " memory - log memory reads and writes\n"
+ " data-short - log memory bytes for memory reads and writes for short "
+ "transactions only\n"
+ " data-long - log memory bytes for memory reads and writes for all "
+ "transactions\n"
+ " process - log process events and activities\n"
#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- " ptrace - log all calls to ptrace\n"
+ " ptrace - log all calls to ptrace\n"
#endif
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n", ProcessPOSIXLog::m_pluginname);
+ " registers - log register read/writes\n"
+ " thread - log thread events and activities\n"
+ " step - log step related activities\n"
+ " verbose - enable verbose logging\n"
+ " watch - log watchpoint related activities\n",
+ ProcessPOSIXLog::m_pluginname);
}
-
-void
-ProcessPOSIXLog::LogIf (uint32_t mask, const char *format, ...)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (mask));
- if (log)
- {
- va_list args;
- va_start (args, format);
- log->VAPrintf (format, args);
- va_end (args);
- }
+void ProcessPOSIXLog::LogIf(uint32_t mask, const char *format, ...) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(mask));
+ if (log) {
+ va_list args;
+ va_start(args, format);
+ log->VAPrintf(format, args);
+ va_end(args);
+ }
}
int ProcessPOSIXLog::m_nestinglevel;
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
index 7edd839152e6..7d187da4e488 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
@@ -1,4 +1,5 @@
-//===-- ProcessPOSIXLog.h -----------------------------------------*- C++ -*-===//
+//===-- ProcessPOSIXLog.h -----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,101 +18,85 @@
// Project includes
#include "lldb/Core/Log.h"
-#define POSIX_LOG_VERBOSE (1u << 0)
-#define POSIX_LOG_PROCESS (1u << 1)
-#define POSIX_LOG_THREAD (1u << 2)
-#define POSIX_LOG_PACKETS (1u << 3)
-#define POSIX_LOG_MEMORY (1u << 4) // Log memory reads/writes calls
-#define POSIX_LOG_MEMORY_DATA_SHORT (1u << 5) // Log short memory reads/writes bytes
-#define POSIX_LOG_MEMORY_DATA_LONG (1u << 6) // Log all memory reads/writes bytes
-#define POSIX_LOG_BREAKPOINTS (1u << 7)
-#define POSIX_LOG_WATCHPOINTS (1u << 8)
-#define POSIX_LOG_STEP (1u << 9)
-#define POSIX_LOG_COMM (1u << 10)
-#define POSIX_LOG_ASYNC (1u << 11)
-#define POSIX_LOG_PTRACE (1u << 12)
-#define POSIX_LOG_REGISTERS (1u << 13)
-#define POSIX_LOG_ALL (UINT32_MAX)
-#define POSIX_LOG_DEFAULT POSIX_LOG_PACKETS
+#define POSIX_LOG_VERBOSE (1u << 0)
+#define POSIX_LOG_PROCESS (1u << 1)
+#define POSIX_LOG_THREAD (1u << 2)
+#define POSIX_LOG_PACKETS (1u << 3)
+#define POSIX_LOG_MEMORY (1u << 4) // Log memory reads/writes calls
+#define POSIX_LOG_MEMORY_DATA_SHORT \
+ (1u << 5) // Log short memory reads/writes bytes
+#define POSIX_LOG_MEMORY_DATA_LONG \
+ (1u << 6) // Log all memory reads/writes bytes
+#define POSIX_LOG_BREAKPOINTS (1u << 7)
+#define POSIX_LOG_WATCHPOINTS (1u << 8)
+#define POSIX_LOG_STEP (1u << 9)
+#define POSIX_LOG_COMM (1u << 10)
+#define POSIX_LOG_ASYNC (1u << 11)
+#define POSIX_LOG_PTRACE (1u << 12)
+#define POSIX_LOG_REGISTERS (1u << 13)
+#define POSIX_LOG_ALL (UINT32_MAX)
+#define POSIX_LOG_DEFAULT POSIX_LOG_PACKETS
// The size which determines "short memory reads/writes".
-#define POSIX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t))
+#define POSIX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t))
-class ProcessPOSIXLog
-{
- static int m_nestinglevel;
- static const char *m_pluginname;
+class ProcessPOSIXLog {
+ static int m_nestinglevel;
+ static const char *m_pluginname;
public:
- // ---------------------------------------------------------------------
- // Public Static Methods
- // ---------------------------------------------------------------------
- static void
- Initialize(lldb_private::ConstString name);
-
- static void
- RegisterPluginName(const char *pluginName)
- {
- m_pluginname = pluginName;
- }
-
- static void
- RegisterPluginName(lldb_private::ConstString pluginName)
- {
- m_pluginname = pluginName.GetCString();
- }
-
- static lldb_private::Log *
- GetLogIfAllCategoriesSet(uint32_t mask = 0);
-
- static void
- DisableLog (const char **args, lldb_private::Stream *feedback_strm);
-
- static lldb_private::Log *
- EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options,
- const char **args, lldb_private::Stream *feedback_strm);
-
- static void
- ListLogCategories (lldb_private::Stream *strm);
-
- static void
- LogIf (uint32_t mask, const char *format, ...);
-
- // The following functions can be used to enable the client to limit
- // logging to only the top level function calls. This is useful for
- // recursive functions. FIXME: not thread safe!
- // Example:
- // void NestingFunc() {
- // LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
- // if (log)
- // {
- // ProcessPOSIXLog::IncNestLevel();
- // if (ProcessPOSIXLog::AtTopNestLevel())
- // log->Print(msg);
- // }
- // NestingFunc();
- // if (log)
- // ProcessPOSIXLog::DecNestLevel();
- // }
-
- static bool
- AtTopNestLevel()
- {
- return m_nestinglevel == 1;
- }
-
- static void
- IncNestLevel()
- {
- ++m_nestinglevel;
- }
-
- static void
- DecNestLevel()
- {
- --m_nestinglevel;
- assert(m_nestinglevel >= 0);
- }
+ // ---------------------------------------------------------------------
+ // Public Static Methods
+ // ---------------------------------------------------------------------
+ static void Initialize(lldb_private::ConstString name);
+
+ static void RegisterPluginName(const char *pluginName) {
+ m_pluginname = pluginName;
+ }
+
+ static void RegisterPluginName(lldb_private::ConstString pluginName) {
+ m_pluginname = pluginName.GetCString();
+ }
+
+ static lldb_private::Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
+
+ static void DisableLog(const char **args,
+ lldb_private::Stream *feedback_strm);
+
+ static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char **args,
+ lldb_private::Stream *feedback_strm);
+
+ static void ListLogCategories(lldb_private::Stream *strm);
+
+ static void LogIf(uint32_t mask, const char *format, ...);
+
+ // The following functions can be used to enable the client to limit
+ // logging to only the top level function calls. This is useful for
+ // recursive functions. FIXME: not thread safe!
+ // Example:
+ // void NestingFunc() {
+ // LogSP log
+ // (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
+ // if (log)
+ // {
+ // ProcessPOSIXLog::IncNestLevel();
+ // if (ProcessPOSIXLog::AtTopNestLevel())
+ // log->Print(msg);
+ // }
+ // NestingFunc();
+ // if (log)
+ // ProcessPOSIXLog::DecNestLevel();
+ // }
+
+ static bool AtTopNestLevel() { return m_nestinglevel == 1; }
+
+ static void IncNestLevel() { ++m_nestinglevel; }
+
+ static void DecNestLevel() {
+ --m_nestinglevel;
+ assert(m_nestinglevel >= 0);
+ }
};
-#endif // liblldb_ProcessPOSIXLog_h_
+#endif // liblldb_ProcessPOSIXLog_h_