程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> [Fixed Eclipse CDT]可正常運行,無法調試

[Fixed Eclipse CDT]可正常運行,無法調試

編輯:關於C語言

1.Eclipse CDT是開發C/C++的
2.現象:
直接使用Eclipse IDE for C/C++ Developers可正常編寫運行、調試c/c++
使用Eclipse for RCP RAP,已集成了MyEclipse,再安裝Eclipse CDT插件時,只能正常運行,但是無法調試程序,運行調試時報異常(貌似是spring ide插件工具和CDT有沖突,畢竟是java開發環境來開發c/c++):
Java代碼 
ENTRY org.eclipse.core.jobs 4 2 2011-07-19 02:27:53.796 
MESSAGE An internal error occurred during: "Launching tst". 
STACK 0 
java.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) 
 
解決:
創建插件項目,引入CDT依賴包,org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getLaunchEnvironment(LaunchUtils.java:389)處設置斷點,觀察問題現象
通過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中參考代碼
因為對CDT和Spring IDE插件都不了解,治標修復LaunchUtils代碼,getLaunchEnvironmen方法中的envMap.put(var.getName(), var.getStringValue());替換為:
Java代碼 
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)); 

 
替換包org.eclipse.cdt.dsf.gdb_3.0.0.201102110609.jar中的二進制代碼即可
附件說明:
zip包是LaunchUtils.class代碼
org.eclipse.cdt.dsf.gdb_3.0.0.201102110609.jar是修復後的包

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved