eclipse 获取调试类型
时间: 2023-09-03 13:07:34 浏览: 84
可以通过以下代码获取 Eclipse 中当前调试的类型:
```
// 获取调试类型
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
ISelection selection = page.getSelection(DebugPlugin.getUniqueIdentifier() + ".org.eclipse.debug.ui.DebugView");
if (selection instanceof IStructuredSelection) {
Object obj = ((IStructuredSelection)selection).getFirstElement();
if (obj instanceof IDebugElement) {
IDebugElement debugElement = (IDebugElement)obj;
String debugType = debugElement.getModelIdentifier();
}
}
```
其中,`DebugView` 是 Eclipse 中的调试器视图,可以通过 `DebugPlugin.getUniqueIdentifier() + ".org.eclipse.debug.ui.DebugView"` 获取该视图的 ID。然后通过获取该视图的选择项,即可获取当前正在进行调试的元素 `IDebugElement`,再通过 `getModelIdentifier()` 方法获取调试类型。常见的调试类型包括 `org.eclipse.jdt.launching.debugType.javaApplication`(Java 应用程序调试)、`org.eclipse.cdt.launch.applicationLaunchType`(C/C++ 应用程序调试)等。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)