【问题标题】:Custom Eclipse debug configuration自定义 Eclipse 调试配置
【发布时间】:2011-02-07 23:20:17
【问题描述】:

我有一个自定义构建的 gcc/gdb,我正在尝试与 Eclipse CDT 插件集成。我已经创建了一个自定义 Eclipse 工具链,并且可以使用它成功构建。

我现在要做的是启用远程调试,但目前我没有成功。

我创建了一个扩展 AbstractCLaunchDelegate 的启动配置子类。在启动方法中,我有这样的代码:

public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException
{
    // Get path to binary
    IPath exePath = CDebugUtils.verifyProgramPath(configuration);
    ICProject project = CDebugUtils.verifyCProject(configuration);
    IBinaryObject exeFile = verifyBinary(project, exePath);

    // If debugging
    if(mode.equals("debug"))
    {
        // Get debug configuration
        ICDebugConfiguration config = getDebugConfig(configuration);

        // Get debugger instance
        ICDIDebugger2 debugger = (ICDIDebugger2)config.createDebugger();

        // Create session
        ICDISession session = debugger2.createSession(launch, exePath.toFile(), monitor);

        // Note: Copied from LocalCDILaunchDelegate
        boolean stopInMain = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false );
        String stopSymbol = null;
        if ( stopInMain )
            stopSymbol = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
        ICDITarget[] targets = session.getTargets();
        for( int i = 0; i < targets.length; i++ ) {
            Process process = targets[i].getProcess();
            IProcess iprocess = null;
            if ( process != null ) {
                iprocess = DebugPlugin.newProcess( launch, process, renderProcessLabel( exePath.toOSString() ), getDefaultProcessMap() );
            }

            // Note: Failing here with SIGILL
            CDIDebugModel.newDebugTarget( launch, project.getProject(), targets[i], renderTargetLabel( config ), iprocess, exeFile, true, false, stopSymbol, true );
        }
    }
}

我的问题是调用 CDIDebugModel.newDebugTarget() 时从 GDB 返回 SIGILL 错误。如果我不考虑这一行,则会创建调试器会话,但不会遇到断点。

当我尝试使用在 Eclipse 中创建(但失败)的相同二进制文件在命令提示符下手动调试时,我没有任何问题。我注意到的唯一区别是我在运行“继续”命令之前调用了“加载 [BinaryName]”(不这样做会导致相同的 SIGILL 错误)。

有什么想法吗?

谢谢, 艾伦

【问题讨论】:

    标签: plugins gcc gdb debugging eclipse-cdt


    【解决方案1】:

    我想我已经找到了问题所在,这与我在从命令提示符而不是在 Eclipse 中调试时调用“load [BinaryName]”这一事实有关。

    我发现我需要获取一个 MISession,然后调用 MITargetDownload 命令(这似乎相当于我的手动“load [BinaryName]”命令)。

    这个的基本代码是:

    // Get MI session
    MISession miSession = target.getMISession();
    
    // Get target download command for loading program on target
    MITargetDownload targetDownload = miSession.getCommandFactory().createMITargetDownload(exePath.toOSString());
    
    // Load program on target
    miSession.postCommand(targetDownload);
    

    这需要在对 CDIDebugModel.newDebugTarget 的任何调用之前进行。

    希望这可以在问题下划清界限,并且至少可以帮助处于类似情况的其他人。

    谢谢, 艾伦

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-25
      • 1970-01-01
      • 2013-03-02
      • 2016-04-19
      • 2017-09-22
      • 2016-01-22
      • 2011-12-14
      相关资源
      最近更新 更多