Skip to content

Commit

Permalink
Remove typedefs for MIchar, MIschar, MIuchar.
Browse files Browse the repository at this point in the history
Summary:
This is a start on bringing lldb-mi more in line with the typical
LLDB coding style. This just removes the usage of the typedefs and
doesn't yet clean up any logic or other issues. (This is to keep
the review simple.)

Reviewers: abidh, ki.stfu, domipheus

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D10917

llvm-svn: 241349
  • Loading branch information
waywardmonkeys committed Jul 3, 2015
1 parent 34375d5 commit 3b25b47
Show file tree
Hide file tree
Showing 41 changed files with 149 additions and 152 deletions.
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmdArgContext.h
Expand Up @@ -44,6 +44,6 @@ class CMICmdArgContext
// Attributes:
private:
CMIUtilString m_strCmdArgsAndOptions;
const MIchar m_constCharSpace;
const char m_constCharSpace;
const CMIUtilString m_constStrSpace;
};
6 changes: 3 additions & 3 deletions lldb/tools/lldb-mi/MICmdArgValFile.cpp
Expand Up @@ -121,7 +121,7 @@ CMICmdArgValFile::GetFileNamePath(const CMIUtilString &vrTxt) const
CMIUtilString fileNamePath(vrTxt);

// Look for a space in the path
const MIchar cSpace = ' ';
const char cSpace = ' ';
const MIint nPos = fileNamePath.find(cSpace);
if (nPos != (MIint)std::string::npos)
fileNamePath = CMIUtilString::Format("\"%s\"", fileNamePath.c_str());
Expand Down Expand Up @@ -182,10 +182,10 @@ bool
CMICmdArgValFile::IsValidChars(const CMIUtilString &vrText) const
{
static CMIUtilString s_strSpecialCharacters(".'\"`@#$%^&*()_+-={}[]| ");
const MIchar *pPtr = const_cast<MIchar *>(vrText.c_str());
const char *pPtr = const_cast<char *>(vrText.c_str());
for (MIuint i = 0; i < vrText.length(); i++, pPtr++)
{
const MIchar c = *pPtr;
const char c = *pPtr;
if (::isalnum((int)c) == 0)
{
if (s_strSpecialCharacters.find(c) == CMIUtilString::npos)
Expand Down
12 changes: 6 additions & 6 deletions lldb/tools/lldb-mi/MICmdArgValString.cpp
Expand Up @@ -179,7 +179,7 @@ CMICmdArgValString::ValidateQuotedText(CMICmdArgContext &vrwArgContext)
if (vrwArgContext.RemoveArg(rArg))
{
m_bValid = true;
const MIchar cQuote = '"';
const char cQuote = '"';
m_argValue = rArg.Trim(cQuote).StripSlashes();
return MIstatus::success;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ CMICmdArgValString::IsStringArgQuotedText(const CMIUtilString &vrTxt) const
return true;

// CODETAG_QUOTEDTEXT_SIMILAR_CODE
const MIchar cQuote = '"';
const char cQuote = '"';
const MIint nPos = vrTxt.find(cQuote);
if (nPos == (MIint)std::string::npos)
return false;
Expand All @@ -273,8 +273,8 @@ CMICmdArgValString::IsStringArgQuotedText(const CMIUtilString &vrTxt) const

// Quote must be the first character in the string or be preceded by a space
// Also check for embedded string formating quote
const MIchar cBckSlash = '\\';
const MIchar cSpace = ' ';
const char cBckSlash = '\\';
const char cSpace = ' ';
if ((nPos > 1) && (vrTxt[nPos - 1] == cBckSlash) && (vrTxt[nPos - 2] != cSpace))
{
return false;
Expand Down Expand Up @@ -308,13 +308,13 @@ bool
CMICmdArgValString::IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const
{
// CODETAG_QUOTEDTEXT_SIMILAR_CODE
const MIchar cBckSlash = '\\';
const char cBckSlash = '\\';
const MIint nPos = vrTxt.find(cBckSlash);
if (nPos == (MIint)std::string::npos)
return false;

// Slash must be the first character in the string or be preceded by a space
const MIchar cSpace = ' ';
const char cSpace = ' ';
if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
return false;

Expand Down
20 changes: 10 additions & 10 deletions lldb/tools/lldb-mi/MICmdCmdData.cpp
Expand Up @@ -265,7 +265,7 @@ CMICmdCmdDataEvaluateExpression::CreateSelf(void)
// Throws: None.
//--
bool
CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, MIchar &vrwInvalidChar)
CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, char &vrwInvalidChar)
{
static const std::string strInvalidCharacters(";#\\");
const size_t nInvalidCharacterOffset = vrExpr.find_first_of(strInvalidCharacters);
Expand Down Expand Up @@ -403,20 +403,20 @@ CMICmdCmdDataDisassemble::Execute(void)

for (size_t i = 0; i < nInstructions; i++)
{
const MIchar *pUnknown = "??";
const char *pUnknown = "??";
lldb::SBInstruction instrt = instructions.GetInstructionAtIndex(i);
const MIchar *pStrMnemonic = instrt.GetMnemonic(sbTarget);
const char *pStrMnemonic = instrt.GetMnemonic(sbTarget);
pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
const MIchar *pStrComment = instrt.GetComment(sbTarget);
const char *pStrComment = instrt.GetComment(sbTarget);
CMIUtilString strComment;
if (pStrComment != nullptr && *pStrComment != '\0')
strComment = CMIUtilString::Format("; %s", pStrComment);
lldb::SBAddress address = instrt.GetAddress();
lldb::addr_t addr = address.GetLoadAddress(sbTarget);
const MIchar *pFnName = address.GetFunction().GetName();
const char *pFnName = address.GetFunction().GetName();
pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
lldb::addr_t addrOffSet = address.GetOffset() - start_offset;
const MIchar *pStrOperands = instrt.GetOperands(sbTarget);
const char *pStrOperands = instrt.GetOperands(sbTarget);
pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
const size_t instrtSize = instrt.GetByteSize();

Expand All @@ -441,7 +441,7 @@ CMICmdCmdDataDisassemble::Execute(void)
{
lldb::SBLineEntry lineEntry = address.GetLineEntry();
const MIuint nLine = lineEntry.GetLine();
const MIchar *pFileName = lineEntry.GetFileSpec().GetFilename();
const char *pFileName = lineEntry.GetFileSpec().GetFilename();
pFileName = (pFileName != nullptr) ? pFileName : pUnknown;

// MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
Expand Down Expand Up @@ -660,7 +660,7 @@ CMICmdCmdDataReadMemoryBytes::Execute(void)
nAddrStart += nAddrOffset;
const MIuint64 nAddrNumBytes = pArgNumBytes->GetValue();

m_pBufferMemory = new MIuchar[nAddrNumBytes];
m_pBufferMemory = new unsigned char[nAddrNumBytes];
if (m_pBufferMemory == nullptr)
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE), m_cmdData.strMiCmd.c_str(), nAddrNumBytes));
Expand Down Expand Up @@ -1544,13 +1544,13 @@ CMICmdCmdDataWriteMemory::Execute(void)
m_nCount = pArgNumber->GetValue();
const MIuint64 nValue = pArgContents->GetValue();

m_pBufferMemory = new MIuchar[m_nCount];
m_pBufferMemory = new unsigned char[m_nCount];
if (m_pBufferMemory == nullptr)
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE), m_cmdData.strMiCmd.c_str(), m_nCount));
return MIstatus::failure;
}
*m_pBufferMemory = static_cast<MIchar>(nValue);
*m_pBufferMemory = static_cast<char>(nValue);

CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
Expand Down
8 changes: 4 additions & 4 deletions lldb/tools/lldb-mi/MICmdCmdData.h
Expand Up @@ -68,7 +68,7 @@ class CMICmdCmdDataEvaluateExpression : public CMICmdBase

// Methods:
private:
bool HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, MIchar &vrwInvalidChar);
bool HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, char &vrwInvalidChar);

// Attributes:
private:
Expand All @@ -78,7 +78,7 @@ class CMICmdCmdDataEvaluateExpression : public CMICmdBase
CMICmnMIValueTuple m_miValueTuple;
bool m_bCompositeVarType; // True = yes composite type, false = internal type
bool m_bFoundInvalidChar; // True = yes found unexpected character in the expression, false = all ok
MIchar m_cExpressionInvalidChar;
char m_cExpressionInvalidChar;
const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option. Not handled by command.
const CMIUtilString m_constStrArgExpr;
Expand Down Expand Up @@ -155,7 +155,7 @@ class CMICmdCmdDataReadMemoryBytes : public CMICmdBase
const CMIUtilString m_constStrArgByteOffset;
const CMIUtilString m_constStrArgAddrExpr;
const CMIUtilString m_constStrArgNumBytes;
MIuchar *m_pBufferMemory;
unsigned char *m_pBufferMemory;
MIuint64 m_nAddrStart;
MIuint64 m_nAddrNumBytesToRead;
};
Expand Down Expand Up @@ -368,7 +368,7 @@ class CMICmdCmdDataWriteMemory : public CMICmdBase
MIuint64 m_nAddr;
CMIUtilString m_strContents;
MIuint64 m_nCount;
MIuchar *m_pBufferMemory;
unsigned char *m_pBufferMemory;
};

//++ ============================================================================
Expand Down
14 changes: 7 additions & 7 deletions lldb/tools/lldb-mi/MICmdCmdExec.cpp
Expand Up @@ -198,7 +198,7 @@ CMICmdCmdExecContinue::~CMICmdCmdExecContinue(void)
bool
CMICmdCmdExecContinue::Execute(void)
{
const MIchar *pCmd = "continue";
const char *pCmd = "continue";
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
const lldb::ReturnStatus rtn = rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, m_lldbResult);
MIunused(rtn);
Expand All @@ -217,7 +217,7 @@ CMICmdCmdExecContinue::Execute(void)
{
// ToDo: Re-evaluate if this is required when application near finished as this is parsing LLDB error message
// which seems a hack and is code brittle
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
if (strLldbMsg == "error: Process must be launched.")
{
Expand Down Expand Up @@ -367,7 +367,7 @@ CMICmdCmdExecNext::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down Expand Up @@ -494,7 +494,7 @@ CMICmdCmdExecStep::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down Expand Up @@ -621,7 +621,7 @@ CMICmdCmdExecNextInstruction::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down Expand Up @@ -748,7 +748,7 @@ CMICmdCmdExecStepInstruction::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down Expand Up @@ -876,7 +876,7 @@ CMICmdCmdExecFinish::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
MIunused(pLldbErr);
const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-mi/MICmdCmdFile.cpp
Expand Up @@ -106,8 +106,8 @@ CMICmdCmdFileExecAndSymbols::Execute(void)
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
lldb::SBError error;
const MIchar *pTargetTriple = nullptr; // Let LLDB discover the triple required
const MIchar *pTargetPlatformName = platformName.c_str();
const char *pTargetTriple = nullptr; // Let LLDB discover the triple required
const char *pTargetPlatformName = platformName.c_str();
const bool bAddDepModules = false;
lldb::SBTarget target = rDbgr.CreateTarget(strExeFilePath.c_str(), pTargetTriple, pTargetPlatformName, bAddDepModules, error);
CMIUtilString strWkDir;
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp
Expand Up @@ -330,8 +330,8 @@ CMICmdCmdListThreadGroups::Acknowledge(void)
if (rSessionInfo.GetTarget().IsValid())
{
lldb::SBTarget sbTrgt = rSessionInfo.GetTarget();
const MIchar *pDir = sbTrgt.GetExecutable().GetDirectory();
const MIchar *pFileName = sbTrgt.GetExecutable().GetFilename();
const char *pDir = sbTrgt.GetExecutable().GetDirectory();
const char *pFileName = sbTrgt.GetExecutable().GetFilename();
const CMIUtilString strFile(CMIUtilString::Format("%s/%s", pDir, pFileName));
const CMICmnMIValueConst miValueConst4(strFile);
const CMICmnMIValueResult miValueResult4("executable", miValueConst4);
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmdCmdSymbol.cpp
Expand Up @@ -104,7 +104,7 @@ CMICmdCmdSymbolListLines::Acknowledge(void)
{
if (m_lldbResult.GetErrorSize() > 0)
{
const MIchar *pLldbErr = m_lldbResult.GetError();
const char *pLldbErr = m_lldbResult.GetError();
const CMIUtilString strMsg(CMIUtilString(pLldbErr).StripCRAll());
const CMICmnMIValueConst miValueConst(strMsg);
const CMICmnMIValueResult miValueResult("message", miValueConst);
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmdCmdTarget.cpp
Expand Up @@ -111,7 +111,7 @@ CMICmdCmdTargetSelect::Execute(void)
const CMIUtilString strUrl = CMIUtilString::Format("connect://%s", pArgParameters->GetValue().c_str());

// Ask LLDB to collect to the target port
const MIchar *pPlugin("gdb-remote");
const char *pPlugin("gdb-remote");
lldb::SBError error;
lldb::SBProcess process = rSessionInfo.GetTarget().ConnectRemote(rSessionInfo.GetListener(), strUrl.c_str(), pPlugin, error);

Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-mi/MICmdCmdVar.cpp
Expand Up @@ -461,7 +461,7 @@ CMICmdCmdVarUpdate::CreateSelf(void)
// Throws: None.
//--
bool
CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName, const MIchar *const vpValue, const CMIUtilString &vrStrScope)
CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope)
{
// MI print "[{name=\"%s\",value=\"%s\",in_scope=\"%s\",type_changed=\"false\",has_more=\"0\"}]"
const CMICmnMIValueConst miValueConst(vrStrVarName);
Expand Down Expand Up @@ -1335,7 +1335,7 @@ CMICmdCmdVarInfoPathExpression::Execute(void)
return MIstatus::failure;
}

const MIchar *pPathExpression = stream.GetData();
const char *pPathExpression = stream.GetData();
if (pPathExpression == nullptr)
{
// Build expression from what we do know
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmdCmdVar.h
Expand Up @@ -122,7 +122,7 @@ class CMICmdCmdVarUpdate : public CMICmdBase
// Methods:
private:
bool ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbChanged);
bool MIFormResponse(const CMIUtilString &vrStrVarName, const MIchar *const vpValue, const CMIUtilString &vrStrScope);
bool MIFormResponse(const CMIUtilString &vrStrVarName, const char *const vpValue, const CMIUtilString &vrStrScope);

// Attribute:
private:
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmdInterpreter.cpp
Expand Up @@ -186,7 +186,7 @@ CMICmdInterpreter::MiHasCmdTokenEndingHyphen(const CMIUtilString &vTextLine)
bool
CMICmdInterpreter::MiHasCmdTokenEndingAlpha(const CMIUtilString &vTextLine)
{
MIchar cChar = vTextLine[0];
char cChar = vTextLine[0];
MIuint i = 0;
while (::isdigit(cChar) != 0)
{
Expand Down
20 changes: 10 additions & 10 deletions lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
Expand Up @@ -380,11 +380,11 @@ CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData,
return MIstatus::failure;

// Add "target-id"
const MIchar *pThreadName = rThread.GetName();
const char *pThreadName = rThread.GetName();
const MIuint len = (pThreadName != nullptr) ? CMIUtilString(pThreadName).length() : 0;
const bool bHaveName = ((pThreadName != nullptr) && (len > 0) && (len < 32) &&
CMIUtilString::IsAllValidAlphaAndNumeric(pThreadName)); // 32 is arbitary number
const MIchar *pThrdFmt = bHaveName ? "%s" : "Thread %d";
const char *pThrdFmt = bHaveName ? "%s" : "Thread %d";
CMIUtilString strThread;
if (bHaveName)
strThread = CMIUtilString::Format(pThrdFmt, pThreadName);
Expand Down Expand Up @@ -635,17 +635,17 @@ CMICmnLLDBDebugSessionInfo::GetFrameInfo(const lldb::SBFrame &vrFrame, lldb::add
const MIuint nBytes = rFrame.GetLineEntry().GetFileSpec().GetPath(&pBuffer[0], sizeof(pBuffer));
MIunused(nBytes);
CMIUtilString strResolvedPath(&pBuffer[0]);
const MIchar *pUnkwn = "??";
const char *pUnkwn = "??";
if (!ResolvePath(pUnkwn, strResolvedPath))
return MIstatus::failure;
vwPath = strResolvedPath;

vwPc = rFrame.GetPC();

const MIchar *pFnName = rFrame.GetFunctionName();
const char *pFnName = rFrame.GetFunctionName();
vwFnName = (pFnName != nullptr) ? pFnName : pUnkwn;

const MIchar *pFileName = rFrame.GetLineEntry().GetFileSpec().GetFilename();
const char *pFileName = rFrame.GetLineEntry().GetFileSpec().GetFilename();
vwFileName = (pFileName != nullptr) ? pFileName : pUnkwn;

vwnLine = rFrame.GetLineEntry().GetLine();
Expand Down Expand Up @@ -801,13 +801,13 @@ CMICmnLLDBDebugSessionInfo::GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkP
lldb::SBBreakpointLocation brkPtLoc = rBrkPt.GetLocationAtIndex(0);
lldb::SBAddress brkPtAddr = brkPtLoc.GetAddress();
lldb::SBSymbolContext symbolCntxt = brkPtAddr.GetSymbolContext(lldb::eSymbolContextEverything);
const MIchar *pUnkwn = "??";
const char *pUnkwn = "??";
lldb::SBModule rModule = symbolCntxt.GetModule();
const MIchar *pModule = rModule.IsValid() ? rModule.GetFileSpec().GetFilename() : pUnkwn;
const char *pModule = rModule.IsValid() ? rModule.GetFileSpec().GetFilename() : pUnkwn;
MIunused(pModule);
const MIchar *pFile = pUnkwn;
const MIchar *pFn = pUnkwn;
const MIchar *pFilePath = pUnkwn;
const char *pFile = pUnkwn;
const char *pFn = pUnkwn;
const char *pFilePath = pUnkwn;
size_t nLine = 0;
lldb::addr_t nAddr = brkPtAddr.GetLoadAddress(GetTarget());
if (nAddr == LLDB_INVALID_ADDRESS)
Expand Down

0 comments on commit 3b25b47

Please sign in to comment.