summaryrefslogtreecommitdiffstats
path: root/lldb/tools
diff options
context:
space:
mode:
authorDeepak Panickal <deepak@codeplay.com>2014-08-08 16:47:42 +0000
committerDeepak Panickal <deepak@codeplay.com>2014-08-08 16:47:42 +0000
commitd249928b84c2fc11b0940d702288cbf4f7f2d332 (patch)
tree15c9c86005af89960c902e4f24513d5e173d00a6 /lldb/tools
parentcaa565887d7a8701624534516308da497ae46078 (diff)
downloadbcm5719-llvm-d249928b84c2fc11b0940d702288cbf4f7f2d332.tar.gz
bcm5719-llvm-d249928b84c2fc11b0940d702288cbf4f7f2d332.zip
Add new MI commands, features and fixes to the lldb-mi driver.
- Can now load an executable directly as an argument. - Fixes towards supporting local debugging. - Fixes for stack-list-arguments, data-evaluate-expression, environment-cd, stack-list-locals, interpreter-exec. - Fix breakpoint event handling. - Support dynamic loading of libraries using the search paths provided by Eclipse. llvm-svn: 215223
Diffstat (limited to 'lldb/tools')
-rw-r--r--lldb/tools/lldb-mi/CMakeLists.txt2
-rw-r--r--lldb/tools/lldb-mi/MICmdArgContext.cpp4
-rw-r--r--lldb/tools/lldb-mi/MICmdArgSet.cpp65
-rw-r--r--lldb/tools/lldb-mi/MICmdArgSet.h3
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValFile.cpp49
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValFile.h4
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValListBase.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValListOfN.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValNumber.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp4
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValOptionShort.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValString.cpp227
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValString.h4
-rw-r--r--lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp4
-rw-r--r--lldb/tools/lldb-mi/MICmdBase.cpp37
-rw-r--r--lldb/tools/lldb-mi/MICmdBase.h2
-rw-r--r--lldb/tools/lldb-mi/MICmdCmd.cpp28
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdBreak.cpp60
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdData.cpp133
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdData.h16
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdEnviro.cpp21
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdExec.cpp49
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdExec.h2
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdFile.cpp33
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdFile.h1
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp10
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp10
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp118
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdMiscellanous.h28
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdStack.cpp110
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp11
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdSupportList.cpp1
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdTarget.cpp17
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdThread.cpp21
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdTrace.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdVar.cpp111
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdVar.h1
-rw-r--r--lldb/tools/lldb-mi/MICmdCommands.cpp1
-rw-r--r--lldb/tools/lldb-mi/MICmdInvoker.cpp25
-rw-r--r--lldb/tools/lldb-mi/MICmdInvoker.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnConfig.h10
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp606
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h15
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp59
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h7
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugger.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp132
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp4
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp324
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.h71
-rw-r--r--lldb/tools/lldb-mi/MICmnLog.cpp1
-rw-r--r--lldb/tools/lldb-mi/MICmnLogMediumFile.cpp10
-rw-r--r--lldb/tools/lldb-mi/MICmnLogMediumFile.h13
-rw-r--r--lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnMIValueList.cpp35
-rw-r--r--lldb/tools/lldb-mi/MICmnMIValueList.h5
-rw-r--r--lldb/tools/lldb-mi/MICmnMIValueTuple.cpp69
-rw-r--r--lldb/tools/lldb-mi/MICmnMIValueTuple.h8
-rw-r--r--lldb/tools/lldb-mi/MICmnResources.cpp43
-rw-r--r--lldb/tools/lldb-mi/MICmnResources.h77
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStderr.cpp55
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStderr.h2
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStdin.cpp10
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmnStreamStdinWindows.cpp18
-rw-r--r--lldb/tools/lldb-mi/MIDriver.cpp178
-rw-r--r--lldb/tools/lldb-mi/MIDriver.h26
-rw-r--r--lldb/tools/lldb-mi/MIDriverMain.cpp7
-rw-r--r--lldb/tools/lldb-mi/MIDriverMgr.cpp65
-rw-r--r--lldb/tools/lldb-mi/MIReadMe.txt126
-rw-r--r--lldb/tools/lldb-mi/MIUtilDateTimeStd.cpp53
-rw-r--r--lldb/tools/lldb-mi/MIUtilDateTimeStd.h15
-rw-r--r--lldb/tools/lldb-mi/MIUtilFileStd.cpp3
-rw-r--r--lldb/tools/lldb-mi/MIUtilFileStd.h1
-rw-r--r--lldb/tools/lldb-mi/MIUtilSingletonHelper.h6
-rw-r--r--lldb/tools/lldb-mi/MIUtilString.cpp82
-rw-r--r--lldb/tools/lldb-mi/MIUtilString.h15
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemLinux.cpp7
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemLinux.h7
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemOsx.cpp3
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemOsx.h3
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemWindows.cpp3
-rw-r--r--lldb/tools/lldb-mi/MIUtilSystemWindows.h3
-rw-r--r--lldb/tools/lldb-mi/MIUtilThreadBaseStd.cpp3
-rw-r--r--lldb/tools/lldb-mi/MIUtilThreadBaseStd.h1
-rw-r--r--lldb/tools/lldb-mi/MIUtilVariant.cpp166
-rw-r--r--lldb/tools/lldb-mi/MIUtilVariant.h36
90 files changed, 2751 insertions, 864 deletions
diff --git a/lldb/tools/lldb-mi/CMakeLists.txt b/lldb/tools/lldb-mi/CMakeLists.txt
index 816bca9bcb7..cc4347f01f4 100644
--- a/lldb/tools/lldb-mi/CMakeLists.txt
+++ b/lldb/tools/lldb-mi/CMakeLists.txt
@@ -47,6 +47,7 @@ add_lldb_executable(lldb-mi
MICmnLLDBDebugSessionInfo.cpp
MICmnLLDBDebugSessionInfoVarObj.cpp
MICmnLLDBProxySBValue.cpp
+ MICmnLLDBUtilSBValue.cpp
MICmnLog.cpp
MICmnLogMediumFile.cpp
MICmnMIOutOfBandRecord.cpp
@@ -127,6 +128,7 @@ add_lldb_executable(lldb-mi
MICmnLLDBDebugSessionInfo.cpp
MICmnLLDBDebugSessionInfoVarObj.cpp
MICmnLLDBProxySBValue.cpp
+ MICmnLLDBUtilSBValue.cpp
MICmnLog.cpp
MICmnLogMediumFile.cpp
MICmnMIOutOfBandRecord.cpp
diff --git a/lldb/tools/lldb-mi/MICmdArgContext.cpp b/lldb/tools/lldb-mi/MICmdArgContext.cpp
index 26e6f24cbe5..b6efa9660c3 100644
--- a/lldb/tools/lldb-mi/MICmdArgContext.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgContext.cpp
@@ -220,7 +220,7 @@ bool CMICmdArgContext::RemoveArgAtPos( const CMIUtilString & vArg, const MIuint
MIuint CMICmdArgContext::GetNumberArgsPresent( void ) const
{
CMIUtilString::VecString_t vecOptions;
- return m_strCmdArgsAndOptions.Split( m_constStrSpace, vecOptions );
+ return m_strCmdArgsAndOptions.SplitConsiderQuotes( m_constStrSpace, vecOptions );
}
//++ ------------------------------------------------------------------------------------
@@ -233,7 +233,7 @@ MIuint CMICmdArgContext::GetNumberArgsPresent( void ) const
CMIUtilString::VecString_t CMICmdArgContext::GetArgs( void ) const
{
CMIUtilString::VecString_t vecOptions;
- m_strCmdArgsAndOptions.Split( m_constStrSpace, vecOptions );
+ m_strCmdArgsAndOptions.SplitConsiderQuotes( m_constStrSpace, vecOptions );
return vecOptions;
}
diff --git a/lldb/tools/lldb-mi/MICmdArgSet.cpp b/lldb/tools/lldb-mi/MICmdArgSet.cpp
index a1df2f79f69..845d67173f5 100644
--- a/lldb/tools/lldb-mi/MICmdArgSet.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgSet.cpp
@@ -24,7 +24,6 @@
#include "MICmdArgValBase.h"
#include "MICmnResources.h"
#include "MICmnLog.h"
-#include "MICmnConfig.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgSet constructor.
@@ -85,7 +84,7 @@ void CMICmdArgSet::Destroy( void )
//++ ------------------------------------------------------------------------------------
// Details: Retrieve the state flag indicating that the command set up ready to parse
-// command arguments or options found that one or more arguments was indeed
+// command arguments or options found that one or more arguemnts was indeed
// present but not handled. This is given as a warning in the MI log file.
// Type: Method.
// Args: None.
@@ -98,7 +97,7 @@ bool CMICmdArgSet::IsArgsPresentButNotHandledByCmd( void ) const
}
//++ ------------------------------------------------------------------------------------
-// Details: Add the list of command's arguments to parse and validate another one.
+// Details: Add the the list of command's arguments to parse and validate another one.
// Type: Method.
// Args: vArg - (R) A command argument object.
// Return: MIstatus::success - Functional succeeded.
@@ -161,7 +160,7 @@ const CMICmdArgSet::SetCmdArgs_t & CMICmdArgSet::GetArgsNotHandledByCmd( void )
//++ ------------------------------------------------------------------------------------
// Details: Given a set of command argument objects parse the context option string to
// find those argument and retrieve their value. If the function fails call
-// GetArgsThatAreMissing() to see which commands that were mandatory were
+// GetArgsThatAreMissing() to see which commands that were manadatory were
// missing or failed to parse.
// Type: Method.
// Args: vStrMiCmd - (R) Command's name.
@@ -214,15 +213,23 @@ bool CMICmdArgSet::Validate( const CMIUtilString & vStrMiCmd, CMICmdArgContext &
return MIstatus::failure;
}
- if( !vwCmdArgsText.IsEmpty() )
- {
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN ), vwCmdArgsText.GetArgsLeftToParse().c_str() ) );
- return MIstatus::failure;
- }
-
if( IsArgsPresentButNotHandledByCmd() )
WarningArgsNotHandledbyCmdLogFile( vStrMiCmd );
+ return ValidationFormErrorMessages( vwCmdArgsText );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Having validated the command's options text and failed for some reason form
+// the error message made up with the faults found.
+// Type: Method.
+// vCmdArgsText - (RW) A command's options or argument.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdArgSet::ValidationFormErrorMessages( const CMICmdArgContext & vwCmdArgsText )
+{
CMIUtilString strListMissing;
CMIUtilString strListInvalid;
CMIUtilString strListMissingInfo;
@@ -279,27 +286,49 @@ bool CMICmdArgSet::Validate( const CMIUtilString & vStrMiCmd, CMICmdArgContext &
++it;
}
}
+
+ bool bHaveOneError = false;
+ CMIUtilString strError = MIRSRC( IDS_CMD_ARGS_ERR_PREFIX_MSG );
if( bArgsMissing && bArgsInvalid )
{
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID ), strListMissing.c_str(), strListInvalid.c_str() ) );
- return MIstatus::failure;
+ bHaveOneError = true;
+ strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID ), strListMissing.c_str(), strListInvalid.c_str() );
}
if( bArgsMissing )
{
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY ), strListMissing.c_str() ) );
- return MIstatus::failure;
+ if( bHaveOneError )
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY ), strListMissing.c_str() );
}
if( bArgsMissingInfo )
{
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF ), strListMissingInfo.c_str() ) );
- return MIstatus::failure;
+ if( bHaveOneError )
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF ), strListMissingInfo.c_str() );
}
if( bArgsInvalid )
{
- SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_INVALID ), strListInvalid.c_str() ) );
+ if( bHaveOneError )
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_VALIDATION_INVALID ), strListInvalid.c_str() );
+ }
+ if( !vwCmdArgsText.IsEmpty() )
+ {
+ if( bHaveOneError )
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format( MIRSRC( IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN ), vwCmdArgsText.GetArgsLeftToParse().c_str() );
+ }
+
+ if( bHaveOneError )
+ {
+ SetErrorDescription( strError );
return MIstatus::failure;
}
-
+
return MIstatus::success;
}
diff --git a/lldb/tools/lldb-mi/MICmdArgSet.h b/lldb/tools/lldb-mi/MICmdArgSet.h
index 5deaeb51ad1..5f8f5049d9a 100644
--- a/lldb/tools/lldb-mi/MICmdArgSet.h
+++ b/lldb/tools/lldb-mi/MICmdArgSet.h
@@ -93,7 +93,8 @@ public:
private:
const SetCmdArgs_t & GetArgsNotHandledByCmd( void ) const;
void Destroy( void ); // Release resources used by *this object
-
+ bool ValidationFormErrorMessages( const CMICmdArgContext & vwCmdArgsText );
+
// Attributes:
private:
bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by a command, false = all args handled
diff --git a/lldb/tools/lldb-mi/MICmdArgValFile.cpp b/lldb/tools/lldb-mi/MICmdArgValFile.cpp
index e111852b349..31e644de588 100644
--- a/lldb/tools/lldb-mi/MICmdArgValFile.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValFile.cpp
@@ -50,7 +50,7 @@ CMICmdArgValFile::CMICmdArgValFile( const CMIUtilString & vrArgName, const bool
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValFile destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
@@ -74,6 +74,7 @@ bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
return MIstatus::success;
// The GDB/MI spec suggests there is only parameter
+
if( vwArgContext.GetNumberArgsPresent() == 1 )
{
const CMIUtilString & rFile( vwArgContext.GetArgsLeftToParse() );
@@ -81,7 +82,7 @@ bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
{
m_bFound = true;
m_bValid = true;
- m_argValue = rFile;
+ m_argValue = rFile.Trim( '"' );
vwArgContext.RemoveArg( rFile );
return MIstatus::success;
}
@@ -103,7 +104,7 @@ bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
if( vwArgContext.RemoveArg( rTxt ) )
{
m_bValid = true;
- m_argValue = rTxt;
+ m_argValue = rTxt.Trim( '"' );
return MIstatus::success;
}
else
@@ -118,7 +119,8 @@ bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
}
//++ ------------------------------------------------------------------------------------
-// Details: Given some text extract the file name path from it.
+// Details: Given some text extract the file name path from it. If a space is found in
+// path done return the path surrounded in quotes.
// Type: Method.
// Args: vrTxt - (R) The text to extract the file name path from.
// Return: CMIUtilString - File name and or path.
@@ -126,7 +128,15 @@ bool CMICmdArgValFile::Validate( CMICmdArgContext & vwArgContext )
//--
CMIUtilString CMICmdArgValFile::GetFileNamePath( const CMIUtilString & vrTxt ) const
{
- return vrTxt;
+ CMIUtilString fileNamePath( vrTxt );
+
+ // Look for a space in the path
+ const MIchar cSpace = ' ';
+ const MIint nPos = fileNamePath.find( cSpace );
+ if( nPos != (MIint) std::string::npos )
+ fileNamePath = CMIUtilString::Format( "\"%s\"", fileNamePath.c_str() );
+
+ return fileNamePath;
}
//++ ------------------------------------------------------------------------------------
@@ -138,6 +148,9 @@ CMIUtilString CMICmdArgValFile::GetFileNamePath( const CMIUtilString & vrTxt ) c
//--
bool CMICmdArgValFile::IsFilePath( const CMIUtilString & vrFileNamePath ) const
{
+ if( vrFileNamePath.empty() )
+ return false;
+
const bool bHavePosSlash = (vrFileNamePath.find_first_of( "/" ) != std::string::npos);
const bool bHaveBckSlash = (vrFileNamePath.find_first_of( "\\" ) != std::string::npos);
@@ -159,9 +172,33 @@ bool CMICmdArgValFile::IsFilePath( const CMIUtilString & vrFileNamePath ) const
if( bFoundI1 )
return false;
- const bool bValidChars = CMIUtilString::IsAllValidAlphaAndNumeric( *vrFileNamePath.c_str() );
+ const bool bValidChars = IsValidChars( vrFileNamePath );
if( bValidChars || bHavePosSlash || bHaveBckSlash )
return true;
return false;
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Determine if the path contains valid characters for a file path. Letters can be
+// either upper or lower case.
+// Type: Method.
+// Args: vrText - (R) The text data to examine.
+// Return: bool - True = yes valid, false = one or more chars is valid.
+// Throws: None.
+//--
+bool CMICmdArgValFile::IsValidChars( const CMIUtilString & vrText ) const
+{
+ const MIchar * pPtr = const_cast< MIchar * >( vrText.c_str() );
+ for( MIuint i = 0; i < vrText.length(); i++, pPtr++ )
+ {
+ const MIchar c = *pPtr;
+ if( ::isalnum( (int) c ) == 0 )
+ {
+ if( (c != '.') && (c != '-') && (c != '_') )
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/lldb/tools/lldb-mi/MICmdArgValFile.h b/lldb/tools/lldb-mi/MICmdArgValFile.h
index 3cbe81761df..07172740145 100644
--- a/lldb/tools/lldb-mi/MICmdArgValFile.h
+++ b/lldb/tools/lldb-mi/MICmdArgValFile.h
@@ -54,4 +54,8 @@ public:
/* dtor */ virtual ~CMICmdArgValFile( void );
// From CMICmdArgSet::IArg
virtual bool Validate( CMICmdArgContext & vwArgContext );
+
+// Methods:
+private:
+ bool IsValidChars( const CMIUtilString & vrText ) const;
};
diff --git a/lldb/tools/lldb-mi/MICmdArgValListBase.cpp b/lldb/tools/lldb-mi/MICmdArgValListBase.cpp
index 99639205465..4a0d0734d8e 100644
--- a/lldb/tools/lldb-mi/MICmdArgValListBase.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValListBase.cpp
@@ -75,7 +75,7 @@ CMICmdArgValListBase::CMICmdArgValListBase( const CMIUtilString & vrArgName, con
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmdArgValListOfN.cpp b/lldb/tools/lldb-mi/MICmdArgValListOfN.cpp
index 2ba735e46c0..ee3df542f8b 100644
--- a/lldb/tools/lldb-mi/MICmdArgValListOfN.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValListOfN.cpp
@@ -57,7 +57,7 @@ CMICmdArgValListOfN::CMICmdArgValListOfN( const CMIUtilString & vrArgName, const
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmdArgValNumber.cpp b/lldb/tools/lldb-mi/MICmdArgValNumber.cpp
index 18bdccdc9ac..67affda878b 100644
--- a/lldb/tools/lldb-mi/MICmdArgValNumber.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValNumber.cpp
@@ -52,7 +52,7 @@ CMICmdArgValNumber::CMICmdArgValNumber( const CMIUtilString & vrArgName, const b
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp b/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp
index 6c87984ba81..6fa6a590196 100644
--- a/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp
@@ -72,7 +72,7 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong( const CMIUtilString & vrArgName,
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
@@ -107,7 +107,7 @@ void CMICmdArgValOptionLong::Destroy( void )
//++ ------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the long
-// argument *this argument type is looking for.
+// arguemnt *this argument type is looking for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
// Return: MIstatus::success - Functional succeeded.
diff --git a/lldb/tools/lldb-mi/MICmdArgValOptionShort.cpp b/lldb/tools/lldb-mi/MICmdArgValOptionShort.cpp
index 76adb7f1149..77128b7ba6d 100644
--- a/lldb/tools/lldb-mi/MICmdArgValOptionShort.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValOptionShort.cpp
@@ -66,7 +66,7 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort( const CMIUtilString & vrArgNam
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmdArgValString.cpp b/lldb/tools/lldb-mi/MICmdArgValString.cpp
index b21346d2755..24881d011f7 100644
--- a/lldb/tools/lldb-mi/MICmdArgValString.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValString.cpp
@@ -74,7 +74,7 @@ CMICmdArgValString::CMICmdArgValString( const CMIUtilString & vrArgName, const b
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValString destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
@@ -98,7 +98,7 @@ bool CMICmdArgValString::Validate( CMICmdArgContext & vrwArgContext )
return MIstatus::success;
if( m_bHandleQuotedString )
- return ValidateQuotedText( vrwArgContext );
+ return (ValidateQuotedText( vrwArgContext ) || ValidateQuotedTextEmbedded( vrwArgContext ) );
return ValidateSingleText( vrwArgContext );
}
@@ -158,7 +158,8 @@ bool CMICmdArgValString::ValidateSingleText( CMICmdArgContext & vrwArgContext )
//++ ------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract all the words
-// between quotes then delimited by the next space.
+// between quotes then delimited by the next space. Can fall through to
+// ValidateSingleText() or ValidateQuotedQuotedTextEmbedded().
// Type: Method.
// Args: vrwArgContext - (RW) The command's argument options string.
// Return: MIstatus::success - Functional succeeded.
@@ -168,32 +169,146 @@ bool CMICmdArgValString::ValidateSingleText( CMICmdArgContext & vrwArgContext )
bool CMICmdArgValString::ValidateQuotedText( CMICmdArgContext & vrwArgContext )
{
// CODETAG_QUOTEDTEXT_SIMILAR_CODE
- const CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
const MIchar cQuote = '"';
- const MIint nPos = strOptions.find( cQuote );
+
+ // Look for first quote of two
+ MIint nPos = strOptions.find( cQuote );
if( nPos == (MIint) std::string::npos )
return ValidateSingleText( vrwArgContext );
// Is one and only quote at end of the string
- if( nPos == (MIint)(strOptions.length() - 1) )
+ const MIint nLen = strOptions.length();
+ if( nPos == (MIint)(nLen - 1) )
return MIstatus::failure;
// Quote must be the first character in the string or be preceeded by a space
- if( (nPos > 0) && (strOptions[ nPos - 1 ] != ' ' ) )
- return MIstatus::failure;
-
+ if( (nPos > 0) && (strOptions[ nPos - 1 ] != ' ') )
+ return MIstatus::failure;
+
// Need to find the other quote
- const MIint nPos2 = strOptions.find( cQuote, nPos + 1 );
+ const MIint nPos2 = strOptions.rfind( cQuote );
if( nPos2 == (MIint) std::string::npos )
return MIstatus::failure;
+ // Is there quotes surrounding string formatting embedded quotes
+ if( IsStringArgQuotedQuotedTextEmbedded( strOptions ) )
+ return ValidateQuotedQuotedTextEmbedded( vrwArgContext );
+
+ // Make sure not same back quote, need two quotes
+ if( nPos == nPos2 )
+ return MIstatus::failure;
+
// Extract quoted text
const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPos2 - nPos + 1 ).c_str();
if( vrwArgContext.RemoveArg( strQuotedTxt ) )
{
m_bFound = true;
m_bValid = true;
- m_argValue = strOptions.substr( nPos + 1, nPos2 - nPos - 1 ).c_str();;
+ m_argValue = strOptions.substr( nPos + 1, nPos2 - nPos - 1 ).c_str();
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract all the words
+// between quotes then delimited by the next space. If there any string format
+// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
+// becomes "%5d". Can fall through to ValidateQuotedText().
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdArgValString::ValidateQuotedTextEmbedded( CMICmdArgContext & vrwArgContext )
+{
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ const MIchar cBckSlash = '\\';
+ const MIint nPos = strOptions.find( cBckSlash );
+ if( nPos == (MIint) std::string::npos )
+ return ValidateQuotedText( vrwArgContext );
+
+ // Back slash must be the first character in the string or be preceeded by a space
+ // or '\\'
+ const MIchar cSpace = ' ';
+ if( (nPos > 0) && (strOptions[ nPos - 1 ] != cSpace) )
+ return MIstatus::failure;
+
+ // Need to find the other back slash
+ const MIint nPos2 = strOptions.rfind( cBckSlash );
+ if( nPos2 == (MIint) std::string::npos )
+ return MIstatus::failure;
+
+ // Make sure not same back slash, need two slashs
+ if( nPos == nPos2 )
+ return MIstatus::failure;
+
+ // Look for the two quotes
+ const MIint nLen = strOptions.length();
+ const MIchar cQuote = '"';
+ const MIint nPosQuote1 = nPos + 1;
+ const MIint nPosQuote2 = (nPos2 < nLen) ? nPos2 + 1 : nPos2;
+ if( (nPosQuote1 != nPosQuote2) &&
+ (strOptions[ nPosQuote1 ] != cQuote) && (strOptions[ nPosQuote2 ] != cQuote) )
+ return MIstatus::failure;
+
+ // Extract quoted text
+ const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPosQuote2 - nPos + 1 ).c_str();
+ if( vrwArgContext.RemoveArg( strQuotedTxt ) )
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = strQuotedTxt;
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract all the words
+// between quotes then delimited by the next space. If there any string format
+// characters '\\' used to embed quotes these are ignored i.e. "\\\"%5d\\\""
+// becomes "%5d".
+// Type: Method.
+// Args: vrwArgContext - (RW) The command's argument options string.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdArgValString::ValidateQuotedQuotedTextEmbedded( CMICmdArgContext & vrwArgContext )
+{
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ CMIUtilString strOptions = vrwArgContext.GetArgsLeftToParse();
+ const MIint nPos = strOptions.find( "\"\\\"" );
+ if( nPos == (MIint) std::string::npos )
+ return MIstatus::failure;
+
+ const MIint nPos2 = strOptions.rfind( "\\\"\"" );
+ if( nPos2 == (MIint) std::string::npos )
+ return MIstatus::failure;
+
+ const MIint nLen = strOptions.length();
+ if( (nLen > 5) && ((nPos + 2) == (nPos2 - 2)) )
+ return MIstatus::failure;
+
+ // Quote must be the first character in the string or be preceeded by a space
+ // or '\\'
+ const MIchar cSpace = ' ';
+ if( (nPos > 0) && (strOptions[ nPos - 1 ] != cSpace) )
+ return MIstatus::failure;
+
+ // Extract quoted text
+ const CMIUtilString strQuotedTxt = strOptions.substr( nPos, nPos2 - nPos + 3 ).c_str();
+ if( vrwArgContext.RemoveArg( strQuotedTxt ) )
+ {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = strQuotedTxt;
return MIstatus::success;
}
@@ -210,7 +325,10 @@ bool CMICmdArgValString::ValidateQuotedText( CMICmdArgContext & vrwArgContext )
bool CMICmdArgValString::IsStringArg( const CMIUtilString & vrTxt ) const
{
if( m_bHandleQuotedString )
- return IsStringArgQuotedText( vrTxt );
+ return (IsStringArgQuotedText( vrTxt ) ||
+ IsStringArgQuotedTextEmbedded( vrTxt ) ||
+ IsStringArgQuotedQuotedTextEmbedded( vrTxt ) ||
+ IsStringArgSingleText( vrTxt ) ); // Still test for this as could just be one word still
return IsStringArgSingleText( vrTxt );
}
@@ -241,11 +359,11 @@ bool CMICmdArgValString::IsStringArgSingleText( const CMIUtilString & vrTxt ) co
return false;
// Look for -f type short options, if found reject
- if( (0 == vrTxt.find( "-" )) && (vrTxt.length() == 2 ) )
+ if( (0 == vrTxt.find( "-" )) && (vrTxt.length() == 2) )
return false;
// Look for thread group i1 i2 i3...., if found reject
- if( (vrTxt.find( "i" ) == 0) && (::isdigit( vrTxt[ 1 ] )) )
+ if( (vrTxt.find( "i" ) == 0) && ::isdigit( vrTxt[ 1 ]) )
return false;
// Look for numbers, if found reject
@@ -257,6 +375,8 @@ bool CMICmdArgValString::IsStringArgSingleText( const CMIUtilString & vrTxt ) co
//++ ------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Note this function falls
+// through to IsStringArgSingleText() should the criteria match fail.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
@@ -268,20 +388,93 @@ bool CMICmdArgValString::IsStringArgQuotedText( const CMIUtilString & vrTxt ) co
const MIchar cQuote = '"';
const MIint nPos = vrTxt.find( cQuote );
if( nPos == (MIint) std::string::npos )
- return IsStringArgSingleText( vrTxt );
+ return false;
// Is one and only quote at end of the string
if( nPos == (MIint)(vrTxt.length() - 1) )
return false;
// Quote must be the first character in the string or be preceeded by a space
- if( (nPos > 0) && (vrTxt[ nPos - 1 ] != ' ' ) )
+ // Also check for embedded string formating quote
+ const MIchar cBckSlash = '\\';
+ const MIchar cSpace = ' ';
+ if( (nPos > 1) && (vrTxt[ nPos - 1 ] == cBckSlash) && (vrTxt[ nPos - 2 ] != cSpace) )
+ {
+ return false;
+ }
+ if( (nPos > 0) && (vrTxt[ nPos - 1 ] != cSpace) )
return false;
// Need to find the other quote
- const MIint nPos2 = vrTxt.find( cQuote, nPos + 1 );
+ const MIint nPos2 = vrTxt.rfind( cQuote );
if( nPos2 == (MIint) std::string::npos )
return false;
+ // Make sure not same quote, need two quotes
+ if( nPos == nPos2 )
+ return MIstatus::failure;
+
+ return true;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Take into account string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
+// through to IsStringArgQuotedText() should the criteria match fail.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
+//--
+bool CMICmdArgValString::IsStringArgQuotedTextEmbedded( const CMIUtilString & vrTxt ) const
+{
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ const MIchar 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 preceeded by a space
+ const MIchar cSpace = ' ';
+ if( (nPos > 0) && (vrTxt[ nPos - 1 ] != cSpace) )
+ return false;
+
+ // Need to find the other matching slash
+ const MIint nPos2 = vrTxt.rfind( cBckSlash );
+ if( nPos2 == (MIint) std::string::npos )
+ return false;
+
+ // Make sure not same back slash, need two slashs
+ if( nPos == nPos2 )
+ return MIstatus::failure;
+
+ return false;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type argument.
+// Take into account quotes surrounding the text. Take into account string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
+// through to IsStringArgQuotedTextEmbedded() should the criteria match fail.
+// Type: Method.
+// Args: vrTxt - (R) Some text.
+// Return: bool - True = yes valid arg, false = no.
+// Throws: None.
+//--
+bool CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded( const CMIUtilString & vrTxt ) const
+{
+ const MIint nPos = vrTxt.find( "\"\\\"" );
+ if( nPos == (MIint) std::string::npos )
+ return false;
+
+ const MIint nPos2 = vrTxt.rfind( "\\\"\"" );
+ if( nPos2 == (MIint) std::string::npos )
+ return false;
+
+ const MIint nLen = vrTxt.length();
+ if( (nLen > 5) && ((nPos + 2) == (nPos2 - 2)) )
+ return false;
+
return true;
}
diff --git a/lldb/tools/lldb-mi/MICmdArgValString.h b/lldb/tools/lldb-mi/MICmdArgValString.h
index 89996780080..8d80e98c2e3 100644
--- a/lldb/tools/lldb-mi/MICmdArgValString.h
+++ b/lldb/tools/lldb-mi/MICmdArgValString.h
@@ -59,8 +59,12 @@ public:
private:
bool ValidateSingleText( CMICmdArgContext & vrwArgContext );
bool ValidateQuotedText( CMICmdArgContext & vrwArgContext );
+ bool ValidateQuotedTextEmbedded( CMICmdArgContext & vrwArgContext );
+ bool ValidateQuotedQuotedTextEmbedded( CMICmdArgContext & vrwArgContext );
bool IsStringArgSingleText( const CMIUtilString & vrTxt ) const;
bool IsStringArgQuotedText( const CMIUtilString & vrTxt ) const;
+ bool IsStringArgQuotedTextEmbedded( const CMIUtilString & vrTxt ) const;
+ bool IsStringArgQuotedQuotedTextEmbedded( const CMIUtilString & vrTxt ) const;
// Attribute:
private:
diff --git a/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp
index 5ac103aa8fe..0f6a867ddaa 100644
--- a/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp
+++ b/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp
@@ -52,7 +52,7 @@ CMICmdArgValThreadGrp::CMICmdArgValThreadGrp( const CMIUtilString & vrArgName, c
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
@@ -169,4 +169,4 @@ bool CMICmdArgValThreadGrp::ExtractNumber( const CMIUtilString & vrTxt )
MIuint CMICmdArgValThreadGrp::GetNumber( void ) const
{
return m_nThreadGrp;
-}
+} \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MICmdBase.cpp b/lldb/tools/lldb-mi/MICmdBase.cpp
index 3ec6e09cce6..cedcba7e042 100644
--- a/lldb/tools/lldb-mi/MICmdBase.cpp
+++ b/lldb/tools/lldb-mi/MICmdBase.cpp
@@ -224,3 +224,40 @@ bool CMICmdBase::ParseArgs( void )
return MIstatus::success;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument or option
+// definitions for the command to handle proceed to parse and validate the
+// command's options text for those arguments and extract the values for each if
+// any.
+// Type: Method.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdBase::ParseValidateCmdOptions( void )
+{
+ CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
+ if( m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
+ return MIstatus::success;
+
+ SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
+
+ return MIstatus::failure;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
+// on a executable passed in as a argument to the drive then what should the driver
+// do on a command failing? Either continue operating or exit the application.
+// Override this function where a command failure cannot allow the driver to
+// continue operating.
+// Type: Overrideable.
+// Args: None.
+// Return: bool - True = Fatal if command fails, false = can continue if command fails.
+// Throws: None.
+//--
+bool CMICmdBase::GetExitAppOnCommandFailure( void ) const
+{
+ return false;
+}
diff --git a/lldb/tools/lldb-mi/MICmdBase.h b/lldb/tools/lldb-mi/MICmdBase.h
index 85ed3299306..b05e97d2082 100644
--- a/lldb/tools/lldb-mi/MICmdBase.h
+++ b/lldb/tools/lldb-mi/MICmdBase.h
@@ -87,12 +87,14 @@ public:
// Overrideable:
public:
/* dtor */ virtual ~CMICmdBase( void );
+ virtual bool GetExitAppOnCommandFailure( void ) const;
// Methods:
protected:
void SetError( const CMIUtilString & rErrMsg );
template< class T >
T * GetOption( const CMIUtilString & vStrOptionName );
+ bool ParseValidateCmdOptions( void );
// Attributes:
protected:
diff --git a/lldb/tools/lldb-mi/MICmdCmd.cpp b/lldb/tools/lldb-mi/MICmdCmd.cpp
index ab2ed6995da..3c6d52b2476 100644
--- a/lldb/tools/lldb-mi/MICmdCmd.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmd.cpp
@@ -20,36 +20,8 @@
// Copyright: None.
//--
-// Third Party Headers:
-#include <lldb/API/SBBreakpointLocation.h>
-#include <lldb/API/SBCommandInterpreter.h>
-#include <lldb/API/SBStream.h>
-#include <lldb/API/SBThread.h>
-#include <lldb/API/SBTypeFormat.h>
-#include <limits.h>
-
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmd.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmnMIOutOfBandRecord.h"
-#include "MICmnResources.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MIDriverBase.h"
-#include "MIUtilDebug.h"
-#include "MIDriver.h"
-#include "MIUtilFileStd.h"
-#include "MICmnLLDBProxySBValue.h"
-#include "MICmdArgContext.h"
-#include "MICmdArgValFile.h"
-#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
-#include "MICmdArgValOptionLong.h"
-#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdEnablePrettyPrinting constructor.
diff --git a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp
index f0037ac70ca..f0e9acfe908 100644
--- a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp
@@ -28,14 +28,12 @@
#include <lldb/API/SBBreakpointLocation.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdBreak.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnMIOutOfBandRecord.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValFile.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
@@ -102,7 +100,7 @@ bool CMICmdCmdBreakInsert::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTempBrkPt, false, true )) );
//Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedPendinfBrkPt, false, true, CMICmdArgValListBase::eArgValType_String, 1 ) ) );
+ bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedPendinfBrkPt, false, true, CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedDisableBrkPt, false, false ) ) );
//Not implemented bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedConditionalBrkPt, false, true, CMICmdArgValListBase::eArgValType_StringQuoted, 1 ) ) );
@@ -110,14 +108,7 @@ bool CMICmdCmdBreakInsert::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgNamedRestrictBrkPtToThreadId, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedLocation, false, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGroup, false, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -285,6 +276,8 @@ bool CMICmdCmdBreakInsert::Execute( void )
SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_INVALID ), m_cmdData.strMiCmd.c_str(), m_brkName.c_str() ) );
return MIstatus::failure;
}
+
+ // CODETAG_LLDB_BRKPT_ID_MAX
if( m_brkPt.GetID() > (lldb::break_id_t) rSessionInfo.m_nBrkPointCntMax )
{
SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_CNT_EXCEEDED ), m_cmdData.strMiCmd.c_str(), rSessionInfo.m_nBrkPointCntMax, m_brkName.c_str() ) );
@@ -401,14 +394,7 @@ bool CMICmdCmdBreakDelete::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -522,14 +508,7 @@ bool CMICmdCmdBreakDisable::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -663,14 +642,7 @@ bool CMICmdCmdBreakEnable::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -806,14 +778,7 @@ bool CMICmdCmdBreakAfter::ParseArgs( void )
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedNumber, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedCount, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -939,14 +904,7 @@ bool CMICmdCmdBreakCondition::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedNumber, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedExpr, true, true, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedExprNoQuotes, true, false, CMICmdArgValListBase::eArgValType_StringQuotedNumber ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdData.cpp b/lldb/tools/lldb-mi/MICmdCmdData.cpp
index 8b0691e0ac6..69012ef042c 100644
--- a/lldb/tools/lldb-mi/MICmdCmdData.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdData.cpp
@@ -34,14 +34,12 @@
#include <lldb/API/SBStream.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdData.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
#include "MICmnLLDBProxySBValue.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
@@ -50,6 +48,7 @@
#include "MICmdArgValListOfN.h"
#include "MICmdArgValConsume.h"
#include "MICmnLLDBDebugSessionInfoVarObj.h"
+#include "MICmnLLDBUtilSBValue.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression constructor.
@@ -63,6 +62,8 @@ CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression( void )
, m_bEvaluatedExpression( true )
, m_strValue( "??" )
, m_bCompositeVarType( false )
+, m_bFoundInvalidChar( false )
+, m_cExpressionInvalidChar( 0x00 )
, m_constStrArgThread( "thread" )
, m_constStrArgFrame( "frame" )
, m_constStrArgExpr( "expr" )
@@ -99,14 +100,7 @@ bool CMICmdCmdDataEvaluateExpression::ParseArgs( void )
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgExpr, true, true, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -139,13 +133,29 @@ bool CMICmdCmdDataEvaluateExpression::Execute( void )
m_bEvaluatedExpression = false;
return MIstatus::success;
}
+ const CMICmnLLDBUtilSBValue utilValue( value );
+ if( !utilValue.HasName() )
+ {
+ if( HaveInvalidCharacterInExpression( rExpression, m_cExpressionInvalidChar ) )
+ {
+ m_bFoundInvalidChar = true;
+ return MIstatus::success;
+ }
+
+ m_strValue = rExpression;
+ return MIstatus::success;
+ }
+ if( rExpression.IsQuoted() )
+ {
+ m_strValue = rExpression.Trim( '\"' );
+ return MIstatus::success;
+ }
MIuint64 nNumber = 0;
if( CMICmnLLDBProxySBValue::GetValueAsUnsigned( value, nNumber ) == MIstatus::success )
{
const lldb::ValueType eValueType = value.GetValueType(); MIunused( eValueType );
- m_strValue = (value.GetValue() != nullptr) ? value.GetValue() : "??";
-
+ m_strValue = utilValue.GetValue();
CMIUtilString strCString;
if( CMICmnLLDBProxySBValue::GetCString( value, strCString ) )
{
@@ -156,7 +166,7 @@ bool CMICmdCmdDataEvaluateExpression::Execute( void )
// Composite type i.e. struct
m_bCompositeVarType = true;
- MIuint nChild = value.GetNumChildren();
+ const MIuint nChild = value.GetNumChildren();
for( MIuint i = 0; i < nChild; i++ )
{
lldb::SBValue member = value.GetChildAtIndex( i );
@@ -204,6 +214,15 @@ bool CMICmdCmdDataEvaluateExpression::Acknowledge( void )
m_miResultRecord = miRecordResult;
return MIstatus::success;
}
+
+ if( m_bFoundInvalidChar )
+ {
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "Invalid character '%c' in expression", m_cExpressionInvalidChar ) );
+ const CMICmnMIValueResult miValueResult( "msg", miValueConst );
+ const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
const CMICmnMIValueConst miValueConst( m_strValue );
const CMICmnMIValueResult miValueResult( "value", miValueConst );
@@ -212,14 +231,14 @@ bool CMICmdCmdDataEvaluateExpression::Acknowledge( void )
return MIstatus::success;
}
- const CMICmnMIValueConst miValueConst( "could not evaluate expression" );
+ const CMICmnMIValueConst miValueConst( "Could not evaluate expression" );
const CMICmnMIValueResult miValueResult( "msg", miValueConst );
const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
m_miResultRecord = miRecordResult;
return MIstatus::success;
}
- const CMICmnMIValueConst miValueConst( "invalid expression" );
+ const CMICmnMIValueConst miValueConst( "Invalid expression" );
const CMICmnMIValueResult miValueResult( "msg", miValueConst );
const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult );
m_miResultRecord = miRecordResult;
@@ -240,6 +259,29 @@ CMICmdBase * CMICmdCmdDataEvaluateExpression::CreateSelf( void )
return new CMICmdCmdDataEvaluateExpression();
}
+//++ ------------------------------------------------------------------------------------
+// Details: Examine the expression string to see if it contains invalid characters.
+// Type: Method.
+// Args: vrExpr - (R) Expression string given to *this command.
+// vrwInvalidChar - (W) True = Invalid character found, false = nothing found.
+// Return: bool - True = Invalid character found, false = nothing found.
+// Throws: None.
+//--
+bool CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression( const CMIUtilString & vrExpr, MIchar & vrwInvalidChar )
+{
+ bool bFoundInvalidCharInExpression = false;
+ vrwInvalidChar = 0x00;
+
+ if( vrExpr.at( 0 ) == '\\' )
+ {
+ // Example: Mouse hover over "%5d" expression has \"%5d\" in it
+ bFoundInvalidCharInExpression = true;
+ vrwInvalidChar = '\\';
+ }
+
+ return bFoundInvalidCharInExpression;
+}
+
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
@@ -293,14 +335,7 @@ bool CMICmdCmdDataDisassemble::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValConsume( m_constStrArgConsume, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgMode, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -505,14 +540,7 @@ bool CMICmdCmdDataReadMemoryBytes::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgAddrStart, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumBytes, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -745,14 +773,7 @@ bool CMICmdCmdDataListRegisterNames::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThreadGroup, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -781,18 +802,13 @@ bool CMICmdCmdDataListRegisterNames::Execute( void )
for( MIuint i = 0; i < nRegisters; i++ )
{
lldb::SBValue value = registers.GetValueAtIndex( i );
- const MIchar * pRegName = value.GetName();
- const MIchar * pUnknown = "??";
- pRegName = (pRegName != nullptr) ? pRegName : pUnknown;
const MIuint nRegChildren = value.GetNumChildren();
for( MIuint j = 0; j < nRegChildren; j++ )
{
lldb::SBValue value2 = value.GetChildAtIndex( j );
if( value2.IsValid() )
{
- const MIchar * pRegName = value2.GetName();
- pRegName = (pRegName != nullptr) ? pRegName : pUnknown;
- const CMICmnMIValueConst miValueConst( pRegName );
+ const CMICmnMIValueConst miValueConst( CMICmnLLDBUtilSBValue( value2 ).GetName() );
m_miValueList.Add( miValueConst );
}
}
@@ -884,14 +900,7 @@ bool CMICmdCmdDataListRegisterValues::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgSkip, false, false ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgFormat, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1147,14 +1156,7 @@ bool CMICmdCmdDataWriteMemoryBytes::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgAddr, true, true, false, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgContents, true, true, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgCount, false, true, false, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1274,14 +1276,7 @@ bool CMICmdCmdDataWriteMemory::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgD, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumber, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgContents, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdData.h b/lldb/tools/lldb-mi/MICmdCmdData.h
index 8cdce068852..c1501de3918 100644
--- a/lldb/tools/lldb-mi/MICmdCmdData.h
+++ b/lldb/tools/lldb-mi/MICmdCmdData.h
@@ -70,15 +70,21 @@ public:
// From CMICmnBase
/* dtor */ virtual ~CMICmdCmdDataEvaluateExpression( void );
+// Methods:
+private:
+ bool HaveInvalidCharacterInExpression( const CMIUtilString & vrExpr, MIchar & vrwInvalidChar );
+
// Attributes:
private:
- bool m_bExpressionValid; // True = yes is valid, false = not valid
- bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed
+ bool m_bExpressionValid; // True = yes is valid, false = not valid
+ bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed
CMIUtilString m_strValue;
CMICmnMIValueTuple m_miValueTuple;
- bool m_bCompositeVarType; // True = yes composite type, false = internal type
- 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.
+ 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;
+ 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;
};
diff --git a/lldb/tools/lldb-mi/MICmdCmdEnviro.cpp b/lldb/tools/lldb-mi/MICmdCmdEnviro.cpp
index 9c7e1f86326..b47327af940 100644
--- a/lldb/tools/lldb-mi/MICmdCmdEnviro.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdEnviro.cpp
@@ -20,25 +20,12 @@
//--
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdEnviro.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MIDriverBase.h"
-#include "MIUtilDebug.h"
-#include "MIDriver.h"
-#include "MIUtilFileStd.h"
-#include "MICmnLLDBProxySBValue.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValFile.h"
-#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
-#include "MICmdArgValOptionLong.h"
-#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdEnvironmentCd constructor.
@@ -81,13 +68,7 @@ bool CMICmdCmdEnvironmentCd::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValFile( m_constStrArgNamePathDir, true, true ) ) );
CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdExec.cpp b/lldb/tools/lldb-mi/MICmdCmdExec.cpp
index 9d7bf312f18..417492d2314 100644
--- a/lldb/tools/lldb-mi/MICmdCmdExec.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdExec.cpp
@@ -17,7 +17,7 @@
// CMICmdCmdExecNextInstruction implementation.
// CMICmdCmdExecStepInstruction implementation.
// CMICmdCmdExecFinish implementation.
-// CMICmdCmdExecInterupt implementation.
+// CMICmdCmdExecInterrupt implementation.
//
// Environment: Compilers: Visual C++ 12.
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
@@ -30,14 +30,12 @@
#include <lldb/API/SBCommandInterpreter.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdExec.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
#include "MIDriver.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
@@ -300,14 +298,7 @@ bool CMICmdCmdExecNext::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumber, false, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -428,14 +419,7 @@ bool CMICmdCmdExecStep::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumber, false, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -556,14 +540,7 @@ bool CMICmdCmdExecNextInstruction::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumber, false, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -684,14 +661,7 @@ bool CMICmdCmdExecStepInstruction::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNumber, false, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -812,14 +782,7 @@ bool CMICmdCmdExecFinish::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdExec.h b/lldb/tools/lldb-mi/MICmdCmdExec.h
index 9dccc43572f..a712b23ca5e 100644
--- a/lldb/tools/lldb-mi/MICmdCmdExec.h
+++ b/lldb/tools/lldb-mi/MICmdCmdExec.h
@@ -17,7 +17,7 @@
// CMICmdCmdExecNextInstruction interface.
// CMICmdCmdExecStepInstruction interface.
// CMICmdCmdExecFinish interface.
-// CMICmdCmdExecInterupt interface.
+// CMICmdCmdExecInterrupt interface.
//
// To implement new MI commands derive a new command class from the command base
// class. To enable the new command for interpretation add the new command class
diff --git a/lldb/tools/lldb-mi/MICmdCmdFile.cpp b/lldb/tools/lldb-mi/MICmdCmdFile.cpp
index d723b199322..1d0b494362c 100644
--- a/lldb/tools/lldb-mi/MICmdCmdFile.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdFile.cpp
@@ -23,21 +23,13 @@
#include <lldb/API/SBStream.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdFile.h"
#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
#include "MIUtilFileStd.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValFile.h"
-#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
#include "MICmdArgValOptionLong.h"
-#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdFileExecAndSymbols constructor.
@@ -81,14 +73,7 @@ bool CMICmdCmdFileExecAndSymbols::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThreadGrp, false, false, CMICmdArgValListBase::eArgValType_ThreadGrp, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValFile( m_constStrArgNameFile, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -181,3 +166,19 @@ CMICmdBase * CMICmdCmdFileExecAndSymbols::CreateSelf( void )
{
return new CMICmdCmdFileExecAndSymbols();
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
+// on a executable passed in as a argument to the drive then what should the driver
+// do on a command failing? Either continue operating or exit the application.
+// Override this function where a command failure cannot allow the driver to
+// continue operating.
+// Type: Overridden.
+// Args: None.
+// Return: bool - True = Fatal if command fails, false = can continue if command fails.
+// Throws: None.
+//--
+bool CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure( void ) const
+{
+ return true;
+} \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MICmdCmdFile.h b/lldb/tools/lldb-mi/MICmdCmdFile.h
index 0b200fdb8a6..a80a313ea7b 100644
--- a/lldb/tools/lldb-mi/MICmdCmdFile.h
+++ b/lldb/tools/lldb-mi/MICmdCmdFile.h
@@ -62,6 +62,7 @@ public:
virtual bool ParseArgs( void );
// From CMICmnBase
/* dtor */ virtual ~CMICmdCmdFileExecAndSymbols( void );
+ virtual bool GetExitAppOnCommandFailure( void ) const;
// Attributes:
private:
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp
index 5b593597149..62bb1f280bc 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp
@@ -26,7 +26,6 @@
#include "MICmdCmdGdbInfo.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValString.h"
#include "MICmnStreamStdout.h"
#include "MICmnLLDBDebugSessionInfo.h"
@@ -80,14 +79,7 @@ CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo( void )
bool CMICmdCmdGdbInfo::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedPrint, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
index 4d1b9042ca1..b37d6af171f 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
@@ -23,7 +23,6 @@
#include "MICmdCmdGdbSet.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValString.h"
#include "MICmdArgValListOfN.h"
#include "MICmnLLDBDebugSessionInfo.h"
@@ -81,14 +80,7 @@ CMICmdCmdGdbSet::~CMICmdCmdGdbSet( void )
bool CMICmdCmdGdbSet::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumberPath ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp
index 0abffeeff7f..c3e9507d109 100644
--- a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp
@@ -13,6 +13,7 @@
// Overview: CMICmdCmdGdbExit implementation.
// CMICmdCmdListThreadGroups implementation.
// CMICmdCmdInterpreterExec implementation.
+// CMICmdCmdInferiorTtySet implementation.
//
// Environment: Compilers: Visual C++ 12.
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
@@ -26,7 +27,6 @@
#include <lldb/API/SBThread.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdMiscellanous.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
@@ -34,7 +34,6 @@
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
#include "MIDriverBase.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValFile.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
@@ -182,14 +181,7 @@ bool CMICmdCmdListThreadGroups::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgNamedRecurse, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedGroup, false, true, CMICmdArgValListBase::eArgValType_Number ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValThreadGrp( m_constStrArgNamedThreadGroup, false, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -248,7 +240,7 @@ bool CMICmdCmdListThreadGroups::Execute( void )
if( thread.IsValid() )
{
CMICmnMIValueTuple miTuple;
- if( !rSessionInfo.MIResponseFormThreadInfo( m_cmdData, thread, miTuple ) )
+ if( !rSessionInfo.MIResponseFormThreadInfo2( m_cmdData, thread, miTuple ) )
return MIstatus::failure;
m_vecMIValueTuple.push_back( miTuple );
@@ -431,14 +423,7 @@ bool CMICmdCmdInterpreterExec::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedInterpreter, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedCommand, true, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -454,11 +439,14 @@ bool CMICmdCmdInterpreterExec::Execute( void )
{
CMICMDBASE_GETOPTION( pArgInterpreter, String, m_constStrArgNamedInterpreter );
CMICMDBASE_GETOPTION( pArgCommand, String, m_constStrArgNamedCommand );
- const CMIUtilString & rStrInterpreter( pArgInterpreter->GetValue() );
+
+ // Handle the interpreter parameter by do nothing on purpose (set to 'handled' in
+ // the arg definition above)
+ const CMIUtilString & rStrInterpreter( pArgInterpreter->GetValue() ); MIunused( rStrInterpreter );
+
const CMIUtilString & rStrCommand( pArgCommand->GetValue() );
- const CMIUtilString strCmd( CMIUtilString::Format( "%s %s", rStrInterpreter.c_str(), rStrCommand.c_str() ) );
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- const lldb::ReturnStatus rtn = rSessionInfo.m_rLldbDebugger.GetCommandInterpreter().HandleCommand( strCmd.c_str(), m_lldbResult, true ); MIunused( rtn );
+ const lldb::ReturnStatus rtn = rSessionInfo.m_rLldbDebugger.GetCommandInterpreter().HandleCommand( rStrCommand.c_str(), m_lldbResult, true ); MIunused( rtn );
return MIstatus::success;
}
@@ -479,12 +467,19 @@ bool CMICmdCmdInterpreterExec::Acknowledge( void )
CMIUtilString strMsg( m_lldbResult.GetOutput() );
strMsg = strMsg.StripCREndOfLine();
CMICmnStreamStdout::TextToStdout( strMsg );
+
+ // Send the LLDB result message to console so the user can see the result of the
+ // command they typed. It is not necessary an error message.
+ CMICmnStreamStderr::LLDBMsgToConsole( strMsg );
}
if( m_lldbResult.GetErrorSize() > 0 )
{
CMIUtilString strMsg( m_lldbResult.GetError() );
strMsg = strMsg.StripCREndOfLine();
- CMICmnStreamStderr::TextToStderr( strMsg );
+ CMICmnStreamStderr::LLDBMsgToConsole( strMsg );
+
+ // Send LLDB's error message to the MI Driver's Log file
+ CMICmnStreamStdout::TextToStdout( strMsg );
}
const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
@@ -505,3 +500,80 @@ CMICmdBase * CMICmdCmdInterpreterExec::CreateSelf( void )
{
return new CMICmdCmdInterpreterExec();
}
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdInferiorTtySet constructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet( void )
+{
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "inferior-tty-set";
+
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdInferiorTtySet::CreateSelf;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmdCmdInferiorTtySet destructor.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet( void )
+{
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command does work in this function.
+// The command is likely to communicate with the LLDB SBDebugger in here.
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdCmdInferiorTtySet::Execute( void )
+{
+ // Do nothing
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command prepares a MI Record Result
+// for the work carried out in the Execute().
+// Type: Overridden.
+// Args: None.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmdCmdInferiorTtySet::Acknowledge( void )
+{
+ const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done );
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Required by the CMICmdFactory when registering *this command. The factory
+// calls this function to create an instance of *this command.
+// Type: Static method.
+// Args: None.
+// Return: CMICmdBase * - Pointer to a new command.
+// Throws: None.
+//--
+CMICmdBase * CMICmdCmdInferiorTtySet::CreateSelf( void )
+{
+ return new CMICmdCmdInferiorTtySet();
+} \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.h b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.h
index 35453ca03f6..ea71f123341 100644
--- a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.h
+++ b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.h
@@ -13,6 +13,7 @@
// Overview: CMICmdCmdGdbExit interface.
// CMICmdCmdListThreadGroups interface.
// CMICmdCmdInterpreterExec interface.
+// CMICmdCmdInferiorTtySet interface.
//
// To implement new MI commands derive a new command class from the command base
// class. To enable the new command for interpretation add the new command class
@@ -145,3 +146,30 @@ private:
const CMIUtilString m_constStrArgNamedCommand;
lldb::SBCommandReturnObject m_lldbResult;
};
+
+//++ ============================================================================
+// Details: MI command class. MI commands derived from the command base class.
+// *this class implements MI command "inferior-tty-set".
+// Gotchas: None.
+// Authors: Illya Rudkin 22/07/2014.
+// Changes: None.
+//--
+class CMICmdCmdInferiorTtySet : public CMICmdBase
+{
+// Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase * CreateSelf( void );
+
+// Methods:
+public:
+ /* ctor */ CMICmdCmdInferiorTtySet( void );
+
+// Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ virtual bool Execute( void );
+ virtual bool Acknowledge( void );
+ // From CMICmnBase
+ /* dtor */ virtual ~CMICmdCmdInferiorTtySet( void );
+}; \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MICmdCmdStack.cpp b/lldb/tools/lldb-mi/MICmdCmdStack.cpp
index 7f5cac10c05..5f5b355758c 100644
--- a/lldb/tools/lldb-mi/MICmdCmdStack.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdStack.cpp
@@ -26,14 +26,12 @@
#include <lldb/API/SBThread.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdStack.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnMIOutOfBandRecord.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
@@ -84,14 +82,7 @@ bool CMICmdCmdStackInfoDepth::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgMaxDepth, false, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -117,7 +108,9 @@ bool CMICmdCmdStackInfoDepth::Execute( void )
}
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- m_nThreadFrames = rSessionInfo.m_lldbProcess.GetThreadByIndexID( nThreadId ).GetNumFrames();
+ lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID( nThreadId ) : rProcess.GetSelectedThread();
+ m_nThreadFrames = thread.GetNumFrames();
return MIstatus::success;
}
@@ -205,14 +198,7 @@ bool CMICmdCmdStackListFrames::ParseArgs( void )
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, true, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgFrameLow, false, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgFrameHigh, false, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -243,7 +229,8 @@ bool CMICmdCmdStackListFrames::Execute( void )
const MIuint nFrameLow = pArgFrameLow->GetFound() ? pArgFrameLow->GetValue() : 0;
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- lldb::SBThread thread = rSessionInfo.m_lldbProcess.GetThreadByIndexID( nThreadId );
+ lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID( nThreadId ) : rProcess.GetSelectedThread();
MIuint nThreadFrames = thread.GetNumFrames();
// Adjust nThreadFrames for the nFrameHigh argument as we use nFrameHigh+1 in the min calc as the arg
@@ -385,14 +372,7 @@ bool CMICmdCmdStackListArguments::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgPrintValues, true, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -422,11 +402,7 @@ bool CMICmdCmdStackListArguments::Execute( void )
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread;
- if( nThreadId == UINT64_MAX )
- thread = rProcess.GetSelectedThread();
- else
- thread = rProcess.GetThreadByIndexID( nThreadId );
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID( nThreadId ) : rProcess.GetSelectedThread();
m_bThreadInvalid = !thread.IsValid();
if( m_bThreadInvalid )
return MIstatus::success;
@@ -438,13 +414,23 @@ bool CMICmdCmdStackListArguments::Execute( void )
return MIstatus::success;
}
- lldb::SBFrame frame = thread.GetFrameAtIndex( 0 );
- CMICmnMIValueList miValueList( true );
- const MIuint vMaskVarTypes = 0x1000;
- if( !rSessionInfo.MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList ) )
- return MIstatus::failure;
- m_miValueList = miValueList;
+ const MIuint nFrames = thread.GetNumFrames();
+ for( MIuint i = 0; i < nFrames; i++ )
+ {
+ lldb::SBFrame frame = thread.GetFrameAtIndex( i );
+ CMICmnMIValueList miValueList( true );
+ const MIuint maskVarTypes = 0x1000;
+ if( !rSessionInfo.MIResponseFormVariableInfo3( frame, maskVarTypes, miValueList ) )
+ return MIstatus::failure;
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%d", i ) );
+ const CMICmnMIValueResult miValueResult( "level", miValueConst );
+ CMICmnMIValueTuple miValueTuple( miValueResult );
+ const CMICmnMIValueResult miValueResult2( "args", miValueList );
+ miValueTuple.Add( miValueResult2 );
+ const CMICmnMIValueResult miValueResult3( "frame", miValueTuple );
+ m_miValueList.Add( miValueResult3 );
+ }
return MIstatus::success;
}
@@ -470,15 +456,8 @@ bool CMICmdCmdStackListArguments::Acknowledge( void )
return MIstatus::success;
}
- // MI print "%s^done,stack-args=[frame={level=\"0\",args=[%s]}]"
- const CMICmnMIValueConst miValueConst( "0" );
- const CMICmnMIValueResult miValueResult( "level", miValueConst );
- CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueResult miValueResult2( "args", m_miValueList );
- miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueResult miValueResult3( "frame", miValueTuple );
- const CMICmnMIValueList miValueList( miValueResult3 );
- const CMICmnMIValueResult miValueResult4( "stack-args", miValueList );
+ // MI print "%s^done,stack-args=[frame={level=\"0\",args=[%s]},frame={level=\"1\",args=[%s]}]"
+ const CMICmnMIValueResult miValueResult4( "stack-args", m_miValueList );
const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult4 );
m_miResultRecord = miRecordResult;
@@ -546,16 +525,9 @@ CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals( void )
bool CMICmdCmdStackListLocals::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
- bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgFrame, false, false, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
+ bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValOptionLong( m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgPrintValues, true, false ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -570,7 +542,7 @@ bool CMICmdCmdStackListLocals::ParseArgs( void )
bool CMICmdCmdStackListLocals::Execute( void )
{
CMICMDBASE_GETOPTION( pArgThread, OptionLong, m_constStrArgThread );
- CMICMDBASE_GETOPTION( pArgPrintValues, Number, m_constStrArgPrintValues );
+ CMICMDBASE_GETOPTION( pArgFrame, OptionLong, m_constStrArgFrame );
// Retrieve the --thread option's thread ID (only 1)
MIuint64 nThreadId = UINT64_MAX;
@@ -582,14 +554,19 @@ bool CMICmdCmdStackListLocals::Execute( void )
return MIstatus::failure;
}
}
+ MIuint64 nFrame = UINT64_MAX;
+ if( pArgFrame->GetFound() )
+ {
+ if( !pArgFrame->GetExpectedOption< CMICmdArgValNumber, MIuint64 >( nFrame ) )
+ {
+ SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_OPTION_NOT_FOUND ), m_cmdData.strMiCmd.c_str(), m_constStrArgFrame.c_str() ) );
+ return MIstatus::failure;
+ }
+ }
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
lldb::SBProcess & rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread;
- if( nThreadId == UINT64_MAX )
- thread = rProcess.GetSelectedThread();
- else
- thread = rProcess.GetThreadByIndexID( nThreadId );
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID( nThreadId ) : rProcess.GetSelectedThread();
m_bThreadInvalid = !thread.IsValid();
if( m_bThreadInvalid )
return MIstatus::success;
@@ -601,10 +578,11 @@ bool CMICmdCmdStackListLocals::Execute( void )
return MIstatus::success;
}
- lldb::SBFrame frame = thread.GetFrameAtIndex( 0 );
+ const MIuint nFrames = thread.GetNumFrames(); MIunused( nFrames );
+ lldb::SBFrame frame = (nFrame != UINT64_MAX) ? thread.GetFrameAtIndex( nFrame ) : thread.GetSelectedFrame();
CMICmnMIValueList miValueList( true );
- const MIuint vMaskVarTypes = 0x0100;
- if( !rSessionInfo.MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList ) )
+ const MIuint maskVarTypes = 0x0110;
+ if( !rSessionInfo.MIResponseFormVariableInfo( frame, maskVarTypes, miValueList ) )
return MIstatus::failure;
m_miValueList = miValueList;
diff --git a/lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp b/lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp
index f4d9d0dc62a..e6f96f094e5 100644
--- a/lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp
@@ -20,12 +20,10 @@
//--
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdSupportInfo.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnMIValueTuple.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValString.h"
#include "MICmdFactory.h"
@@ -70,14 +68,7 @@ CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery( void )
bool CMICmdCmdSupportInfoMiCmdQuery::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgCmdName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdSupportList.cpp b/lldb/tools/lldb-mi/MICmdCmdSupportList.cpp
index c78aa53876a..2e4beb3edc8 100644
--- a/lldb/tools/lldb-mi/MICmdCmdSupportList.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdSupportList.cpp
@@ -20,7 +20,6 @@
//--
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdSupportList.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
diff --git a/lldb/tools/lldb-mi/MICmdCmdTarget.cpp b/lldb/tools/lldb-mi/MICmdCmdTarget.cpp
index 3e781571143..60c1c5e4bba 100644
--- a/lldb/tools/lldb-mi/MICmdCmdTarget.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdTarget.cpp
@@ -25,21 +25,13 @@
#include <lldb/API/SBCommandReturnObject.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdTarget.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnMIOutOfBandRecord.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgContext.h"
-#include "MICmdArgValFile.h"
-#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
-#include "MICmdArgValOptionLong.h"
-#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetSelect constructor.
@@ -83,14 +75,7 @@ bool CMICmdCmdTargetSelect::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedType, true, true )) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedParameters, true, true )) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdThread.cpp b/lldb/tools/lldb-mi/MICmdCmdThread.cpp
index 169d248b25f..8cfaae80493 100644
--- a/lldb/tools/lldb-mi/MICmdCmdThread.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdThread.cpp
@@ -24,20 +24,12 @@
#include <lldb/API/SBThread.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdThread.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgContext.h"
-#include "MICmdArgValFile.h"
#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
-#include "MICmdArgValOptionLong.h"
-#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdThreadInfo constructor.
@@ -82,14 +74,7 @@ CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo( void )
bool CMICmdCmdThreadInfo::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgNamedThreadId, false, true )) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -123,7 +108,7 @@ bool CMICmdCmdThreadInfo::Execute( void )
return MIstatus::success;
CMICmnMIValueTuple miTuple;
- if( !rSessionInfo.MIResponseFormThreadInfo( m_cmdData, thread, miTuple ) )
+ if( !rSessionInfo.MIResponseFormThreadInfo3( m_cmdData, thread, miTuple ) )
return MIstatus::failure;
m_miValueTupleThread = miTuple;
@@ -140,7 +125,7 @@ bool CMICmdCmdThreadInfo::Execute( void )
if( thread.IsValid() )
{
CMICmnMIValueTuple miTuple;
- if( !rSessionInfo.MIResponseFormThreadInfo( m_cmdData, thread, miTuple ) )
+ if( !rSessionInfo.MIResponseFormThreadInfo3( m_cmdData, thread, miTuple ) )
return MIstatus::failure;
m_vecMIValueTuple.push_back( miTuple );
diff --git a/lldb/tools/lldb-mi/MICmdCmdTrace.cpp b/lldb/tools/lldb-mi/MICmdCmdTrace.cpp
index f4ff50d09a3..8623db9eb15 100644
--- a/lldb/tools/lldb-mi/MICmdCmdTrace.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdTrace.cpp
@@ -20,12 +20,10 @@
//--
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdTrace.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdTraceStatus constructor.
// Type: Method.
diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.cpp b/lldb/tools/lldb-mi/MICmdCmdVar.cpp
index f0977178145..346d6960076 100644
--- a/lldb/tools/lldb-mi/MICmdCmdVar.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdVar.cpp
@@ -32,13 +32,11 @@
#include <lldb/API/SBThread.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmdCmdVar.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgContext.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
@@ -46,6 +44,7 @@
#include "MICmdArgValOptionShort.h"
#include "MICmdArgValListOfN.h"
#include "MICmnLLDBProxySBValue.h"
+#include "MICmnLLDBUtilSBValue.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdCmdVarCreate constructor.
@@ -60,6 +59,7 @@ CMICmdCmdVarCreate::CMICmdCmdVarCreate( void )
, m_nThreadId( 0 )
, m_strType( "??" )
, m_bValid( false )
+, m_strValue( "??" )
, m_constStrArgThread( "thread" )
, m_constStrArgThreadGroup( "thread-group" )
, m_constStrArgFrame( "frame" )
@@ -102,14 +102,7 @@ bool CMICmdCmdVarCreate::ParseArgs( void )
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, false, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgFrameAddr, false, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgExpression, true, true, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -166,7 +159,7 @@ bool CMICmdCmdVarCreate::Execute( void )
m_strExpression = rStrExpression;
CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
- m_strVarName = "unnamedvariable";
+ m_strVarName = "<unnamedvariable>";
if( bAutoName )
{
m_strVarName = CMIUtilString::Format( "var%u", CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet() );
@@ -182,14 +175,11 @@ bool CMICmdCmdVarCreate::Execute( void )
{
m_bValid = true;
m_nChildren = value.GetNumChildren();
- const MIchar * pCType = value.GetTypeName();
- m_strType = (pCType != nullptr) ? pCType : m_strType;
- }
-
- if( m_bValid )
- {
+ m_strType = CMICmnLLDBUtilSBValue( value ).GetTypeNameDisplay();
+
// This gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs
CMICmnLLDBDebugSessionInfoVarObj varObj( rStrExpression, m_strVarName, value );
+ m_strValue = varObj.GetValueFormatted();
}
return MIstatus::success;
@@ -214,9 +204,7 @@ bool CMICmdCmdVarCreate::Acknowledge( void )
const CMIUtilString strNumChild( CMIUtilString::Format( "%d", m_nChildren ) );
const CMICmnMIValueConst miValueConst2( strNumChild );
miValueResultAll.Add( "numchild", miValueConst2 );
- CMICmnLLDBDebugSessionInfoVarObj varObj;
- const bool bOk = CMICmnLLDBDebugSessionInfoVarObj::VarObjGet( m_strVarName, varObj ); MIunused( bOk );
- const CMICmnMIValueConst miValueConst3( varObj.GetValueFormatted() );
+ const CMICmnMIValueConst miValueConst3( m_strValue );
miValueResultAll.Add( "value", miValueConst3 );
const CMICmnMIValueConst miValueConst4( m_strType );
miValueResultAll.Add( "type", miValueConst4 );
@@ -225,7 +213,7 @@ bool CMICmdCmdVarCreate::Acknowledge( void )
miValueResultAll.Add( "thread-id", miValueConst5 );
const CMICmnMIValueConst miValueConst6( "0" );
miValueResultAll.Add( "has_more", miValueConst6 );
-
+
const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResultAll );
m_miResultRecord = miRecordResult;
@@ -303,14 +291,7 @@ bool CMICmdCmdVarUpdate::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgPrintValues, false, false ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -609,14 +590,7 @@ CMICmdCmdVarDelete::CMICmdCmdVarDelete( void )
bool CMICmdCmdVarDelete::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -726,14 +700,7 @@ bool CMICmdCmdVarAssign::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgExpression, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -862,14 +829,7 @@ bool CMICmdCmdVarSetFormat::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgFormatSpec, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1008,14 +968,7 @@ bool CMICmdCmdVarListChildren::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValNumber( m_constStrArgPrintValues, false, false ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1051,13 +1004,10 @@ bool CMICmdCmdVarListChildren::Execute( void )
lldb::SBValue member = rValue.GetChildAtIndex( i );
if( !member.IsValid() )
continue;
-
- const MIchar * pExp = member.GetName();
- const CMIUtilString strExp = (pExp != nullptr) ? pExp : "??";
+ const CMICmnLLDBUtilSBValue utilValue( member );
+ const CMIUtilString strExp = utilValue.GetName();
const CMIUtilString name( CMIUtilString::Format( "%s.%s", rVarObjName.c_str(), strExp.c_str() ) );
const MIuint nChildren = member.GetNumChildren();
- const MIchar * pTypeName = member.GetType().GetName();
- const CMIUtilString strType = (pTypeName != nullptr) ? pTypeName : MIRSRC( IDS_WORD_UNKNOWNTYPE_BRKTS );
const CMIUtilString strThreadId( CMIUtilString::Format( "%u", member.GetThread().GetIndexID() ) );
// Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs
@@ -1074,7 +1024,7 @@ bool CMICmdCmdVarListChildren::Execute( void )
const CMICmnMIValueConst miValueConst3( strNumChild );
const CMICmnMIValueResult miValueResult3( "numchild", miValueConst3 );
miValueTuple.Add( miValueResult3 );
- const CMICmnMIValueConst miValueConst5( strType );
+ const CMICmnMIValueConst miValueConst5( utilValue.GetTypeNameDisplay() );
const CMICmnMIValueResult miValueResult5( "type", miValueConst5 );
miValueTuple.Add( miValueResult5 );
const CMICmnMIValueConst miValueConst6( strThreadId );
@@ -1203,14 +1153,7 @@ bool CMICmdCmdVarEvaluateExpression::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValOptionShort( m_constStrArgFormatSpec, false, false, CMICmdArgValListBase::eArgValType_String, 1 ) ) );
bOk = bOk && m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1332,14 +1275,7 @@ CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression( void )
bool CMICmdCmdVarInfoPathExpression::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
@@ -1495,14 +1431,7 @@ CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes( void )
bool CMICmdCmdVarShowAttributes::ParseArgs( void )
{
bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgName, true, true ) ) );
- CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption );
- if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) )
- {
- SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) );
- return MIstatus::failure;
- }
-
- return bOk;
+ return (bOk && ParseValidateCmdOptions() );
}
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.h b/lldb/tools/lldb-mi/MICmdCmdVar.h
index 853bbe102dc..387cfc4ada8 100644
--- a/lldb/tools/lldb-mi/MICmdCmdVar.h
+++ b/lldb/tools/lldb-mi/MICmdCmdVar.h
@@ -83,6 +83,7 @@ private:
CMIUtilString m_strType;
bool m_bValid; // True = Variable is valid, false = not valid
CMIUtilString m_strExpression;
+ CMIUtilString m_strValue;
const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgThreadGroup; // Not specified in MI spec but Eclipse gives this option
const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option
diff --git a/lldb/tools/lldb-mi/MICmdCommands.cpp b/lldb/tools/lldb-mi/MICmdCommands.cpp
index b3630382e9e..4187b059b39 100644
--- a/lldb/tools/lldb-mi/MICmdCommands.cpp
+++ b/lldb/tools/lldb-mi/MICmdCommands.cpp
@@ -110,6 +110,7 @@ bool MICmnCommands::RegisterAll( void )
bOk &= Register< CMICmdCmdGdbInfo >();
bOk &= Register< CMICmdCmdGdbSet >();
bOk &= Register< CMICmdCmdGdbThread >();
+ bOk &= Register< CMICmdCmdInferiorTtySet >();
bOk &= Register< CMICmdCmdInterpreterExec >();
bOk &= Register< CMICmdCmdListThreadGroups >();
bOk &= Register< CMICmdCmdSource >();
diff --git a/lldb/tools/lldb-mi/MICmdInvoker.cpp b/lldb/tools/lldb-mi/MICmdInvoker.cpp
index 2ab09ccca60..41f9f77542a 100644
--- a/lldb/tools/lldb-mi/MICmdInvoker.cpp
+++ b/lldb/tools/lldb-mi/MICmdInvoker.cpp
@@ -25,6 +25,7 @@
#include "MICmdMgr.h"
#include "MICmnLog.h"
#include "MICmnStreamStdout.h"
+#include "MIDriver.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmdInvoker constructor.
@@ -197,6 +198,7 @@ bool CMICmdInvoker::CmdExecute( CMICmdBase & vCmd )
// Report command execution failed
const SMICmdData cmdData( vCmd.GetCmdData() );
CmdStdout( cmdData );
+ CmdCauseAppExit( vCmd );
CmdDelete( cmdData.id );
// Proceed to wait or execute next command
@@ -208,6 +210,7 @@ bool CMICmdInvoker::CmdExecute( CMICmdBase & vCmd )
// Report command execution failed
const SMICmdData cmdData( vCmd.GetCmdData() );
CmdStdout( cmdData );
+ CmdCauseAppExit( vCmd );
CmdDelete( cmdData.id );
// Proceed to wait or execute next command
@@ -240,6 +243,7 @@ bool CMICmdInvoker::CmdExecuteFinished( CMICmdBase & vCmd )
// Report command acknowledge functionality failed
const SMICmdData cmdData( vCmd.GetCmdData() );
CmdStdout( cmdData );
+ CmdCauseAppExit( vCmd );
CmdDelete( cmdData.id );
// Proceed to wait or execute next command
@@ -268,6 +272,27 @@ bool CMICmdInvoker::CmdExecuteFinished( CMICmdBase & vCmd )
}
//++ ------------------------------------------------------------------------------------
+// Details: If the MI Driver is not operating via a client i.e. Eclipse check the command
+// on failure suggests the application exits. A command can be such that a
+// failure cannot the allow the application to continue operating.
+// Args: vCmd - (R) Command object.
+// Return: None.
+// Return: None.
+// Throws: None.
+//--
+void CMICmdInvoker::CmdCauseAppExit( const CMICmdBase & vCmd ) const
+{
+ if( vCmd.GetExitAppOnCommandFailure() )
+ {
+ CMIDriver & rDriver( CMIDriver::Instance() );
+ if( rDriver.IsDriverDebuggingArgExecutable() )
+ {
+ rDriver.SetExitApplicationFlag( true );
+ }
+ }
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Write to stdout and the Log file the command's MI formatted result.
// Type: vCmdData - (R) A command's information.
// Return: MIstatus::success - Functionality succeeded.
diff --git a/lldb/tools/lldb-mi/MICmdInvoker.h b/lldb/tools/lldb-mi/MICmdInvoker.h
index e4ed2d98797..b89d506b1f5 100644
--- a/lldb/tools/lldb-mi/MICmdInvoker.h
+++ b/lldb/tools/lldb-mi/MICmdInvoker.h
@@ -102,6 +102,7 @@ private:
bool CmdDelete( const MIuint vCmdId, const bool vbYesDeleteCmd = false );
bool CmdAdd( const CMICmdBase & vCmd );
bool CmdStdout( const SMICmdData & vCmdData ) const;
+ void CmdCauseAppExit( const CMICmdBase & vCmd ) const;
// Overridden:
private:
diff --git a/lldb/tools/lldb-mi/MICmnConfig.h b/lldb/tools/lldb-mi/MICmnConfig.h
index 1e27c92accb..68093e87998 100644
--- a/lldb/tools/lldb-mi/MICmnConfig.h
+++ b/lldb/tools/lldb-mi/MICmnConfig.h
@@ -1,4 +1,4 @@
-//===-- MIConfig.h ----------------------------------------------*- C++ -*-===//
+//===-- MICmnConfig.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//++
-// File: MIConfig.h
+// File: MICmnConfig.h
//
// Overview: Common defines to guide feature inclusion at compile time.
//
@@ -26,11 +26,10 @@
#define MICONFIG_COMPILE_MIDRIVER_VERSION 1
// 1 = Show debug process attach modal dialog, 0 = do not show
-// For windows only ATM, other OS use an infinite loop which a debug has to change a value to continue
+// For windows only ATM, other OS's code is an infinite loop which a debugger must change a value to continue
#define MICONFIG_DEBUG_SHOW_ATTACH_DBG_DLG 0
// 1 = Compile in and init LLDB driver code alongside MI version, 0 = do not compile in
-// ToDo: This has not been fully implemented as may not be required in the future
#define MICONFIG_COMPILE_MIDRIVER_WITH_LLDBDRIVER 1
// 1 = Give runtime our own custom buffer, 0 = Use runtime managed buffer
@@ -46,3 +45,6 @@
// 1 = Write to MI's Log file warnings about commands that did not handle arguments or
// options present to them by the driver's client, 0 = no warnings given
#define MICONFIG_GIVE_WARNING_CMD_ARGS_NOT_HANDLED 1
+
+// 1 = Enable MI Driver in MI mode to create a local debug session, 0 = Report "Not implemented"
+#define MICONFIG_ENABLE_MI_DRIVER_MI_MODE_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION 0 \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
index 6574c2385ba..3b7789ee1d6 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -37,6 +37,7 @@
#include "MICmnMIValueList.h"
#include "MICmnMIValueTuple.h"
#include "MICmdData.h"
+#include "MICmnLLDBUtilSBValue.h"
//++ ------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfo constructor.
@@ -216,17 +217,21 @@ bool CMICmnLLDBDebugSessionInfo::RecordBrkPtInfoDelete( const MIuint vnBrkPtId )
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool CMICmnLLDBDebugSessionInfo::GetThreadFrames( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMICmnMIValueTuple & vwrThreadFrames )
+bool CMICmnLLDBDebugSessionInfo::GetThreadFrames( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMIUtilString & vwrThreadFrames )
{
lldb::SBThread thread = m_lldbProcess.GetThreadByIndexID( vThreadIdx );
const uint32_t nFrames = thread.GetNumFrames();
if( nFrames == 0 )
{
- vwrThreadFrames = CMICmnMIValueTuple();
+ // MI print "frame={}"
+ CMICmnMIValueTuple miValueTuple;
+ CMICmnMIValueResult miValueResult( "frame", miValueTuple );
+ vwrThreadFrames = miValueResult.GetString();
return MIstatus::success;
}
- CMICmnMIValueTuple miValueTupleAll;
+ // MI print "frame={level=\"%d\",addr=\"0x%08llx\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"},frame={level=\"%d\",addr=\"0x%08llx\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"}, ..."
+ CMIUtilString strListCommaSeperated;
for( MIuint nLevel = 0; nLevel < nFrames; nLevel++ )
{
lldb::SBFrame frame = thread.GetFrameAtIndex( nLevel );
@@ -240,8 +245,8 @@ bool CMICmnLLDBDebugSessionInfo::GetThreadFrames( const SMICmdData & vCmdData, c
// Function args
CMICmnMIValueList miValueList( true );
- const MIuint vMaskVarTypes = 0x1000;
- if( !MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList ) )
+ const MIuint maskVarTypes = 0x1000;
+ if( !MIResponseFormVariableInfo( frame, maskVarTypes, miValueList ) )
return MIstatus::failure;
const MIchar * pUnknown = "??";
@@ -252,17 +257,91 @@ bool CMICmnLLDBDebugSessionInfo::GetThreadFrames( const SMICmdData & vCmdData, c
std::replace( fnName.begin(), fnName.end(), '\'', ' ' );
}
+ CMICmnMIValueTuple miValueTuple;
const CMIUtilString strLevel( CMIUtilString::Format( "%d", nLevel ) );
const CMICmnMIValueConst miValueConst( strLevel );
const CMICmnMIValueResult miValueResult( "level", miValueConst );
- miValueTupleAll.Add( miValueResult );
-
- CMICmnMIValueTuple miValueTuple( miValueResult );
- if( !MIResponseFormFrameInfo( pc, fnName, miValueList.GetString(), fileName, path, nLine, miValueTuple ) )
+ miValueTuple.Add( miValueResult );
+ if( !MIResponseFormFrameInfo2( pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple ) )
return MIstatus::failure;
+
+ const CMICmnMIValueResult miValueResult2( "frame", miValueTuple );
+ if( nLevel != 0 )
+ strListCommaSeperated += ",";
+ strListCommaSeperated += miValueResult2.GetString();
}
- vwrThreadFrames = miValueTupleAll;
+ vwrThreadFrames = strListCommaSeperated;
+
+ return MIstatus::success;
+}
+
+// Todo: Refactor maybe to so only one function with this name, but not just yet
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the specified thread's frame information.
+// Type: Method.
+// Args: vCmdData - (R) A command's information.
+// vThreadIdx - (R) Thread index.
+// vwrThreadFrames - (W) Frame data.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::GetThreadFrames2( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMIUtilString & vwrThreadFrames )
+{
+ lldb::SBThread thread = m_lldbProcess.GetThreadByIndexID( vThreadIdx );
+ const uint32_t nFrames = thread.GetNumFrames();
+ if( nFrames == 0 )
+ {
+ // MI print "frame={}"
+ CMICmnMIValueTuple miValueTuple;
+ CMICmnMIValueResult miValueResult( "frame", miValueTuple );
+ vwrThreadFrames = miValueResult.GetString();
+ return MIstatus::success;
+ }
+
+ // MI print "frame={level=\"%d\",addr=\"0x%08llx\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"},frame={level=\"%d\",addr=\"0x%08llx\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"}, ..."
+ CMIUtilString strListCommaSeperated;
+ for( MIuint nLevel = 0; nLevel < nFrames; nLevel++ )
+ {
+ lldb::SBFrame frame = thread.GetFrameAtIndex( nLevel );
+ lldb::addr_t pc = 0;
+ CMIUtilString fnName;
+ CMIUtilString fileName;
+ CMIUtilString path;
+ MIuint nLine = 0;
+ if( !GetFrameInfo( frame, pc, fnName, fileName, path, nLine ) )
+ return MIstatus::failure;
+
+ // Function args
+ CMICmnMIValueList miValueList( true );
+ const MIuint maskVarTypes = 0x1000;
+ if( !MIResponseFormVariableInfo2( frame, maskVarTypes, miValueList ) )
+ return MIstatus::failure;
+
+ const MIchar * pUnknown = "??";
+ if( fnName != pUnknown )
+ {
+ std::replace( fnName.begin(), fnName.end(), ')', ' ' );
+ std::replace( fnName.begin(), fnName.end(), '(', ' ' );
+ std::replace( fnName.begin(), fnName.end(), '\'', ' ' );
+ }
+
+ CMICmnMIValueTuple miValueTuple;
+ const CMIUtilString strLevel( CMIUtilString::Format( "%d", nLevel ) );
+ const CMICmnMIValueConst miValueConst( strLevel );
+ const CMICmnMIValueResult miValueResult( "level", miValueConst );
+ miValueTuple.Add( miValueResult );
+ if( !MIResponseFormFrameInfo2( pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple ) )
+ return MIstatus::failure;
+
+ const CMICmnMIValueResult miValueResult2( "frame", miValueTuple );
+ if( nLevel != 0 )
+ strListCommaSeperated += ",";
+ strListCommaSeperated += miValueResult2.GetString();
+ }
+
+ vwrThreadFrames = strListCommaSeperated;
return MIstatus::success;
}
@@ -378,8 +457,69 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo( const SMICmdData & vC
{
lldb::SBThread & rThread = const_cast< lldb::SBThread & >( vrThread );
- CMICmnMIValueTuple miValueTupleFrame;
- if( !GetThreadFrames( vCmdData, rThread.GetIndexID(), miValueTupleFrame ) )
+ CMIUtilString strFrames;
+ if( !GetThreadFrames( vCmdData, rThread.GetIndexID(), strFrames ) )
+ return MIstatus::failure;
+
+ const bool bSuspended = rThread.IsSuspended();
+ const lldb::StopReason eReason = rThread.GetStopReason();
+ const bool bValidReason = !((eReason == lldb::eStopReasonNone) || (eReason == lldb::eStopReasonInvalid));
+ const CMIUtilString strState( (bSuspended || bValidReason) ? "stopped" : "running" );
+
+ // Add "id"
+ const CMIUtilString strId( CMIUtilString::Format( "%d", rThread.GetIndexID() ) );
+ const CMICmnMIValueConst miValueConst1( strId );
+ const CMICmnMIValueResult miValueResult1( "id", miValueConst1 );
+ if( !vwrMIValueTuple.Add( miValueResult1 ) )
+ return MIstatus::failure;
+
+ // Add "target-id"
+ const MIchar * 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";
+ CMIUtilString strThread;
+ if( bHaveName )
+ strThread = CMIUtilString::Format( pThrdFmt, pThreadName );
+ else
+ strThread = CMIUtilString::Format( pThrdFmt, rThread.GetIndexID() );
+ const CMICmnMIValueConst miValueConst2( strThread );
+ const CMICmnMIValueResult miValueResult2( "target-id", miValueConst2 );
+ if( !vwrMIValueTuple.Add( miValueResult2 ) )
+ return MIstatus::failure;
+
+ // Add "frame"
+ const CMICmnMIValueConst miValueConst3( strFrames, true );
+ if( !vwrMIValueTuple.Add( miValueConst3, false ) )
+ return MIstatus::failure;
+
+ // Add "state"
+ const CMICmnMIValueConst miValueConst4( strState );
+ const CMICmnMIValueResult miValueResult4( "state", miValueConst4 );
+ if( !vwrMIValueTuple.Add( miValueResult4 ) )
+ return MIstatus::failure;
+
+ return MIstatus::success;
+}
+
+// Todo: Refactor maybe to so only one function with this name, but not just yet
+//++ ------------------------------------------------------------------------------------
+// Details: Form MI partial response by appending more MI value type objects to the
+// tuple type object past in.
+// Type: Method.
+// Args: vCmdData - (R) A command's information.
+// vrThread - (R) LLDB thread object.
+// vwrMIValueTuple - (W) MI value tuple object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo3( const SMICmdData & vCmdData, const lldb::SBThread & vrThread, CMICmnMIValueTuple & vwrMIValueTuple )
+{
+ lldb::SBThread & rThread = const_cast< lldb::SBThread & >( vrThread );
+
+ CMIUtilString strFrames;
+ if( !GetThreadFrames2( vCmdData, rThread.GetIndexID(), strFrames ) )
return MIstatus::failure;
const bool bSuspended = rThread.IsSuspended();
@@ -410,8 +550,8 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo( const SMICmdData & vC
return MIstatus::failure;
// Add "frame"
- const CMICmnMIValueResult miValueResult3( "frame", miValueTupleFrame );
- if( !vwrMIValueTuple.Add( miValueResult3 ) )
+ const CMICmnMIValueConst miValueConst3( strFrames, true );
+ if( !vwrMIValueTuple.Add( miValueConst3, false ) )
return MIstatus::failure;
// Add "state"
@@ -423,6 +563,59 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo( const SMICmdData & vC
return MIstatus::success;
}
+// Todo: Refactor maybe to so only one function with this name, but not just yet
+//++ ------------------------------------------------------------------------------------
+// Details: Form MI partial response by appending more MI value type objects to the
+// tuple type object past in.
+// Type: Method.
+// Args: vCmdData - (R) A command's information.
+// vrThread - (R) LLDB thread object.
+// vwrMIValueTuple - (W) MI value tuple object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo2( const SMICmdData & vCmdData, const lldb::SBThread & vrThread, CMICmnMIValueTuple & vwrMIValueTuple )
+{
+ lldb::SBThread & rThread = const_cast< lldb::SBThread & >( vrThread );
+
+ const bool bSuspended = rThread.IsSuspended();
+ const lldb::StopReason eReason = rThread.GetStopReason();
+ const bool bValidReason = !((eReason == lldb::eStopReasonNone) || (eReason == lldb::eStopReasonInvalid));
+ const CMIUtilString strState( (bSuspended || bValidReason) ? "stopped" : "running" );
+
+ // Add "id"
+ const CMIUtilString strId( CMIUtilString::Format( "%d", rThread.GetIndexID() ) );
+ const CMICmnMIValueConst miValueConst1( strId );
+ const CMICmnMIValueResult miValueResult1( "id", miValueConst1 );
+ if( !vwrMIValueTuple.Add( miValueResult1 ) )
+ return MIstatus::failure;
+
+ // Add "target-id"
+ const MIchar * 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";
+ CMIUtilString strThread;
+ if( bHaveName )
+ strThread = CMIUtilString::Format( pThrdFmt, pThreadName );
+ else
+ strThread = CMIUtilString::Format( pThrdFmt, rThread.GetIndexID() );
+ const CMICmnMIValueConst miValueConst2( strThread );
+ const CMICmnMIValueResult miValueResult2( "target-id", miValueConst2 );
+ if( !vwrMIValueTuple.Add( miValueResult2 ) )
+ return MIstatus::failure;
+
+ // Add "state"
+ const CMICmnMIValueConst miValueConst4( strState );
+ const CMICmnMIValueResult miValueResult4( "state", miValueConst4 );
+ if( !vwrMIValueTuple.Add( miValueResult4 ) )
+ return MIstatus::failure;
+
+ return MIstatus::success;
+}
+
+// Todo: Refactor maybe to so only one function with this name, but not just yet
//++ ------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to the
// tuple type object past in.
@@ -437,7 +630,7 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo( const SMICmdData & vC
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList )
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo2( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList )
{
bool bOk = MIstatus::success;
lldb::SBFrame & rFrame = const_cast< lldb::SBFrame & >( vrFrame );
@@ -446,20 +639,16 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo( const lldb::SBFrame
const bool bLocals = (vMaskVarTypes & 0x0100);
const bool bStatics = (vMaskVarTypes & 0x0010);
const bool bInScopeOnly = (vMaskVarTypes & 0x0001);
- const MIchar * pUnkwn = "??";
lldb::SBValueList listArg = rFrame.GetVariables( bArg, bLocals, bStatics, bInScopeOnly );
const MIuint nArgs = listArg.GetSize();
for( MIuint i = 0; bOk && (i < nArgs); i++ )
{
- lldb::SBValue val = listArg.GetValueAtIndex( i );
- const MIchar * pValue = val.GetValue();
- pValue = (pValue != nullptr) ? pValue : pUnkwn;
- const MIchar * pName = val.GetName();
- pName = (pName != nullptr) ? pName : pUnkwn;
- const CMICmnMIValueConst miValueConst( pName );
+ lldb::SBValue value = listArg.GetValueAtIndex( i );
+ const CMICmnLLDBUtilSBValue utilValue( value );
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
const CMICmnMIValueResult miValueResult( "name", miValueConst );
CMICmnMIValueTuple miValueTuple( miValueResult );
- const CMICmnMIValueConst miValueConst2( pValue );
+ const CMICmnMIValueConst miValueConst2( utilValue.GetValue() );
const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
miValueTuple.Add( miValueResult2 );
bOk = vwrMiValueList.Add( miValueTuple );
@@ -472,6 +661,317 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo( const lldb::SBFrame
// Details: Form MI partial response by appending more MI value type objects to the
// tuple type object past in.
// Type: Method.
+// Args: vrFrame - (R) LLDB thread object.
+// vMaskVarTypes - (R) 0x1000 = arguments,
+// 0x0100 = locals,
+// 0x0010 = statics,
+// 0x0001 = in scope only.
+// vwrMIValueList - (W) MI value list object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList )
+{
+ bool bOk = MIstatus::success;
+ lldb::SBFrame & rFrame = const_cast< lldb::SBFrame & >( vrFrame );
+
+ const bool bArg = (vMaskVarTypes & 0x1000);
+ const bool bLocals = (vMaskVarTypes & 0x0100);
+ const bool bStatics = (vMaskVarTypes & 0x0010);
+ const bool bInScopeOnly = (vMaskVarTypes & 0x0001);
+ const MIuint nMaxRecusiveDepth = 10;
+ MIuint nCurrentRecursiveDepth = 0;
+ lldb::SBValueList listArg = rFrame.GetVariables( bArg, bLocals, bStatics, bInScopeOnly );
+ const MIuint nArgs = listArg.GetSize();
+ for( MIuint i = 0; bOk && (i < nArgs); i++ )
+ {
+ lldb::SBValue value = listArg.GetValueAtIndex( i );
+ bOk = GetVariableInfo( nMaxRecusiveDepth, value, false, vwrMiValueList, nCurrentRecursiveDepth );
+ }
+
+ return bOk;
+}
+
+// *** Do not refactor this function to be one function with same name as it can break more than
+// *** than one stack type command
+//++ ------------------------------------------------------------------------------------
+// Details: Form MI partial response by appending more MI value type objects to the
+// tuple type object past in.
+// Type: Method.
+// Args: vrFrame - (R) LLDB thread object.
+// vMaskVarTypes - (R) 0x1000 = arguments,
+// 0x0100 = locals,
+// 0x0010 = statics,
+// 0x0001 = in scope only.
+// vwrMIValueList - (W) MI value list object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo3( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList )
+{
+ bool bOk = MIstatus::success;
+ lldb::SBFrame & rFrame = const_cast< lldb::SBFrame & >( vrFrame );
+
+ const bool bArg = (vMaskVarTypes & 0x1000);
+ const bool bLocals = (vMaskVarTypes & 0x0100);
+ const bool bStatics = (vMaskVarTypes & 0x0010);
+ const bool bInScopeOnly = (vMaskVarTypes & 0x0001);
+ const MIuint nMaxRecusiveDepth = 10;
+ MIuint nCurrentRecursiveDepth = 0;
+ lldb::SBValueList listArg = rFrame.GetVariables( bArg, bLocals, bStatics, bInScopeOnly );
+ const MIuint nArgs = listArg.GetSize();
+ for( MIuint i = 0; bOk && (i < nArgs); i++ )
+ {
+ lldb::SBValue value = listArg.GetValueAtIndex( i );
+ bOk = GetVariableInfo2( nMaxRecusiveDepth, value, false, vwrMiValueList, nCurrentRecursiveDepth );
+ }
+
+ return bOk;
+}
+
+// *** Do not refactor this function to be one function with same name as it can break more than
+// *** than one stack type command
+//++ ------------------------------------------------------------------------------------
+// Details: Extract the value's name and value or recurse into child value object.
+// Type: Method.
+// Args: vnMaxDepth - (R) The max recursive depth for this function.
+// vrValue - (R) LLDB value object.
+// vbIsChildValue - (R) True = Value object is a child of a higher Value object,
+// - False = Value object not a child.
+// vwrMIValueList - (W) MI value list object.
+// vnDepth - (RW) The current recursive depth of this function.
+// // Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::GetVariableInfo( const MIuint vnMaxDepth, const lldb::SBValue & vrValue, const bool vbIsChildValue, CMICmnMIValueList & vwrMiValueList, MIuint & vrwnDepth )
+{
+ // *** Update GetVariableInfo2() with any code changes here ***
+
+ // Check recursive depth
+ if( vrwnDepth >= vnMaxDepth )
+ return MIstatus::success;
+
+ bool bOk = MIstatus::success;
+ lldb::SBValue & rValue = const_cast< lldb::SBValue & >( vrValue );
+ const CMICmnLLDBUtilSBValue utilValue( vrValue, true );
+ CMICmnMIValueTuple miValueTuple;
+ const MIchar * pName = rValue.GetName(); MIunused( pName );
+ const bool bIsPointerType = rValue.GetType().IsPointerType();
+ const MIuint nChildren = rValue.GetNumChildren();
+ if( nChildren == 0 )
+ {
+ if( vbIsChildValue )
+ {
+ if( utilValue.IsCharType() )
+ {
+ // For char types and try to form text string
+ const CMICmnMIValueConst miValueConst( utilValue.GetValue().c_str(), true );
+ miValueTuple.Add( miValueConst, true );
+ }
+ else
+ {
+ // For composite types
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%s = %s", utilValue.GetName().c_str(), utilValue.GetValue().c_str() ), true );
+ miValueTuple.Add( miValueConst, true );
+ }
+ return vwrMiValueList.Add( CMICmnMIValueConst( miValueTuple.ExtractContentNoBrackets(), true ) );
+ }
+ else
+ {
+ // Basic types
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+ const CMICmnMIValueConst miValueConst2( utilValue.GetValue() );
+ const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
+ miValueTuple.Add( miValueResult2 );
+ return vwrMiValueList.Add( miValueTuple );
+ }
+ }
+ else if( bIsPointerType && utilValue.IsChildCharType() )
+ {
+ // Append string text to the parent value information
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+
+ const CMIUtilString & rText( utilValue.GetChildValueCString() );
+ if( rText.empty() )
+ {
+ const CMICmnMIValueConst miValueConst( utilValue.GetValue() );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ else
+ {
+ if( utilValue.IsValueUnknown() )
+ {
+ const CMICmnMIValueConst miValueConst( rText );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ else
+ {
+ // Note code that has const in will not show the text suffix to the string pointer
+ // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this
+ // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%s %s", utilValue.GetValue().c_str(), rText.c_str() ) );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ }
+ return vwrMiValueList.Add( miValueTuple );
+ }
+ else if( bIsPointerType )
+ {
+ if( vbIsChildValue )
+ {
+ // For composite types
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%s = %s", utilValue.GetName().c_str(), utilValue.GetValue().c_str() ), true );
+ miValueTuple.Add( miValueConst, true );
+ return vwrMiValueList.Add( CMICmnMIValueConst( miValueTuple.ExtractContentNoBrackets(), true ) );
+ }
+ else
+ {
+ // Basic types
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+ const CMICmnMIValueConst miValueConst2( utilValue.GetValue() );
+ const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
+ miValueTuple.Add( miValueResult2 );
+ return vwrMiValueList.Add( miValueTuple );
+ }
+ }
+ else
+ {
+ // Build parent child composite types
+ CMICmnMIValueList miValueList( true );
+ for( MIuint i = 0; bOk && (i < nChildren); i++ )
+ {
+ lldb::SBValue member = rValue.GetChildAtIndex( i );
+ bOk = GetVariableInfo( vnMaxDepth, member, true, miValueList, ++vrwnDepth );
+ }
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+ const CMICmnMIValueConst miValueConst2( CMIUtilString::Format( "{%s}", miValueList.ExtractContentNoBrackets().c_str() ) );
+ const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
+ miValueTuple.Add( miValueResult2 );
+ return vwrMiValueList.Add( miValueTuple );
+ }
+}
+
+// *** Do not refactor this function to be one function with same name as it can break more than
+// *** than one stack type command
+//++ ------------------------------------------------------------------------------------
+// Details: Extract the value's name and value or recurse into child value object.
+// Type: Method.
+// Args: vnMaxDepth - (R) The max recursive depth for this function.
+// vrValue - (R) LLDB value object.
+// vbIsChildValue - (R) True = Value object is a child of a higher Value object,
+// - False = Value object not a child.
+// vwrMIValueList - (W) MI value list object.
+// vnDepth - (RW) The current recursive depth of this function.
+// // Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::GetVariableInfo2( const MIuint vnMaxDepth, const lldb::SBValue & vrValue, const bool vbIsChildValue, CMICmnMIValueList & vwrMiValueList, MIuint & vrwnDepth )
+{
+ // *** Update GetVariableInfo() with any code changes here ***
+
+ // Check recursive depth
+ if( vrwnDepth >= vnMaxDepth )
+ return MIstatus::success;
+
+ bool bOk = MIstatus::success;
+ lldb::SBValue & rValue = const_cast< lldb::SBValue & >( vrValue );
+ const CMICmnLLDBUtilSBValue utilValue( vrValue, true );
+ CMICmnMIValueTuple miValueTuple;
+ const MIchar * pName = rValue.GetName(); MIunused( pName );
+ const MIuint nChildren = rValue.GetNumChildren();
+ if( nChildren == 0 )
+ {
+ if( vbIsChildValue && utilValue.IsCharType() )
+ {
+ // For char types and try to form text string
+ const CMICmnMIValueConst miValueConst( utilValue.GetValue().c_str(), true );
+ miValueTuple.Add( miValueConst, true );
+ return vwrMiValueList.Add( CMICmnMIValueConst( miValueTuple.ExtractContentNoBrackets(), true ) );
+ }
+ else
+ {
+ // Basic types
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+ const CMICmnMIValueConst miValueConst2( utilValue.GetValue() );
+ const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
+ miValueTuple.Add( miValueResult2 );
+ return vwrMiValueList.Add( miValueTuple );
+ }
+ }
+ else if( utilValue.IsChildCharType() )
+ {
+ // Append string text to the parent value information
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+
+ const CMIUtilString & rText( utilValue.GetChildValueCString() );
+ if( rText.empty() )
+ {
+ const CMICmnMIValueConst miValueConst( utilValue.GetValue() );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ else
+ {
+ if( utilValue.IsValueUnknown() )
+ {
+ const CMICmnMIValueConst miValueConst( rText );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ else
+ {
+ // Note code that has const in will not show the text suffix to the string pointer
+ // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this
+ // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this
+ const CMICmnMIValueConst miValueConst( CMIUtilString::Format( "%s %s", utilValue.GetValue().c_str(), rText.c_str() ) );
+ const CMICmnMIValueResult miValueResult( "value", miValueConst );
+ miValueTuple.Add( miValueResult );
+ }
+ }
+ return vwrMiValueList.Add( miValueTuple );
+ }
+ else
+ {
+ // Build parent child composite types
+ CMICmnMIValueList miValueList( true );
+ for( MIuint i = 0; bOk && (i < nChildren); i++ )
+ {
+ lldb::SBValue member = rValue.GetChildAtIndex( i );
+ bOk = GetVariableInfo( vnMaxDepth, member, true, miValueList, ++vrwnDepth );
+ }
+ const CMICmnMIValueConst miValueConst( utilValue.GetName() );
+ const CMICmnMIValueResult miValueResult( "name", miValueConst );
+ miValueTuple.Add( miValueResult );
+ const CMICmnMIValueConst miValueConst2( CMIUtilString::Format( "{%s}", miValueList.ExtractContentNoBrackets().c_str() ) );
+ const CMICmnMIValueResult miValueResult2( "value", miValueConst2 );
+ miValueTuple.Add( miValueResult2 );
+ return vwrMiValueList.Add( miValueTuple );
+ }
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Form MI partial response by appending more MI value type objects to the
+// tuple type object past in.
+// Type: Method.
// Args: vrThread - (R) LLDB thread object.
// vwrMIValueTuple - (W) MI value tuple object.
// Return: MIstatus::success - Functional succeeded.
@@ -491,17 +991,12 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo( const lldb::SBThread &
if( !GetFrameInfo( frame, pc, fnName, fileName, path, nLine ) )
return MIstatus::failure;
- CMICmnMIValueList miValueList( true );
- const MIuint vMaskVarTypes = 0x1000;
- if( !MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList ) )
- return MIstatus::failure;
-
- // MI print "{level=\"0\",addr=\"0x%08llx\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"}"
+ // MI print "{level=\"0\",addr=\"0x%08llx\",func=\"%s\",file=\"%s\",fullname=\"%s\",line=\"%d\"}"
const CMIUtilString strLevel( CMIUtilString::Format( "%d", vnLevel ) );
const CMICmnMIValueConst miValueConst( strLevel );
const CMICmnMIValueResult miValueResult( "level", miValueConst );
CMICmnMIValueTuple miValueTuple( miValueResult );
- if( !MIResponseFormFrameInfo( pc, fnName, miValueList.GetString(), fileName, path, nLine, miValueTuple ) )
+ if( !MIResponseFormFrameInfo( pc, fnName, fileName, path, nLine, miValueTuple ) )
return MIstatus::failure;
vwrMiValueTuple = miValueTuple;
@@ -553,7 +1048,6 @@ bool CMICmnLLDBDebugSessionInfo::GetFrameInfo( const lldb::SBFrame & vrFrame, ll
// Type: Method.
// Args: vPc - (R) Address number.
// vFnName - (R) Function name.
-// vArgs - (R) Variable information MI response.
// vFileName - (R) File name text.
// vPath - (R) Full file name and path text.
// vnLine - (R) File line number.
@@ -562,7 +1056,51 @@ bool CMICmnLLDBDebugSessionInfo::GetFrameInfo( const lldb::SBFrame & vrFrame, ll
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo( const lldb::addr_t vPc, const CMIUtilString & vFnName, const CMIUtilString & vArgs, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple )
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo( const lldb::addr_t vPc, const CMIUtilString & vFnName, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple )
+{
+ const CMIUtilString strAddr( CMIUtilString::Format( "0x%08llx", vPc ) );
+ const CMICmnMIValueConst miValueConst2( strAddr );
+ const CMICmnMIValueResult miValueResult2( "addr", miValueConst2 );
+ if( !vwrMiValueTuple.Add( miValueResult2 ) )
+ return MIstatus::failure;
+ const CMICmnMIValueConst miValueConst3( vFnName );
+ const CMICmnMIValueResult miValueResult3( "func", miValueConst3 );
+ if( !vwrMiValueTuple.Add( miValueResult3 ) )
+ return MIstatus::failure;
+ const CMICmnMIValueConst miValueConst5( vFileName );
+ const CMICmnMIValueResult miValueResult5( "file", miValueConst5 );
+ if( !vwrMiValueTuple.Add( miValueResult5 ) )
+ return MIstatus::failure;
+ const CMICmnMIValueConst miValueConst6( vPath );
+ const CMICmnMIValueResult miValueResult6( "fullname", miValueConst6 );
+ if( !vwrMiValueTuple.Add( miValueResult6 ) )
+ return MIstatus::failure;
+ const CMIUtilString strLine( CMIUtilString::Format( "%d", vnLine ) );
+ const CMICmnMIValueConst miValueConst7( strLine );
+ const CMICmnMIValueResult miValueResult7( "line", miValueConst7 );
+ if( !vwrMiValueTuple.Add( miValueResult7 ) )
+ return MIstatus::failure;
+
+ return MIstatus::success;
+}
+
+// Todo: Refactor maybe to so only one function with this name, but not just yet
+//++ ------------------------------------------------------------------------------------
+// Details: Form MI partial response by appending more MI value type objects to the
+// tuple type object past in.
+// Type: Method.
+// Args: vPc - (R) Address number.
+// vArgInfo - (R) Args information in MI response form.
+// vFnName - (R) Function name.
+// vFileName - (R) File name text.
+// vPath - (R) Full file name and path text.
+// vnLine - (R) File line number.
+// vwrMIValueTuple - (W) MI value tuple object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo2( const lldb::addr_t vPc, const CMIUtilString & vArgInfo, const CMIUtilString & vFnName, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple )
{
const CMIUtilString strAddr( CMIUtilString::Format( "0x%08llx", vPc ) );
const CMICmnMIValueConst miValueConst2( strAddr );
@@ -573,8 +1111,8 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo( const lldb::addr_t vPc
const CMICmnMIValueResult miValueResult3( "func", miValueConst3 );
if( !vwrMiValueTuple.Add( miValueResult3 ) )
return MIstatus::failure;
- const CMICmnMIValueConst miValueConst8( vArgs, true );
- const CMICmnMIValueResult miValueResult4( "args", miValueConst8 );
+ const CMICmnMIValueConst miValueConst4( vArgInfo, true );
+ const CMICmnMIValueResult miValueResult4( "args", miValueConst4 );
if( !vwrMiValueTuple.Add( miValueResult4 ) )
return MIstatus::failure;
const CMICmnMIValueConst miValueConst5( vFileName );
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
index 4685ce519dc..ca7ea27f561 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -124,13 +124,19 @@ public:
// Common command required functionality
bool AccessPath( const CMIUtilString & vPath, bool & vwbYesAccessible );
bool GetFrameInfo( const lldb::SBFrame & vrFrame, lldb::addr_t & vwPc, CMIUtilString & vwFnName, CMIUtilString & vwFileName, CMIUtilString & vwPath, MIuint & vwnLine );
- bool GetThreadFrames( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMICmnMIValueTuple & vwrThreadFrames );
+ bool GetThreadFrames( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMIUtilString & vwrThreadFrames );
+ bool GetThreadFrames2( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMIUtilString & vwrThreadFrames );
bool ResolvePath( const SMICmdData & vCmdData, const CMIUtilString & vPath, CMIUtilString & vwrResolvedPath );
bool ResolvePath( const CMIUtilString & vstrUnknown, CMIUtilString & vwrResolvedPath );
bool MIResponseFormFrameInfo( const lldb::SBThread & vrThread, const MIuint vnLevel, CMICmnMIValueTuple & vwrMiValueTuple );
- bool MIResponseFormFrameInfo( const lldb::addr_t vPc, const CMIUtilString & vFnName, const CMIUtilString & vArgs, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple );
+ bool MIResponseFormFrameInfo( const lldb::addr_t vPc, const CMIUtilString & vFnName, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple );
+ bool MIResponseFormFrameInfo2( const lldb::addr_t vPc, const CMIUtilString & vArgInfo, const CMIUtilString & vFnName, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple );
bool MIResponseFormThreadInfo( const SMICmdData & vCmdData, const lldb::SBThread & vrThread, CMICmnMIValueTuple & vwrMIValueTuple );
+ bool MIResponseFormThreadInfo2( const SMICmdData & vCmdData, const lldb::SBThread & vrThread, CMICmnMIValueTuple & vwrMIValueTuple );
+ bool MIResponseFormThreadInfo3( const SMICmdData & vCmdData, const lldb::SBThread & vrThread, CMICmnMIValueTuple & vwrMIValueTuple );
bool MIResponseFormVariableInfo( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList );
+ bool MIResponseFormVariableInfo2( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList );
+ bool MIResponseFormVariableInfo3( const lldb::SBFrame & vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList & vwrMiValueList );
bool MIResponseFormBrkPtFrameInfo( const SBrkPtInfo & vrBrkPtInfo, CMICmnMIValueTuple & vwrMiValueTuple );
bool MIResponseFormBrkPtInfo( const SBrkPtInfo & vrBrkPtInfo, CMICmnMIValueTuple & vwrMiValueTuple );
bool GetBrkPtInfo( const lldb::SBBreakpoint & vBrkPt, SBrkPtInfo & vrwBrkPtInfo ) const;
@@ -165,7 +171,10 @@ private:
/* ctor */ CMICmnLLDBDebugSessionInfo( void );
/* ctor */ CMICmnLLDBDebugSessionInfo( const CMICmnLLDBDebugSessionInfo & );
void operator=( const CMICmnLLDBDebugSessionInfo & );
-
+ //
+ bool GetVariableInfo( const MIuint vnMaxDepth, const lldb::SBValue & vrValue, const bool vbIsChildValue, CMICmnMIValueList & vwrMiValueList, MIuint & vrwnDepth );
+ bool GetVariableInfo2( const MIuint vnMaxDepth, const lldb::SBValue & vrValue, const bool vbIsChildValue, CMICmnMIValueList & vwrMiValueList, MIuint & vrwnDepth );
+
// Overridden:
private:
// From CMICmnBase
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
index 29b0cf5fb79..d519875993f 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
@@ -22,6 +22,7 @@
// In-house headers:
#include "MICmnLLDBDebugSessionInfoVarObj.h"
#include "MICmnLLDBProxySBValue.h"
+#include "MICmnLLDBUtilSBValue.h"
// Instantiations:
const MIchar * CMICmnLLDBDebugSessionInfoVarObj::ms_aVarFormatStrings[] =
@@ -128,7 +129,19 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj( CMICmnLLDBDe
}
//++ ------------------------------------------------------------------------------------
-// Details: CMICmnLLDBDebugSessionInfoVarObj assignment opertator.
+// Details: CMICmnLLDBDebugSessionInfoVarObj move constructor.
+// Type: Method.
+// Args: vrwOther - (R) The object to copy from.
+// Return: None.
+// Throws: None.
+//--
+CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj( CMICmnLLDBDebugSessionInfoVarObj && vrwOther )
+{
+ MoveOther( vrwOther );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmnLLDBDebugSessionInfoVarObj assignment operator.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
// Return: CMICmnLLDBDebugSessionInfoVarObj & - Updated *this object.
@@ -142,7 +155,21 @@ CMICmnLLDBDebugSessionInfoVarObj & CMICmnLLDBDebugSessionInfoVarObj::operator= (
}
//++ ------------------------------------------------------------------------------------
-// Details: Copy the other instance of *this object to *this object.
+// Details: CMICmnLLDBDebugSessionInfoVarObj assignment operator.
+// Type: Method.
+// Args: vrwOther - (R) The object to copy from.
+// Return: CMICmnLLDBDebugSessionInfoVarObj & - Updated *this object.
+// Throws: None.
+//--
+CMICmnLLDBDebugSessionInfoVarObj & CMICmnLLDBDebugSessionInfoVarObj::operator= ( CMICmnLLDBDebugSessionInfoVarObj && vrwOther )
+{
+ MoveOther( vrwOther );
+
+ return *this;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Copy the other instance of that object to *this object.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
// Return: MIstatus::success - Functional succeeded.
@@ -167,8 +194,34 @@ bool CMICmnLLDBDebugSessionInfoVarObj::CopyOther( const CMICmnLLDBDebugSessionIn
}
//++ ------------------------------------------------------------------------------------
+// Details: Move that object to *this object.
+// Type: Method.
+// Args: vrwOther - (RW) The object to copy from.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebugSessionInfoVarObj::MoveOther( CMICmnLLDBDebugSessionInfoVarObj & vrwOther )
+{
+ // Check for self-assignment
+ if( this == &vrwOther )
+ return MIstatus::success;
+
+ CopyOther( vrwOther );
+ vrwOther.m_eVarFormat = eVarFormat_Natural;
+ vrwOther.m_eVarType = eVarType_Internal;
+ vrwOther.m_strName.clear();
+ vrwOther.m_SBValue.Clear();
+ vrwOther.m_strNameReal.clear();
+ vrwOther.m_strFormattedValue.clear();
+ vrwOther.m_strVarObjParentName.clear();
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj destructor.
-// Type: Overridable.
+// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
index fc33c9f3bab..1db7bd8daa0 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
@@ -87,8 +87,10 @@ public:
/* ctor */ CMICmnLLDBDebugSessionInfoVarObj( const CMIUtilString & vrStrNameReal, const CMIUtilString & vrStrName, const lldb::SBValue & vrValue, const CMIUtilString & vrStrVarObjParentName );
/* ctor */ CMICmnLLDBDebugSessionInfoVarObj( const CMICmnLLDBDebugSessionInfoVarObj & vrOther );
/* ctor */ CMICmnLLDBDebugSessionInfoVarObj( CMICmnLLDBDebugSessionInfoVarObj & vrOther );
+ /* ctor */ CMICmnLLDBDebugSessionInfoVarObj( CMICmnLLDBDebugSessionInfoVarObj && vrOther );
//
CMICmnLLDBDebugSessionInfoVarObj & operator= ( const CMICmnLLDBDebugSessionInfoVarObj & vrOther );
+ CMICmnLLDBDebugSessionInfoVarObj & operator= ( CMICmnLLDBDebugSessionInfoVarObj && vrwOther );
//
const CMIUtilString & GetName( void ) const;
const CMIUtilString & GetNameReal( void ) const;
@@ -116,6 +118,7 @@ private:
// Methods:
private:
bool CopyOther( const CMICmnLLDBDebugSessionInfoVarObj & vrOther );
+ bool MoveOther( CMICmnLLDBDebugSessionInfoVarObj & vrwOther );
// Attributes:
private:
@@ -124,7 +127,7 @@ private:
static MapKeyToVarObj_t ms_mapVarIdToVarObj;
static MIuint ms_nVarUniqueId;
//
- // *** Upate the copy constructors and assignment operator ***
+ // *** Upate the copy move constructors and assignment operator ***
varFormat_e m_eVarFormat;
varType_e m_eVarType;
CMIUtilString m_strName;
@@ -132,5 +135,5 @@ private:
CMIUtilString m_strNameReal;
CMIUtilString m_strFormattedValue;
CMIUtilString m_strVarObjParentName;
- // *** Upate the copy constructors and assignment operator ***
+ // *** Upate the copy move constructors and assignment operator ***
};
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp
index 783508f79f7..f68f5083054 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -26,7 +26,6 @@
#include <lldb/API/SBCommandInterpreter.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmnLLDBDebugger.h"
#include "MICmnResources.h"
#include "MICmnLog.h"
@@ -34,7 +33,6 @@
#include "MICmnThreadMgrStd.h"
#include "MICmnLLDBDebuggerHandleEvents.h"
#include "MICmnLLDBDebugSessionInfo.h"
-#include "MIUtilDebug.h"
#include "MIUtilSingletonHelper.h"
//++ ------------------------------------------------------------------------------------
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugger.h b/lldb/tools/lldb-mi/MICmnLLDBDebugger.h
index dd3539865e5..0d608997d95 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugger.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugger.h
@@ -29,7 +29,6 @@
#include <lldb/API/SBEvent.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmnBase.h"
#include "MIUtilThreadBaseStd.h"
#include "MIUtilSingletonBase.h"
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index 85f991a55e3..08218a2e87e 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -226,7 +226,7 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakPoint( const lldb::SBEven
break;
case lldb::eBreakpointEventTypeAdded:
pEventType = "eBreakpointEventTypeAdded";
- bOk = HandleEventSBBreakpointCmn( vEvent );
+ bOk = HandleEventSBBreakpointAdded( vEvent );
break;
case lldb::eBreakpointEventTypeRemoved:
pEventType = "eBreakpointEventTypeRemoved";
@@ -348,6 +348,111 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointCmn( const lldb::SBE
}
//++ ------------------------------------------------------------------------------------
+// Details: Handle a LLDB SBBreakpoint added event.
+// Add more breakpoint information or overwrite existing information.
+// Normally a break point session info objects exists by now when an MI command
+// was issued to insert a break so the retrieval would normally always succeed
+// however should a user type "b main" into a console then LLDB will create a
+// breakpoint directly, hence no MI command, hence no previous record of the
+// breakpoint so RecordBrkPtInfoGet() will fail. We still get the event though
+// so need to create a breakpoint info object here and send appropriate MI
+// response.
+// Type: Method.
+// Args: vEvent - (R) An LLDB broadcast event.
+// Return: MIstatus::success - Functionality succeeded.
+// MIstatus::failure - Functionality failed.
+// Throws: None.
+//--
+bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded( const lldb::SBEvent & vEvent )
+{
+ lldb::SBBreakpoint brkPt = lldb::SBBreakpoint::GetBreakpointFromEvent( vEvent );
+ if( !brkPt.IsValid() )
+ return MIstatus::success;
+
+ CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if( !rSessionInfo.GetBrkPtInfo( brkPt, sBrkPtInfo ) )
+ {
+ SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_GET ), "HandleEventSBBreakpointAdded()", brkPt.GetID() ) );
+ return MIstatus::failure;
+ }
+
+ // CODETAG_LLDB_BREAKPOINT_CREATION
+ // This is in a worker thread
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfoRec;
+ const bool bBrkPtExistAlready = rSessionInfo.RecordBrkPtInfoGet( brkPt.GetID(), sBrkPtInfoRec );
+ if( bBrkPtExistAlready )
+ {
+ // Update breakpoint information object
+ sBrkPtInfo.m_bDisp = sBrkPtInfoRec.m_bDisp;
+ sBrkPtInfo.m_bEnabled = brkPt.IsEnabled();
+ sBrkPtInfo.m_bHaveArgOptionThreadGrp = false;
+ sBrkPtInfo.m_strOptThrdGrp.clear();
+ sBrkPtInfo.m_nTimes = brkPt.GetHitCount();
+ sBrkPtInfo.m_strOrigLoc = sBrkPtInfoRec.m_strOrigLoc;
+ sBrkPtInfo.m_nIgnore = sBrkPtInfoRec.m_nIgnore;
+ sBrkPtInfo.m_bPending = sBrkPtInfoRec.m_bPending;
+ sBrkPtInfo.m_bCondition = sBrkPtInfoRec.m_bCondition;
+ sBrkPtInfo.m_strCondition = sBrkPtInfoRec.m_strCondition;
+ sBrkPtInfo.m_bBrkPtThreadId = sBrkPtInfoRec.m_bBrkPtThreadId;
+ sBrkPtInfo.m_nBrkPtThreadId = sBrkPtInfoRec.m_nBrkPtThreadId;
+ }
+ else
+ {
+ // Create a breakpoint information object
+ sBrkPtInfo.m_bDisp = brkPt.IsOneShot();
+ sBrkPtInfo.m_bEnabled = brkPt.IsEnabled();
+ sBrkPtInfo.m_bHaveArgOptionThreadGrp = false;
+ sBrkPtInfo.m_strOptThrdGrp.clear();
+ sBrkPtInfo.m_strOrigLoc = CMIUtilString::Format( "%s:%d", sBrkPtInfo.m_fileName.c_str(), sBrkPtInfo.m_nLine );
+ sBrkPtInfo.m_nIgnore = brkPt.GetIgnoreCount();
+ sBrkPtInfo.m_bPending = false;
+ const MIchar * pStrCondition = brkPt.GetCondition();
+ sBrkPtInfo.m_bCondition = (pStrCondition != nullptr) ? true : false;
+ sBrkPtInfo.m_strCondition = (pStrCondition != nullptr) ? pStrCondition : "??";
+ sBrkPtInfo.m_bBrkPtThreadId = (brkPt.GetThreadID() != 0) ? true : false;
+ sBrkPtInfo.m_nBrkPtThreadId = brkPt.GetThreadID();
+ }
+
+ CMICmnMIValueTuple miValueTuple;
+ if( !rSessionInfo.MIResponseFormBrkPtInfo( sBrkPtInfo, miValueTuple ) )
+ {
+ SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBOUTOFBAND_ERR_FORM_MI_RESPONSE ), "HandleEventSBBreakpointAdded()" ) );
+ return MIstatus::failure;
+ }
+
+ bool bOk = MIstatus::success;
+ if( bBrkPtExistAlready )
+ {
+ // MI print "=breakpoint-modified,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%08x\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",times=\"%d\",original-location=\"%s\"}"
+ const CMICmnMIValueResult miValueResult( "bkpt", miValueTuple );
+ const CMICmnMIOutOfBandRecord miOutOfBandRecord( CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult );
+ bOk = MiOutOfBandRecordToStdout( miOutOfBandRecord );
+ }
+ else
+ {
+ // CODETAG_LLDB_BRKPT_ID_MAX
+ if( brkPt.GetID() > (lldb::break_id_t) rSessionInfo.m_nBrkPointCntMax )
+ {
+ SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_BRKPT_CNT_EXCEEDED ), "HandleEventSBBreakpointAdded()", rSessionInfo.m_nBrkPointCntMax, sBrkPtInfo.m_id ) );
+ return MIstatus::failure;
+ }
+ if( !rSessionInfo.RecordBrkPtInfo( brkPt.GetID(), sBrkPtInfo ) )
+ {
+ SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_SET ), "HandleEventSBBreakpointAdded()", sBrkPtInfo.m_id ) );
+ return MIstatus::failure;
+ }
+
+ // MI print "=breakpoint-created,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%08x\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",times=\"%d\",original-location=\"%s\"}"
+ const CMICmnMIValueResult miValueResult( "bkpt", miValueTuple );
+ const CMICmnMIOutOfBandRecord miOutOfBandRecord( CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, miValueResult );
+ bOk = MiOutOfBandRecordToStdout( miOutOfBandRecord );
+ }
+
+ return bOk;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Handle a LLDB SBThread event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -834,15 +939,12 @@ bool CMICmnLLDBDebuggerHandleEvents::MiHelpGetCurrentThreadFrame( CMICmnMIValueT
const MIuint nFrame = thread.GetNumFrames();
if( nFrame == 0 )
{
- // MI print "addr=\"??\",func=\"??\",args=[],file=\"??\",fullname=\"??\",line=\"??\""
+ // MI print "addr=\"??\",func=\"??\",file=\"??\",fullname=\"??\",line=\"??\""
const CMICmnMIValueConst miValueConst( "??" );
const CMICmnMIValueResult miValueResult( "addr", miValueConst );
CMICmnMIValueTuple miValueTuple( miValueResult );
const CMICmnMIValueResult miValueResult2( "func", miValueConst );
miValueTuple.Add( miValueResult2 );
- const CMICmnMIValueConst miValueConst2( "[]", true );
- const CMICmnMIValueResult miValueResult3( "args", miValueConst2 );
- miValueTuple.Add( miValueResult3 );
const CMICmnMIValueResult miValueResult4( "file", miValueConst );
miValueTuple.Add( miValueResult4 );
const CMICmnMIValueResult miValueResult5( "fullname", miValueConst );
@@ -966,10 +1068,11 @@ bool CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint( const MIuint64 vBrkP
if( bOk )
{
CMICmnMIValueList miValueList( true );
- const MIuint vMaskVarTypes = 0x1000;
- bOk = rSession.MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList );
+ const MIuint maskVarTypes = 0x1000;
+ bOk = rSession.MIResponseFormVariableInfo2( frame, maskVarTypes, miValueList );
+
CMICmnMIValueTuple miValueTuple;
- bOk = bOk && rSession.MIResponseFormFrameInfo( pc, fnName, miValueList.GetString(), fileName, path, nLine, miValueTuple );
+ bOk = bOk && rSession.MIResponseFormFrameInfo2( pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple );
const CMICmnMIValueResult miValueResult8( "frame", miValueTuple );
bOk = bOk && miOutOfBandRecord.Add( miValueResult8 );
}
@@ -1024,7 +1127,7 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace( void )
CMICmnLLDBDebugSessionInfo & rSession = CMICmnLLDBDebugSessionInfo::Instance();
- // MI print "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x%08x\",func=\"%s\",args=[],file=\"%s\",fullname=\"%s\",line=\"%d\"},thread-id=\"%d\",stopped-threads=\"all\""
+ // MI print "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x%08x\",func=\"%s\",args=[\"%s\"],file=\"%s\",fullname=\"%s\",line=\"%d\"},thread-id=\"%d\",stopped-threads=\"all\""
lldb::SBFrame frame = thread.GetFrameAtIndex( 0 );
lldb::addr_t pc = 0;
CMIUtilString fnName;
@@ -1037,15 +1140,20 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace( void )
return MIstatus::failure;
}
- // frame={addr=\"0x%08x\",func=\"%s\",args=[],file=\"%s\",fullname=\"%s\",line=\"%d\"}
+ // Function args
+ CMICmnMIValueList miValueList( true );
+ const MIuint maskVarTypes = 0x1000;
+ if( !rSession.MIResponseFormVariableInfo2( frame, maskVarTypes, miValueList ) )
+ return MIstatus::failure;
CMICmnMIValueTuple miValueTuple;
- if( !rSession.MIResponseFormFrameInfo( pc, fnName, "[]", fileName, path, nLine, miValueTuple ) )
+ if( !rSession.MIResponseFormFrameInfo2( pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple ) )
return MIstatus::failure;
const CMICmnMIValueConst miValueConst( "end-stepping-range" );
const CMICmnMIValueResult miValueResult( "reason", miValueConst );
CMICmnMIOutOfBandRecord miOutOfBandRecord( CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult );
- bOk = miOutOfBandRecord.Add( miValueTuple );
+ const CMICmnMIValueResult miValueResult2( "frame", miValueTuple );
+ bOk = miOutOfBandRecord.Add( miValueResult2 );
// Add to MI thread-id=\"%d\",stopped-threads=\"all\"
if( bOk )
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
index 1a1c9ff0c1d..fdcb2ea4e14 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -65,6 +65,7 @@ private:
bool GetProcessStderr( void );
bool HandleEventSBBreakPoint( const lldb::SBEvent & vEvent );
bool HandleEventSBBreakpointCmn( const lldb::SBEvent & vEvent );
+ bool HandleEventSBBreakpointAdded( const lldb::SBEvent & vEvent );
bool HandleEventSBBreakpointLocationsAdded( const lldb::SBEvent & vEvent );
bool HandleEventSBProcess( const lldb::SBEvent & vEvent, bool & vrbExitAppEvent );
bool HandleEventSBThread( const lldb::SBEvent & vEvent );
diff --git a/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
index aa2b23b4423..4480f9b39dd 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
@@ -19,11 +19,8 @@
// Copyright: None.
//--
-#include <stdlib.h>
-
// Third Party Headers:
#include <lldb/API/SBError.h>
-#include <cstdlib>
// In-house headers:
#include "MICmnLLDBProxySBValue.h"
@@ -151,3 +148,4 @@ bool CMICmnLLDBProxySBValue::GetCString( const lldb::SBValue & vrValue, CMIUtilS
return MIstatus::success;
}
+
diff --git a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
new file mode 100644
index 00000000000..004be071260
--- /dev/null
+++ b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -0,0 +1,324 @@
+//===-- MICmnLLDBUtilSBValue.cpp --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//++
+// File: MICmnLLDBUtilSBValue.cpp
+//
+// Overview: CMICmnLLDBUtilSBValue implementation.
+//
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
+//
+// Copyright: None.
+//--
+
+// In-house headers:
+#include "MICmnLLDBUtilSBValue.h"
+#include "MIUtilString.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmnLLDBUtilSBValue constructor.
+// Type: Method.
+// Args: vrValue - (R) The LLDb value object.
+// vbHandleCharType - (R) True = Yes return text molding to char type,
+// False = just return data.
+// Return: None.
+// Throws: None.
+//--
+CMICmnLLDBUtilSBValue::CMICmnLLDBUtilSBValue( const lldb::SBValue & vrValue, const bool vbHandleCharType /* = false */ )
+: m_rValue( const_cast< lldb::SBValue & >( vrValue ) )
+, m_pUnkwn( "??" )
+, m_bHandleCharType( vbHandleCharType )
+{
+ m_bValidSBValue = m_rValue.IsValid();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMICmnLLDBUtilSBValue destructor.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue( void )
+{
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve from the LLDB SB Value object the name of the variable. If the name
+// is invalid (or the SBValue object invalid) then "??" is returned.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Name of the variable or "??" for unknown.
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetName( void ) const
+{
+ const MIchar * pName = m_bValidSBValue ? m_rValue.GetName() : nullptr;
+ const CMIUtilString text( (pName != nullptr) ? pName : m_pUnkwn );
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve from the LLDB SB Value object the value of the variable described in
+// text. If the value is invalid (or the SBValue object invalid) then "??" is
+// returned.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Text description of the variable's value or "??".
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetValue( void ) const
+{
+ CMIUtilString text;
+
+ if( m_bHandleCharType && IsCharType() )
+ {
+ const lldb::addr_t addr = m_rValue.GetLoadAddress();
+ text = CMIUtilString::Format( "0x%08x", addr );
+ const CMIUtilString cString( GetValueCString() );
+ if( !cString.empty() )
+ text += CMIUtilString::Format( " %s", cString.c_str() );
+ }
+ else
+ {
+ const MIchar * pValue = m_bValidSBValue ? m_rValue.GetValue() : nullptr;
+ text = (pValue != nullptr) ? pValue : m_pUnkwn;
+ }
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: If the LLDB SB Value object is a char type then form the text data string
+// otherwise return nothing. m_bHandleCharType must be true to return text data
+// if any.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Text description of the variable's value.
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetValueCString( void ) const
+{
+ CMIUtilString text;
+
+ if( m_bHandleCharType && IsCharType() )
+ {
+ text = ReadCStringFromHostMemory( m_rValue );
+ }
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the flag stating whether this value object is a char type or some
+// other type. Char type can be signed or unsigned.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes is a char type, false = some other type.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsCharType( void ) const
+{
+ const MIchar * pName = m_rValue.GetName(); MIunused( pName );
+ const lldb::BasicType eType = m_rValue.GetType().GetBasicType();
+ return ((eType == lldb::eBasicTypeChar) ||
+ (eType == lldb::eBasicTypeSignedChar) ||
+ (eType == lldb::eBasicTypeUnsignedChar) );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the flag stating whether any child value object of *this object is a
+// char type or some other type. Returns false if there are not children. Char
+// type can be signed or unsigned.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes is a char type, false = some other type.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsChildCharType( void ) const
+{
+ const MIuint nChildren = m_rValue.GetNumChildren();
+
+ // Is it a basic type
+ if( nChildren == 0 )
+ return false;
+
+ // Is it a composite type
+ if( nChildren > 1 )
+ return false;
+
+ lldb::SBValue member = m_rValue.GetChildAtIndex( 0 );
+ const CMICmnLLDBUtilSBValue utilValue( member );
+ return utilValue.IsCharType();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the C string data for a child of char type (one and only child) for
+// the parent value object. If the child is not a char type or the parent has
+// more than one child then an empty string is returned. Char type can be
+// signed or unsigned.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Text description of the variable's value.
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetChildValueCString( void ) const
+{
+ CMIUtilString text;
+ const MIuint nChildren = m_rValue.GetNumChildren();
+
+ // Is it a basic type
+ if( nChildren == 0 )
+ return text;
+
+ // Is it a composite type
+ if( nChildren > 1 )
+ return text;
+
+ lldb::SBValue member = m_rValue.GetChildAtIndex( 0 );
+ const CMICmnLLDBUtilSBValue utilValue( member );
+ if( m_bHandleCharType && utilValue.IsCharType() )
+ {
+ text = ReadCStringFromHostMemory( member );
+ }
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the C string data of value object by read the memory where the
+// variable is held.
+// Type: Method.
+// Args: vrValueObj - (R) LLDB SBValue variable object.
+// Return: CMIUtilString - Text description of the variable's value.
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory( const lldb::SBValue & vrValueObj ) const
+{
+ CMIUtilString text;
+
+ lldb::SBValue & rValue = const_cast< lldb::SBValue & >( vrValueObj );
+ const lldb::addr_t addr = rValue.GetLoadAddress();
+ CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() );
+ const MIuint nBytes( 128 );
+ const MIchar * pBufferMemory = new MIchar[ nBytes ];
+ lldb::SBError error;
+ const MIuint64 nReadBytes = rSessionInfo.m_lldbProcess.ReadMemory( addr, (void *) pBufferMemory, nBytes, error ); MIunused( nReadBytes );
+ text = CMIUtilString::Format( "\\\"%s\\\"", pBufferMemory );
+ delete [] pBufferMemory;
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the state of the value object's name.
+// Type: Method.
+// Args: None.
+// Return: bool - True = yes name is indeterminate, false = name is valid.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsNameUnknown( void ) const
+{
+ const CMIUtilString name( GetName() );
+ return (name == m_pUnkwn);
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the state of the value object's value data.
+// Type: Method.
+// Args: None.
+// Return: bool - True = yes value is indeterminate, false = value valid.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsValueUnknown( void ) const
+{
+ const CMIUtilString value( GetValue() );
+ return (value == m_pUnkwn);
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the value object's type name if valid.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - The type name or "??".
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetTypeName( void ) const
+{
+ const MIchar * pName = m_bValidSBValue ? m_rValue.GetTypeName() : nullptr;
+ const CMIUtilString text( (pName != nullptr) ? pName : m_pUnkwn );
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the value object's display type name if valid.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - The type name or "??".
+// Throws: None.
+//--
+CMIUtilString CMICmnLLDBUtilSBValue::GetTypeNameDisplay( void ) const
+{
+ const MIchar * pName = m_bValidSBValue ? m_rValue.GetDisplayTypeName() : nullptr;
+ const CMIUtilString text( (pName != nullptr) ? pName : m_pUnkwn );
+
+ return text;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve whether the value object's is valid or not.
+// Type: Method.
+// Args: None.
+// Return: bool - True = valid, false = not valid.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsValid( void ) const
+{
+ return m_bValidSBValue;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the value object' has a name. A value object can be valid but still
+// have no name which suggest it is not a variable.
+// Type: Method.
+// Args: None.
+// Return: bool - True = valid, false = not valid.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::HasName( void ) const
+{
+ bool bHasAName = false;
+
+ const MIchar * pName = m_bValidSBValue ? m_rValue.GetDisplayTypeName() : nullptr;
+ if( pName != nullptr )
+ {
+ bHasAName = (CMIUtilString( pName ).length() > 0);
+ }
+
+ return bHasAName;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Determine if the value object' respresents a LLDB variable i.e. "$0".
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes LLDB variable, false = no.
+// Throws: None.
+//--
+bool CMICmnLLDBUtilSBValue::IsLLDBVariable( void ) const
+{
+ return (GetName().at( 0 ) == '$' );
+}
+
+
diff --git a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.h b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.h
new file mode 100644
index 00000000000..d2c1876c44b
--- /dev/null
+++ b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.h
@@ -0,0 +1,71 @@
+//===-- MICmnLLDBUtilSBValue.h ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//++
+// File: MICmnLLDBUtilSBValue.h
+//
+// Overview: CMICmnLLDBUtilSBValue interface.
+//
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
+//
+// Copyright: None.
+//--
+
+#pragma once
+
+// Third Party Headers:
+#include <lldb/API/SBValue.h>
+
+// In-house headers:
+#include "MIDataTypes.h"
+
+// Declerations:
+class CMIUtilString;
+
+//++ ============================================================================
+// Details: Utility helper class to lldb::SBValue. Using a lldb::SBValue extract
+// value object information to help form verbose debug information.
+// Gotchas: None.
+// Authors: Illya Rudkin 08/07/2014.
+// Changes: None.
+//--
+class CMICmnLLDBUtilSBValue
+{
+// Methods:
+public:
+ /* ctor */ CMICmnLLDBUtilSBValue( const lldb::SBValue & vrValue, const bool vbHandleCharType = false );
+ /* dtor */ ~CMICmnLLDBUtilSBValue( void );
+ //
+ CMIUtilString GetName( void ) const;
+ CMIUtilString GetValue( void ) const;
+ CMIUtilString GetValueCString( void ) const;
+ CMIUtilString GetChildValueCString( void ) const;
+ CMIUtilString GetTypeName( void ) const;
+ CMIUtilString GetTypeNameDisplay( void ) const;
+ bool IsCharType( void ) const;
+ bool IsChildCharType( void ) const;
+ bool IsLLDBVariable( void ) const;
+ bool IsNameUnknown( void ) const;
+ bool IsValueUnknown( void ) const;
+ bool IsValid( void ) const;
+ bool HasName( void ) const;
+
+// Methods:
+private:
+ CMIUtilString ReadCStringFromHostMemory( const lldb::SBValue & vrValueObj ) const;
+
+// Attributes:
+private:
+ lldb::SBValue & m_rValue;
+ const MIchar * m_pUnkwn;
+ bool m_bValidSBValue; // True = SBValue is a valid object, false = not valid.
+ bool m_bHandleCharType; // True = Yes return text molding to char type, false = just return data.
+};
diff --git a/lldb/tools/lldb-mi/MICmnLog.cpp b/lldb/tools/lldb-mi/MICmnLog.cpp
index a698a741d61..4ccbd3ef992 100644
--- a/lldb/tools/lldb-mi/MICmnLog.cpp
+++ b/lldb/tools/lldb-mi/MICmnLog.cpp
@@ -20,7 +20,6 @@
//--
// In-house headers:
-#include "MICmnConfig.h"
#include "MICmnLog.h"
#include "MICmnLogMediumFile.h"
#include "MIDriverMgr.h"
diff --git a/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp b/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp
index 382db074d45..8f2289d02c8 100644
--- a/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp
+++ b/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp
@@ -19,23 +19,17 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
// In-house headers:
#include "MICmnLogMediumFile.h"
#include "MICmnResources.h"
-
#if defined( _MSC_VER )
#include "MIUtilSystemWindows.h"
-#elif defined( __FreeBSD__ ) || defined( __linux__ )
+#elif defined( __FreeBSD__ ) || defined( __linux )
#include "MIUtilSystemLinux.h"
#elif defined( __APPLE__ )
#include "MIUtilSystemOsx.h"
#endif // defined( _MSC_VER )
-#include "MIUtilDateTimeStd.h"
-
//++ ------------------------------------------------------------------------------------
// Details: CMICmnLogMediumFile constructor.
// Type: Method.
@@ -285,7 +279,7 @@ CMIUtilString CMICmnLogMediumFile::MassagedData( const CMIUtilString & vData, co
const CMIUtilString strCr( "\n" );
CMIUtilString data;
const MIchar verbosityCode( ConvertLogVerbosityTypeToId( veType ) );
- const CMIUtilString dt( CMIUtilString::Format( "%s %s", m_strDate.c_str(), CMIUtilDateTimeStd().GetTime().c_str() ) );
+ const CMIUtilString dt( CMIUtilString::Format( "%s %s", m_strDate.c_str(), m_dateTime.GetTime().c_str() ) );
data = CMIUtilString::Format( "%c,%s,%s", verbosityCode, dt.c_str(), vData.c_str() );
data = ConvertCr( data );
diff --git a/lldb/tools/lldb-mi/MICmnLogMediumFile.h b/lldb/tools/lldb-mi/MICmnLogMediumFile.h
index 3d4d8f6fc21..affe24e09e5 100644
--- a/lldb/tools/lldb-mi/MICmnLogMediumFile.h
+++ b/lldb/tools/lldb-mi/MICmnLogMediumFile.h
@@ -22,11 +22,11 @@
#pragma once
// In-house headers:
-#include "MICmnConfig.h"
#include "MIUtilFileStd.h"
#include "MIUtilString.h"
#include "MICmnBase.h"
#include "MICmnLog.h"
+#include "MIUtilDateTimeStd.h"
//++ ============================================================================
// Details: MI common code implementation class. Logs application fn trace/message/
@@ -87,9 +87,10 @@ private:
const CMIUtilString m_constThisMediumName;
const CMIUtilString m_constMediumFileName;
//
- CMIUtilString m_fileNamePath;
- MIuint m_eVerbosityType;
- CMIUtilString m_strDate;
- CMIUtilString m_fileHeaderTxt;
- CMIUtilFileStd m_file;
+ CMIUtilString m_fileNamePath;
+ MIuint m_eVerbosityType;
+ CMIUtilString m_strDate;
+ CMIUtilString m_fileHeaderTxt;
+ CMIUtilFileStd m_file;
+ CMIUtilDateTimeStd m_dateTime;
};
diff --git a/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp b/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
index 0c85b6fe4a2..c3826f01ae8 100644
--- a/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
+++ b/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
@@ -28,6 +28,7 @@ CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBan
{
{ CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped" },
+ { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "" }, // "" Meant to be empty
{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added" },
@@ -42,6 +43,7 @@ CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTex
{
{ CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*" },
+ { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "=" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "=" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@" },
{ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "=" },
diff --git a/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.h b/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.h
index d89c5da8415..1a8f7a2e200 100644
--- a/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.h
+++ b/lldb/tools/lldb-mi/MICmnMIOutOfBandRecord.h
@@ -63,6 +63,7 @@ public:
{
eOutOfBand_Running = 0,
eOutOfBand_Stopped,
+ eOutOfBand_BreakPointCreated,
eOutOfBand_BreakPointModified,
eOutOfBand_Thread,
eOutOfBand_ThreadGroupAdded,
diff --git a/lldb/tools/lldb-mi/MICmnMIValueList.cpp b/lldb/tools/lldb-mi/MICmnMIValueList.cpp
index 9fbc7280b61..97a08cd29f0 100644
--- a/lldb/tools/lldb-mi/MICmnMIValueList.cpp
+++ b/lldb/tools/lldb-mi/MICmnMIValueList.cpp
@@ -143,17 +143,9 @@ bool CMICmnMIValueList::BuildList( const CMICmnMIValueResult & vResult )
return BuildList();
}
- if( m_strValue[ 0 ] == '[' )
- {
- m_strValue = m_strValue.substr( 1, m_strValue.size() - 1 );
- }
- if( m_strValue[ m_strValue.size() - 1 ] == ']' )
- {
- m_strValue = m_strValue.substr( 0, m_strValue.size() - 1 );
- }
-
+ const CMIUtilString data( ExtractContentNoBrackets() );
const MIchar * pFormat = "[%s,%s]";
- m_strValue = CMIUtilString::Format( pFormat, m_strValue.c_str(), vResult.GetString().c_str() );
+ m_strValue = CMIUtilString::Format( pFormat, data.c_str(), vResult.GetString().c_str() );
return MIstatus::success;
}
@@ -186,3 +178,26 @@ bool CMICmnMIValueList::BuildList( const CMICmnMIValue & vValue )
return MIstatus::success;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the contents of *this value object but without the outer most
+// brackets.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Data within the object.
+// Throws: None.
+//--
+CMIUtilString CMICmnMIValueList::ExtractContentNoBrackets( void ) const
+{
+ CMIUtilString data( m_strValue );
+
+ if( data[ 0 ] == '[' )
+ {
+ data = data.substr( 1, data.length() - 1 );
+ }
+ if( data[ data.size() - 1 ] == ']' )
+ {
+ data = data.substr( 0, data.length() - 1 );
+ }
+
+ return data;
+}
diff --git a/lldb/tools/lldb-mi/MICmnMIValueList.h b/lldb/tools/lldb-mi/MICmnMIValueList.h
index ef037f1a149..cd1a98f7705 100644
--- a/lldb/tools/lldb-mi/MICmnMIValueList.h
+++ b/lldb/tools/lldb-mi/MICmnMIValueList.h
@@ -53,8 +53,9 @@ public:
/* ctor */ CMICmnMIValueList( const CMICmnMIValueResult & vResult );
/* ctor */ CMICmnMIValueList( const CMICmnMIValue & vValue );
//
- bool Add( const CMICmnMIValueResult & vResult );
- bool Add( const CMICmnMIValue & vValue );
+ bool Add( const CMICmnMIValueResult & vResult );
+ bool Add( const CMICmnMIValue & vValue );
+ CMIUtilString ExtractContentNoBrackets( void ) const;
// Overridden:
public:
diff --git a/lldb/tools/lldb-mi/MICmnMIValueTuple.cpp b/lldb/tools/lldb-mi/MICmnMIValueTuple.cpp
index 1f23478321b..2f1349e7979 100644
--- a/lldb/tools/lldb-mi/MICmnMIValueTuple.cpp
+++ b/lldb/tools/lldb-mi/MICmnMIValueTuple.cpp
@@ -94,7 +94,7 @@ bool CMICmnMIValueTuple::BuildTuple( void )
}
//++ ------------------------------------------------------------------------------------
-// Details: Add another MI result object to the value's list of tuples.
+// Details: Add another MI result object to the value's list of tuples.
// Type: Method.
// Args: vResult - (R) The MI result object.
// Return: MIstatus::success - Functional succeeded.
@@ -127,6 +127,31 @@ bool CMICmnMIValueTuple::BuildTuple( const CMICmnMIValueResult & vResult )
}
//++ ------------------------------------------------------------------------------------
+// Details: Add string value to the value's list of tuples.
+// Type: Method.
+// Args: vValue - (R) The string object.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnMIValueTuple::BuildTuple( const CMIUtilString & vValue )
+{
+ // Clear out the default "<Invalid>" text
+ if( m_bJustConstructed )
+ {
+ m_bJustConstructed = false;
+ m_strValue = vValue;
+ return BuildTuple();
+ }
+
+ const CMIUtilString data( ExtractContentNoBrackets() );
+ const MIchar * pFormat = m_bSpaceAfterComma ? "{%s, %s}" : "{%s,%s}";
+ m_strValue = CMIUtilString::Format( pFormat, data.c_str(), vValue.c_str() );
+
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this function
// will return MIstatus::failure.
@@ -158,3 +183,45 @@ bool CMICmnMIValueTuple::Add( const CMICmnMIValueResult & vResult, const bool vb
return BuildTuple( vResult );
}
+//++ ------------------------------------------------------------------------------------
+// Details: Add another MI value object to the value list's of list is values.
+// Only values objects can be added to a list of values otherwise this function
+// will return MIstatus::failure.
+// Type: Method.
+// Args: vValue - (R) The MI value object.
+// vbUseSpacing - (R) True = put space seperators into the string, false = no spaces used.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool CMICmnMIValueTuple::Add( const CMICmnMIValueConst & vValue, const bool vbUseSpacing )
+{
+ m_bSpaceAfterComma = vbUseSpacing;
+ return BuildTuple( vValue.GetString() );
+}
+
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the contents of *this value object but without the outer most
+// brackets.
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString - Data within the object.
+// Throws: None.
+//--
+CMIUtilString CMICmnMIValueTuple::ExtractContentNoBrackets( void ) const
+{
+ CMIUtilString data( m_strValue );
+
+ if( data[ 0 ] == '{' )
+ {
+ data = data.substr( 1, data.length() - 1 );
+ }
+ if( data[ data.size() - 1 ] == '}' )
+ {
+ data = data.substr( 0, data.length() - 1 );
+ }
+
+ return data;
+}
+
diff --git a/lldb/tools/lldb-mi/MICmnMIValueTuple.h b/lldb/tools/lldb-mi/MICmnMIValueTuple.h
index dc7e6f23911..0399c9d5068 100644
--- a/lldb/tools/lldb-mi/MICmnMIValueTuple.h
+++ b/lldb/tools/lldb-mi/MICmnMIValueTuple.h
@@ -24,6 +24,7 @@
// In-house headers:
#include "MICmnMIValue.h"
#include "MICmnMIValueResult.h"
+#include "MICmnMIValueConst.h"
//++ ============================================================================
// Details: MI common code MI Result class. Part of the CMICmnMIValueTupleRecord
@@ -53,8 +54,10 @@ public:
/* ctor */ CMICmnMIValueTuple( const CMICmnMIValueResult & vResult );
/* ctor */ CMICmnMIValueTuple( const CMICmnMIValueResult & vResult, const bool vbUseSpacing );
//
- bool Add( const CMICmnMIValueResult & vResult );
- bool Add( const CMICmnMIValueResult & vResult, const bool vbUseSpacing );
+ bool Add( const CMICmnMIValueResult & vResult );
+ bool Add( const CMICmnMIValueResult & vResult, const bool vbUseSpacing );
+ bool Add( const CMICmnMIValueConst & vValue, const bool vbUseSpacing );
+ CMIUtilString ExtractContentNoBrackets( void ) const;
// Overridden:
public:
@@ -65,6 +68,7 @@ public:
private:
bool BuildTuple( void );
bool BuildTuple( const CMICmnMIValueResult & vResult );
+ bool BuildTuple( const CMIUtilString & vValue );
// Attributes:
private:
diff --git a/lldb/tools/lldb-mi/MICmnResources.cpp b/lldb/tools/lldb-mi/MICmnResources.cpp
index dbd798ff3a0..aea6fbbe4ab 100644
--- a/lldb/tools/lldb-mi/MICmnResources.cpp
+++ b/lldb/tools/lldb-mi/MICmnResources.cpp
@@ -29,8 +29,8 @@
const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[] =
{
{ IDS_PROJNAME, "LLDB Machine Interface Driver (MI) All rights reserved" },
- { IDS_MI_VERSION_DESCRIPTION_DEBUG, "Version: 1.0.0.6 (Debug)" }, // See version history in MIDriverMain.cpp
- { IDS_MI_VERSION_DESCRIPTION, "Version: 1.0.0.6" },
+ { IDS_MI_VERSION_DESCRIPTION_DEBUG, "Version: 1.0.0.9 (Debug)" }, // See version history in MIDriverMain.cpp
+ { IDS_MI_VERSION_DESCRIPTION, "Version: 1.0.0.9" },
{ IDS_MI_APPNAME_SHORT, "MI" },
{ IDS_MI_APPNAME_LONG, "Machine Interface Driver" },
{ IDS_MI_APP_FILEPATHNAME, "Application: %s" },
@@ -64,18 +64,23 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{ IDE_MI_APP_EXIT_OK, "Program exited OK" },
{ IDE_MI_APP_EXIT_WITH_PROBLEM, "Program exited with a problem, see '%s' file" },
{ IDE_MI_APP_EXIT_WITH_PROBLEM_NO_LOG, "Program exited with a problem, the application's log file '%s' was disabled" },
- { IDE_MI_APP_ARG_USAGE, "MI driver usage:" },
- { IDE_MI_APP_ARG_HELP, "-h\n--help\n\tPrints out usage information for the MI debugger." },
- { IDE_MI_APP_ARG_VERSION, "--version\n\tPrints out GNU (gdb) version information." },
- { IDE_MI_APP_ARG_VERSION_LONG, "--versionLong\n\tPrints out MI version information." },
- { IDE_MI_APP_ARG_INTERPRETER, "--interpreter\n\tUse the MI driver for the debugger (Default is the LLDB driver).\n\tAny LLDB command line options are ignored even if the MI driver\n\tfalls through to the LLDB driver. (Depends on build\n\t configuration see MICmnConfig.h)" },
- { IDE_MI_APP_ARG_NO_APP_LOG, "--noLog\n\tUse this argument to tell the MI driver not to update it's log\n\tfile '%s'." },
+ { IDE_MI_APP_DESCRIPTION, "Description:\nThe Machine Interface Driver (MI Driver) is a stand alone executable\nthat either be used via a client i.e. Eclipse or directly from the command\nline. It processes MI commands, actions those commands using the internal\ndebugger then forms MI response formatted text which is returned to the\nclient." },
+ { IDE_MI_APP_INFORMATION, "Information:\nCurrent limitations. The MI Driver currently only handles remote target\ndebugging. Local debugging has not been implemented. The MI Driver has\nbeen designed primarily to be used with Eclipse Juno and a custom plugin.\nThe custom plugin is not necessary to operate the MI Driver." },
+ { IDE_MI_APP_ARG_USAGE, "\nMI driver usage:\n\n\tlldb-mi [--longOption] [-s hortOption] [executeable]\n\n[] = optional argument." },
+ { IDE_MI_APP_ARG_HELP, "-h\n--help\n\tPrints out usage information for the MI debugger. Exit the MI\n\tDriver immediately." },
+ { IDE_MI_APP_ARG_VERSION, "--version\n\tPrints out GNU (gdb) version information. Exit the MI Driver\n\timmediately." },
+ { IDE_MI_APP_ARG_VERSION_LONG, "--versionLong\n\tPrints out MI Driver version information. Exit the MI Driver\n\timmediately." },
+ { IDE_MI_APP_ARG_INTERPRETER, "--interpreter\n\tUse the MI Driver for the debugger (MI mode)(Default is the\n\tLLDB driver). Any LLDB command line options are ignored even\n\tif the MI Driver falls through to the LLDB driver. (Depends\n\ton the build configuration see MICmnConfig.h)\n\tNormally specified by the driver client i.e. Eclipse.\n\tCannot specify an executable with this option, use --executable." },
+ { IDE_MI_APP_ARG_EXECUTEABLE, "--executable\n\tUse the MI Driver in MI mode for the debugging the specified\n\texecutable. Any LLDB command line options are ignored even\n\tif the MI Driver falls through to the LLDB driver. (Depends\n\ton the build configuration see MICmnConfig.h)\n\tNormally specified from the command line." },
+ { IDE_MI_APP_ARG_NO_APP_LOG, "--noLog\n\tUse this argument to tell the MI Driver not to update it's log\n\tfile '%s'." },
{ IDE_MI_APP_ARG_EXAMPLE, "Example MI command:\n\t3-info-gdb-mi-command gdb-set\n\t3^done,command={exists=\"true\"}" },
+ { IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file path to the executable i.e. '\"C:\\My Dev\\foo.exe\"'." },
{ IDS_STDIN_ERR_INVALID_PROMPT, "Stdin. Invalid prompt description '%s'" },
{ IDS_STDIN_ERR_THREAD_CREATION_FAILED, "Stdin. Thread creation failed '%s'" },
{ IDS_STDIN_ERR_THREAD_DELETE, "Stdin. Thread failed to delete '%s'" },
{ IDS_STDIN_ERR_CHKING_BYTE_AVAILABLE, "Stdin. Peeking on stdin stream '%s'" },
- { IDS_CMD_QUIT_HELP, "Cmd: quit\n\tExit the MI driver application." },
+ { IDS_STDIN_INPUT_CTRL_CHARS, "Stdin. Receive characters not handled as a command: " },
+ { IDS_CMD_QUIT_HELP, "MI Driver Command: quit\n\tExit the MI Driver application." },
{ IDS_THREADMGR_ERR_THREAD_ID_INVALID, "Thread Mgr. Thread ID '%s' is not valid" },
{ IDS_THREADMGR_ERR_THREAD_FAIL_CREATE, "Thread Mgr: Failed to create thread '%s'" },
{ IDS_THREADMGR_ERR_THREAD_ID_NOT_FOUND, "Thread Mgr: Thread with ID '%s' not found" },
@@ -109,6 +114,8 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{ IDS_MI_INIT_ERR_OUTOFBANDHANDLER, "Out-of-band handler. %s " },
{ IDS_MI_INIT_ERR_DEBUGSESSIONINFO, "LLDB debug session info. %s " },
{ IDS_MI_INIT_ERR_THREADMANAGER, "Unable to init thread manager." },
+ { IDS_MI_INIT_ERR_CLIENT_USING_DRIVER, "Initialising the client to this driver failed." },
+ { IDS_MI_INIT_ERR_LOCAL_DEBUG_SESSION, "Initialising a local debug session failed." },
{ IDS_CODE_ERR_INVALID_PARAMETER_VALUE, "Code. Invalid parameter passed to function '%s'" },
{ IDS_CODE_ERR_INVALID_PARAM_NULL_POINTER, "Code. NULL pointer passes as a parameter to function '%s'" },
{ IDS_CODE_ERR_INVALID_ENUMERATION_VALUE, "Code. Invalid enumeration value encountered in function '%s'" },
@@ -128,9 +135,11 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{ IDS_LLDBOUTOFBAND_ERR_PROCESS_INVALID, "LLDB Out-of-band. Invalid '%s' in '%s'" },
{ IDS_LLDBOUTOFBAND_ERR_BRKPT_NOTFOUND, "LLDB Out-of-band. %s. Breakpoint information for breakpoint ID %d not found" },
{ IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_GET, "LLDB Out-of-band. %s. Failed to retrieve breakpoint information for for breakpoint ID %d" },
+ { IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_SET, "LLDB Out-of-band. %s. Failed to set breakpoint information for for breakpoint ID %d" },
{ IDS_LLDBOUTOFBAND_ERR_FORM_MI_RESPONSE, "LLDB Out-of-band. %s. Failed to form the MI Out-of-band response" },
{ IDS_LLDBOUTOFBAND_ERR_FRAME_INFO_GET, "LLDB Out-of-band. %s. Failed to retrieve frame information" },
{ IDS_LLDBOUTOFBAND_ERR_SETNEWDRIVERSTATE, "LLDB Out-of-band. %s. Event handler tried to set new MI Driver running state and failed. %s" },
+ { IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED, "LLDB Out-of-band. '%s'. Number of valid breakpoint exceeded %d. Cannot create new breakpoint with ID %d" },
{ IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE, "LLDB debug session info. Release some or all of the data shared across command instances failed" },
{ IDS_DBGSESSION_ERR_SHARED_DATA_ADD, "LLDB debug session info. Failed to add '%s' data to the shared data command container" },
{ IDS_MI_SHTDWN_ERR_LOG, "Log. Error occurred during shutdown. %s" },
@@ -163,15 +172,19 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{ IDS_DRIVER_CMD_NOT_IN_FACTORY, ". Command '%s' not in Command Factory" },
{ IDS_DRIVER_ERR_DRIVER_STATE_ERROR, "Driver. Driver running state error. Cannot go to next state from present state as not allowed", },
{ IDS_DRIVER_WAITING_STDIN_DATA, "Driver. Main thread suspended waiting on Stdin Monitor to resume main thread" },
+ { IDS_DRIVER_ERR_MAINLOOP, "Driver. Error in do main loop. %s" },
+ { IDS_DRIVER_ERR_LOCAL_DEBUG_NOT_IMPL, "Driver. --executable argument given. Local debugging is not implemented." },
+ { IDS_DRIVER_ERR_LOCAL_DEBUG_INIT, "Driver. --executable argument given. Initialising local debugging failed." },
{ IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN, "Stdout. Not all data was written to stream. The data '%s'" },
{ IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN, "Stderr. Not all data was written to stream. The data '%s'" },
{ IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED, "Command Args. Missing options, %d or more required" },
{ IDS_CMD_ARGS_ERR_OPTION_NOT_FOUND, "Command Args. Option '%s' not found" },
- { IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY, "Command Args. Validation failed. Mandatory args not found: %s" },
- { IDS_CMD_ARGS_ERR_VALIDATION_INVALID, "Command Args. Validation failed. Invalid args: %s" },
- { IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID, "Command Args. Validation failed. Mandatory args not found: %s. Invalid args: %s" },
- { IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF, "Command Args. Validation failed. Args missing additional information: %s." },
- { IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN, "Command Args. Validation failed. Not all arguments or options were recognised: %s" },
+ { IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY, "Mandatory args not found: %s" },
+ { IDS_CMD_ARGS_ERR_VALIDATION_INVALID, "Invalid args: %s" },
+ { IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID, "Mandatory args not found: %s. Invalid args: %s" },
+ { IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF, "Args missing additional information: %s" },
+ { IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN, "Not all arguments or options were recognised: %s" },
+ { IDS_CMD_ARGS_ERR_PREFIX_MSG, "Command Args. Validation failed. " },
{ IDS_VARIANT_ERR_USED_BASECLASS, "Variant container: Variant object used the base class. See CMIUtilVariant" },
{ IDS_VARIANT_ERR_MAP_KEY_INVALID, "Variant container: Invalid ID '%s'" },
{ IDS_WORD_INVALIDBRKTS, "<Invalid>" },
@@ -245,7 +258,7 @@ CMICmnResources::CMICmnResources( void )
//++ ------------------------------------------------------------------------------------
// Details: CMICmnResources destructor.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
diff --git a/lldb/tools/lldb-mi/MICmnResources.h b/lldb/tools/lldb-mi/MICmnResources.h
index a67ee553da4..f836f8d1b8a 100644
--- a/lldb/tools/lldb-mi/MICmnResources.h
+++ b/lldb/tools/lldb-mi/MICmnResources.h
@@ -44,18 +44,18 @@ enum
IDS_MI_APP_ARGS ,
IDE_MI_VERSION_GDB ,
- IDS_UTIL_FILE_ERR_INVALID_PATHNAME = 10,
+ IDS_UTIL_FILE_ERR_INVALID_PATHNAME ,
IDS_UTIL_FILE_ERR_OPENING_FILE ,
IDS_UTIL_FILE_ERR_OPENING_FILE_UNKNOWN ,
IDE_UTIL_FILE_ERR_WRITING_FILE ,
IDE_UTIL_FILE_ERR_WRITING_NOTOPEN ,
- IDS_RESOURCES_ERR_STRING_NOT_FOUND = 20,
+ IDS_RESOURCES_ERR_STRING_NOT_FOUND ,
IDS_RESOURCES_ERR_STRING_TABLE_INVALID ,
- IDS_MI_CLIENT_MSG = 50,
+ IDS_MI_CLIENT_MSG ,
- IDS_LOG_MSG_CREATION_DATE = 60,
+ IDS_LOG_MSG_CREATION_DATE ,
IDS_LOG_MSG_FILE_LOGGER_PATH ,
IDS_LOG_MSG_VERSION ,
IDS_LOG_ERR_FILE_LOGGER_DISABLED ,
@@ -64,56 +64,61 @@ enum
IDS_LOG_MEDIUM_ERR_WRITE_MEDIUMFAIL ,
IDE_MEDIUMFILE_ERR_GET_FILE_PATHNAME_SYS,
- IDS_MEDIUMFILE_NAME = 70,
+ IDS_MEDIUMFILE_NAME ,
IDS_MEDIUMFILE_ERR_INVALID_PATH ,
IDS_MEDIUMFILE_ERR_FILE_HEADER ,
IDS_MEDIUMFILE_NAME_LOG ,
- IDE_OS_ERR_UNKNOWN = 80,
+ IDE_OS_ERR_UNKNOWN ,
IDE_OS_ERR_RETRIEVING ,
- IDS_DRIVERMGR_DRIVER_ERR_INIT = 90,
+ IDS_DRIVERMGR_DRIVER_ERR_INIT ,
- IDE_MEDIUMSTDERR_NAME = 110,
+ IDE_MEDIUMSTDERR_NAME ,
IDE_MEDIUMSTDOUT_NAME ,
- IDE_MI_APP_EXIT_OK = 120,
+ IDE_MI_APP_EXIT_OK ,
IDE_MI_APP_EXIT_WITH_PROBLEM ,
IDE_MI_APP_EXIT_WITH_PROBLEM_NO_LOG ,
- IDE_MI_APP_ARG_USAGE = 130,
- IDE_MI_APP_ARG_HELP ,
+ IDE_MI_APP_DESCRIPTION ,
+ IDE_MI_APP_INFORMATION ,
+ IDE_MI_APP_ARG_USAGE ,
+ IDE_MI_APP_ARG_HELP ,
IDE_MI_APP_ARG_VERSION ,
IDE_MI_APP_ARG_VERSION_LONG ,
IDE_MI_APP_ARG_INTERPRETER ,
+ IDE_MI_APP_ARG_EXECUTEABLE ,
IDE_MI_APP_ARG_NO_APP_LOG ,
IDE_MI_APP_ARG_EXAMPLE ,
+ IDE_MI_APP_ARG_EXECUTABLE ,
- IDS_STDIN_ERR_INVALID_PROMPT = 140,
+ IDS_STDIN_ERR_INVALID_PROMPT ,
IDS_STDIN_ERR_THREAD_CREATION_FAILED ,
IDS_STDIN_ERR_THREAD_DELETE ,
IDS_STDIN_ERR_CHKING_BYTE_AVAILABLE ,
+ IDS_STDIN_INPUT_CTRL_CHARS ,
- IDS_CMD_QUIT_HELP = 150,
+ IDS_CMD_QUIT_HELP ,
- IDS_THREADMGR_ERR_THREAD_ID_INVALID = 160,
+ IDS_THREADMGR_ERR_THREAD_ID_INVALID ,
IDS_THREADMGR_ERR_THREAD_FAIL_CREATE ,
IDS_THREADMGR_ERR_THREAD_ID_NOT_FOUND ,
IDS_THREADMGR_ERR_THREAD_STILL_ALIVE ,
- IDS_FALLTHRU_DRIVER_CMD_RECEIVED = 170,
+ IDS_FALLTHRU_DRIVER_CMD_RECEIVED ,
- IDS_CMDFACTORY_ERR_INVALID_CMD_NAME = 180,
+ IDS_CMDFACTORY_ERR_INVALID_CMD_NAME ,
IDS_CMDFACTORY_ERR_INVALID_CMD_CR8FN ,
IDS_CMDFACTORY_ERR_CMD_NOT_REGISTERED ,
IDS_CMDFACTORY_ERR_CMD_ALREADY_REGED ,
- IDS_CMDMGR_ERR_CMD_FAILED_CREATE = 190,
+ IDS_CMDMGR_ERR_CMD_FAILED_CREATE ,
IDS_CMDMGR_ERR_CMD_INVOKER ,
- IDS_PROCESS_SIGNAL_RECEIVED = 210,
+ IDS_PROCESS_SIGNAL_RECEIVED ,
- IDS_MI_INIT_ERR_LOG = 230,
+ IDS_MI_INIT_ERR_LOG ,
IDS_MI_INIT_ERR_RESOURCES ,
IDS_MI_INIT_ERR_INIT ,
IDS_MI_INIT_ERR_STREAMSTDIN ,
@@ -134,12 +139,14 @@ enum
IDS_MI_INIT_ERR_OUTOFBANDHANDLER ,
IDS_MI_INIT_ERR_DEBUGSESSIONINFO ,
IDS_MI_INIT_ERR_THREADMANAGER ,
+ IDS_MI_INIT_ERR_CLIENT_USING_DRIVER ,
+ IDS_MI_INIT_ERR_LOCAL_DEBUG_SESSION ,
- IDS_CODE_ERR_INVALID_PARAMETER_VALUE = 250,
+ IDS_CODE_ERR_INVALID_PARAMETER_VALUE ,
IDS_CODE_ERR_INVALID_PARAM_NULL_POINTER ,
IDS_CODE_ERR_INVALID_ENUMERATION_VALUE ,
- IDS_LLDBDEBUGGER_ERR_INVALIDLISTENER = 260,
+ IDS_LLDBDEBUGGER_ERR_INVALIDLISTENER ,
IDS_LLDBDEBUGGER_ERR_INVALIDDEBUGGER ,
IDS_LLDBDEBUGGER_ERR_CLIENTDRIVER ,
IDS_LLDBDEBUGGER_ERR_STARTLISTENER ,
@@ -152,19 +159,21 @@ enum
IDS_LLDBDEBUGGER_ERR_BROARDCASTER_NAME ,
IDS_LLDBDEBUGGER_WRN_UNKNOWN_EVENT ,
- IDS_LLDBOUTOFBAND_ERR_UNKNOWN_EVENT = 280,
+ IDS_LLDBOUTOFBAND_ERR_UNKNOWN_EVENT ,
IDS_LLDBOUTOFBAND_ERR_PROCESS_INVALID ,
IDS_LLDBOUTOFBAND_ERR_BRKPT_NOTFOUND ,
IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_GET ,
+ IDS_LLDBOUTOFBAND_ERR_BRKPT_INFO_SET ,
IDS_LLDBOUTOFBAND_ERR_FORM_MI_RESPONSE ,
IDS_LLDBOUTOFBAND_ERR_FRAME_INFO_GET ,
IDS_LLDBOUTOFBAND_ERR_SETNEWDRIVERSTATE ,
+ IDS_LLDBOUTOFBAND_ERR_BRKPT_CNT_EXCEEDED,
- IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE = 290,
+ IDS_DBGSESSION_ERR_SHARED_DATA_RELEASE ,
IDS_DBGSESSION_ERR_SHARED_DATA_ADD ,
- IDS_MI_SHTDWN_ERR_LOG = 340,
+ IDS_MI_SHTDWN_ERR_LOG ,
IDS_MI_SHUTDOWN_ERR ,
IDE_MI_SHTDWN_ERR_RESOURCES ,
IDE_MI_SHTDWN_ERR_STREAMSTDIN ,
@@ -184,7 +193,7 @@ enum
IDS_MI_SHTDWN_ERR_DEBUGSESSIONINFO ,
IDE_MI_SHTDWN_ERR_THREADMANAGER ,
- IDS_DRIVER_ERR_PARSE_ARGS = 400,
+ IDS_DRIVER_ERR_PARSE_ARGS ,
IDS_DRIVER_ERR_PARSE_ARGS_UNKNOWN ,
IDS_DRIVER_ERR_CURRENT_NOT_SET ,
IDS_DRIVER_ERR_NON_REGISTERED ,
@@ -194,24 +203,28 @@ enum
IDS_DRIVER_CMD_RECEIVED ,
IDS_DRIVER_CMD_NOT_IN_FACTORY ,
IDS_DRIVER_ERR_DRIVER_STATE_ERROR ,
+ IDS_DRIVER_ERR_MAINLOOP ,
+ IDS_DRIVER_ERR_LOCAL_DEBUG_NOT_IMPL ,
+ IDS_DRIVER_ERR_LOCAL_DEBUG_INIT ,
- IDS_DRIVER_WAITING_STDIN_DATA = 420,
+ IDS_DRIVER_WAITING_STDIN_DATA ,
- IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN = 430,
- IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN = 440,
+ IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN ,
+ IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN ,
- IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED = 450,
+ IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED ,
IDS_CMD_ARGS_ERR_OPTION_NOT_FOUND ,
IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY ,
IDS_CMD_ARGS_ERR_VALIDATION_INVALID ,
IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID ,
IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF ,
IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN ,
+ IDS_CMD_ARGS_ERR_PREFIX_MSG ,
- IDS_VARIANT_ERR_USED_BASECLASS = 460,
+ IDS_VARIANT_ERR_USED_BASECLASS ,
IDS_VARIANT_ERR_MAP_KEY_INVALID,
- IDS_WORD_INVALIDBRKTS = 1000,
+ IDS_WORD_INVALIDBRKTS ,
IDS_WORD_NONE ,
IDS_WORD_NOT ,
IDS_WORD_INVALIDEMPTY ,
@@ -222,7 +235,7 @@ enum
IDS_WORD_UNKNOWNTYPE_BRKTS ,
IDS_WORD_ERR_MSG_NOT_IMPLEMENTED_BRKTS ,
- IDS_CMD_ERR_N_OPTIONS_REQUIRED = 2000,
+ IDS_CMD_ERR_N_OPTIONS_REQUIRED ,
IDS_CMD_ERR_OPTION_NOT_FOUND ,
IDS_CMD_ERR_ARGS ,
IDS_CMD_WRN_ARGS_NOT_HANDLED ,
diff --git a/lldb/tools/lldb-mi/MICmnStreamStderr.cpp b/lldb/tools/lldb-mi/MICmnStreamStderr.cpp
index 1b7917dc659..1d66110eab0 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStderr.cpp
+++ b/lldb/tools/lldb-mi/MICmnStreamStderr.cpp
@@ -102,9 +102,9 @@ bool CMICmnStreamStderr::Shutdown( void )
}
//++ ------------------------------------------------------------------------------------
-// Details: Write text data to stderr. The text data does not need to
-// include a carrage line return as this is added to the text. The function also
-// then passes the text data into the CMICmnLog logger.
+// Details: Write text data to stderr. Prefix the message with "MI:". The text data does
+// not need to include a carrage 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)
@@ -123,11 +123,33 @@ bool CMICmnStreamStderr::Write( const CMIUtilString & vText, const bool vbSendTo
}
//++ ------------------------------------------------------------------------------------
+// Details: Write an LLDB text message to stderr.
+// The text data does not need to include a carrage 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)
+// 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;
+
+ const CMIUtilString strPrefixed( CMIUtilString::Format( "LLDB: %s", vText.c_str() ) );
+
+ return WritePriv( vText, strPrefixed, vbSendToLog );
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Write text data to stderr. The text data does not need to
// include a carrage 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.
+// 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)
// Return: MIstatus::success - Functional succeeded.
@@ -196,8 +218,8 @@ bool CMICmnStreamStderr::Unlock( void )
}
//++ ------------------------------------------------------------------------------------
-// Details: Take a text data and send to the stderr stream. Also output to the MI Log
-// file.
+// 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.
// Return: MIstatus::success - Functionality succeeded.
@@ -212,3 +234,24 @@ bool CMICmnStreamStderr::TextToStderr( const CMIUtilString & vrTxt )
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.
+// Also output to the MI Log file.
+// Type: Static method.
+// Args: vrTxt - (R) Text.
+// Return: MIstatus::success - Functionality succeeded.
+// 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;
+}
+
diff --git a/lldb/tools/lldb-mi/MICmnStreamStderr.h b/lldb/tools/lldb-mi/MICmnStreamStderr.h
index 01550718fe6..45a1cf3bfc7 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStderr.h
+++ b/lldb/tools/lldb-mi/MICmnStreamStderr.h
@@ -45,6 +45,7 @@ class CMICmnStreamStderr
// Statics:
public:
static bool TextToStderr( const CMIUtilString & vrTxt );
+ static bool LLDBMsgToConsole( const CMIUtilString & vrTxt );
// Methods:
public:
@@ -54,6 +55,7 @@ public:
bool Lock( void );
bool Unlock( void );
bool Write( const CMIUtilString & vText, const bool vbSendToLog = true );
+ bool WriteLLDBMsg( const CMIUtilString & vText, const bool vbSendToLog = true );
// Methods:
private:
diff --git a/lldb/tools/lldb-mi/MICmnStreamStdin.cpp b/lldb/tools/lldb-mi/MICmnStreamStdin.cpp
index ccd3544c40f..d4f53dff014 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStdin.cpp
+++ b/lldb/tools/lldb-mi/MICmnStreamStdin.cpp
@@ -187,7 +187,7 @@ bool CMICmnStreamStdin::SetPrompt( const CMIUtilString & vNewPrompt )
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the command line prompt text currently being used.
+// Details: Retreive the command line prompt text currently being used.
// Type: Method.
// Args: None.
// Return: const CMIUtilString & - Functional failed.
@@ -201,7 +201,7 @@ const CMIUtilString & CMICmnStreamStdin::GetPrompt( void ) const
//++ ------------------------------------------------------------------------------------
// Details: Wait on input from stream Stdin. On each line of input received it is
// validated and providing there are no errors on the stream or the input
-// buffer is not exceeded the data is passed to the visitor.
+// buffer is not exceeded the data is passed to the vistor.
// Type: Method.
// Args: vrVisitor - (W) A client deriver callback.
// Return: MIstatus::success - Functional succeeded.
@@ -216,7 +216,7 @@ bool CMICmnStreamStdin::SetVisitor( IStreamStdin & vrVisitor )
//++ ------------------------------------------------------------------------------------
// Details: Set whether to display optional command line prompt. The prompt is output to
-// stdout. Disable it when this may interfere with the client reading stdout as
+// stdout. Disable it when this may interfer with the client reading stdout as
// input and it tries to interpret the prompt text to.
// Type: Method.
// Args: vbYes - (R) True = Yes prompt is shown/output to the user (stdout), false = no prompt.
@@ -231,7 +231,7 @@ void CMICmnStreamStdin::SetEnablePrompt( const bool vbYes )
//++ ------------------------------------------------------------------------------------
// Details: Get whether to display optional command line prompt. The prompt is output to
-// stdout. Disable it when this may interfere with the client reading stdout as
+// stdout. Disable it when this may interfer with the client reading stdout as
// input and it tries to interpret the prompt text to.
// Type: Method.
// Args: None.
@@ -366,7 +366,7 @@ void CMICmnStreamStdin::SetCtrlCHit( void )
//++ ------------------------------------------------------------------------------------
// Details: The main worker method for this thread.
-// Type: Overridden.
+// Type: Overidden.
// Args: vrbIsAlive = (W) True = *this thread is working, false = thread has exited.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
diff --git a/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp b/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp
index 86ce7a8c012..75703b71942 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp
+++ b/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp
@@ -150,7 +150,6 @@ bool CMICmnStreamStdinLinux::Shutdown( void )
//--
bool CMICmnStreamStdinLinux::InputAvailable( bool & vwbAvail )
{
-#ifndef _MSC_VER
/* AD: Not used ATM but could come in handy just in case we need to do
this, poll for input
@@ -174,7 +173,6 @@ bool CMICmnStreamStdinLinux::InputAvailable( bool & vwbAvail )
return MIstatus::success;
*/
-#endif // ifndef _MSC_VER
return MIstatus::success;
}
diff --git a/lldb/tools/lldb-mi/MICmnStreamStdinWindows.cpp b/lldb/tools/lldb-mi/MICmnStreamStdinWindows.cpp
index 572c671ad48..2b24df8d61a 100644
--- a/lldb/tools/lldb-mi/MICmnStreamStdinWindows.cpp
+++ b/lldb/tools/lldb-mi/MICmnStreamStdinWindows.cpp
@@ -98,10 +98,7 @@ bool CMICmnStreamStdinWindows::Initialize( void )
// Clear error indicators for std input
::clearerr( stdin );
- }
- if( bOk )
- {
#if defined( _MSC_VER )
m_bRunningInConsoleWin = ::_isatty( ::fileno( stdin ) );
#endif // #if defined( _MSC_VER )
@@ -175,12 +172,7 @@ bool CMICmnStreamStdinWindows::Shutdown( void )
//--
bool CMICmnStreamStdinWindows::InputAvailable( bool & vwbAvail )
{
-#ifdef _MSC_VER
return m_bRunningInConsoleWin ? InputAvailableConsoleWin( vwbAvail ) : InputAvailableApplication( vwbAvail );
-#else
- // Do nothing
- return MIstatus::success;
-#endif // ifdef _MSC_VER
}
//++ ------------------------------------------------------------------------------------
@@ -194,7 +186,7 @@ bool CMICmnStreamStdinWindows::InputAvailable( bool & vwbAvail )
//--
bool CMICmnStreamStdinWindows::InputAvailableConsoleWin( bool & vwbAvail )
{
-#ifdef _MSC_VER
+#if defined( _MSC_VER )
if( m_nBytesToBeRead == 0 )
{
// Get a windows handle to std input stream
@@ -207,7 +199,7 @@ bool CMICmnStreamStdinWindows::InputAvailableConsoleWin( bool & vwbAvail )
// Return state of whether bytes are waiting or not
vwbAvail = (nBytesWaiting > 0);
}
-#endif // ifdef _MSC_VER
+#endif // #if defined( _MSC_VER )
return MIstatus::success;
}
@@ -222,8 +214,8 @@ bool CMICmnStreamStdinWindows::InputAvailableConsoleWin( bool & vwbAvail )
//--
bool CMICmnStreamStdinWindows::InputAvailableApplication( bool & vwbAvail )
{
-#ifdef _MSC_VER
- if( m_nBytesToBeRead == 0 )
+ #if defined( _MSC_VER )
+ if( m_nBytesToBeRead == 0 )
{
// Get a windows handle to std input stream
HANDLE handle = ::GetStdHandle( STD_INPUT_HANDLE );
@@ -245,7 +237,7 @@ bool CMICmnStreamStdinWindows::InputAvailableApplication( bool & vwbAvail )
// Return state of whether bytes are waiting or not
vwbAvail = (nBytesWaiting > 0);
}
-#endif // ifdef _MSC_VER
+#endif // #if defined( _MSC_VER )
return MIstatus::success;
}
diff --git a/lldb/tools/lldb-mi/MIDriver.cpp b/lldb/tools/lldb-mi/MIDriver.cpp
index 14f9cc8b0da..2125b847258 100644
--- a/lldb/tools/lldb-mi/MIDriver.cpp
+++ b/lldb/tools/lldb-mi/MIDriver.cpp
@@ -38,6 +38,9 @@
#include "MIUtilSingletonHelper.h"
#include "MICmnStreamStdout.h"
#include "MICmnStreamStderr.h"
+#include "MICmdArgValFile.h"
+#include "MICmdArgValString.h"
+#include "MICmnConfig.h"
// Instantiations:
#if _DEBUG
@@ -63,6 +66,8 @@ CMIDriver::CMIDriver( void )
, m_rLldbDebugger( CMICmnLLDBDebugger::Instance() )
, m_rStdOut( CMICmnStreamStdout::Instance() )
, m_eCurrentDriverState( eDriverState_NotRunning )
+, m_bHaveExecutableFileNamePathOnCmdLine( false )
+, m_bDriverDebuggingArgExecutable( false )
{
}
@@ -192,7 +197,6 @@ bool CMIDriver::Initialize( void )
#endif // MICONFIG_COMPILE_MIDRIVER_WITH_LLDBDRIVER
m_bExitApp = false;
- bOk = bOk && InitClientIDEToMIDriver(); // Init Eclipse IDE
m_bInitialized = bOk;
@@ -390,7 +394,18 @@ lldb::SBError CMIDriver::DoParseArgs( const int argc, const char * argv[], FILE
//++ ------------------------------------------------------------------------------------
// Details: Check the arguments that were passed to this program to make sure they are
-// valid and to get their argument values (if any).
+// valid and to get their argument values (if any). The following are options
+// that are only handled by *this driver:
+// --executable
+// The application's options --interpreter and --executable in code act very similar.
+// The --executable is necessary to differentiate whither the MI Driver is being
+// using by a client i.e. Eclipse or from the command line. Eclipse issues the option
+// --interpreter and also passes additional arguments which can be interpreted as an
+// executable if called from the command line. Using --executable tells the MI
+// Driver is being called the command line and that the executable argument is indeed
+// a specified executable an so actions commands to set up the executable for a
+// debug session. Using --interpreter on the commnd line does not action additional
+// commands to initialise a debug session and so be able to launch the process.
// Type: Overridden.
// Args: argc - (R) An integer that contains the count of arguments that follow in
// argv. The argc parameter is always greater than or equal to 1.
@@ -408,8 +423,47 @@ lldb::SBError CMIDriver::DoParseArgs( const int argc, const char * argv[], FILE
lldb::SBError CMIDriver::ParseArgs( const int argc, const char * argv[], FILE * vpStdOut, bool & vwbExiting )
{
lldb::SBError errStatus;
+ const bool bHaveArgs( argc >= 2 );
+
+ // *** Add any args handled here to GetHelpOnCmdLineArgOptions() ***
+
+ // CODETAG_MIDRIVE_CMD_LINE_ARG_HANDLING
+ // Look for the command line options
+ bool bHaveExecutableFileNamePath = false;
+ bool bHaveExecutableLongOption = false;
+
+ if( bHaveArgs )
+ {
+ // Search right to left to look for the executable
+ for( MIint i = argc - 1; i > 0; i-- )
+ {
+ const CMIUtilString strArg( argv[ i ] );
+ const CMICmdArgValFile argFile;
+ if( argFile.IsFilePath( strArg ) ||
+ CMICmdArgValString( true, false, true ).IsStringArg( strArg ))
+ {
+ bHaveExecutableFileNamePath = true;
+ m_strCmdLineArgExecuteableFileNamePath = argFile.GetFileNamePath( strArg );
+ m_bHaveExecutableFileNamePathOnCmdLine = true;
+ }
+ // This argument is also check for in CMIDriverMgr::ParseArgs()
+ if( 0 == strArg.compare( "--executable" ) ) // Used to specify that there is executable argument also on the command line
+ { // See fn description.
+ bHaveExecutableLongOption = true;
+ }
+ }
+ }
- // Do nothing - no options to handle for *this driver
+ if( bHaveExecutableFileNamePath && bHaveExecutableLongOption )
+ {
+ // CODETAG_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+#if MICONFIG_ENABLE_MI_DRIVER_MI_MODE_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+ SetDriverDebuggingArgExecutable();
+#else
+ vwbExiting = true;
+ errStatus.SetErrorString( MIRSRC( IDS_DRIVER_ERR_LOCAL_DEBUG_NOT_IMPL ) );
+#endif // MICONFIG_ENABLE_MI_DRIVER_MI_MODE_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+ }
return errStatus;
}
@@ -522,12 +576,30 @@ bool CMIDriver::StopWorkerThreads( void )
//--
bool CMIDriver::DoMainLoop( void )
{
+ if( !InitClientIDEToMIDriver() ) // Init Eclipse IDE
+ {
+ SetErrorDescriptionn( MIRSRC( IDS_MI_INIT_ERR_CLIENT_USING_DRIVER ) );
+ return MIstatus::failure;
+ }
+
if( !StartWorkerThreads() )
return MIstatus::failure;
// App is not quitting currently
m_bExitApp = false;
+ // CODETAG_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+#if MICONFIG_ENABLE_MI_DRIVER_MI_MODE_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+ if( HaveExecutableFileNamePathOnCmdLine() )
+ {
+ if( !LocalDebugSessionStartupInjectCommands() )
+ {
+ SetErrorDescription( MIRSRC( IDS_MI_INIT_ERR_LOCAL_DEBUG_SESSION ) );
+ return MIstatus::failure;
+ }
+ }
+#endif // MICONFIG_ENABLE_MI_DRIVER_MI_MODE_CMDLINE_ARG_EXECUTABLE_DEBUG_SESSION
+
// While the app is active
while( !m_bExitApp )
{
@@ -747,7 +819,7 @@ FILE * CMIDriver::GetStdin( void ) const
//++ ------------------------------------------------------------------------------------
// Details: *this driver provides a file stream to other pass through assigned drivers
// so they know what to write to.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: FILE * - Pointer to stream.
// Throws: None.
@@ -764,7 +836,7 @@ FILE * CMIDriver::GetStdout( void ) const
//++ ------------------------------------------------------------------------------------
// Details: *this driver provides a error file stream to other pass through assigned drivers
// so they know what to write to.
-// Type: Overridden.
+// Type: Overidden.
// Args: None.
// Return: FILE * - Pointer to stream.
// Throws: None.
@@ -775,7 +847,7 @@ FILE * CMIDriver::GetStderr( void ) const
// available before *this driver has been initialized! Flaw?
// This very likely to change later to a stream that the pass thru driver
- // will write to and *this driver reads from to pass on the CMICmnLog object
+ // will write to and *this driver reads from to pass on the the CMICmnLog object
return stderr;
}
@@ -898,6 +970,20 @@ bool CMIDriver::InterpretCommandThisDriver( const CMIUtilString & vTextLine, boo
return ExecuteCommand( cmdData );
}
+ // Check for escape character, may be cursor control characters
+ // This code is not necessary for application operation, just want to keep tabs on what
+ // is been given to the driver to try and intepret.
+ if( vTextLine.at( 0 ) == 27 )
+ {
+ CMIUtilString logInput( MIRSRC( IDS_STDIN_INPUT_CTRL_CHARS ) );
+ for( MIuint i = 0; i < vTextLine.length(); i++ )
+ {
+ logInput += CMIUtilString::Format( "%d ", vTextLine.at( i ) );
+ }
+ m_pLog->WriteLog( logInput );
+ return MIstatus::success;
+ }
+
// Write to the Log that a 'command' was not valid.
// Report back to the MI client via MI result record.
CMIUtilString strNotInCmdFactory;
@@ -932,7 +1018,7 @@ bool CMIDriver::ExecuteCommand( const SMICmdData & vCmdData )
//++ ------------------------------------------------------------------------------------
// Details: Set the MI Driver's exit application flag. The application checks this flag
-// after every stdin line is read so the exit may not be instantaneous.
+// after every stdin line is read so the exit may not be instantious.
// If vbForceExit is false the MI Driver queries its state and determines if is
// should exit or continue operating depending on that running state.
// This is related to the running state of the MI driver.
@@ -989,9 +1075,8 @@ CMIDriver::DriverState_e CMIDriver::GetCurrentDriverState( void ) const
}
//++ ------------------------------------------------------------------------------------
-// Details: Set the current running state of the MI Driver to running and currently in
-// a debug session. The driver's state must in the state running and not in a
-// debug session to set this new state.
+// Details: Set the current running state of the MI Driver to running and currently not in
+// a debug session.
// Type: Method.
// Return: MIstatus::success - Functionality succeeded.
// MIstatus::failure - Functionality failed.
@@ -1115,3 +1200,76 @@ bool CMIDriver::InitClientIDEEclipse( void ) const
return MIstatus::success;
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Ask *this driver whether it found an executable in the MI Driver's list of
+// arguments which to open and debug. If so instigate commands to set up a debug
+// session for that executable.
+// Type: Method.
+// Args: None.
+// Return: bool - True = True = Yes executable given as one of the parameters to the MI
+// Driver.
+// False = not found.
+// Throws: None.
+//--
+bool CMIDriver::HaveExecutableFileNamePathOnCmdLine( void ) const
+{
+ return m_bHaveExecutableFileNamePathOnCmdLine;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve from *this driver executable file name path to start a debug session
+// with (if present see HaveExecutableFileNamePathOnCmdLine()).
+// Type: Method.
+// Args: None.
+// Return: CMIUtilString & - Executeable file name path or empty string.
+// Throws: None.
+//--
+const CMIUtilString & CMIDriver::GetExecutableFileNamePathOnCmdLine( void ) const
+{
+ return m_strCmdLineArgExecuteableFileNamePath;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Execute commands (by injecting them into the stdin line queue container) and
+// other code to set up the MI Driver such that is can take the executable
+// argument passed on the command and create a debug session for it.
+// Type: Method.
+// Args: None.
+// Return: MIstatus::success - Functionality succeeded.
+// MIstatus::failure - Functionality failed.
+// Throws: None.
+//--
+bool CMIDriver::LocalDebugSessionStartupInjectCommands( void )
+{
+ const CMIUtilString strCmd( CMIUtilString::Format( "-file-exec-and-symbols %s", m_strCmdLineArgExecuteableFileNamePath.c_str() ) );
+
+ return InjectMICommand( strCmd );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Set the MI Driver into "its debugging an executable passed as an argument"
+// mode as against running via a client like Eclipse.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+void CMIDriver::SetDriverDebuggingArgExecutable( void )
+{
+ m_bDriverDebuggingArgExecutable = true;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Retrieve the MI Driver state indicating if it is operating in "its debugging
+// an executable passed as an argument" mode as against running via a client
+// like Eclipse.
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+bool CMIDriver::IsDriverDebuggingArgExecutable( void ) const
+{
+ return m_bDriverDebuggingArgExecutable;
+}
diff --git a/lldb/tools/lldb-mi/MIDriver.h b/lldb/tools/lldb-mi/MIDriver.h
index 5332b26f648..c565e825096 100644
--- a/lldb/tools/lldb-mi/MIDriver.h
+++ b/lldb/tools/lldb-mi/MIDriver.h
@@ -90,6 +90,8 @@ public:
DriverState_e GetCurrentDriverState( void ) const;
bool SetDriverStateRunningNotDebugging( void );
bool SetDriverStateRunningDebugging( void );
+ void SetDriverDebuggingArgExecutable( void );
+ bool IsDriverDebuggingArgExecutable( void ) const;
// MI information about itself
const CMIUtilString & GetAppNameShort( void ) const;
@@ -97,11 +99,13 @@ public:
const CMIUtilString & GetVersionDescription( void ) const;
// MI do work
- bool WriteMessageToLog( const CMIUtilString & vMessage );
- bool SetEnableFallThru( const bool vbYes );
- bool GetEnableFallThru( void ) const;
- bool InjectMICommand( const CMIUtilString & vMICmd );
-
+ bool WriteMessageToLog( const CMIUtilString & vMessage );
+ bool SetEnableFallThru( const bool vbYes );
+ bool GetEnableFallThru( void ) const;
+ bool InjectMICommand( const CMIUtilString & vMICmd );
+ bool HaveExecutableFileNamePathOnCmdLine( void ) const;
+ const CMIUtilString & GetExecutableFileNamePathOnCmdLine( void ) const;
+
// Overridden:
public:
// From CMIDriverMgr::IDriver
@@ -150,6 +154,7 @@ private:
bool InitClientIDEToMIDriver( void ) const;
bool InitClientIDEEclipse( void ) const;
bool QueueMICommand( const CMIUtilString & vMICmd );
+ bool LocalDebugSessionStartupInjectCommands( void );
// Overridden:
private:
@@ -162,13 +167,16 @@ private:
static const CMIUtilString ms_constAppNameLong;
static const CMIUtilString ms_constMIVersion;
//
- bool m_bFallThruToOtherDriverEnabled; // True = yes fall through, false = do not pass on command
+ bool m_bFallThruToOtherDriverEnabled; // True = yes fall through, false = do not pass on command
CMIUtilThreadMutex m_threadMutex;
- QueueStdinLine_t m_queueStdinLine; // Producer = stdin monitor, consumer = *this driver
- bool m_bDriverIsExiting; // True = yes, driver told to quit, false = continue working
- void * m_handleMainThread; // *this driver is run by the main thread
+ QueueStdinLine_t m_queueStdinLine; // Producer = stdin monitor, consumer = *this driver
+ bool m_bDriverIsExiting; // True = yes, driver told to quit, false = continue working
+ void * m_handleMainThread; // *this driver is run by the main thread
CMICmnStreamStdin & m_rStdin;
CMICmnLLDBDebugger & m_rLldbDebugger;
CMICmnStreamStdout & m_rStdOut;
DriverState_e m_eCurrentDriverState;
+ bool m_bHaveExecutableFileNamePathOnCmdLine; // True = Yes executable given as one of the parameters to the MI Driver, false = not found
+ CMIUtilString m_strCmdLineArgExecuteableFileNamePath;
+ bool m_bDriverDebuggingArgExecutable; // True = The MI Driver (MI mode) is debugging executable passed as argument, false = running via a client i.e Eclipse
};
diff --git a/lldb/tools/lldb-mi/MIDriverMain.cpp b/lldb/tools/lldb-mi/MIDriverMain.cpp
index 8b381bb7dea..a72e4ab20f3 100644
--- a/lldb/tools/lldb-mi/MIDriverMain.cpp
+++ b/lldb/tools/lldb-mi/MIDriverMain.cpp
@@ -26,9 +26,14 @@
// Versions: 1.0.0.1 First version from scratch 28/1/2014 to 28/3/2014. MI not complete.
// 1.0.0.2 First deliverable to client 7/3/2014. MI not complete.
// 1.0.0.3 Code refactor tidy. Release to community for evaluation 17/5/2014. MI not complete.
-// 1.0.0.4 Post release to community for evaluation 17/5/2014. MI not complete.
+// 1.0.0.4 Post release to the community for evaluation 17/5/2014. MI not complete.
// 1.0.0.5 Second deliverable to client 16/6/2014.
// 1.0.0.6 Post release of second deliverable to client 16/6/2014.
+// Released to the community 24/6/2014.
+// 1.0.0.7 Post release to the community.
+// Delivered to client 30/6/2014.
+// 1.0.0.8 Delivered to client 29/7/2014.
+// 1.0.0.9 Post release to client 29/7/2014.
// See MIreadme.txt for list of MI commands implemented.
//
// Environment: Compilers: Visual C++ 12.
diff --git a/lldb/tools/lldb-mi/MIDriverMgr.cpp b/lldb/tools/lldb-mi/MIDriverMgr.cpp
index 7b9b04414ad..b5cb7d4b515 100644
--- a/lldb/tools/lldb-mi/MIDriverMgr.cpp
+++ b/lldb/tools/lldb-mi/MIDriverMgr.cpp
@@ -23,7 +23,6 @@
#include <lldb/API/SBError.h>
// In-house headers:
-#include "MICmnConfig.h"
#include "MIDriverMgr.h"
#include "MICmnResources.h"
#include "MICmnLog.h"
@@ -329,9 +328,22 @@ CMIDriverMgr::IDriver * CMIDriverMgr::GetUseThisDriverToDoWork( void ) const
bool CMIDriverMgr::DriverMainLoop( void )
{
if( m_pDriverCurrent != nullptr )
- return m_pDriverCurrent->DoMainLoop();
+ {
+ if( !m_pDriverCurrent->DoMainLoop() )
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_MAINLOOP ), m_pDriverCurrent->GetError().c_str() ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ return MIstatus::failure;
+ }
+ }
+ else
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ return MIstatus::failure;
+ }
- return MIstatus::failure;
+ return MIstatus::success;
}
//++ ------------------------------------------------------------------------------------
@@ -346,6 +358,11 @@ void CMIDriverMgr::DriverResizeWindow( const uint32_t vWindowSizeWsCol )
{
if( m_pDriverCurrent != nullptr )
return m_pDriverCurrent->DoResizeWindow( vWindowSizeWsCol );
+ else
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ }
}
//++ ------------------------------------------------------------------------------------
@@ -376,7 +393,7 @@ bool CMIDriverMgr::DriverParseArgs( const int argc, const char * argv[], FILE *
if( !bOk )
{
CMIUtilString errMsg;
- const char * pErrorCstr = error.GetCString();
+ const MIchar * pErrorCstr = error.GetCString();
if( pErrorCstr != nullptr )
errMsg = CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_PARSE_ARGS ), m_pDriverCurrent->GetName().c_str(), pErrorCstr );
else
@@ -399,6 +416,11 @@ CMIUtilString CMIDriverMgr::DriverGetError( void ) const
{
if( m_pDriverCurrent != nullptr )
return m_pDriverCurrent->GetError();
+ else
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ }
return CMIUtilString();
}
@@ -415,6 +437,11 @@ CMIUtilString CMIDriverMgr::DriverGetName( void ) const
{
if( m_pDriverCurrent != nullptr )
return m_pDriverCurrent->GetName();
+ else
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ }
return CMIUtilString();
}
@@ -432,6 +459,11 @@ lldb::SBDebugger * CMIDriverMgr::DriverGetTheDebugger( void )
lldb::SBDebugger * pDebugger = nullptr;
if( m_pDriverCurrent != nullptr )
pDebugger = &m_pDriverCurrent->GetTheDebugger();
+ else
+ {
+ const CMIUtilString errMsg( CMIUtilString::Format( MIRSRC( IDS_DRIVER_ERR_CURRENT_NOT_SET ) ) );
+ CMICmnStreamStdout::Instance().Write( errMsg, true );
+ }
return pDebugger;
}
@@ -446,7 +478,18 @@ lldb::SBDebugger * CMIDriverMgr::DriverGetTheDebugger( void )
// --interpreter
// --version
// --versionLong
-// The above arguments are not handled by any driver object.
+// --noLog
+// --executable
+// The above arguments are not handled by any driver object except for --executable.
+// The options --interpreter and --executable in code act very similar. The
+// --executable is necessary to differentiate whither the MI Driver is being using
+// by a client i.e. Eclipse or from the command line. Eclipse issues the option
+// --interpreter and also passes additional arguments which can be interpreted as an
+// executable if called from the command line. Using --executable tells the MI
+// Driver is being called the command line and that the executable argument is indeed
+// a specified executable an so actions commands to set up the executable for a
+// debug session. Using --interpreter on the commnd line does not action additional
+// commands to initialise a debug session and so be able to launch the process.
// Type: Method.
// Args: argc - (R) An integer that contains the count of arguments that follow in
// argv. The argc parameter is always greater than or equal to 1.
@@ -501,12 +544,16 @@ bool CMIDriverMgr::ParseArgs( const int argc, const char * argv[], bool & vwbExi
if( bHaveArgs )
{
+ // CODETAG_MIDRIVE_CMD_LINE_ARG_HANDLING
for( MIint i = 1; i < argc; i++ )
{
// *** Add args to help in GetHelpOnCmdLineArgOptions() ***
const CMIUtilString strArg( argv[ i ] );
- if( 0 == strArg.compare( "--interpreter" ) )
- {
+
+ // Argument "--executable" is also check for in CMIDriver::ParseArgs()
+ if( (0 == strArg.compare( "--interpreter" )) || // Given by the client such as Eclipse
+ (0 == strArg.compare( "--executable" )) ) // Used to specify that there is executable argument also on the command line
+ { // See fn description.
bHaveArgInterpret = true;
}
if( 0 == strArg.compare( "--version" ) )
@@ -613,12 +660,16 @@ CMIUtilString CMIDriverMgr::GetHelpOnCmdLineArgOptions( void ) const
{
const CMIUtilString pHelp[] =
{
+ MIRSRC( IDE_MI_APP_DESCRIPTION ),
+ MIRSRC( IDE_MI_APP_INFORMATION ),
MIRSRC( IDE_MI_APP_ARG_USAGE ),
MIRSRC( IDE_MI_APP_ARG_HELP ),
MIRSRC( IDE_MI_APP_ARG_VERSION ),
MIRSRC( IDE_MI_APP_ARG_VERSION_LONG ),
MIRSRC( IDE_MI_APP_ARG_INTERPRETER ),
+ MIRSRC( IDE_MI_APP_ARG_EXECUTEABLE ),
CMIUtilString::Format( MIRSRC( IDE_MI_APP_ARG_NO_APP_LOG ), CMICmnLogMediumFile::Instance().GetFileName().c_str() ),
+ MIRSRC( IDE_MI_APP_ARG_EXECUTABLE ),
MIRSRC( IDS_CMD_QUIT_HELP ),
MIRSRC( IDE_MI_APP_ARG_EXAMPLE )
};
diff --git a/lldb/tools/lldb-mi/MIReadMe.txt b/lldb/tools/lldb-mi/MIReadMe.txt
index b3c4b2bb1c6..fbd3b2d364f 100644
--- a/lldb/tools/lldb-mi/MIReadMe.txt
+++ b/lldb/tools/lldb-mi/MIReadMe.txt
@@ -1,8 +1,11 @@
========================================================================
The MI Driver - LLDB Machine Interface V2 (MI) Project Overview
- 28/01/2014
+ 24/07/2014
========================================================================
+The MI Driver is a stand alone executable that either be used via a
+client i.e. Eclipse or directly from the command line.
+
All the files in this directory are required to build the MI executable.
The executable is intended to compile and work on the following platforms:
@@ -10,26 +13,33 @@ The executable is intended to compile and work on the following platforms:
LINUX (Compiler: gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1)
OSX (Not tested)
-The MI Driver (CMIDriver) is a driver in its own right to work alongside
-the LLDB driver (driver .h/.cpp). Only one is operated at a time depending
-on the options entered on the command line. The MI driver inputs and
-outputs MI (GDB instruction) to be interpreted by a client i.e. Eclipse.
-Should MI not understand an instruction it can be passed to the LLDB driver for
-interpretation (the MI stub is on top of LLDB driver not GDB)(build
-configuration dependant). Should the LLDB driver be chosen then it the
-MI driver will behave as a normal LLDB driver code MI.
+THe MI Driver has two modes of operation; LLDB and MI. The MI Driver (CMIDriver)
+which operates the MI mode is a driver in its own right to work alongside
+the LLDB driver (driver .h/.cpp). Only one is operatational at a time depending
+on the options entered on the command line. The MI Driver reads MI inputs and
+outputs MI responses to be interpreted by a client i.e. Eclipse.
+Should the MI Driver not understand an instruction it could be passed to the
+LLDB driver for interpretation (MI Driver build configuration dependant). Should
+the LLDB driver mode be chosen then it the MI Driver will behave as the normal
+LLDB driver.
+
+For help information on using the MI driver type at the command line:
+
+ lldb-mi --interpreter --help
-Type --help for instruction on using the MI driver. MI produces a MILog.txt file
-which records the actions of the MI driver (only) found in the directory
-of the lldbMI executable.
+A blog about the MI Driver is available on CodePlay's website
+http://www.codeplay.com/portal/.
-Note any command or text sent to the MI Driver that is not a command registered
-in the MI Driver's Command Factory will be rejected given an error.
+The MI Driver produces a MILog.txt file which records the actions of the MI
+Driver when in the MI mode only.
+
+Note any command or text sent to the MI Driver in MI mode that is not a command
+registered in the MI Driver's Command Factory will be rejected given an error.
The MILogfile.txt keeps a history of the MI Driver's activity for one session
-only. It is used to aid debugging the MI Driver. As well as recorded commands
-that are recognised by the MI Driver it also gives warnings about command's which
-do not support certain argument or options.
+only. It is used to aid the debugging of the MI Driver in MI mode only. As well
+as recorded commands that are recognised by the MI Driver it also gives warnings
+about command's which do not support certain argument or options.
All the files prefix with MI are specifically for the MI driver code only.
Non prefixed code is the original LLDB driver which has been left untouched
@@ -40,6 +50,24 @@ File MIDriverMain.cpp contains the executables main() function and some
common global functions common to the two drivers.
=========================================================================
+Current limitations:
+1. Commands implemented likely not to have all their arguments supported
+2. The MI Driver has only been tested with Eclipse Juno with an in-house
+ plugin
+3. Local target has been implemented but not tested
+4. The MI Driver has been designed primarily to work in a 'remote-target'
+ mode only. The MI Driver does not currently except arguments beyond
+ those described above.
+5. The MI Driver does not accept as arguments an executable to create a
+ target instance.
+6. Not all MI commands have been implemented. See section MI Driver
+ commands for those that have been fully or partially implemented (not
+ indicated - see command class).
+7. Not necessarily a limitation but the MI Driver is used with Codeplay's
+ own Eclipse plugin (not supplied) which has allowed more control over
+ the interaction with the MI Driver between Eclipse.
+
+=========================================================================
Versions:
1.0.0.1 First version from scratch 28/1/2014 to 28/3/2014.
MI working alpha. MI framework not complete.
@@ -72,6 +100,7 @@ Versions:
Command Factory". (Removed from command section in this readme.txt)
1.0.0.5 Second deliverable to client 16/6/2014.
1.0.0.6 Post release of second deliverable to client 16/6/2014.
+ Released to the community 24/6/2014.
1. The MI Driver has a new option --noLog. If present the MI Driver
does not output progress or status messages to it's log file.
2. Moved OS specific handling of the stdin stream to their own class
@@ -87,24 +116,44 @@ Versions:
was always the MI Driver interpreter.
6. Re-enable the compilation of the original LLDB driver code into
the MI Driver's code. See MICmnConfig.h for build configuration.
-
-=========================================================================
-Current limitations:
-1. Commands implemented likely not to have all their arguments supported
-2. The MI Driver has only been tested with Eclipse Juno with an in-house
- plugin
-3. Local target has been implemented but not tested
-4. The MI Driver has been designed primarily to work in a 'remote-target'
- mode only. The MI Driver does not currently except arguments beyond
- those described above.
-5. The MI Driver does not accept as arguments an executable to create a
- target instance.
-6. Not all MI commands have been implemented. See section MI Driver
- commands for those that have been fully or partially implemented (not
- indicated - see command class).
-7. Not necessarily a limitation but the MI Driver is used with Codeplay's
- own Eclipse plugin (not supplied) which has allowed more control over
- the interaction with the MI Driver between Eclipse.
+1.0.0.7 Post release to community. Delivered to client 30/6/2014.
+ 1. Fix MI Driver's output of "(gdb)" appearing when running in LLDB
+ mode (no --interpreter argument)'
+ 2. Fix command "interpret-exec" to allow commands to be entered
+ directly in the IDE console.
+1.0.0.8 Post release to client. Delivered to client 29/07/2014
+ 1. Fix command "break-insert" argument -f not accepting file paths
+ as a string. Looked like the MI Driver was not accepting LINUX
+ style file paths in the Windows version and vice versa.
+ 2. Fix command "stack-list-arguments" handling only the current
+ stack frame. Eclipse now shows variables for all frames.
+ 3. Fix and improve MI response for sending back information on
+ stack local variables, stack arguments and stack frame selection.
+ 4. Fix recursive crash when asking to gather information on link
+ lists.
+ 5. Fix MI Driver's Log date and time field.
+ 6. Fix MI response return from event 'StopReason' and 'Breakpoint-
+ hit'.
+ 7. Fix command "environment-cd" to handle paths with spaces in the
+ path.
+ 8. Fix not displaying backtrace (stack) variable information when
+ choosing frames other than the current frame.
+ 9. Fix command "data-evaluate-expression" to be able to handle
+ valid SBValue objects but have no value object name. Fix same
+ command to handle expressions surround by string format inserted
+ quotes.
+ 10.Fix command "break-insert" to handle file location that is
+ surrounded by quotes.
+ 11.For commands "var-create" and "data-evaluate-expression" improve
+ variable type handling for quoted expressions.
+ 12.Implement command "inferior-tty-set". It just responds with
+ "^Done".
+ 13.Improve the MI Driver's help description.
+ 14.Fix file name paths that contained '.', '-' and '_' in the path
+ as being treated as invalid.
+ 15.Fix trying to interpret escapse character text as an errorous
+ command.
+1.0.0.9 Post release to client.
=========================================================================
MI Driver Commands
@@ -113,7 +162,7 @@ one are more commands required by other IDEs are missing or do not
support all arguments or options. Additionally some commands may handle
additional arguments or options not documented here
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Data-Manipulation.html#GDB_002fMI-Data-Manipulation.
-The command implemented are:
+The implemented commands are:
CMICmdCmdBreakAfter
CMICmdCmdBreakCondition
CMICmdCmdBreakDelete
@@ -141,8 +190,9 @@ CMICmdCmdExecStepInstruction
CMICmdCmdFileExecAndSymbols
CMICmdCmdGdbExit
CMICmdCmdGdbInfo
-CMICmdCmdGdbSet
+CMICmdCmdGdbSet
CMICmdCmdGdbSet - solib-search-path option
+CMICmdCmdInferiorTtySet (not functionally implemented)
CMICmdCmdInterpreterExec
CMICmdCmdListThreadGroups
CMICmdCmdSource
@@ -192,6 +242,8 @@ MI Driver license:
The MI Driver code is under the University of Illinois Open Source License
agreement. Submitted by Codeplay Ltd UK.
+Source code found at: llvm/tools/lldb/tools/lldb-mi.
+
=========================================================================
The MI Driver uses the following libraries:
Standard Template library
diff --git a/lldb/tools/lldb-mi/MIUtilDateTimeStd.cpp b/lldb/tools/lldb-mi/MIUtilDateTimeStd.cpp
index c3760adc2f5..9938deb131c 100644
--- a/lldb/tools/lldb-mi/MIUtilDateTimeStd.cpp
+++ b/lldb/tools/lldb-mi/MIUtilDateTimeStd.cpp
@@ -19,12 +19,6 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
-// Third party headers
-#include <time.h>
-
// In-house headers:
#include "MIUtilDateTimeStd.h"
#include "MICmnResources.h"
@@ -52,20 +46,21 @@ CMIUtilDateTimeStd::~CMIUtilDateTimeStd( void )
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve system local current date. Format is DD/MM/YYYY.
+// Details: Retrieve system local current date. Format is MM/DD/YYYY.
// Type: Method.
// Args: None.
// Return: CMIUtilString - Text description.
// Throws: None.
//--
-CMIUtilString CMIUtilDateTimeStd::GetDate( void ) const
+CMIUtilString CMIUtilDateTimeStd::GetDate( void )
{
CMIUtilString strDate( MIRSRC( IDS_WORD_INVALIDBRKTS ) );
- CMIUtilString localDate;
- CMIUtilString localTime;
- if( GetDateTimeShort( localDate, localTime ) )
- strDate = localDate;
+ std::time( &m_rawTime );
+ const std::tm * pTi = std::localtime( &m_rawTime );
+ if( std::strftime( &m_pScratch[ 0 ], sizeof( m_pScratch ), "%d/%m/%y", pTi ) > 0 )
+ strDate = m_pScratch;
+
return strDate;
}
@@ -76,34 +71,14 @@ CMIUtilString CMIUtilDateTimeStd::GetDate( void ) const
// Return: CMIUtilString - Text description.
// Throws: None.
//--
-CMIUtilString CMIUtilDateTimeStd::GetTime( void ) const
+CMIUtilString CMIUtilDateTimeStd::GetTime( void )
{
- CMIUtilString strTime( MIRSRC( IDS_WORD_INVALIDBRKTS ) );
- CMIUtilString localDate;
- CMIUtilString localTime;
- if( GetDateTimeShort( localDate, localTime ) )
- strTime = localTime;
-
+ std::time( &m_rawTime );
+ const std::tm * pTi = std::localtime( &m_rawTime );
+ const CMIUtilString seconds( CMIUtilString::Format( "%d", pTi->tm_sec ) );
+ const CMIUtilString zero( (seconds.length() == 1) ? "0" : "" );
+ const CMIUtilString strTime( CMIUtilString::Format( "%d:%d:%s%s", pTi->tm_hour, pTi->tm_min, zero.c_str(), seconds.c_str() ) );
+
return strTime;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve system local time and date, short version.
-// Type: Method.
-// Args: vrwLocalDate - (W) Text date. Format is DD/MM/YYYY.
-// vrwLocalTime - (W) Text time. Format is HH:MM:SS 24 hour clock.
-// Return: MIstatus::success - Functional succeeded.
-// MIstatus::failure - Functional failed.
-// Throws: None.
-//--
-bool CMIUtilDateTimeStd::GetDateTimeShort( CMIUtilString & vrwLocalDate, CMIUtilString & vrwLocalTime ) const
-{
- time_t rawTime;
- ::time( &rawTime );
- struct tm * pTi = ::localtime( &rawTime );
-
- vrwLocalDate = CMIUtilString::Format( "%d/%d/%d", pTi->tm_wday, pTi->tm_mon, pTi->tm_year );
- vrwLocalTime = CMIUtilString::Format( "%d:%d:%d", pTi->tm_hour, pTi->tm_min, pTi->tm_sec );
-
- return MIstatus::success;
-}
diff --git a/lldb/tools/lldb-mi/MIUtilDateTimeStd.h b/lldb/tools/lldb-mi/MIUtilDateTimeStd.h
index 4e88dff62b5..da857d6358e 100644
--- a/lldb/tools/lldb-mi/MIUtilDateTimeStd.h
+++ b/lldb/tools/lldb-mi/MIUtilDateTimeStd.h
@@ -21,8 +21,8 @@
#pragma once
-// Include compiler configuration
-#include "MICmnConfig.h"
+// Third party headers
+#include <ctime>
// In-house headers:
#include "MIUtilString.h"
@@ -31,7 +31,7 @@
// Details: MI common code utility class. Used to retrieve system local date
// time.
// Gotchas: None.
-// Authors: Aidan Dodds 10/03/2014.
+// Authors: Illya Rudkin 16/07/2014.
// Changes: None.
//--
class CMIUtilDateTimeStd
@@ -40,15 +40,16 @@ class CMIUtilDateTimeStd
public:
/* ctor */ CMIUtilDateTimeStd( void );
- CMIUtilString GetDate( void ) const;
- CMIUtilString GetTime( void ) const;
+ CMIUtilString GetDate( void );
+ CMIUtilString GetTime( void );
// Overrideable:
public:
// From CMICmnBase
/* dtor */ virtual ~CMIUtilDateTimeStd( void );
-// Methods:
+// Attributes:
private:
- bool GetDateTimeShort( CMIUtilString & vrwLocalDate, CMIUtilString & vrwLocalTime ) const;
+ std::time_t m_rawTime;
+ MIchar m_pScratch[ 16 ];
};
diff --git a/lldb/tools/lldb-mi/MIUtilFileStd.cpp b/lldb/tools/lldb-mi/MIUtilFileStd.cpp
index b2dd2061b97..1f17b0875c0 100644
--- a/lldb/tools/lldb-mi/MIUtilFileStd.cpp
+++ b/lldb/tools/lldb-mi/MIUtilFileStd.cpp
@@ -19,9 +19,6 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
// Third party headers
#include <stdio.h>
#include <assert.h>
diff --git a/lldb/tools/lldb-mi/MIUtilFileStd.h b/lldb/tools/lldb-mi/MIUtilFileStd.h
index dd8235eb792..b6655b2ecfe 100644
--- a/lldb/tools/lldb-mi/MIUtilFileStd.h
+++ b/lldb/tools/lldb-mi/MIUtilFileStd.h
@@ -22,7 +22,6 @@
#pragma once
// In-house headers:
-#include "MICmnConfig.h"
#include "MIUtilString.h"
#include "MICmnBase.h"
diff --git a/lldb/tools/lldb-mi/MIUtilSingletonHelper.h b/lldb/tools/lldb-mi/MIUtilSingletonHelper.h
index ab8d0789e37..01bcc4f5bf9 100644
--- a/lldb/tools/lldb-mi/MIUtilSingletonHelper.h
+++ b/lldb/tools/lldb-mi/MIUtilSingletonHelper.h
@@ -37,8 +37,8 @@ namespace MI
// Type: Template method.
// Args: vErrorResrcId - (R) The string resource ID error message identifier to place in errMsg.
// vwrbOk - (RW) On input True = Try to initalise MI driver module.
-// On output True = MI driver module initialise successfully.
-// vwrErrMsg - (W) MI driver module initialise error description on failure.
+// On output True = MI driver module intialise successfully.
+// vwrErrMsg - (W) MI driver module intialise error description on failure.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Authors: Aidan Dodds 17/03/2014.
@@ -65,7 +65,7 @@ bool ModuleInit( const MIint vErrorResrcId, bool & vwrbOk, CMIUtilString & vwrEr
// vwrbOk - (W) If not already false make false on module
// shutdown failure.
// vwrErrMsg - (RW) Append to existing error description string MI
-// driver module initialise error description on
+// driver module intialise error description on
// failure.
// Return: True - Module shutdown succeeded.
// False - Module shutdown failed.
diff --git a/lldb/tools/lldb-mi/MIUtilString.cpp b/lldb/tools/lldb-mi/MIUtilString.cpp
index 2ca5a82701f..11c246290ca 100644
--- a/lldb/tools/lldb-mi/MIUtilString.cpp
+++ b/lldb/tools/lldb-mi/MIUtilString.cpp
@@ -261,7 +261,9 @@ MIuint CMIUtilString::Split( const CMIUtilString & vDelimiter, VecString_t & vwV
// Details: Splits string into array of strings using delimiter. However the string is
// also considered for text surrounded by quotes. Text with quotes including the
// delimiter is treated as a whole. If multiple delimiter are found in sequence
-// then they are not added to the list of splits.
+// then they are not added to the list of splits. Quotes that are embedded in the
+// the string as string formatted quotes are ignored (proceeded by a '\\') i.e.
+// "\"MI GDB local C++.cpp\":88".
// Type: Method.
// Args: vData - (R) String data to be split up.
// vDelimiter - (R) Delimiter char or text.
@@ -291,12 +293,20 @@ MIuint CMIUtilString::SplitConsiderQuotes( const CMIUtilString & vDelimiter, Vec
// Look for more quotes
bool bHaveQuotes = false;
+ const MIchar cBckSlash = '\\';
const MIchar cQuote = '"';
MIint nPosQ = find( cQuote );
MIint nPosQ2 = (MIint) std::string::npos;
if( nPosQ != (MIint) std::string::npos )
{
- nPosQ2 = find( cQuote, nPosQ + 1 );
+ nPosQ2 = nPosQ + 1;
+ while( nPosQ2 < strLen )
+ {
+ nPosQ2 = find( cQuote, nPosQ2 );
+ if( (nPosQ2 == (MIint) std::string::npos) || (at( nPosQ2 - 1 ) != cBckSlash) )
+ break;
+ nPosQ2++;
+ }
bHaveQuotes = (nPosQ2 != (MIint) std::string::npos);
}
@@ -557,7 +567,7 @@ CMIUtilString CMIUtilString::Trim( void ) const
CMIUtilString CMIUtilString::Trim( const MIchar vChar ) const
{
CMIUtilString strNew( *this );
- const MIuint nLen = strNew.length();
+ const MIint nLen = strNew.length();
if( nLen > 1 )
{
if( (strNew[ 0 ] == vChar) && (strNew[ nLen - 1 ] == vChar) )
@@ -602,3 +612,69 @@ CMIUtilString CMIUtilString::FormatBinary( const MIuint64 vnDecimal )
return strBinaryNumber;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Remove from a string doubled up characters so only one set left. Characters
+// are only removed if the previous character is already a same character.
+// Type: Method.
+// Args: vChar - (R) The character to search for and remove adjacent duplicates.
+// Return: CMIUtilString - New version of the string.
+// Throws: None.
+//--
+CMIUtilString CMIUtilString::RemoveRepeatedCharacters( const MIchar vChar )
+{
+ return RemoveRepeatedCharacters( 0, vChar );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Recursively remove from a string doubled up characters so only one set left.
+// Characters are only removed if the previous character is already a same
+// character.
+// Type: Method.
+// Args: vChar - (R) The character to search for and remove adjacent duplicates.
+// vnPos - (R) Character position in the string.
+// Return: CMIUtilString - New version of the string.
+// Throws: None.
+//--
+CMIUtilString CMIUtilString::RemoveRepeatedCharacters( const MIint vnPos, const MIchar vChar )
+{
+ const MIchar cQuote = '"';
+
+ // Look for first quote of two
+ MIint nPos = find( cQuote, vnPos );
+ if( nPos == (MIint) std::string::npos )
+ return *this;
+
+ const MIint nPosNext = nPos + 1;
+ if( nPosNext > (MIint) length() )
+ return *this;
+
+ if( at( nPosNext ) == cQuote )
+ {
+ *this = substr( 0, nPos ) + substr( nPosNext, length() );
+ RemoveRepeatedCharacters( nPosNext, vChar );
+ }
+
+ return *this;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Is the text in *this string surrounded by quotes.
+// Type: Method.
+// Args: None.
+// Return: bool - True = Yes string is quoted, false = no quoted.
+// Throws: None.
+//--
+bool CMIUtilString::IsQuoted( void ) const
+{
+ const MIchar cQuote = '"';
+
+ if( at( 0 ) != cQuote )
+ return false;
+
+ const MIint nLen = length();
+ if( (nLen > 0) && (at( nLen - 1 ) != cQuote) )
+ return false;
+
+ return true;
+}
+ \ No newline at end of file
diff --git a/lldb/tools/lldb-mi/MIUtilString.h b/lldb/tools/lldb-mi/MIUtilString.h
index a52cddfd304..30b027a9d31 100644
--- a/lldb/tools/lldb-mi/MIUtilString.h
+++ b/lldb/tools/lldb-mi/MIUtilString.h
@@ -55,15 +55,17 @@ public:
/* ctor */ CMIUtilString( const MIchar * vpData );
/* ctor */ CMIUtilString( const MIchar * const * vpData );
//
+ bool ExtractNumber( MIint64 & vwrNumber ) const;
+ CMIUtilString FindAndReplace( const CMIUtilString & vFind, const CMIUtilString & vReplaceWith ) const;
+ bool IsNumber( void ) const;
+ bool IsQuoted( void ) const;
+ CMIUtilString RemoveRepeatedCharacters( const MIchar vChar );
MIuint Split( const CMIUtilString & vDelimiter, VecString_t & vwVecSplits ) const;
MIuint SplitConsiderQuotes( const CMIUtilString & vDelimiter, VecString_t & vwVecSplits ) const;
- CMIUtilString Trim( void ) const;
- CMIUtilString Trim( const MIchar vChar ) const;
CMIUtilString StripCREndOfLine( void ) const;
CMIUtilString StripCRAll( void ) const;
- CMIUtilString FindAndReplace( const CMIUtilString & vFind, const CMIUtilString & vReplaceWith ) const;
- bool IsNumber( void ) const;
- bool ExtractNumber( MIint64 & vwrNumber ) const;
+ CMIUtilString Trim( void ) const;
+ CMIUtilString Trim( const MIchar vChar ) const;
//
CMIUtilString & operator= ( const MIchar * vpRhs );
CMIUtilString & operator= ( const std::string & vrRhs );
@@ -78,5 +80,6 @@ private:
// Methods:
private:
- bool ExtractNumberFromHexadecimal( MIint64 & vwrNumber ) const;
+ bool ExtractNumberFromHexadecimal( MIint64 & vwrNumber ) const;
+ CMIUtilString RemoveRepeatedCharacters( const MIint vnPos, const MIchar vChar );
};
diff --git a/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp b/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp
index 9c4deb45d9d..d23c1646055 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp
+++ b/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp
@@ -19,10 +19,7 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
-#if defined( __FreeBSD__ ) || defined( __linux__ )
+#if defined( __FreeBSD__ ) || defined( __linux )
// In-house headers:
#include "MIUtilSystemLinux.h"
@@ -119,4 +116,4 @@ bool CMIUtilSystemLinux::GetLogFilesPath( CMIUtilString & vrwFileNamePath ) cons
return MIstatus::success;
}
-#endif // #if defined( __linux__ )
+#endif // #if defined( __linux )
diff --git a/lldb/tools/lldb-mi/MIUtilSystemLinux.h b/lldb/tools/lldb-mi/MIUtilSystemLinux.h
index 0d9062a7595..c0276a4619a 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemLinux.h
+++ b/lldb/tools/lldb-mi/MIUtilSystemLinux.h
@@ -21,10 +21,7 @@
#pragma once
-// Include compiler configuration
-#include "MICmnConfig.h"
-
-#if defined( __FreeBSD__ ) || defined( __linux__ )
+#if defined( __FreeBSD__ ) || defined( __linux )
// In-house headers:
#include "MIUtilString.h"
@@ -57,4 +54,4 @@ public:
typedef CMIUtilSystemLinux CMIUtilSystem;
-#endif // #if defined( __linux__ )
+#endif // #if defined( __linux )
diff --git a/lldb/tools/lldb-mi/MIUtilSystemOsx.cpp b/lldb/tools/lldb-mi/MIUtilSystemOsx.cpp
index 06de41c4ab7..e291304789d 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemOsx.cpp
+++ b/lldb/tools/lldb-mi/MIUtilSystemOsx.cpp
@@ -19,9 +19,6 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
#if defined( __APPLE__ )
// In-house headers:
diff --git a/lldb/tools/lldb-mi/MIUtilSystemOsx.h b/lldb/tools/lldb-mi/MIUtilSystemOsx.h
index 3832b43b16d..d0825c6e344 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemOsx.h
+++ b/lldb/tools/lldb-mi/MIUtilSystemOsx.h
@@ -21,9 +21,6 @@
#pragma once
-// Include compiler configuration
-#include "MICmnConfig.h"
-
#if defined( __APPLE__ )
// In-house headers:
diff --git a/lldb/tools/lldb-mi/MIUtilSystemWindows.cpp b/lldb/tools/lldb-mi/MIUtilSystemWindows.cpp
index 9449f6787ed..5873aad0ec6 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemWindows.cpp
+++ b/lldb/tools/lldb-mi/MIUtilSystemWindows.cpp
@@ -19,9 +19,6 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
#if defined( _MSC_VER )
// Third party headers
diff --git a/lldb/tools/lldb-mi/MIUtilSystemWindows.h b/lldb/tools/lldb-mi/MIUtilSystemWindows.h
index 54b824edced..c0d8b543a2f 100644
--- a/lldb/tools/lldb-mi/MIUtilSystemWindows.h
+++ b/lldb/tools/lldb-mi/MIUtilSystemWindows.h
@@ -20,9 +20,6 @@
//--
#pragma once
-// Include compiler configuration
-#include "MICmnConfig.h"
-
#if defined( _MSC_VER )
// In-house headers:
diff --git a/lldb/tools/lldb-mi/MIUtilThreadBaseStd.cpp b/lldb/tools/lldb-mi/MIUtilThreadBaseStd.cpp
index eb45d394cb0..38f3eb4fae3 100644
--- a/lldb/tools/lldb-mi/MIUtilThreadBaseStd.cpp
+++ b/lldb/tools/lldb-mi/MIUtilThreadBaseStd.cpp
@@ -21,9 +21,6 @@
// Copyright: None.
//--
-// Include compiler configuration
-#include "MICmnConfig.h"
-
// Third Party Headers:
#include <assert.h>
diff --git a/lldb/tools/lldb-mi/MIUtilThreadBaseStd.h b/lldb/tools/lldb-mi/MIUtilThreadBaseStd.h
index 2beae347910..277e14c0fc8 100644
--- a/lldb/tools/lldb-mi/MIUtilThreadBaseStd.h
+++ b/lldb/tools/lldb-mi/MIUtilThreadBaseStd.h
@@ -32,7 +32,6 @@
#include <mutex>
// In-house headers:
-#include "MICmnConfig.h"
#include "MIDataTypes.h"
#include "MIUtilString.h"
diff --git a/lldb/tools/lldb-mi/MIUtilVariant.cpp b/lldb/tools/lldb-mi/MIUtilVariant.cpp
index 91709d5417d..1c9ea1c9697 100644
--- a/lldb/tools/lldb-mi/MIUtilVariant.cpp
+++ b/lldb/tools/lldb-mi/MIUtilVariant.cpp
@@ -48,6 +48,30 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase( const CDataObjectBase & vrOthe
}
//++ ------------------------------------------------------------------------------------
+// Details: CDataObjectBase copy constructor.
+// Type: Method.
+// Args: vrOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant::CDataObjectBase::CDataObjectBase( CDataObjectBase & vrOther )
+{
+ MIunused( vrOther );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CDataObjectBase move constructor.
+// Type: Method.
+// Args: vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant::CDataObjectBase::CDataObjectBase( CDataObjectBase && vrwOther )
+{
+ MIunused( vrwOther );
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: CDataObjectBase destructor.
// Type: Overrideable.
// Args: None.
@@ -56,10 +80,11 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase( const CDataObjectBase & vrOthe
//--
CMIUtilVariant::CDataObjectBase::~CDataObjectBase( void )
{
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
-// Details: CDataObjectBase copy operator.
+// Details: CDataObjectBase copy assignment.
// Type: Method.
// Args: vrOther - (R) The other object.
// Return: None.
@@ -67,7 +92,21 @@ CMIUtilVariant::CDataObjectBase::~CDataObjectBase( void )
//--
CMIUtilVariant::CDataObjectBase & CMIUtilVariant::CDataObjectBase::operator= ( const CDataObjectBase & vrOther )
{
- MIunused( vrOther );
+ Copy( vrOther );
+ return *this;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CDataObjectBase move assignment.
+// Type: Method.
+// Args: vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant::CDataObjectBase & CMIUtilVariant::CDataObjectBase::operator= ( CDataObjectBase && vrwOther )
+{
+ Copy( vrwOther );
+ vrwOther.Destroy();
return *this;
}
@@ -110,6 +149,18 @@ void CMIUtilVariant::CDataObjectBase::Copy( const CDataObjectBase & vrOther )
MIunused( vrOther );
}
+//++ ------------------------------------------------------------------------------------
+// Details: Release any resources used by *this object.
+// Type: Overrideable.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+void CMIUtilVariant::CDataObjectBase::Destroy( void )
+{
+ // Do nothing - override to implement
+}
+
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
@@ -127,12 +178,44 @@ CMIUtilVariant::CDataObject< T >::CDataObject( const CDataObject & vrOther )
{
if( this == &vrOther )
return;
- CDataObjectBase::Copy( vrOther );
Copy( vrOther );
}
//++ ------------------------------------------------------------------------------------
-// Details: CDataObject copy operator.
+// Details: CDataObject copy constructor.
+// Type: Method.
+// Args: T - The object's type.
+// vrOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+template< typename T >
+CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject & vrOther )
+{
+ if( this == &vrOther )
+ return;
+ Copy( vrOther );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CDataObject move constructor.
+// Type: Method.
+// Args: T - The object's type.
+// vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+template< typename T >
+CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject && vrwOther )
+{
+ if( this == &vrwOther )
+ return;
+ Copy( vrwOther );
+ vrwOther.Destroy();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CDataObject copy assignment.
// Type: Method.
// Args: T - The object's type.
// vrOther - (R) The other object.
@@ -144,11 +227,28 @@ CMIUtilVariant::CDataObject< T > & CMIUtilVariant::CDataObject< T >::operator= (
{
if( this == &vrOther )
return *this;
- CDataObjectBase::Copy( vrOther );
Copy( vrOther );
return *this;
}
+//++ ------------------------------------------------------------------------------------
+// Details: CDataObject move assignment.
+// Type: Method.
+// Args: T - The object's type.
+// vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+template< typename T >
+CMIUtilVariant::CDataObject< T > & CMIUtilVariant::CDataObject< T >::operator= ( CDataObject && vrwOther )
+{
+ if( this == &vrwOther )
+ return *this;
+ Copy( vrwOther );
+ vrwOther.Destroy();
+ return *this;
+}
+
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
@@ -182,6 +282,39 @@ CMIUtilVariant::CMIUtilVariant( const CMIUtilVariant & vrOther )
}
//++ ------------------------------------------------------------------------------------
+// Details: CMIUtilVariant copy constructor.
+// Type: Method.
+// Args: vrOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant::CMIUtilVariant( CMIUtilVariant & vrOther )
+: m_pDataObject( nullptr )
+{
+ if( this == &vrOther )
+ return;
+
+ Copy( vrOther );
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: CMIUtilVariant move constructor.
+// Type: Method.
+// Args: vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant::CMIUtilVariant( CMIUtilVariant && vrwOther )
+: m_pDataObject( nullptr )
+{
+ if( this == &vrwOther )
+ return;
+
+ Copy( vrwOther );
+ vrwOther.Destroy();
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: CMIUtilVariant destructor.
// Type: Method.
// Args: None.
@@ -194,7 +327,7 @@ CMIUtilVariant::~CMIUtilVariant( void )
}
//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilVariant copy operator.
+// Details: CMIUtilVariant copy assignment.
// Type: Method.
// Args: vrOther - (R) The other object.
// Return: None.
@@ -210,6 +343,23 @@ CMIUtilVariant & CMIUtilVariant::operator= ( const CMIUtilVariant & vrOther )
}
//++ ------------------------------------------------------------------------------------
+// Details: CMIUtilVariant move assignment.
+// Type: Method.
+// Args: vrwOther - (R) The other object.
+// Return: None.
+// Throws: None.
+//--
+CMIUtilVariant & CMIUtilVariant::operator= ( CMIUtilVariant && vrwOther )
+{
+ if( this == &vrwOther )
+ return *this;
+
+ Copy( vrwOther );
+ vrwOther.Destroy();
+ return *this;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Release the resources used by *this object.
// Type: Method.
// Args: None.
@@ -225,9 +375,6 @@ void CMIUtilVariant::Destroy( void )
//++ ------------------------------------------------------------------------------------
// Details: Bitwise copy another data object to *this variant object.
-// Because *this Variant class does not store the type of the object
-// held it performs a bitwise copy of the data object whenever the variant
-// object is copied. This could lead to issues.
// Type: Method.
// Args: vrOther - (R) The other object.
// Return: None.
@@ -242,3 +389,4 @@ void CMIUtilVariant::Copy( const CMIUtilVariant & vrOther )
m_pDataObject = vrOther.m_pDataObject->CreateCopyOfSelf();
}
}
+
diff --git a/lldb/tools/lldb-mi/MIUtilVariant.h b/lldb/tools/lldb-mi/MIUtilVariant.h
index b0eb9b78793..3cb59796e5c 100644
--- a/lldb/tools/lldb-mi/MIUtilVariant.h
+++ b/lldb/tools/lldb-mi/MIUtilVariant.h
@@ -42,6 +42,8 @@ class CMIUtilVariant
public:
/* ctor */ CMIUtilVariant( void );
/* ctor */ CMIUtilVariant( const CMIUtilVariant & vrOther );
+ /* ctor */ CMIUtilVariant( CMIUtilVariant & vrOther );
+ /* ctor */ CMIUtilVariant( CMIUtilVariant && vrwOther );
/* dtor */ ~CMIUtilVariant( void );
template< typename T >
@@ -50,6 +52,7 @@ public:
T * Get( void ) const;
CMIUtilVariant & operator= ( const CMIUtilVariant & vrOther );
+ CMIUtilVariant & operator= ( CMIUtilVariant && vrwOther );
// Classes:
private:
@@ -65,8 +68,11 @@ private:
public:
/* ctor */ CDataObjectBase( void );
/* ctor */ CDataObjectBase( const CDataObjectBase & vrOther );
+ /* ctor */ CDataObjectBase( CDataObjectBase & vrOther );
+ /* ctor */ CDataObjectBase( CDataObjectBase && vrwOther );
//
CDataObjectBase & operator= ( const CDataObjectBase & vrOther ) ;
+ CDataObjectBase & operator= ( CDataObjectBase && vrwOther ) ;
// Overrideable:
public:
@@ -77,6 +83,7 @@ private:
// Overrideable:
protected:
virtual void Copy( const CDataObjectBase & vrOther );
+ virtual void Destroy( void );
};
//++ ----------------------------------------------------------------------
@@ -87,18 +94,18 @@ private:
template< typename T >
class CDataObject : public CDataObjectBase
{
- // Statics:
- public:
-
// Methods:
public:
/* ctor */ CDataObject( void );
/* ctor */ CDataObject( const T & vArg );
/* ctor */ CDataObject( const CDataObject & vrOther );
+ /* ctor */ CDataObject( CDataObject & vrOther );
+ /* ctor */ CDataObject( CDataObject && vrwOther );
//
CDataObject & operator= ( const CDataObject & vrOther );
- //
- T & GetDataObject( void );
+ CDataObject & operator= ( CDataObject && vrwOther );
+ //
+ T & GetDataObject( void );
// Overridden:
public:
@@ -111,6 +118,7 @@ private:
private:
// From CDataObjectBase
virtual void Copy( const CDataObject & vrOther );
+ virtual void Destroy( void );
// Attributes:
private:
@@ -167,6 +175,7 @@ CMIUtilVariant::CDataObject< T >::CDataObject( const T & vArg )
template< typename T >
CMIUtilVariant::CDataObject< T >::~CDataObject( void )
{
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
@@ -222,9 +231,23 @@ bool CMIUtilVariant::CDataObject< T >::GetIsDerivedClass( void ) const
template< typename T >
void CMIUtilVariant::CDataObject< T >::Copy( const CDataObject & vrOther )
{
+ CDataObjectBase::Copy( vrOther );
m_dataObj = vrOther.m_dataObj;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Release any resources used by *this object.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+template< typename T >
+void CMIUtilVariant::CDataObject< T >::Destroy( void )
+{
+ CDataObjectBase::Destroy();
+}
+
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
@@ -261,4 +284,5 @@ T * CMIUtilVariant::Get( void ) const
// Do not use a CDataObjectBase object, use only CDataObjectBase derived objects
return nullptr;
-} \ No newline at end of file
+}
+
OpenPOWER on IntegriCloud