Author: abidh
Date: Thu Aug 14 11:40:27 2014
New Revision: 215656

URL: http://llvm.org/viewvc/llvm-project?rev=215656&view=rev
Log:
Implementation of exec-run using lldb API.

Previously it was using run command which did not set the process
pointer in the sessionInfo. This commit also sends the proper
out-of-band data.

Modified:
    lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=215656&r1=215655&r2=215656&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Thu Aug 14 11:40:27 2014
@@ -28,6 +28,9 @@
 
 // Third Party Headers:
 #include <lldb/API/SBCommandInterpreter.h>
+#include <lldb/API/SBProcess.h>
+#include <lldb/API/SBStream.h>
+#include "lldb/lldb-enumerations.h"
 
 // In-house headers:
 #include "MICmdCmdExec.h"
@@ -83,20 +86,29 @@ CMICmdCmdExecRun::~CMICmdCmdExecRun( voi
 //--
 bool CMICmdCmdExecRun::Execute( void )
 {
-    const MIchar * pCmd = "run";
     CMICmnLLDBDebugSessionInfo & rSessionInfo( 
CMICmnLLDBDebugSessionInfo::Instance() );
-    const lldb::ReturnStatus rtn = 
rSessionInfo.m_rLldbDebugger.GetCommandInterpreter().HandleCommand( pCmd, 
m_lldbResult ); MIunused( rtn );
-       
-       if( m_lldbResult.GetErrorSize() == 0 )
+    lldb::SBError error;
+    lldb::SBStream errMsg;
+    uint32_t launch_flags = lldb::LaunchFlags::eLaunchFlagDebug;
+    lldb::SBProcess process = rSessionInfo.m_lldbTarget.Launch 
(rSessionInfo.m_rLlldbListener,
+                nullptr, nullptr, nullptr, nullptr, nullptr,
+                nullptr, launch_flags, false, error);
+
+       if( (!process.IsValid()) || (error.Fail()) )
        {
-               if( !CMIDriver::Instance().SetDriverStateRunningDebugging() )
-               {
-                       const CMIUtilString & rErrMsg( 
CMIDriver::Instance().GetErrorDescription() );
-                       SetError( CMIUtilString::Format( MIRSRC( 
IDS_CMD_ERR_SET_NEW_DRIVER_STATE ), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str() 
) );
-                       return MIstatus::failure;
-               }
+               SetError( CMIUtilString::Format( MIRSRC( 
IDS_CMD_ERR_INVALID_PROCESS ), m_cmdData.strMiCmd.c_str(), errMsg.GetData() ) );
+               return MIstatus::failure;
        }
 
+       // Save the process in the session info
+       rSessionInfo.m_lldbProcess = process;
+
+       if( !CMIDriver::Instance().SetDriverStateRunningDebugging() )
+       {
+               const CMIUtilString & rErrMsg( 
CMIDriver::Instance().GetErrorDescription() );
+               SetError( CMIUtilString::Format( MIRSRC( 
IDS_CMD_ERR_SET_NEW_DRIVER_STATE ), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str() 
) );
+               return MIstatus::failure;
+       }
         return MIstatus::success;
 }
 
@@ -122,6 +134,19 @@ bool CMICmdCmdExecRun::Acknowledge( void
     {
         const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, 
CMICmnMIResultRecord::eResultClass_Running );
         m_miResultRecord = miRecordResult;
+
+       CMICmnLLDBDebugSessionInfo & rSessionInfo( 
CMICmnLLDBDebugSessionInfo::Instance() );
+       lldb::pid_t pid = rSessionInfo.m_lldbProcess.GetProcessID();
+       // Give the client '=thread-group-started,id="i1" pid="xyz"'
+       m_bHasResultRecordExtra = true;
+       const CMICmnMIValueConst miValueConst2( "i1" );
+       const CMICmnMIValueResult miValueResult2( "id", miValueConst2 );
+       const CMIUtilString strPid( CMIUtilString::Format( "%lld", pid ) );
+       const CMICmnMIValueConst miValueConst( strPid );
+       const CMICmnMIValueResult miValueResult( "pid", miValueConst );
+       CMICmnMIOutOfBandRecord miOutOfBand( 
CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2 );
+       miOutOfBand.Add( miValueResult );
+       m_miResultRecordExtra = miOutOfBand.GetString();
     }
        
        return MIstatus::success;


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to