自定义 Eclipse 调试配置
我有一个 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 中创建(但失败)的相同二进制文件在命令提示符下手动调试时,没有任何问题。我注意到的唯一区别是我在运行“继续”命令之前调用“load [BinaryName]”(不这样做会导致相同的 SIGILL 错误)。
有什么想法吗?
谢谢, 艾伦
I have a custom build of gcc/gdb that I'm trying to integrate with an Eclipse CDT plugin. I've created a custom Eclipse toolchain and can successfully build with it.
What I'm trying to do now is enable remote debugging but I'm not succeeding at the moment.
I've created a launch configuration subclass that extends AbstractCLaunchDelegate. In the launch method I have code like this:
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 );
}
}
}
My problem is that I am getting a SIGILL error back from GDB when calling CDIDebugModel.newDebugTarget(). If I leave this line out then the debugger session is created but no breakpoints are hit.
When I try to debug manually at the command prompt using the same binary that was created (and failing) in Eclipse, I don't have any issues. The only difference I noticed was that I am calling "load [BinaryName]" before running the "continue" command (not doing this results in the same SIGILL error).
Any ideas?
Thanks,
Alan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经找到了问题,它与我在从命令提示符调试时调用“load [BinaryName]”而不是在 Eclipse 中调用“load [BinaryName]”这一事实有关。
我发现我需要获取 MISession,然后调用 MITargetDownload 命令(这似乎相当于我的手动“load [BinaryName]”命令)。
其基本代码是:
这需要在对 CDIDebugModel.newDebugTarget 的任何调用之前进行。
希望这能解决这个问题,并至少能帮助处于类似情况的其他人。
谢谢,
艾伦
I think I've found the problem and it was related to the fact that I was calling "load [BinaryName]" when debugging from the command prompt but not within Eclipse.
I found that I needed to get hold of an MISession and then invoke the MITargetDownload command (which seems to be the equivalent to my manual "load [BinaryName]" command).
The basic code for this is:
This needs to go before any calls to CDIDebugModel.newDebugTarget.
Hopefully this draws a line under the issue and will at least help anyone else in a similar situation.
Thanks,
Alan