diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/tools/lldb-mi/MICmnStreamStderr.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/tools/lldb-mi/MICmnStreamStderr.cpp')
-rw-r--r-- | lldb/tools/lldb-mi/MICmnStreamStderr.cpp | 250 |
1 files changed, 129 insertions, 121 deletions
diff --git a/lldb/tools/lldb-mi/MICmnStreamStderr.cpp b/lldb/tools/lldb-mi/MICmnStreamStderr.cpp index e5c494ba38f..2bbbd4b5058 100644 --- a/lldb/tools/lldb-mi/MICmnStreamStderr.cpp +++ b/lldb/tools/lldb-mi/MICmnStreamStderr.cpp @@ -1,4 +1,5 @@ -//===-- MICmnStreamStderr.cpp ------------------------------------*- C++ -*-===// +//===-- MICmnStreamStderr.cpp ------------------------------------*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -13,30 +14,28 @@ #include "MICmnResources.h" #include "MIDriver.h" -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: CMICmnStreamStderr constructor. // Type: Method. // Args: None. // Return: None. // Throws: None. //-- -CMICmnStreamStderr::CMICmnStreamStderr() -{ -} +CMICmnStreamStderr::CMICmnStreamStderr() {} -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: CMICmnStreamStderr destructor. // Type: Overridable. // Args: None. // Return: None. // Throws: None. //-- -CMICmnStreamStderr::~CMICmnStreamStderr() -{ - Shutdown(); -} +CMICmnStreamStderr::~CMICmnStreamStderr() { Shutdown(); } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Initialize resources for *this stderr stream. // Type: Method. // Args: None. @@ -44,15 +43,13 @@ CMICmnStreamStderr::~CMICmnStreamStderr() // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::Initialize() -{ - m_clientUsageRefCnt++; +bool CMICmnStreamStderr::Initialize() { + m_clientUsageRefCnt++; - if (m_bInitialized) - return MIstatus::success; + if (m_bInitialized) + return MIstatus::success; - bool bOk = MIstatus::success; + bool bOk = MIstatus::success; #ifdef _MSC_VER // Debugging / I/O issues with client. @@ -62,12 +59,13 @@ CMICmnStreamStderr::Initialize() //::setbuf( stderr, NULL ); #endif // _MSC_VER - m_bInitialized = bOk; + m_bInitialized = bOk; - return MIstatus::success; + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Release resources for *this stderr stream. // Type: Method. // Args: None. @@ -75,114 +73,125 @@ CMICmnStreamStderr::Initialize() // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::Shutdown() -{ - if (--m_clientUsageRefCnt > 0) - return MIstatus::success; +bool CMICmnStreamStderr::Shutdown() { + if (--m_clientUsageRefCnt > 0) + return MIstatus::success; - if (!m_bInitialized) - return MIstatus::success; + if (!m_bInitialized) + return MIstatus::success; - ClrErrorDescription(); + ClrErrorDescription(); - m_bInitialized = false; + m_bInitialized = false; - return MIstatus::success; + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ -// Details: Write text data to stderr. Prefix the message with "MI:". The text data does -// not need to include a carriage line return as this is added to the text. The +//++ +//------------------------------------------------------------------------------------ +// Details: Write text data to stderr. Prefix the message with "MI:". The text +// data does +// not need to include a carriage line return as this is added to the +// text. The // function also then passes the text data into the CMICmnLog logger. // Type: Method. // Args: vText - (R) Text data. -// vbSendToLog - (R) True = Yes send to the Log file too, false = do not. (Dflt = true) +// vbSendToLog - (R) True = Yes send to the Log file too, false = do +// not. (Dflt = true) // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::Write(const CMIUtilString &vText, const bool vbSendToLog /* = true */) -{ - if (vText.length() == 0) - return MIstatus::failure; +bool CMICmnStreamStderr::Write(const CMIUtilString &vText, + const bool vbSendToLog /* = true */) { + if (vText.length() == 0) + return MIstatus::failure; - const CMIUtilString strPrefixed(CMIUtilString::Format("%s: %s", CMIDriver::Instance().GetAppNameShort().c_str(), vText.c_str())); + const CMIUtilString strPrefixed(CMIUtilString::Format( + "%s: %s", CMIDriver::Instance().GetAppNameShort().c_str(), + vText.c_str())); - return WritePriv(strPrefixed, vText, vbSendToLog); + return WritePriv(strPrefixed, vText, vbSendToLog); } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Write an LLDB text message to stderr. -// The text data does not need to include a carriage line return as this is added -// to the text. The function also then passes the text data into the CMICmnLog +// The text data does not need to include a carriage line return as +// this is added +// to the text. The function also then passes the text data into the +// CMICmnLog // logger. // Type: Method. // Args: vText - (R) Text data. -// vbSendToLog - (R) True = Yes send to the Log file too, false = do not. (Dflt = true) +// vbSendToLog - (R) True = Yes send to the Log file too, false = do +// not. (Dflt = true) // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::WriteLLDBMsg(const CMIUtilString &vText, const bool vbSendToLog /* = true */) -{ - if (vText.length() == 0) - return MIstatus::failure; +bool CMICmnStreamStderr::WriteLLDBMsg(const CMIUtilString &vText, + const bool vbSendToLog /* = true */) { + if (vText.length() == 0) + return MIstatus::failure; - const CMIUtilString strPrefixed(CMIUtilString::Format("LLDB: %s", vText.c_str())); + const CMIUtilString strPrefixed( + CMIUtilString::Format("LLDB: %s", vText.c_str())); - return WritePriv(vText, strPrefixed, vbSendToLog); + return WritePriv(vText, strPrefixed, vbSendToLog); } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Write text data to stderr. The text data does not need to -// include a carriage line return as this is added to the text. The function also +// include a carriage line return as this is added to the text. The +// function also // then passes the text data into the CMICmnLog logger. // Type: Method. -// Args: vText - (R) Text data. May be prefixed with MI app's short name. +// Args: vText - (R) Text data. May be prefixed with MI app's short +// name. // vTxtForLogFile - (R) Text data. -// vbSendToLog - (R) True = Yes send to the Log file too, false = do not. (Dflt = true) +// vbSendToLog - (R) True = Yes send to the Log file too, false = +// do not. (Dflt = true) // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::WritePriv(const CMIUtilString &vText, const CMIUtilString &vTxtForLogFile, const bool vbSendToLog /* = true */) -{ - if (vText.length() == 0) - return MIstatus::failure; - - bool bOk = MIstatus::success; - { - // Grab the stderr thread lock while we print - CMIUtilThreadLock _lock(m_mutex); - - // Send this text to stderr - const MIint status = ::fputs(vText.c_str(), stderr); - if (status == EOF) - { - const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN), vText.c_str())); - SetErrorDescription(errMsg); - bOk = MIstatus::failure; - } - else - { - ::fprintf(stderr, "\n"); - ::fflush(stderr); - } - - // Send this text to the log - if (bOk && vbSendToLog) - bOk &= m_pLog->WriteLog(vTxtForLogFile); +bool CMICmnStreamStderr::WritePriv(const CMIUtilString &vText, + const CMIUtilString &vTxtForLogFile, + const bool vbSendToLog /* = true */) { + if (vText.length() == 0) + return MIstatus::failure; + + bool bOk = MIstatus::success; + { + // Grab the stderr thread lock while we print + CMIUtilThreadLock _lock(m_mutex); + + // Send this text to stderr + const MIint status = ::fputs(vText.c_str(), stderr); + if (status == EOF) { + const CMIUtilString errMsg(CMIUtilString::Format( + MIRSRC(IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN), vText.c_str())); + SetErrorDescription(errMsg); + bOk = MIstatus::failure; + } else { + ::fprintf(stderr, "\n"); + ::fflush(stderr); } - return bOk; + // Send this text to the log + if (bOk && vbSendToLog) + bOk &= m_pLog->WriteLog(vTxtForLogFile); + } + + return bOk; } -//++ ------------------------------------------------------------------------------------ -// Details: Lock the availability of the stream stderr. Other users of *this stream will +//++ +//------------------------------------------------------------------------------------ +// Details: Lock the availability of the stream stderr. Other users of *this +// stream will // be stalled until it is available (Unlock()). // Type: Method. // Args: None. @@ -190,14 +199,13 @@ CMICmnStreamStderr::WritePriv(const CMIUtilString &vText, const CMIUtilString &v // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::Lock() -{ - m_mutex.Lock(); - return MIstatus::success; +bool CMICmnStreamStderr::Lock() { + m_mutex.Lock(); + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Release a previously locked stderr. // Type: Method. // Args: None. @@ -205,15 +213,15 @@ CMICmnStreamStderr::Lock() // MIstatus::failure - Functional failed. // Throws: None. //-- -bool -CMICmnStreamStderr::Unlock() -{ - m_mutex.Unlock(); - return MIstatus::success; +bool CMICmnStreamStderr::Unlock() { + m_mutex.Unlock(); + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ -// Details: Take MI Driver text message and send to the stderr stream. Also output to the +//++ +//------------------------------------------------------------------------------------ +// Details: Take MI Driver text message and send to the stderr stream. Also +// output to the // MI Log file. // Type: Static method. // Args: vrTxt - (R) Text. @@ -221,20 +229,22 @@ CMICmnStreamStderr::Unlock() // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmnStreamStderr::TextToStderr(const CMIUtilString &vrTxt) -{ - const bool bLock = CMICmnStreamStderr::Instance().Lock(); - const bool bOk = bLock && CMICmnStreamStderr::Instance().Write(vrTxt); - bLock &&CMICmnStreamStderr::Instance().Unlock(); - - return bOk; +bool CMICmnStreamStderr::TextToStderr(const CMIUtilString &vrTxt) { + const bool bLock = CMICmnStreamStderr::Instance().Lock(); + const bool bOk = bLock && CMICmnStreamStderr::Instance().Write(vrTxt); + bLock &&CMICmnStreamStderr::Instance().Unlock(); + + return bOk; } -//++ ------------------------------------------------------------------------------------ -// Details: Take an LLDB message and send to the stderr stream. The message is not always -// an error message. The user has typed a command in to the Eclipse console (by- -// passing Eclipse) and this is the result message from LLDB back to the user. +//++ +//------------------------------------------------------------------------------------ +// Details: Take an LLDB message and send to the stderr stream. The message is +// not always +// an error message. The user has typed a command in to the Eclipse +// console (by- +// passing Eclipse) and this is the result message from LLDB back to +// the user. // Also output to the MI Log file. // Type: Static method. // Args: vrTxt - (R) Text. @@ -242,12 +252,10 @@ CMICmnStreamStderr::TextToStderr(const CMIUtilString &vrTxt) // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmnStreamStderr::LLDBMsgToConsole(const CMIUtilString &vrTxt) -{ - const bool bLock = CMICmnStreamStderr::Instance().Lock(); - const bool bOk = bLock && CMICmnStreamStderr::Instance().WriteLLDBMsg(vrTxt); - bLock &&CMICmnStreamStderr::Instance().Unlock(); - - return bOk; +bool CMICmnStreamStderr::LLDBMsgToConsole(const CMIUtilString &vrTxt) { + const bool bLock = CMICmnStreamStderr::Instance().Lock(); + const bool bOk = bLock && CMICmnStreamStderr::Instance().WriteLLDBMsg(vrTxt); + bLock &&CMICmnStreamStderr::Instance().Unlock(); + + return bOk; } |