Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2016-08-02 06:19:13 +0000
committerMarc-Andre Laperle2016-08-18 19:49:41 +0000
commit4548f0a7bc0dcb2dc3ec6ee60ea940b2e7096b30 (patch)
tree54f961781957c919fbdbb14a0101b53012b5d178
parentb7e23cab72c8c21cb710dec9192148c1aeba8ab5 (diff)
downloadorg.eclipse.cdt-4548f0a7bc0dcb2dc3ec6ee60ea940b2e7096b30.tar.gz
org.eclipse.cdt-4548f0a7bc0dcb2dc3ec6ee60ea940b2e7096b30.tar.xz
org.eclipse.cdt-4548f0a7bc0dcb2dc3ec6ee60ea940b2e7096b30.zip
LLDB: Add preference UI
This commit adds a preference page for LLDB. For now, only LLDB path and the "stop at main" preferences are exposed. Bug: 405670 Change-Id: I4ba30fdb48ecd0cdfc6e3aac35fe0de38563c354 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
-rw-r--r--llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/plugin.xml9
-rw-r--r--llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBDebugPreferencePage.java149
-rw-r--r--llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/Messages.java4
-rw-r--r--llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/messages.properties5
4 files changed, 167 insertions, 0 deletions
diff --git a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/plugin.xml b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/plugin.xml
index b50351d6783..dc874077ef7 100644
--- a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/plugin.xml
+++ b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/plugin.xml
@@ -84,5 +84,14 @@
<placement after="org.eclipse.debug.ui.sourceLookupTab"/>
</tab>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.cdt.debug.ui.CDebugPreferencePage"
+ class="org.eclipse.cdt.llvm.dsf.lldb.ui.internal.LLDBDebugPreferencePage"
+ id="org.eclipse.cdt.llvm.dsf.lldb.ui.preferences"
+ name="%lldbPreferencePage.name">
+ </page>
+ </extension>
</plugin>
diff --git a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBDebugPreferencePage.java b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBDebugPreferencePage.java
new file mode 100644
index 00000000000..767bf6d8261
--- /dev/null
+++ b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/LLDBDebugPreferencePage.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ *******************************************************************************/
+package org.eclipse.cdt.llvm.dsf.lldb.ui.internal;
+
+import java.io.File;
+
+import org.eclipse.cdt.llvm.dsf.lldb.core.ILLDBDebugPreferenceConstants;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * A preference page for settings that are currently supported in LLDB. Based on
+ * the GDB equivalent.
+ */
+public class LLDBDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private StringFieldEditor fStringFieldEditorCommand;
+ @SuppressWarnings("restriction")
+ private org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor fEnableStopAtMain;
+
+ /**
+ * Constructs the preference page.
+ */
+ public LLDBDebugPreferencePage() {
+ super(FLAT);
+ IPreferenceStore store = LLDBUIPlugin.getDefault().getCorePreferenceStore();
+ // Note that if we don't set it here, it actually never gets flushed. If
+ // this page was to use two preference stores, make sure that both are
+ // flushed.
+ setPreferenceStore(store);
+ setDescription(Messages.LLDBDebugPreferencePage_description);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ final Composite parent = getFieldEditorParent();
+ final GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ parent.setLayout(layout);
+
+ final Group group1 = new Group(parent, SWT.NONE);
+ group1.setText(Messages.LLDBDebugPreferencePage_defaults_label);
+ GridLayout groupLayout = new GridLayout(3, false);
+ group1.setLayout(groupLayout);
+ group1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ fStringFieldEditorCommand = new StringFieldEditor(ILLDBDebugPreferenceConstants.PREF_DEFAULT_LLDB_COMMAND,
+ Messages.LLDBCDebuggerPage_debugger_command, group1);
+
+ fStringFieldEditorCommand.fillIntoGrid(group1, 2);
+ GridData stringFieldLayoutData = (GridData) fStringFieldEditorCommand.getTextControl(group1).getLayoutData();
+ stringFieldLayoutData.widthHint = 300;
+
+ addField(fStringFieldEditorCommand);
+ Button browsebutton = new Button(group1, SWT.PUSH);
+ browsebutton.setText(Messages.LLDBCDebuggerPage_browse);
+ browsebutton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowseButtonSelected(Messages.LLDBCDebuggerPage_browse_dialog_title, fStringFieldEditorCommand);
+ }
+ });
+ setButtonLayoutData(browsebutton);
+
+ fEnableStopAtMain = createStopAtMainEditor(group1);
+ fEnableStopAtMain.fillIntoGrid(group1, 3);
+ addField(fEnableStopAtMain);
+
+ group1.setLayout(groupLayout);
+
+ createLinkToGdb(parent);
+ }
+
+ /*
+ * Using full qualified name for return value here so that we don't have to
+ * suppress warning on the whole class.
+ */
+ @SuppressWarnings("restriction")
+ private static org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor createStopAtMainEditor(final Group group1) {
+ return new org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor(
+ ILLDBDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
+ ILLDBDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
+ Messages.LLDBDebugPreferencePage_Stop_on_startup_at,
+ group1);
+ }
+
+ private Control createLinkToGdb(Composite parent) {
+ String text = Messages.LLDBDebugPreferencePage_see_gdb_preferences;
+ Link link = new Link(parent, SWT.NONE);
+ link.setText(text);
+ link.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ PreferencesUtil.createPreferenceDialogOn(getShell(), event.text, null, null);
+ }
+ });
+
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ gridData.widthHint = 150;
+ link.setLayoutData(gridData);
+ return link;
+ }
+
+ private void handleBrowseButtonSelected(final String dialogTitle, final StringFieldEditor stringFieldEditor) {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(dialogTitle);
+ String lldbCommand = stringFieldEditor.getStringValue().trim();
+ int lastSeparatorIndex = lldbCommand.lastIndexOf(File.separator);
+ if (lastSeparatorIndex != -1) {
+ dialog.setFilterPath(lldbCommand.substring(0, lastSeparatorIndex));
+ }
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ stringFieldEditor.setStringValue(res);
+ }
+
+ @Override
+ protected void adjustGridLayout() {
+ // Do nothing, already handled during creation of controls.
+ }
+}
diff --git a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/Messages.java b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/Messages.java
index ec0da087cf3..7fe182e6806 100644
--- a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/Messages.java
+++ b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/Messages.java
@@ -20,6 +20,10 @@ public class Messages extends NLS {
public static String LLDBCDebuggerPage_browse_dialog_title;
public static String LLDBCDebuggerPage_tab_name;
public static String LLDBCDebuggerPage_debugger_command;
+ public static String LLDBDebugPreferencePage_Stop_on_startup_at;
+ public static String LLDBDebugPreferencePage_description;
+ public static String LLDBDebugPreferencePage_defaults_label;
+ public static String LLDBDebugPreferencePage_see_gdb_preferences;
static {
// initialize resource bundle
diff --git a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/messages.properties b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/messages.properties
index 3349d030659..0b5a8fc226b 100644
--- a/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/messages.properties
+++ b/llvm/org.eclipse.cdt.llvm.dsf.lldb.ui/src/org/eclipse/cdt/llvm/dsf/lldb/ui/internal/messages.properties
@@ -10,3 +10,8 @@ LLDBCDebuggerPage_browse=&Browse...
LLDBCDebuggerPage_browse_dialog_title=LLDB-MI Debugger
LLDBCDebuggerPage_tab_name=LLDB Debugger Options
LLDBCDebuggerPage_debugger_command=LLDB command:
+LLDBDebugPreferencePage_Stop_on_startup_at=Stop on startup at:
+
+LLDBDebugPreferencePage_description=General settings for LLDB Debugging
+LLDBDebugPreferencePage_defaults_label=Debug Configurations Defaults
+LLDBDebugPreferencePage_see_gdb_preferences=Note: Other preferences that can affect LLDB are available via <a href="org.eclipse.cdt.dsf.gdb.ui.preferences">GDB</a>.

Back to the top