summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-mi/MICmnLog.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/MICmnLog.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-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/MICmnLog.cpp')
-rw-r--r--lldb/tools/lldb-mi/MICmnLog.cpp388
1 files changed, 190 insertions, 198 deletions
diff --git a/lldb/tools/lldb-mi/MICmnLog.cpp b/lldb/tools/lldb-mi/MICmnLog.cpp
index e85ddba316a..8643a8784e3 100644
--- a/lldb/tools/lldb-mi/MICmnLog.cpp
+++ b/lldb/tools/lldb-mi/MICmnLog.cpp
@@ -10,37 +10,34 @@
// In-house headers:
#include "MICmnLog.h"
#include "MICmnLogMediumFile.h"
-#include "MIDriverMgr.h"
#include "MICmnResources.h"
+#include "MIDriverMgr.h"
#include "MIUtilDateTimeStd.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmnLog constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnLog::CMICmnLog()
- : m_bEnabled(false)
- , m_bInitializingATM(false)
-{
- // Do not use this constructor, use Initialize()
+CMICmnLog::CMICmnLog() : m_bEnabled(false), m_bInitializingATM(false) {
+ // Do not use this constructor, use Initialize()
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmnLog destructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnLog::~CMICmnLog()
-{
- Shutdown();
-}
+CMICmnLog::~CMICmnLog() { Shutdown(); }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Logger.
// Type: Method.
// Args: None.
@@ -48,52 +45,57 @@ CMICmnLog::~CMICmnLog()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::Initialize()
-{
- m_clientUsageRefCnt++;
-
- if (m_bInitialized)
- return MIstatus::success;
-
- ClrErrorDescription();
-
- // Mediums set inside because explicitly initing in MIDriverMain.cpp causes compile errors with CAtlFile
- CMICmnLogMediumFile &rFileLog(CMICmnLogMediumFile::Instance());
- bool bOk = RegisterMedium(rFileLog);
- if (bOk)
- {
- // Set the Log trace file's header
- const CMIUtilString &rCR(rFileLog.GetLineReturn());
- CMIUtilDateTimeStd date;
- CMIUtilString msg;
- msg = CMIUtilString::Format("%s\n", CMIDriverMgr::Instance().GetAppVersion().c_str());
- CMIUtilString logHdr(msg);
- msg = CMIUtilString::Format(MIRSRC(IDS_LOG_MSG_CREATION_DATE), date.GetDate().c_str(), date.GetTime().c_str(), rCR.c_str());
- logHdr += msg;
- msg = CMIUtilString::Format(MIRSRC(IDS_LOG_MSG_FILE_LOGGER_PATH), rFileLog.GetFileNamePath().c_str(), rCR.c_str());
- logHdr += msg;
-
- bOk = rFileLog.SetHeaderTxt(logHdr);
-
- // Note log file medium's status is not available until we write at least once to the file (so just write the title 1st line)
- m_bInitializingATM = true;
- CMICmnLog::WriteLog(".");
- if (!rFileLog.IsOk())
- {
- const CMIUtilString msg(
- CMIUtilString::Format(MIRSRC(IDS_LOG_ERR_FILE_LOGGER_DISABLED), rFileLog.GetErrorDescription().c_str()));
- CMICmnLog::WriteLog(msg);
- }
- m_bInitializingATM = false;
+bool CMICmnLog::Initialize() {
+ m_clientUsageRefCnt++;
+
+ if (m_bInitialized)
+ return MIstatus::success;
+
+ ClrErrorDescription();
+
+ // Mediums set inside because explicitly initing in MIDriverMain.cpp causes
+ // compile errors with CAtlFile
+ CMICmnLogMediumFile &rFileLog(CMICmnLogMediumFile::Instance());
+ bool bOk = RegisterMedium(rFileLog);
+ if (bOk) {
+ // Set the Log trace file's header
+ const CMIUtilString &rCR(rFileLog.GetLineReturn());
+ CMIUtilDateTimeStd date;
+ CMIUtilString msg;
+ msg = CMIUtilString::Format(
+ "%s\n", CMIDriverMgr::Instance().GetAppVersion().c_str());
+ CMIUtilString logHdr(msg);
+ msg = CMIUtilString::Format(MIRSRC(IDS_LOG_MSG_CREATION_DATE),
+ date.GetDate().c_str(), date.GetTime().c_str(),
+ rCR.c_str());
+ logHdr += msg;
+ msg =
+ CMIUtilString::Format(MIRSRC(IDS_LOG_MSG_FILE_LOGGER_PATH),
+ rFileLog.GetFileNamePath().c_str(), rCR.c_str());
+ logHdr += msg;
+
+ bOk = rFileLog.SetHeaderTxt(logHdr);
+
+ // Note log file medium's status is not available until we write at least
+ // once to the file (so just write the title 1st line)
+ m_bInitializingATM = true;
+ CMICmnLog::WriteLog(".");
+ if (!rFileLog.IsOk()) {
+ const CMIUtilString msg(
+ CMIUtilString::Format(MIRSRC(IDS_LOG_ERR_FILE_LOGGER_DISABLED),
+ rFileLog.GetErrorDescription().c_str()));
+ CMICmnLog::WriteLog(msg);
}
+ m_bInitializingATM = false;
+ }
- m_bInitialized = bOk;
+ m_bInitialized = bOk;
- return bOk;
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Release resources for *this Logger.
// Type: Method.
// Args: None.
@@ -101,55 +103,52 @@ CMICmnLog::Initialize()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::Shutdown()
-{
- if (--m_clientUsageRefCnt > 0)
- return MIstatus::success;
+bool CMICmnLog::Shutdown() {
+ if (--m_clientUsageRefCnt > 0)
+ return MIstatus::success;
- if (!m_bInitialized)
- return MIstatus::success;
+ if (!m_bInitialized)
+ return MIstatus::success;
- ClrErrorDescription();
+ ClrErrorDescription();
- const bool bOk = UnregisterMediumAll();
+ const bool bOk = UnregisterMediumAll();
- m_bInitialized = bOk;
+ m_bInitialized = bOk;
- return bOk;
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Enabled or disable *this Logger from writing any data to registered clients.
+//++
+//------------------------------------------------------------------------------------
+// Details: Enabled or disable *this Logger from writing any data to registered
+// clients.
// Type: Method.
// Args: vbYes - (R) True = Logger enabled, false = disabled.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::SetEnabled(const bool vbYes)
-{
- m_bEnabled = vbYes;
+bool CMICmnLog::SetEnabled(const bool vbYes) {
+ m_bEnabled = vbYes;
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve state whether *this Logger is enabled writing data to registered clients.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve state whether *this Logger is enabled writing data to
+// registered clients.
// Type: Method.
// Args: None.
// Return: True = Logger enable.
// False = disabled.
// Throws: None.
//--
-bool
-CMICmnLog::GetEnabled() const
-{
- return m_bEnabled;
-}
+bool CMICmnLog::GetEnabled() const { return m_bEnabled; }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Unregister all the Mediums registered with *this Logger.
// Type: Method.
// Args: None.
@@ -157,22 +156,20 @@ CMICmnLog::GetEnabled() const
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::UnregisterMediumAll()
-{
- MapMediumToName_t::const_iterator it = m_mapMediumToName.begin();
- for (; it != m_mapMediumToName.end(); it++)
- {
- IMedium *pMedium = (*it).first;
- pMedium->Shutdown();
- }
+bool CMICmnLog::UnregisterMediumAll() {
+ MapMediumToName_t::const_iterator it = m_mapMediumToName.begin();
+ for (; it != m_mapMediumToName.end(); it++) {
+ IMedium *pMedium = (*it).first;
+ pMedium->Shutdown();
+ }
- m_mapMediumToName.clear();
+ m_mapMediumToName.clear();
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Register a Medium with *this Logger.
// Type: Method.
// Args: vrMedium - (R) The medium to register.
@@ -180,28 +177,28 @@ CMICmnLog::UnregisterMediumAll()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::RegisterMedium(const IMedium &vrMedium)
-{
- if (HaveMediumAlready(vrMedium))
- return MIstatus::success;
-
- IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
- if (!pMedium->Initialize())
- {
- const CMIUtilString &rStrMedName(pMedium->GetName());
- const CMIUtilString &rStrMedErr(pMedium->GetError());
- SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_LOG_MEDIUM_ERR_INIT), rStrMedName.c_str(), rStrMedErr.c_str()));
- return MIstatus::failure;
- }
+bool CMICmnLog::RegisterMedium(const IMedium &vrMedium) {
+ if (HaveMediumAlready(vrMedium))
+ return MIstatus::success;
- MapPairMediumToName_t pr(pMedium, pMedium->GetName());
- m_mapMediumToName.insert(pr);
+ IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
+ if (!pMedium->Initialize()) {
+ const CMIUtilString &rStrMedName(pMedium->GetName());
+ const CMIUtilString &rStrMedErr(pMedium->GetError());
+ SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_LOG_MEDIUM_ERR_INIT),
+ rStrMedName.c_str(),
+ rStrMedErr.c_str()));
+ return MIstatus::failure;
+ }
- return MIstatus::success;
+ MapPairMediumToName_t pr(pMedium, pMedium->GetName());
+ m_mapMediumToName.insert(pr);
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Query the Logger to see if a medium is already registered.
// Type: Method.
// Args: vrMedium - (R) The medium to query.
@@ -209,18 +206,17 @@ CMICmnLog::RegisterMedium(const IMedium &vrMedium)
// False - not registered.
// Throws: None.
//--
-bool
-CMICmnLog::HaveMediumAlready(const IMedium &vrMedium) const
-{
- IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
- const MapMediumToName_t::const_iterator it = m_mapMediumToName.find(pMedium);
- if (it != m_mapMediumToName.end())
- return true;
-
- return false;
+bool CMICmnLog::HaveMediumAlready(const IMedium &vrMedium) const {
+ IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
+ const MapMediumToName_t::const_iterator it = m_mapMediumToName.find(pMedium);
+ if (it != m_mapMediumToName.end())
+ return true;
+
+ return false;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Unregister a medium from the Logger.
// Type: Method.
// Args: vrMedium - (R) The medium to unregister.
@@ -228,22 +224,26 @@ CMICmnLog::HaveMediumAlready(const IMedium &vrMedium) const
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::UnregisterMedium(const IMedium &vrMedium)
-{
- IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
- m_mapMediumToName.erase(pMedium);
+bool CMICmnLog::UnregisterMedium(const IMedium &vrMedium) {
+ IMedium *pMedium = const_cast<IMedium *>(&vrMedium);
+ m_mapMediumToName.erase(pMedium);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The callee client uses this function to write to the Logger. The data to be
-// written is given out to all the mediums registered. The verbosity type parameter
-// indicates to the medium(s) the type of data or message given to it. The medium has
-// modes of verbosity and depending on the verbosity set determines which writes
+//++
+//------------------------------------------------------------------------------------
+// Details: The callee client uses this function to write to the Logger. The
+// data to be
+// written is given out to all the mediums registered. The verbosity
+// type parameter
+// indicates to the medium(s) the type of data or message given to it.
+// The medium has
+// modes of verbosity and depending on the verbosity set determines
+// which writes
// go in to the logger.
-// The logger must be initialized successfully before a write to any registered
+// The logger must be initialized successfully before a write to any
+// registered
// can be carried out.
// Type: Method.
// Args: vData - (R) The data to write to the logger.
@@ -252,58 +252,55 @@ CMICmnLog::UnregisterMedium(const IMedium &vrMedium)
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::Write(const CMIUtilString &vData, const ELogVerbosity veType)
-{
- if (!m_bInitialized && !m_bInitializingATM)
- return MIstatus::success;
- if (m_bRecursiveDive)
- return MIstatus::success;
- if (!m_bEnabled)
- return MIstatus::success;
-
- m_bRecursiveDive = true;
-
- MIuint cnt = 0;
- MIuint cntErr = 0;
- {
- MapMediumToName_t::const_iterator it = m_mapMediumToName.begin();
- while (it != m_mapMediumToName.end())
- {
- IMedium *pMedium = (*it).first;
- const CMIUtilString &rNameMedium = (*it).second;
- MIunused(rNameMedium);
- if (pMedium->Write(vData, veType))
- cnt++;
- else
- cntErr++;
-
- // Next
- ++it;
- }
- }
-
- bool bOk = MIstatus::success;
- const MIuint mediumCnt = m_mapMediumToName.size();
- if ((cnt == 0) && (mediumCnt > 0))
- {
- SetErrorDescription(MIRSRC(IDS_LOG_MEDIUM_ERR_WRITE_ANY));
- bOk = MIstatus::failure;
- }
- if (bOk && (cntErr != 0))
- {
- SetErrorDescription(MIRSRC(IDS_LOG_MEDIUM_ERR_WRITE_MEDIUMFAIL));
- bOk = MIstatus::failure;
- }
+bool CMICmnLog::Write(const CMIUtilString &vData, const ELogVerbosity veType) {
+ if (!m_bInitialized && !m_bInitializingATM)
+ return MIstatus::success;
+ if (m_bRecursiveDive)
+ return MIstatus::success;
+ if (!m_bEnabled)
+ return MIstatus::success;
- m_bRecursiveDive = false;
+ m_bRecursiveDive = true;
- return bOk;
+ MIuint cnt = 0;
+ MIuint cntErr = 0;
+ {
+ MapMediumToName_t::const_iterator it = m_mapMediumToName.begin();
+ while (it != m_mapMediumToName.end()) {
+ IMedium *pMedium = (*it).first;
+ const CMIUtilString &rNameMedium = (*it).second;
+ MIunused(rNameMedium);
+ if (pMedium->Write(vData, veType))
+ cnt++;
+ else
+ cntErr++;
+
+ // Next
+ ++it;
+ }
+ }
+
+ bool bOk = MIstatus::success;
+ const MIuint mediumCnt = m_mapMediumToName.size();
+ if ((cnt == 0) && (mediumCnt > 0)) {
+ SetErrorDescription(MIRSRC(IDS_LOG_MEDIUM_ERR_WRITE_ANY));
+ bOk = MIstatus::failure;
+ }
+ if (bOk && (cntErr != 0)) {
+ SetErrorDescription(MIRSRC(IDS_LOG_MEDIUM_ERR_WRITE_MEDIUMFAIL));
+ bOk = MIstatus::failure;
+ }
+
+ m_bRecursiveDive = false;
+
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Short cut function call to write only to the Log file.
-// The logger must be initialized successfully before a write to any registered
+// The logger must be initialized successfully before a write to any
+// registered
// can be carried out.
// Type: Static.
// Args: vData - (R) The data to write to the logger.
@@ -311,47 +308,42 @@ CMICmnLog::Write(const CMIUtilString &vData, const ELogVerbosity veType)
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmnLog::WriteLog(const CMIUtilString &vData)
-{
- return CMICmnLog::Instance().Write(vData, CMICmnLog::eLogVerbosity_Log);
+bool CMICmnLog::WriteLog(const CMIUtilString &vData) {
+ return CMICmnLog::Instance().Write(vData, CMICmnLog::eLogVerbosity_Log);
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve a string detailing the last error.
// Type: Method.
// Args: None,
// Return: CMIUtilString.
// Throws: None.
//--
-const CMIUtilString &
-CMICmnLog::GetErrorDescription() const
-{
- return m_strMILastErrorDescription;
+const CMIUtilString &CMICmnLog::GetErrorDescription() const {
+ return m_strMILastErrorDescription;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Set the internal description of the last error.
// Type: Method.
// Args: (R) String containing a description of the last error.
// Return: None.
// Throws: None.
//--
-void
-CMICmnLog::SetErrorDescription(const CMIUtilString &vrTxt) const
-{
- m_strMILastErrorDescription = vrTxt;
+void CMICmnLog::SetErrorDescription(const CMIUtilString &vrTxt) const {
+ m_strMILastErrorDescription = vrTxt;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Clear the last error.
// Type: None.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmnLog::ClrErrorDescription() const
-{
- m_strMILastErrorDescription = CMIUtilString("");
+void CMICmnLog::ClrErrorDescription() const {
+ m_strMILastErrorDescription = CMIUtilString("");
}
OpenPOWER on IntegriCloud