Esempio n. 1
0
wxString ClangPlugin::GetCompilerInclDirs(const wxString& compId)
{
    std::map<wxString, wxString>::const_iterator idItr = m_compInclDirs.find(compId);
    if (idItr != m_compInclDirs.end())
        return idItr->second;

    Compiler* comp = CompilerFactory::GetCompiler(compId);
    wxFileName fn(wxEmptyString, comp->GetPrograms().CPP);
    wxString masterPath = comp->GetMasterPath();
    Manager::Get()->GetMacrosManager()->ReplaceMacros(masterPath);
    fn.SetPath(masterPath);
    if (!fn.FileExists())
        fn.AppendDir(wxT("bin"));
#ifdef __WXMSW__
    wxString command = fn.GetFullPath() + wxT(" -v -E -x c++ nul");
#else
    wxString command = fn.GetFullPath() + wxT(" -v -E -x c++ /dev/null");
#endif // __WXMSW__
    wxArrayString output, errors;
    wxExecute(command, output, errors, wxEXEC_NODISABLE);

    wxArrayString::const_iterator errItr = errors.begin();
    for (; errItr != errors.end(); ++errItr)
    {
        if (errItr->IsSameAs(wxT("#include <...> search starts here:")))
        {
            ++errItr;
            break;
        }
    }
    wxString includeDirs;
    for (; errItr != errors.end(); ++errItr)
    {
        if (errItr->IsSameAs(wxT("End of search list.")))
            break;
        includeDirs += wxT(" -I") + errItr->Strip(wxString::both);
    }
    return m_compInclDirs.insert(std::pair<wxString, wxString>(compId, includeDirs)).first->second;
}
Esempio n. 2
0
AutoDetectResult CompilerICC::AutoDetectInstallationDir()
{
    wxString sep = wxFileName::GetPathSeparator();
    wxString extraDir = _T("");
    if (platform::windows)
    {
        if (wxDirExists(_T("C:\\Program Files\\Intel\\Compiler")))
        {
            wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++"));
            if (icc_dir.IsOpened())
            {
                wxArrayString dirs;
                wxIccDirTraverser IccDirTraverser(dirs);
                icc_dir.Traverse(IccDirTraverser);
                if (!dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    dirs.Sort(true);
                    m_MasterPath = dirs[0];
                    m_MasterPath.Append(_T("\\IA32"));

                    // Now check for the installation of MSVC
                    const wxString msvcIds[4] = { _T("msvc6"),
                                                  _T("msvctk"),
                                                  _T("msvc8"),
                                                  _T("msvc10") };

                    bool msvcFound = false;
                    for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc)
                    {
                        Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]);
                        if (vcComp)
                        {
                            if (vcComp->AutoDetectInstallationDir() == adrDetected)
                            {
                                const wxString& vcMasterPath = vcComp->GetMasterPath();
                                if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND &&
                                    wxDirExists(vcMasterPath))
                                {
                                    m_ExtraPaths.Add(vcMasterPath);
                                }
                                AddIncludeDir(vcMasterPath + _T("\\Include"));
                                AddLibDir(vcMasterPath + _T("\\Lib"));
                                AddResourceIncludeDir(vcMasterPath + _T("\\Include"));

                                const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths();
                                for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i)
                                {
                                    if (m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND &&
                                        wxDirExists(vcExtraPaths[i]))
                                    {
                                        m_ExtraPaths.Add(vcExtraPaths[i]);
                                    }
                                }
                                const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs();
                                for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i)
                                {
                                    if (wxDirExists(vcIncludeDirs[i]))
                                    {
                                        if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND)
                                        {
                                            AddIncludeDir(vcIncludeDirs[i]);
                                        }
                                        if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND)
                                        {
                                            AddResourceIncludeDir(vcIncludeDirs[i]);
                                        }
                                    }
                                }
                                const wxArrayString& vcLibDirs = vcComp->GetLibDirs();
                                for (size_t i = 0; i < vcLibDirs.GetCount(); ++i)
                                {
                                    if (m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND &&
                                        wxDirExists(vcLibDirs[i]))
                                    {
                                        AddLibDir(vcLibDirs[i]);
                                    }
                                }
                                msvcFound = true;
                                break;
                            }
                        }
                    }

                    if (!msvcFound)
                    {
                        cbMessageBox(_T("It seems your computer doesn't have a working MSVC compiler.\n\n"
                                        "This compiler requires MS compiler for proper functioning and\n"
                                        "it may not work without it."),
                                     _T("Error"), wxOK | wxICON_ERROR);

                    }
                }
            }
        }

        // Read the ICPP_COMPILER90 environment variable
        wxGetEnv(_T("ICPP_COMPILER90"), &m_MasterPath);
        extraDir = sep + _T("IA32");// Intel also provides compiler for Itanium processors

        if (m_MasterPath.IsEmpty())
        {
            // just a guess the default installation dir
            wxString Programs = _T("C:\\Program Files");
            // what's the "Program Files" location
            // TO DO : support 64 bit ->    32 bit apps are in "ProgramFiles(x86)"
            //                              64 bit apps are in "ProgramFiles"
            wxGetEnv(_T("ProgramFiles"), &Programs);
            m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0");
        }
    }
    else
    {
        m_MasterPath = _T("/opt/intel/cc/9.0");
        if (wxDirExists(_T("/opt/intel")))
        {
            wxDir icc_dir(_T("/opt/intel/cc"));
            if (icc_dir.IsOpened())
            {
                wxArrayString dirs;
                wxIccDirTraverser IccDirTraverser(dirs);
                icc_dir.Traverse(IccDirTraverser);
                if (!dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    dirs.Sort(true);
                    m_MasterPath = dirs[0];
                }
            }
        }
    }

    AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed;
    if (ret == adrDetected)
    {
        m_IncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0);
        m_LibDirs.Insert(m_MasterPath + sep + _T("Lib"), 0);
        m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0);
    }
    // Try to detect the debugger. If not detected successfully the debugger plugin will
    // complain, so only the autodetection of compiler is considered in return value
    wxString path;
    wxString dbg;
    if (platform::windows)
    {
        dbg = _T("idb.exe");
        wxGetEnv(_T("IDB_PATH"), &path);
        path += _T("IDB\\9.0\\IA32");
    }
    else
    {
        dbg = _T("idb");
        path= _T("/opt/intel/idb/9.0");
        if (wxDirExists(_T("/opt/intel")))
        {
            wxDir icc_debug_dir(_T("/opt/intel/idb"));
            if (icc_debug_dir.IsOpened())
            {
                wxArrayString debug_dirs;
                wxIccDirTraverser IccDebugDirTraverser(debug_dirs);
                icc_debug_dir.Traverse(IccDebugDirTraverser);
                if (!debug_dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    debug_dirs.Sort(true);
                    path = debug_dirs[0];
                }
            }
        }
    }

    if (wxFileExists(path + sep + _T("bin") + sep + dbg))
        m_ExtraPaths.Add(path);

    return ret;
}
Esempio n. 3
0
AutoDetectResult CompilerICC::AutoDetectInstallationDir()
{
    wxString sep = wxFileName::GetPathSeparator();

    if (platform::windows)
    {
        if ( wxDirExists(_T("C:\\Program Files\\Intel\\Compiler")) )
        {
            wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++"));
            if (icc_dir.IsOpened())
            {
                wxArrayString dirs;
                wxIccDirTraverser IccDirTraverser(dirs);
                icc_dir.Traverse(IccDirTraverser);
                if (!dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    dirs.Sort(true);
                    m_MasterPath = dirs[0];
                    m_MasterPath.Append(_T("\\IA32"));
                }
            }
        }

        int version = 0;
        while ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) )
        {
            wxString iccEnvVar;
            if (version==0)
            {
                // Try default w/o version number
                iccEnvVar = _T("ICPP_COMPILER");
                version = 8;
            }
            else if (version>15)
                break;  // exit while-loop
            else
            {
                // Try ICPP_COMPILER80 ... ICPP_COMPILER12
                iccEnvVar.Printf(wxT("ICPP_COMPILER%d0"), version);
                version++;
            }

            // Read the ICPP_COMPILER[XX] environment variable
            if ( !wxGetEnv(iccEnvVar, &m_MasterPath) )
                m_MasterPath.Clear();
        }

        // Now check for the installation of MSVC
        const wxString msvcIds[4] = { _T("msvc6"),
                                      _T("msvctk"),
                                      _T("msvc8"),
                                      _T("msvc10") };
        bool msvcFound = false;
        for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc)
        {
            Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]);
            if (!vcComp)
                continue; // compiler not registered? try next one

            wxString vcMasterNoMacros = vcComp->GetMasterPath();
            Manager::Get()->GetMacrosManager()->ReplaceMacros(vcMasterNoMacros);
            if (   !wxFileExists(vcMasterNoMacros + sep + wxT("bin") + sep + vcComp->GetPrograms().C)
                && !wxFileExists(vcMasterNoMacros + sep + vcComp->GetPrograms().C) )
                continue; // this MSVC is not installed; try next one

            const wxString& vcMasterPath = vcComp->GetMasterPath();
            if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND)
                m_ExtraPaths.Add(vcMasterPath);
            if (  !vcMasterPath.EndsWith(wxT("bin"))
                && m_ExtraPaths.Index(vcMasterPath + sep + wxT("bin")) == wxNOT_FOUND )
            {
                m_ExtraPaths.Add(vcMasterPath + sep + wxT("bin"));
            }
            AddIncludeDir(vcMasterPath + _T("\\Include"));
            AddLibDir(vcMasterPath + _T("\\Lib"));
            AddResourceIncludeDir(vcMasterPath + _T("\\Include"));

            const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths();
            for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i)
            {
                if (   m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND
                    && wxDirExists(vcExtraPaths[i]) )
                {
                    m_ExtraPaths.Add(vcExtraPaths[i]);
                }
            }
            const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs();
            for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i)
            {
                if (wxDirExists(vcIncludeDirs[i]))
                {
                    if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND)
                        AddIncludeDir(vcIncludeDirs[i]);

                    if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND)
                        AddResourceIncludeDir(vcIncludeDirs[i]);
                }
            }
            const wxArrayString& vcLibDirs = vcComp->GetLibDirs();
            for (size_t i = 0; i < vcLibDirs.GetCount(); ++i)
            {
                if (   m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND
                    && wxDirExists(vcLibDirs[i]) )
                {
                    AddLibDir(vcLibDirs[i]);
                }
            }
            msvcFound = true;
            break;
        }

        if ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) )
        {
            // Just a final guess for the default installation dir
            wxString Programs = _T("C:\\Program Files");
            // what's the "Program Files" location
            // TO DO : support 64 bit ->    32 bit apps are in "ProgramFiles(x86)"
            //                              64 bit apps are in "ProgramFiles"
            wxGetEnv(_T("ProgramFiles"), &Programs);
            m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0");
        }
        else if (!msvcFound)
        {
            cbMessageBox(_T("It seems your computer doesn't have a MSVC compiler installed.\n\n"
                            "The ICC compiler requires MSVC for proper functioning and\n"
                            "it may not work without it."),
                         _T("Error"), wxOK | wxICON_ERROR);
        }
    }
    else
    {
        m_MasterPath = _T("/opt/intel/cc/9.0");
        if (wxDirExists(_T("/opt/intel")))
        {
            wxDir icc_dir(_T("/opt/intel/cc"));
            if (icc_dir.IsOpened())
            {
                wxArrayString dirs;
                wxIccDirTraverser IccDirTraverser(dirs);
                icc_dir.Traverse(IccDirTraverser);
                if (!dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    dirs.Sort(true);
                    m_MasterPath = dirs[0];
                }
            }
        }
    }

    AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed;
    if (ret == adrGuessed)
        ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ? adrDetected : adrGuessed;
    if (ret == adrGuessed)
        ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ? adrDetected : adrGuessed;

    if (ret == adrDetected)
    {
        if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) )
            m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("ia32"));
        if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) )
            m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("intel64"));

        if ( wxDirExists(m_MasterPath + sep + _T("include")) )
        {
            m_IncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0);
            m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0);
        }
        if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("include")) )
        {
            m_IncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0);
            m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0);
        }

        if ( wxDirExists(m_MasterPath + sep + _T("lib")) )
        {
            m_IncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0);
            m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0);
        }

        if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib")) )
            m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib"), 0);
        if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32")) )
            m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32"), 0);
        if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64")) )
            m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64"), 0);
    }
    // Try to detect the debugger. If not detected successfully the debugger plugin will
    // complain, so only the autodetection of compiler is considered in return value
    wxString path;
    wxString dbg;
    if (platform::windows)
    {
        dbg = _T("idb.exe");
        wxGetEnv(_T("IDB_PATH"), &path);
        if ( !path.IsEmpty() && wxDirExists(path) )
        {
            int version = 9;
            while ( true )
            {
                wxString idbPath = path + sep + _T("IDB") + sep + wxString::Format(_T("%d.0"), version) + sep + _T("IA32");
                if ( wxDirExists(idbPath) )
                {
                    path = idbPath; // found
                    break;  // exit while-loop
                }
                else if (version>15)
                    break;  // exit while-loop
                else
                    version++;
            }
        }
    }
    else
    {
        dbg  = _T("idb");
        path = _T("/opt/intel/idb/9.0");
        if ( wxDirExists(_T("/opt/intel")) )
        {
            wxDir icc_debug_dir(_T("/opt/intel/idb"));
            if (icc_debug_dir.IsOpened())
            {
                wxArrayString debug_dirs;
                wxIccDirTraverser IccDebugDirTraverser(debug_dirs);
                icc_debug_dir.Traverse(IccDebugDirTraverser);
                if (!debug_dirs.IsEmpty())
                {
                    // Now sort the array in reverse order to get the latest version's path
                    debug_dirs.Sort(true);
                    path = debug_dirs[0];
                }
            }
        }
    }

    if ( wxFileExists(path + sep + _T("bin") + sep + dbg) )
        m_ExtraPaths.Add(path);

    return ret;
}
AutoDetectCompilers::AutoDetectCompilers(wxWindow* parent)
{
    //ctor
    wxXmlResource::Get()->LoadObject(this, parent, _T("dlgAutoDetectCompilers"),_T("wxScrollingDialog"));

    wxListCtrl* list = XRCCTRL(*this, "lcCompilers", wxListCtrl);
    if (list)
    {
        list->Connect(wxEVT_MOTION, wxMouseEventHandler(AutoDetectCompilers::OnMouseMotion));
        list->ClearAll();
        list->InsertColumn(0, _("Compiler"), wxLIST_FORMAT_LEFT, 380);
        list->InsertColumn(1, _("Status"),   wxLIST_FORMAT_LEFT, 100);

        for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
        {
            Compiler* compiler = CompilerFactory::GetCompiler(i);
            if (!compiler)
                continue;

            list->InsertItem(list->GetItemCount(), compiler->GetName());

            wxString path = compiler->GetMasterPath();
            wxString path_no_macros = compiler->GetMasterPath();
            Manager::Get()->GetMacrosManager()->ReplaceMacros(path_no_macros);

            int idx = list->GetItemCount() - 1;
            int highlight = 0;
            if (path.IsEmpty() && Manager::Get()->GetConfigManager(wxT("compiler"))->Exists(wxT("/sets/") + compiler->GetID() + wxT("/name")))
            {
                // Here, some user-interaction is required not to show this
                // dialog again on each new start-up of C::B.
                list->SetItem(idx, 1, _("Invalid"));
                // So we better clearly HIGHLIGHT this entry:
                highlight = 1;
            }
            else // The compiler is *probably* invalid, but at least a master-path is set
            {
                list->SetItem(idx, 1, _("Not found"));
                highlight = -1;
            }

            // Inspect deeper and probably try to auto-detect invalid compilers:
            if (compiler->GetParentID().IsEmpty()) // built-in compiler
            {
                // Try auto-detection (which is for built-in compilers only)
                bool detected = compiler->AutoDetectInstallationDir() == adrDetected;
                wxString pathDetected( compiler->GetMasterPath() );

                // In case auto-detection was successful:
                if (detected)
                {
                    // No path setup before OR path detected as it was setup before
                    if (path.IsEmpty() || path == pathDetected || path_no_macros == pathDetected)
                        list->SetItem(idx, 1, _("Detected")); // OK
                    else
                        list->SetItem(idx, 1, _("User-defined")); // OK
                    highlight = 0;
                }
                // In case auto-detection failed but a path was setup before:
                else if ( !path.IsEmpty() )
                {
                    // Check, if the master path is valid:
                    if ( wxFileName::DirExists(path_no_macros) && !(path == pathDetected || path_no_macros == pathDetected) )
                    {
                        list->SetItem(idx, 1, _("User-defined")); // OK
                        highlight = 0;
                    }

                    // Assume the user did the setup on purpose, so reset the old settings anyways:
                    compiler->SetMasterPath(path);
                }
            }
            else // no built-in, but user-defined (i.e. copied) compiler
            {
                // Check, if the master path is valid:
                if ( !path.IsEmpty() && wxFileName::DirExists(path_no_macros) )
                {
                    list->SetItem(idx, 1, _("User-defined")); // OK
                    highlight = 0;
                }
            }

            if (highlight == 1)
                list->SetItemBackgroundColour(idx, *wxRED);
            else if (highlight == -1)
                list->SetItemTextColour(idx, *wxLIGHT_GREY);
        }
        // Resize columns so one can read the whole stuff:
        list->SetColumnWidth(0, wxLIST_AUTOSIZE);
        list->SetColumnWidth(1, wxLIST_AUTOSIZE);
    }

    XRCCTRL(*this, "lblDefCompiler", wxStaticText)->SetLabel(CompilerFactory::GetDefaultCompiler()->GetName());
}
Esempio n. 5
0
/*!
    \brief Launch the OpenOCD program, and redirects standard output to the log window.
        Also starts the telnet / TCL command interface.
    \return 0 if success, -1 it stream output cannot be redirected. -2 if OpenOCD cannot be started.
        -3 if command interface cannot be started.
*/
int OpenOCDDriver::Launch(void)
{
    if (m_bStarted == true)
        return -2;  // Already running

    cbProject *project;

    project = Manager::Get()->GetProjectManager()->GetActiveProject();
    wxString tgt = project->GetActiveBuildTarget();
    ProjectBuildTarget *target = project->GetBuildTarget(tgt);
    Compiler *actualCompiler = CompilerFactory::GetCompiler(target ? target->GetCompilerID() : project->GetCompilerID());

    // Launch remote debug target (i.e OpenOCD)
    wxString masterPath = actualCompiler->GetMasterPath();
    while (masterPath.Last() == '\\' || masterPath.Last() == '/')
        masterPath.RemoveLast();

    wxString wdir;
    wxString cmdline;

    wdir = project ? project->GetBasePath() : _T(".");
    wxString args = wdir + m_ConfigFile; //_T("openocd.cfg");

    //cmdline = masterPath + wxFILE_SEP_PATH + _T("openocd") +
    //    wxFILE_SEP_PATH + _T("openocd.exe ") + args;
    cmdline = m_ProgramPath + _T(" -f ") + args;

    //TargetDebugLog(_T("Command-line: ") + cmdline);
    //TargetDebugLog(_T("Working dir : ") + wdir);

    m_pProcess = new PipedProcess(&m_pProcess, this, idProcess, true, wdir);
    Log(_("Starting OpenOCD: "));

    m_Pid = wxExecute(cmdline, wxEXEC_ASYNC, m_pProcess);

    if (!m_Pid)
    {
        delete m_pProcess;
        m_pProcess = 0;
        Log(_("failed"));
        return -1;
    }
    else if (!m_pProcess->GetOutputStream())
    {
        delete m_pProcess;
        m_pProcess = 0;
        Log(_("failed (to get GDB remote's stdin)"));
        return -1;
    }
    else if (!m_pProcess->GetInputStream())
    {
        delete m_pProcess;
        m_pProcess = 0;
        Log(_("failed (to get GDB remote's stdout)"));
        return -1;
    }
    else if (!m_pProcess->GetErrorStream())
    {
        delete m_pProcess;
        m_pProcess = 0;
        Log(_("failed (to get GDB remote's stderr)"));
        return -1;
    }
    Log(_("done"));

    if (m_Pid == 0)
        return -1;  // Failed to run program

    m_bStarted = true;

    // although I don't really like these do-nothing loops, we must wait a small amount of time
    // for gdb to see if it really started: it may fail to load shared libs or whatever
    // the reason this is added is because I had a case where gdb would error and bail out
    // *while* the driver->Prepare() call was running below and hell broke loose...
    volatile int i = 50;
    while (i)
    {
		wxMilliSleep(1);
		Manager::Yield();
		--i;
    }

    if (m_bStarted == false)
        return -2;  // OpenOCD error

    // Start telnet/TCL command interface
    m_ocdint = new OpenOCDCmdInt();
    bool bRet = m_ocdint->OpenConn(_T("127.0.0.1"), m_TelnetPort);
    if (bRet == false)
        return -3;  // Could not start command interface

    m_TimerPollDebugger.Start(100);

    return 0;
}