tatyana-krasnukha updated this revision to Diff 186892.
tatyana-krasnukha added a comment.

Fixed misspelling


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55653/new/

https://reviews.llvm.org/D55653

Files:
  MICmdCmdGdbInfo.cpp
  MICmdCmdMiscellanous.cpp
  MICmnLLDBDebugSessionInfo.cpp
  MIDataTypes.h

Index: MIDataTypes.h
===================================================================
--- MIDataTypes.h
+++ MIDataTypes.h
@@ -62,3 +62,18 @@
 // Fundamentals:
 typedef long long MIint64;           // 64bit signed integer.
 typedef unsigned long long MIuint64; // 64bit unsigned integer.
+
+template <typename T>
+class MIDereferenceable {
+public:
+  MIDereferenceable(T *ptr) : m_ptr(ptr) {}
+
+  T *Or(T &alt_value) { return m_ptr ? m_ptr : &alt_value; }
+private:
+  T* m_ptr = nullptr;
+};
+
+template<typename T>
+MIDereferenceable<T> GetDereferenceable(T *ptr) {
+  return MIDereferenceable<T>(ptr);
+}
Index: MICmnLLDBDebugSessionInfo.cpp
===================================================================
--- MICmnLLDBDebugSessionInfo.cpp
+++ MICmnLLDBDebugSessionInfo.cpp
@@ -639,11 +639,10 @@
 
   vwPc = rFrame.GetPC();
 
-  const char *pFnName = rFrame.GetFunctionName();
-  vwFnName = (pFnName != nullptr) ? pFnName : pUnkwn;
+  vwFnName = GetDereferenceable(rFrame.GetFunctionName()).Or(*pUnkwn);
 
-  const char *pFileName = rFrame.GetLineEntry().GetFileSpec().GetFilename();
-  vwFileName = (pFileName != nullptr) ? pFileName : pUnkwn;
+  vwFileName = GetDereferenceable(
+      rFrame.GetLineEntry().GetFileSpec().GetFilename()).Or(*pUnkwn);
 
   vwnLine = rFrame.GetLineEntry().GetLine();
 
@@ -829,9 +828,9 @@
   vrwBrkPtInfo.m_id = vBrkPt.GetID();
   vrwBrkPtInfo.m_strType = "breakpoint";
   vrwBrkPtInfo.m_pc = nAddr;
-  vrwBrkPtInfo.m_fnName = pFn;
-  vrwBrkPtInfo.m_fileName = pFile;
-  vrwBrkPtInfo.m_path = pFilePath;
+  vrwBrkPtInfo.m_fnName = GetDereferenceable(pFn).Or(*pUnkwn);
+  vrwBrkPtInfo.m_fileName = GetDereferenceable(pFile).Or(*pUnkwn);
+  vrwBrkPtInfo.m_path = GetDereferenceable(pFilePath).Or(*pUnkwn);
   vrwBrkPtInfo.m_nLine = nLine;
   vrwBrkPtInfo.m_nTimes = vBrkPt.GetHitCount();
 
Index: MICmdCmdMiscellanous.cpp
===================================================================
--- MICmdCmdMiscellanous.cpp
+++ MICmdCmdMiscellanous.cpp
@@ -336,9 +336,12 @@
     }
 
     if (rSessionInfo.GetTarget().IsValid()) {
+      const char *pUnkwn = "??";
       lldb::SBTarget sbTrgt = rSessionInfo.GetTarget();
-      const char *pDir = sbTrgt.GetExecutable().GetDirectory();
-      const char *pFileName = sbTrgt.GetExecutable().GetFilename();
+      const char *pDir =
+          GetDereferenceable(sbTrgt.GetExecutable().GetDirectory()).Or(*pUnkwn);
+      const char *pFileName =
+          GetDereferenceable(sbTrgt.GetExecutable().GetFilename()).Or(*pUnkwn);
       const CMIUtilString strFile(
           CMIUtilString::Format("%s/%s", pDir, pFileName));
       const CMICmnMIValueConst miValueConst4(strFile);
Index: MICmdCmdGdbInfo.cpp
===================================================================
--- MICmdCmdGdbInfo.cpp
+++ MICmdCmdGdbInfo.cpp
@@ -192,6 +192,8 @@
   bool bOk = CMICmnStreamStdout::TextToStdout(
       "~\"From        To          Syms Read   Shared Object Library\"");
 
+  const char *pUnknown = "??";
+
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
       CMICmnLLDBDebugSessionInfo::Instance());
   lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
@@ -199,9 +201,11 @@
   for (MIuint i = 0; bOk && (i < nModules); i++) {
     lldb::SBModule module = sbTarget.GetModuleAtIndex(i);
     if (module.IsValid()) {
+      auto fileSpec = module.GetFileSpec();
       const CMIUtilString strModuleFilePath(
-          module.GetFileSpec().GetDirectory());
-      const CMIUtilString strModuleFileName(module.GetFileSpec().GetFilename());
+          GetDereferenceable(fileSpec.GetDirectory()).Or(*pUnknown));
+      const CMIUtilString strModuleFileName(
+          GetDereferenceable(fileSpec.GetFilename()).Or(*pUnknown));
       const CMIUtilString strModuleFullPath(CMIUtilString::Format(
           "%s/%s", strModuleFilePath.c_str(), strModuleFileName.c_str()));
       const CMIUtilString strHasSymbols =
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to