Running a GDB command file [message #1817619] |
Tue, 26 November 2019 19:43 |
Eli Kakoun Messages: 16 Registered: November 2018 |
Junior Member |
|
|
Hi,
I have a debugger plugin for debugging c code over eclipse.
I tried to configure A GDB command file to run when I debug a process by configuring it in the eclipse where my plugin is installed. Didn't work.
I think the correct way is to configure it when I create the GDB process in my plugin code.
Didn't find how to do so.
This is the code I use to configure my GDB process:
ILaunchConfigurationWorkingCopy wc = types[appTypeIdx].newInstance(null, configurationName);
DebugUITools.setLaunchPerspective(wc.getType(), ILaunchManager.DEBUG_MODE,
IDebugUIConstants.PERSPECTIVE_DEFAULT);
wc.setPreferredLaunchDelegate(debugSet, d[lnchTypeIdx].getId());
if (!createGdbInitFile(resource, port)) {
CSEDebugOutput.getInstance().pError("error creating .gdbinit file");
return null;
}
String gdbinitpath = new File(GDBINITFILENAME).getAbsolutePath();
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, false);
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV,
String.format("%s:%s", CSEConfiguration.getValue(CSEConfiguration.Keys.HOST), port));
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, gdbinitpath);
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, gdbExePath);
String programPath = "./bup.elf";
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, 0);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
if (pm.name.equalsIgnoreCase(CSEConstants.MODUEL_0)
&& (Boolean) CSEConfiguration.getValue(CSEConfiguration.Keys.STOP_ON_START)) {
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
(boolean) CSEConfiguration.getValue(CSEConfiguration.Keys.STOP_ON_START));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
(String) CSEConfiguration.getValue(CSEConfiguration.Keys.STOP_ON_START_SYMBOL));
}
else {
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "");
}
// wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
// "org.eclipse.cdt.debug.mi.core.CDebuggerNew");
// wc.setAttribute("org.eclipse.cdt.debug.mi.core.protocol", "mi");
String type = wc.getType().getSourceLocatorId();
ISourceLocator locator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(type);
if (locator instanceof AbstractSourceLookupDirector) {
AbstractSourceLookupDirector director = (AbstractSourceLookupDirector) locator;
director.initializeDefaults(wc);
int i;
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(
Arrays.asList(director.getSourceContainers()));
for (i = 0; i < containerList.size(); i++) {
if (containerList.get(i).getName().equals("Default")) {
break;
}
}
if (i < containerList.size()) {
containerList.remove(i);
}
containerList.add(new AbsolutePathSourceContainer());
setContainer(resource, containerList);
containerList.add(new ProjectSourceContainer(
ResourcesPlugin.getWorkspace().getRoot().getProject(projName), false));
director.setSourceContainers(containerList.toArray(new ISourceContainer[containerList.size()]));
wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento());
wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId());
}
return wc;
|
|
|
Powered by
FUDForum. Page generated in 0.02924 seconds