예제 #1
0
bool LLDBDebugger::Run( const wxString &in, const wxString& out, const wxString &err, 
                        const wxArrayString& argvArr,
                        const wxArrayString& envArr,
                        const wxString &workingDirectory)
{
    if ( m_thread ) {
        return false;
    }
    
    if ( m_debugger.IsValid() ) {
        // Construct char** arrays
        const char** argv = (const char**)_wxArrayStringToCharPtrPtr(argvArr);
        const char** envp = (const char**)_wxArrayStringToCharPtrPtr(envArr);
        const char* pin  = in.mb_str(wxConvUTF8).data();
        const char* pout = out.mb_str(wxConvUTF8).data();
        const char* perr = err.mb_str(wxConvUTF8).data();
        const char* wd = workingDirectory.mb_str(wxConvUTF8).data();
        
        wxUnusedVar(pin);
        wxUnusedVar(pout);
        wxUnusedVar(perr);
        
        lldb::SBLaunchInfo launchInfo(argv);
        lldb::SBError error;
        
        // Set the launch flags
        launchInfo.SetLaunchFlags(lldb::eLaunchFlagStopAtEntry | lldb::eLaunchFlagLaunchInSeparateProcessGroup);
        launchInfo.SetEnvironmentEntries(envp, false);
        launchInfo.SetWorkingDirectory(wd);
        launchInfo.AddOpenFileAction(STDIN_FILENO,  pin,  true, false);
        launchInfo.AddOpenFileAction(STDERR_FILENO, perr, false, true);
        launchInfo.AddOpenFileAction(STDOUT_FILENO, pout, false, true);
        bool isOk = m_target.Launch(launchInfo, error).IsValid();
        
        //bool isOk = m_target.LaunchSimple(argv, envp, wd).IsValid();
        _deleteCharPtrPtr( const_cast<char**>(argv) );
        _deleteCharPtrPtr( const_cast<char**>(envp) );
        if ( !isOk ) {
            Cleanup();
            NotifyExited();
        }
        
        m_debugeePid = m_target.GetProcess().GetProcessID();
        m_thread = new LLDBDebuggerThread(this, m_debugger.GetListener(), m_target.GetProcess());
        m_thread->Start();
        return isOk;
    }
    return false;
}
예제 #2
0
void onRun(LLDBPlugin* plugin)
{
    // if we haven't started the executable start it here

    if (plugin->state == PDDebugState_NoTarget)
    {
        lldb::SBLaunchInfo launchInfo(0);
        lldb::SBError error;

        plugin->process = plugin->target.Launch(launchInfo, error);

        printf("try start\n");

        if (!error.Success())
        {
			//s_messageFuncs->error("Error to start executable", "The LLDB backend was unable to start the selected executable. Currently ProDBG requires the user to run it as sudo due to the fact that debugging on Mac needs that. This will be made a bit more friendly in the future");
			printf("Error to start executable\nThe LLDB backend was unable to start the selected executable. Currently ProDBG requires the user to run it as sudo due to the fact that debugging on Mac needs that. This will be made a bit more friendly in the future\n");
            return;
        }

        if (!plugin->process.IsValid())
        {
            printf("process not valid\n");
            return;
        }

        printf("Started valid process\n");

        plugin->process.GetBroadcaster().AddListener(
                plugin->listener,
                lldb::SBProcess::eBroadcastBitStateChanged |
                lldb::SBProcess::eBroadcastBitInterrupt);

        plugin->state = PDDebugState_Running;
        plugin->hasValidTarget = true;

        return;
    }

    plugin->process.Continue();
    plugin->state = PDDebugState_Running;
}