Skip to content

Commit 7988d04

Browse files
committed
#535: prefer xpacks/.bin for qemu executable
1 parent 50dd145 commit 7988d04

File tree

5 files changed

+89
-4
lines changed

5 files changed

+89
-4
lines changed

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.core/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/core/Configuration.java

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
2222
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
2323
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
24+
import org.eclipse.core.internal.resources.Project;
2425
import org.eclipse.core.resources.IProject;
26+
import org.eclipse.core.resources.IResource;
2527
import org.eclipse.core.runtime.CoreException;
28+
import org.eclipse.core.runtime.IPath;
2629
import org.eclipse.core.runtime.Platform;
2730
import org.eclipse.debug.core.ILaunchConfiguration;
2831
import org.eclipse.embedcdt.core.EclipseUtils;
@@ -52,7 +55,8 @@ public static String getPrefix(ILaunchConfiguration configuration) {
5255
return prefix;
5356
}
5457

55-
public static String getGdbServerCommand(ILaunchConfiguration configuration, String executable) {
58+
public static String getGdbServerCommand(ILaunchConfiguration configuration, String executable,
59+
Boolean preferXpacksBin) {
5660

5761
try {
5862

@@ -81,6 +85,43 @@ public static String getGdbServerCommand(ILaunchConfiguration configuration, Str
8185

8286
executable = resolveAll(executable, configuration);
8387

88+
if (preferXpacksBin == null) {
89+
preferXpacksBin = configuration.getAttribute(ConfigurationAttributes.DO_START_GDB_SERVER,
90+
DefaultPreferences.DO_GDB_SERVER_PREFER_XPACK_BIN_DEFAULT);
91+
}
92+
93+
if (preferXpacksBin) {
94+
String name = StringUtils.extractNameFromPath(executable);
95+
96+
IResource[] resources = configuration.getMappedResources();
97+
Project project = null;
98+
if (resources != null) {
99+
for (IResource resource : resources) {
100+
if (resource instanceof Project) {
101+
project = (Project) resource;
102+
break;
103+
}
104+
}
105+
106+
if (project != null) {
107+
IPath projectPath = project.getWorkspace().getRoot().getLocation()
108+
.append(project.getFullPath());
109+
IPath serverPath = projectPath.append("xpacks").append(".bin").append(name);
110+
111+
if (serverPath.toFile().exists()) {
112+
executable = serverPath.toString();
113+
} else {
114+
if (EclipseUtils.isWindows()) {
115+
serverPath = projectPath.append("xpacks").append(".bin").append(name + ".cmd");
116+
if (serverPath.toFile().exists()) {
117+
executable = serverPath.toString();
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
84125
} catch (CoreException e) {
85126
Activator.log(e);
86127
return null;
@@ -123,7 +164,7 @@ public static String[] getGdbServerCommandLineArray(ILaunchConfiguration configu
123164
fDefaultPreferences.getGdbServerDoStart(prefix)))
124165
return null;
125166

126-
String executable = getGdbServerCommand(configuration, null);
167+
String executable = getGdbServerCommand(configuration, null, null);
127168
if (executable == null || executable.isEmpty())
128169
return null;
129170

@@ -248,7 +289,7 @@ public static String[] getGdbServerCommandLineArray(ILaunchConfiguration configu
248289

249290
public static String getGdbServerCommandName(ILaunchConfiguration configuration) {
250291

251-
String fullCommand = getGdbServerCommand(configuration, null);
292+
String fullCommand = getGdbServerCommand(configuration, null, null);
252293
return StringUtils.extractNameFromPath(fullCommand);
253294
}
254295

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.core/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/core/ConfigurationAttributes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public interface ConfigurationAttributes extends org.eclipse.embedcdt.debug.gdbj
2626

2727
public static final String DO_START_GDB_SERVER = PREFIX + ".doStartGdbServer"; //$NON-NLS-1$
2828

29+
public static final String DO_GDB_SERVER_PREFER_XPACK_BIN = PREFIX + ".doGdbServerPreferXpacksBin"; //$NON-NLS-1$
30+
2931
public static final String GDB_SERVER_EXECUTABLE = PREFIX + ".gdbServerExecutable"; //$NON-NLS-1$
3032

3133
public static final String GDB_SERVER_MACHINE_NAME = PREFIX + ".gdbServerQemuMachineName"; //$NON-NLS-1$

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.core/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/core/preferences/DefaultPreferences.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class DefaultPreferences extends org.eclipse.embedcdt.debug.gdbjtag.core.
2323
public static final boolean SERVER_DO_START_DEFAULT = true;
2424
public static final boolean DO_START_GDB_SERVER_DEFAULT = true;
2525

26+
public static final boolean DO_GDB_SERVER_PREFER_XPACK_BIN_DEFAULT = false;
27+
2628
public static final String SERVER_EXECUTABLE_DEFAULT = "${qemu_path}/${qemu_executable}";
2729
public static final String PARAMETRIZED_SERVER_EXECUTABLE_DEFAULT = "${qemu_%s_path}/${qemu_%s_executable}";
2830

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/ui/TabDebugger.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public class TabDebugger extends AbstractLaunchConfigurationTab {
112112
private Text fGdbServerOtherOptions;
113113

114114
private Button fDoGdbServerAllocateConsole;
115+
private Button fDoGdbServerPreferXpcksBin;
115116

116117
private Text fGdbServerDelay;
117118

@@ -318,6 +319,16 @@ private void createGdbServerGroup(Composite parent) {
318319
}
319320
}
320321

322+
{
323+
fDoGdbServerPreferXpcksBin = new Button(comp, SWT.CHECK);
324+
fDoGdbServerPreferXpcksBin.setText(Messages.getString("DebuggerTab.gdbServerPreferXpacksBin_Label"));
325+
fDoGdbServerPreferXpcksBin
326+
.setToolTipText(Messages.getString("DebuggerTab.gdbServerPreferXpacksBin_ToolTipText"));
327+
GridData gd = new GridData();
328+
gd.horizontalSpan = ((GridLayout) comp.getLayout()).numColumns;
329+
fDoGdbServerPreferXpcksBin.setLayoutData(gd);
330+
}
331+
321332
{
322333
Label label = new Label(comp, SWT.NONE);
323334
label.setText(Messages.getString("DebuggerTab.gdbServerActualPath_Label"));
@@ -525,6 +536,14 @@ public void widgetSelected(SelectionEvent e) {
525536
}
526537
});
527538

539+
fDoGdbServerPreferXpcksBin.addSelectionListener(new SelectionAdapter() {
540+
@Override
541+
public void widgetSelected(SelectionEvent e) {
542+
543+
updateGdbServerActualPath();
544+
}
545+
});
546+
528547
fEnableSemihosting.addSelectionListener(new SelectionAdapter() {
529548
@Override
530549
public void widgetSelected(SelectionEvent e) {
@@ -818,7 +837,9 @@ public void modifyText(ModifyEvent e) {
818837
private void updateGdbServerActualPath() {
819838

820839
assert (fConfiguration != null);
821-
String fullCommand = Configuration.getGdbServerCommand(fConfiguration, fGdbServerExecutable.getText());
840+
841+
String fullCommand = Configuration.getGdbServerCommand(fConfiguration, fGdbServerExecutable.getText(),
842+
fDoGdbServerPreferXpcksBin.getSelection());
822843
if (Activator.getInstance().isDebugging()) {
823844
System.out.println("qemu.TabDebugger.updateActualpath() \"" + fullCommand + "\"");
824845
}
@@ -839,6 +860,8 @@ private void doStartGdbServerChanged() {
839860

840861
boolean enabled = fDoStartGdbServer.getSelection();
841862

863+
fDoGdbServerPreferXpcksBin.setEnabled(enabled);
864+
842865
fGdbServerExecutable.setEnabled(enabled);
843866
fGdbServerBrowseButton.setEnabled(enabled);
844867
fGdbServerVariablesButton.setEnabled(enabled);
@@ -918,6 +941,10 @@ public void initializeFrom(ILaunchConfiguration configuration) {
918941
fDoStartGdbServer.setSelection(
919942
configuration.getAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanDefault));
920943

944+
fDoGdbServerPreferXpcksBin
945+
.setSelection(configuration.getAttribute(ConfigurationAttributes.DO_GDB_SERVER_PREFER_XPACK_BIN,
946+
DefaultPreferences.DO_GDB_SERVER_PREFER_XPACK_BIN_DEFAULT));
947+
921948
// Executable
922949
stringDefault = fPersistentPreferences.getGdbServerExecutable(fPrefix, fArchitecture);
923950
fGdbServerExecutable.setText(
@@ -1061,6 +1088,8 @@ public void initializeFromDefaults() {
10611088
booleanDefault = fDefaultPreferences.getGdbServerDoStart(fPrefix);
10621089
fDoStartGdbServer.setSelection(booleanDefault);
10631090

1091+
fDoGdbServerPreferXpcksBin.setSelection(DefaultPreferences.DO_GDB_SERVER_PREFER_XPACK_BIN_DEFAULT);
1092+
10641093
// Executable
10651094
stringDefault = fDefaultPreferences.getGdbServerExecutable(fPrefix, fArchitecture);
10661095
fGdbServerExecutable.setText(stringDefault);
@@ -1242,6 +1271,9 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
12421271
configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, booleanValue);
12431272
fPersistentPreferences.putGdbServerDoStart(fPrefix, booleanValue);
12441273

1274+
configuration.setAttribute(ConfigurationAttributes.DO_GDB_SERVER_PREFER_XPACK_BIN,
1275+
fDoGdbServerPreferXpcksBin.getSelection());
1276+
12451277
// Executable
12461278
stringValue = fGdbServerExecutable.getText().trim();
12471279
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, stringValue);
@@ -1404,6 +1436,9 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
14041436
defaultBoolean = fPersistentPreferences.getGdbServerDoStart(fPrefix);
14051437
configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, defaultBoolean);
14061438

1439+
configuration.setAttribute(ConfigurationAttributes.DO_GDB_SERVER_PREFER_XPACK_BIN,
1440+
DefaultPreferences.DO_GDB_SERVER_PREFER_XPACK_BIN_DEFAULT);
1441+
14071442
defaultString = fPersistentPreferences.getGdbServerExecutable(fPrefix, fArchitecture);
14081443
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, defaultString);
14091444

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/qemu/ui/messages.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ DebuggerTab.gdbServerAllocateConsole_ToolTipText=\
125125
Allocate an Eclipse console where the output\n\
126126
generated by QEMU will be displayed.
127127

128+
DebuggerTab.gdbServerPreferXpacksBin_Label=Prefer the xpacks/.bin path
129+
DebuggerTab.gdbServerPreferXpacksBin_ToolTipText=\
130+
Place xpacks/.bin on top of the PATH \n\
131+
when searching for the QEMU binaries.
132+
128133
DebuggerTab.gdbSetupGroup_Text=GDB Client Setup
129134

130135
DebuggerTab.gdbCommand_Label=Executable name:

0 commit comments

Comments
 (0)