当前位置: 代码迷 >> Eclipse >> [Fixed Eclipse CDT]可正常运行,没法调试
  详细解决方案

[Fixed Eclipse CDT]可正常运行,没法调试

热度:640   发布时间:2016-04-23 02:25:08.0
[Fixed Eclipse CDT]可正常运行,无法调试

?

  1. Eclipse CDT是开发C/C++的
  2. 现象:
    1. 直接使用Eclipse IDE for C/C++ Developers可正常编写运行、调试c/c++
    2. 使用Eclipse for RCP RAP,已集成了MyEclipse,再安装Eclipse CDT插件时,只能正常运行,但是无法调试程序,运行调试时报异常(貌似是spring ide插件工具和CDT有冲突,毕竟是java开发环境来开发c/c++):
      ENTRY org.eclipse.core.jobs 4 2 2011-07-19 02:27:53.796MESSAGE An internal error occurred during: "Launching tst".STACK 0java.lang.IllegalArgumentException	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.getBundles(PackageAdminImpl.java:571)	at org.eclipse.core.internal.runtime.InternalPlatform.getBundle(InternalPlatform.java:181)	at org.eclipse.core.runtime.Platform.getBundle(Platform.java:1416)	at org.springframework.ide.eclipse.core.BundleStateLocationVariableResolver.resolveValue(BundleStateLocationVariableResolver.java:32)	at org.eclipse.core.internal.variables.DynamicVariable.getValue(DynamicVariable.java:54)	at org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier$EclipseVarMacro.loadValue(EclipseVariablesVariableSupplier.java:103)	at org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier$EclipseVarMacro.getStringValue(EclipseVariablesVariableSupplier.java:90)	at org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getLaunchEnvironment(LaunchUtils.java:389)	at org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getGDBVersion(LaunchUtils.java:281)	at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.getGDBVersion(GdbLaunchDelegate.java:243)	at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launchDebugSession(GdbLaunchDelegate.java:129)	at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launchDebugger(GdbLaunchDelegate.java:83)	at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launch(GdbLaunchDelegate.java:72)	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:924)	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1128)	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
      ?
  3. 解决:
    1. 创建插件项目,引入CDT依赖包,org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getLaunchEnvironment(LaunchUtils.java:389)处设置断点,观察问题现象
    2. 通过2种不同的目标插件平台:a) 集成了MyEclipse的eclipse RCP 和 b) Eclipse IDE for C/C++ Developers,对比发现他们获取到的env内容有差别,关键在bundle_loc、bundle_state_loc、bundle_version这三个,这三个在org.springframework.ide.eclipse.core/META-INF/MANIFEST.MF中参考代码?
    3. 因为对CDT和Spring IDE插件都不了解,治标修复LaunchUtils代码,getLaunchEnvironmen方法中的envMap.put(var.getName(), var.getStringValue());替换为:
      try {	envMap.put(var.getName(), var.getStringValue());} catch (IllegalArgumentException e) {	if (var.getName() == null || !var.getName().startsWith("bundle_")) throw e;	ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.INFO, GdbPlugin.PLUGIN_ID, "ignore env variable [" + var.getName() + "] fetch error!", e));}
      ?
    4. 替换包org.eclipse.cdt.dsf.gdb_3.0.0.201102110609.jar中的二进制代码即可
  4. 附件说明:
    1. zip包是LaunchUtils.class代码
    2. org.eclipse.cdt.dsf.gdb_3.0.0.201102110609.jar是修复后的包
1 楼 skzr.org 2011-07-20  
ubuntu使用也有2年了,很多开源的都是c/c++的,处于对性能和优秀软件的了解需要。
java主业,c/c++兼顾下。
  相关解决方案