aboutsummaryrefslogtreecommitdiff
path: root/lldb/tools/lldb-mi/MICmnStreamStdout.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/tools/lldb-mi/MICmnStreamStdout.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** 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/MICmnStreamStdout.cpp')
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStdout.cpp216
1 files changed, 110 insertions, 106 deletions
diff --git a/lldb/tools/lldb-mi/MICmnStreamStdout.cpp b/lldb/tools/lldb-mi/MICmnStreamStdout.cpp
index 8b65251..064c74f 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStdout.cpp
+++ b/lldb/tools/lldb-mi/MICmnStreamStdout.cpp
@@ -13,30 +13,28 @@
#include "MICmnResources.h"
#include "MIDriver.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdout constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdout::CMICmnStreamStdout()
-{
-}
+CMICmnStreamStdout::CMICmnStreamStdout() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdout destructor.
// Type: Overridable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnStreamStdout::~CMICmnStreamStdout()
-{
- Shutdown();
-}
+CMICmnStreamStdout::~CMICmnStreamStdout() { Shutdown(); }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Stdout stream.
// Type: Method.
// Args: None.
@@ -44,15 +42,13 @@ CMICmnStreamStdout::~CMICmnStreamStdout()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::Initialize()
-{
- m_clientUsageRefCnt++;
+bool CMICmnStreamStdout::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 +58,13 @@ CMICmnStreamStdout::Initialize()
//::setbuf( stdout, NULL );
#endif // _MSC_VER
- m_bInitialized = bOk;
+ m_bInitialized = bOk;
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Release resources for *this Stdout stream.
// Type: Method.
// Args: None.
@@ -75,106 +72,117 @@ CMICmnStreamStdout::Initialize()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::Shutdown()
-{
- if (--m_clientUsageRefCnt > 0)
- return MIstatus::success;
+bool CMICmnStreamStdout::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 an MI format type response to stdout. The text data does not need to
-// include a carriage line return as this is added to the text. The function also
+//++
+//------------------------------------------------------------------------------------
+// Details: Write an MI format type response to stdout. 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) MI formatted text.
-// 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
-CMICmnStreamStdout::WriteMIResponse(const CMIUtilString &vText, const bool vbSendToLog /* = true */)
-{
- return WritePriv(vText, vText, vbSendToLog);
+bool CMICmnStreamStdout::WriteMIResponse(const CMIUtilString &vText,
+ const bool vbSendToLog /* = true */) {
+ return WritePriv(vText, vText, vbSendToLog);
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Write text data to stdout. 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.
-// 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
-CMICmnStreamStdout::Write(const CMIUtilString &vText, const bool vbSendToLog /* = true */)
-{
- if (vText.length() == 0)
- return MIstatus::failure;
+bool CMICmnStreamStdout::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 text data to stdout. 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 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
-CMICmnStreamStdout::WritePriv(const CMIUtilString &vText, const CMIUtilString &vTxtForLogFile, const bool vbSendToLog /* = true */)
-{
- if (vText.length() == 0)
- return MIstatus::failure;
-
- bool bOk = MIstatus::success;
- {
- // Grab the stdout thread lock while we print
- CMIUtilThreadLock _lock(m_mutex);
-
- // Send this text to stdout
- const MIint status = ::fputs(vText.c_str(), stdout);
- if (status == EOF)
- // Don't call the CMICmnBase::SetErrorDescription() because it will cause a stack overflow:
- // CMICmnBase::SetErrorDescription -> CMICmnStreamStdout::Write -> CMICmnStreamStdout::WritePriv -> CMICmnBase::SetErrorDescription
- bOk = MIstatus::failure;
- else
- {
- ::fprintf(stdout, "\n");
- ::fflush(stdout);
- }
-
- // Send this text to the log
- if (bOk && vbSendToLog)
- bOk &= m_pLog->WriteLog(vTxtForLogFile);
+bool CMICmnStreamStdout::WritePriv(const CMIUtilString &vText,
+ const CMIUtilString &vTxtForLogFile,
+ const bool vbSendToLog /* = true */) {
+ if (vText.length() == 0)
+ return MIstatus::failure;
+
+ bool bOk = MIstatus::success;
+ {
+ // Grab the stdout thread lock while we print
+ CMIUtilThreadLock _lock(m_mutex);
+
+ // Send this text to stdout
+ const MIint status = ::fputs(vText.c_str(), stdout);
+ if (status == EOF)
+ // Don't call the CMICmnBase::SetErrorDescription() because it will cause
+ // a stack overflow:
+ // CMICmnBase::SetErrorDescription -> CMICmnStreamStdout::Write ->
+ // CMICmnStreamStdout::WritePriv -> CMICmnBase::SetErrorDescription
+ bOk = MIstatus::failure;
+ else {
+ ::fprintf(stdout, "\n");
+ ::fflush(stdout);
}
- 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 stdout. Other users of *this stream will
+//++
+//------------------------------------------------------------------------------------
+// Details: Lock the availability of the stream stdout. Other users of *this
+// stream will
// be stalled until it is available (Unlock()).
// Type: Method.
// Args: None.
@@ -182,14 +190,13 @@ CMICmnStreamStdout::WritePriv(const CMIUtilString &vText, const CMIUtilString &v
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::Lock()
-{
- m_mutex.Lock();
- return MIstatus::success;
+bool CMICmnStreamStdout::Lock() {
+ m_mutex.Lock();
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Release a previously locked stdout.
// Type: Method.
// Args: None.
@@ -197,15 +204,15 @@ CMICmnStreamStdout::Lock()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::Unlock()
-{
- m_mutex.Unlock();
- return MIstatus::success;
+bool CMICmnStreamStdout::Unlock() {
+ m_mutex.Unlock();
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Take a text data and send to the stdout stream. Also output to the MI Log
+//++
+//------------------------------------------------------------------------------------
+// Details: Take a text data and send to the stdout stream. Also output to the
+// MI Log
// file.
// Type: Static method.
// Args: vrTxt - (R) Text.
@@ -213,14 +220,13 @@ CMICmnStreamStdout::Unlock()
// MIstatus::failure - Functionality failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt)
-{
- const bool bSendToLog = true;
- return CMICmnStreamStdout::Instance().WriteMIResponse(vrTxt, bSendToLog);
+bool CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt) {
+ const bool bSendToLog = true;
+ return CMICmnStreamStdout::Instance().WriteMIResponse(vrTxt, bSendToLog);
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Write prompt to stdout if it's enabled.
// Type: Static method.
// Args: None.
@@ -228,11 +234,9 @@ CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt)
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmnStreamStdout::WritePrompt()
-{
- const CMICmnStreamStdin &rStdinMan = CMICmnStreamStdin::Instance();
- if (rStdinMan.GetEnablePrompt())
- return TextToStdout(rStdinMan.GetPrompt());
- return MIstatus::success;
+bool CMICmnStreamStdout::WritePrompt() {
+ const CMICmnStreamStdin &rStdinMan = CMICmnStreamStdin::Instance();
+ if (rStdinMan.GetEnablePrompt())
+ return TextToStdout(rStdinMan.GetPrompt());
+ return MIstatus::success;
}