mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 226039
Read the gdbinit file as specified by the user. It does not specify at the command line as the CDT does it, but instead sources it as a GDB command. I believe this allows for easier specialization of the launch.
This commit is contained in:
parent
9ffecad0c8
commit
4093756b37
4 changed files with 68 additions and 1 deletions
|
@ -32,6 +32,7 @@ import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.dd.mi.service.CSourceLookup;
|
import org.eclipse.dd.mi.service.CSourceLookup;
|
||||||
import org.eclipse.dd.mi.service.MIBreakpointsManager;
|
import org.eclipse.dd.mi.service.MIBreakpointsManager;
|
||||||
|
import org.eclipse.dd.mi.service.command.commands.CLISource;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MIBreakInsert;
|
import org.eclipse.dd.mi.service.command.commands.MIBreakInsert;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MICommand;
|
import org.eclipse.dd.mi.service.command.commands.MICommand;
|
||||||
import org.eclipse.dd.mi.service.command.commands.MIExecContinue;
|
import org.eclipse.dd.mi.service.command.commands.MIExecContinue;
|
||||||
|
@ -59,6 +60,38 @@ public class FinalLaunchSequence extends Sequence {
|
||||||
|
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
}},
|
}},
|
||||||
|
/*
|
||||||
|
* Source the gdbinit file specified in the launch
|
||||||
|
*/
|
||||||
|
new Step() { @Override
|
||||||
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
|
try {
|
||||||
|
final String gdbinitFile = fLaunch.getLaunchConfiguration().getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT,
|
||||||
|
IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT );
|
||||||
|
if (gdbinitFile != null && gdbinitFile.length() > 0) {
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new CLISource(fCommandControl.getControlDMContext(), gdbinitFile),
|
||||||
|
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {
|
||||||
|
@Override
|
||||||
|
protected void handleCompleted() {
|
||||||
|
// If the gdbinitFile is the default, then it may not exist and we
|
||||||
|
// should not consider this an error.
|
||||||
|
// If it is not the default, then the user must have specified it and
|
||||||
|
// we want to warn the user if we can't find it.
|
||||||
|
if (!gdbinitFile.equals(IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT )) {
|
||||||
|
requestMonitor.setStatus(getStatus());
|
||||||
|
}
|
||||||
|
requestMonitor.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
requestMonitor.done();
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get gdbinit option", e)); //$NON-NLS-1$
|
||||||
|
requestMonitor.done();
|
||||||
|
}
|
||||||
|
}},
|
||||||
/*
|
/*
|
||||||
* Specify the executable file to be debugged.
|
* Specify the executable file to be debugged.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -374,9 +374,15 @@ public class GDBControl extends AbstractMIControl {
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
List<String> commandList = new ArrayList<String>();
|
List<String> commandList = new ArrayList<String>();
|
||||||
|
|
||||||
|
// The goal here is to keep options to an absolute minimum.
|
||||||
|
// All configuration should be done in the launch sequence
|
||||||
|
// to allow for easy overriding.
|
||||||
commandList.add(fGdbPath.toOSString());
|
commandList.add(fGdbPath.toOSString());
|
||||||
commandList.add("--interpreter"); //$NON-NLS-1$
|
commandList.add("--interpreter"); //$NON-NLS-1$
|
||||||
commandList.add("mi"); //$NON-NLS-1$
|
commandList.add("mi"); //$NON-NLS-1$
|
||||||
|
// Don't read the gdbinit file here. It is read explicitly in
|
||||||
|
// the LaunchSequence to make it easier to customize.
|
||||||
|
commandList.add("--nx"); //$NON-NLS-1$
|
||||||
|
|
||||||
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Ericsson and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.mi.service.command.commands;
|
||||||
|
|
||||||
|
import org.eclipse.dd.mi.service.command.MIControlDMContext;
|
||||||
|
import org.eclipse.dd.mi.service.command.output.MIInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* source FILE
|
||||||
|
*
|
||||||
|
* Source a file of commands
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CLISource extends CLICommand<MIInfo> {
|
||||||
|
public CLISource(MIControlDMContext ctx, String file) {
|
||||||
|
super(ctx, "source " + file); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,6 +58,7 @@ public class BaseTestCase {
|
||||||
attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
|
attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
|
||||||
attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
|
attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
|
||||||
attrs.put(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
|
attrs.put(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
|
||||||
|
attrs.put(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
Loading…
Add table
Reference in a new issue