1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

new browse buttons and gdinit field

This commit is contained in:
David Inglis 2003-01-17 16:51:24 +00:00
parent d70fe7acee
commit c642c08e59
2 changed files with 124 additions and 65 deletions

View file

@ -1,3 +1,7 @@
2003-01-17 David Inglis
* src/.../internal/ui/CDebuggerPage.java
Added some browse buttons and new text field for gdbinit file.
2003-01-03 Alain Magloire 2003-01-03 Alain Magloire
* build.properties: Patch from Judy Green. * build.properties: Patch from Judy Green.

View file

@ -4,6 +4,8 @@
*/ */
package org.eclipse.cdt.debug.mi.internal.ui; package org.eclipse.cdt.debug.mi.internal.ui;
import java.io.File;
import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -18,86 +20,133 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
public class CDebuggerPage extends AbstractLaunchConfigurationTab { public class CDebuggerPage extends AbstractLaunchConfigurationTab {
protected Text fDebuggerCommandText; private Text fGDBCommandText;
private Text fGDBInitText;
private Button fAutoSoLibButton; private Button fAutoSoLibButton;
private Button fGDBButton;
public void createControl(Composite parent) { public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE); GridData gd;
GridLayout topLayout = new GridLayout(); Label label;
topLayout.numColumns = 2; Button button;
comp.setLayout(topLayout); Composite comp, subComp;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
comp.setLayoutData(gd); comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
setControl(comp); setControl(comp);
createVerticalSpacer(comp, 2); subComp = new Composite(comp, SWT.NONE);
GridLayout gdbLayout = new GridLayout();
gdbLayout.numColumns = 2;
gdbLayout.marginHeight = 0;
gdbLayout.marginWidth = 0;
subComp.setLayout(gdbLayout);
subComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label debugCommandLabel= new Label(comp, SWT.NONE); label = new Label(subComp, SWT.NONE);
debugCommandLabel.setText("MI Debugger:"); label.setText("GDB debugger:");
gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
fDebuggerCommandText= new Text(comp, SWT.SINGLE | SWT.BORDER); fGDBCommandText = new Text(subComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
fDebuggerCommandText.setLayoutData(gd); fGDBCommandText.setLayoutData(gd);
fDebuggerCommandText.addModifyListener(new ModifyListener() { fGDBCommandText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) { public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
createVerticalSpacer(comp, 2); button = createPushButton(subComp, "&Browse...", null);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
handleGDBButtonSelected();
updateLaunchConfigurationDialog();
}
private void handleGDBButtonSelected() {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
dialog.setText("GDB Command");
String gdbCommand = fGDBCommandText.getText().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
}
String res = dialog.open();
if (res == null) {
return;
}
fGDBCommandText.setText(res);
}
});
fAutoSoLibButton = new Button(comp, SWT.CHECK ) ; subComp = new Composite(comp, SWT.NONE);
gdbLayout = new GridLayout();
gdbLayout.numColumns = 2;
subComp.setLayout(gdbLayout);
subComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label = new Label(subComp, SWT.NONE);
label.setText("GDB command file:");
gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
fGDBInitText = new Text(subComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
fGDBInitText.setLayoutData(gd);
fGDBInitText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
button = createPushButton(subComp, "&Browse...", null);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
handleGDBInitButtonSelected();
updateLaunchConfigurationDialog();
}
private void handleGDBInitButtonSelected() {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
dialog.setText("GDB command file");
String gdbCommand = fGDBInitText.getText().trim();
int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
}
String res = dialog.open();
if (res == null) {
return;
}
fGDBInitText.setText(res);
}
});
label = new Label(comp,SWT.WRAP);
label.setText("(Warning: Some commands in this file may interfere with the startup operation of the debugger, for example \"run\".)");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 1;
gd.widthHint = 200;
label.setLayoutData(gd);
fAutoSoLibButton = new Button(comp, SWT.CHECK);
fAutoSoLibButton.setText("Load shared library symbols automatically"); fAutoSoLibButton.setText("Load shared library symbols automatically");
fAutoSoLibButton.addSelectionListener(new SelectionAdapter() { fAutoSoLibButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
gd = new GridData();
gd.horizontalSpan = 2;
fAutoSoLibButton.setLayoutData(gd);
/*
ListEditor listEditor = new ListEditor("1", "Shared library search paths:", comp) {
protected String createList(String[] items) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < items.length; i++) {
buf.append(items[i]);
buf.append(';');
}
return buf.toString();
}
protected String getNewInputObject() {
// StringInputDialog dialog= new StringInputDialog(comp.getShell(), "Library Path", null, "Enter a library path", "", null);
// if (dialog.open() == dialog.OK) {
// return dialog.getValue();
// } else {
// return null;
// }
return null;
}
protected String[] parseString(String list) {
StringTokenizer st = new StringTokenizer(list, ";");
ArrayList v = new ArrayList();
while (st.hasMoreElements()) {
v.add(st.nextElement());
}
return (String[]) v.toArray(new String[v.size()]);
}
};
*/
} }
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, "");
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true);
} }
@ -105,7 +154,7 @@ public class CDebuggerPage extends AbstractLaunchConfigurationTab {
* @see ILaunchConfigurationTab#isValid(ILaunchConfiguration) * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
*/ */
public boolean isValid(ILaunchConfiguration launchConfig) { public boolean isValid(ILaunchConfiguration launchConfig) {
boolean valid= fDebuggerCommandText.getText().length() != 0; boolean valid = fGDBCommandText.getText().length() != 0;
if (valid) { if (valid) {
setErrorMessage(null); setErrorMessage(null);
setMessage(null); setMessage(null);
@ -117,25 +166,31 @@ public class CDebuggerPage extends AbstractLaunchConfigurationTab {
} }
public void initializeFrom(ILaunchConfiguration configuration) { public void initializeFrom(ILaunchConfiguration configuration) {
String debuggerCommand = "gdb"; String gdbCommand = "gdb";
String gdbInit = "";
boolean autosolib = false; boolean autosolib = false;
try { try {
debuggerCommand = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); gdbCommand = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb");
gdbInit = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, "");
autosolib = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true); autosolib = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, true);
} catch (CoreException e) { } catch (CoreException e) {
} }
fDebuggerCommandText.setText(debuggerCommand); fGDBCommandText.setText(gdbCommand);
fGDBInitText.setText(gdbInit);
fAutoSoLibButton.setSelection(autosolib); fAutoSoLibButton.setSelection(autosolib);
} }
public void performApply(ILaunchConfigurationWorkingCopy configuration) { public void performApply(ILaunchConfigurationWorkingCopy configuration) {
String debuggerCommand = fDebuggerCommandText.getText(); String gdbStr = fGDBCommandText.getText();
debuggerCommand.trim(); gdbStr.trim();
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, debuggerCommand); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, gdbStr);
gdbStr = fGDBInitText.getText();
gdbStr.trim();
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, gdbStr);
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, fAutoSoLibButton.getSelection()); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_AUTO_SOLIB, fAutoSoLibButton.getSelection());
} }
public String getName() { public String getName() {
return "GDB/MI Debugger Options"; return "GDB Debugger Options";
} }
} }