mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-06 00:25:25 +02:00
Report LLDB version and clean up LLDB-MI launch sequence
We use CLI 'version' to replace the MI '-gdb-version' command.
This commit is contained in:
parent
1035ef2bcc
commit
7479f4ddcf
6 changed files with 169 additions and 9 deletions
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
|
||||
Bundle-Version: 7.1.700.qualifier
|
||||
Bundle-Version: 7.2.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.33.0,4)",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2018 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2025 QNX Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -31,6 +31,7 @@
|
|||
* Marc Khouzam (Ericsson) - Support for -gdb-version (Bug 455408)
|
||||
* Intel Corporation - Added Reverse Debugging BTrace support
|
||||
* Samuel Hultgren (STMicroelectronics) - Bug 533771
|
||||
* John Dallaway - Add CLI version command (#1186)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command;
|
||||
|
@ -77,6 +78,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITraceDump;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetSubstitutePath;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIVersion;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIAddInferior;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCommands;
|
||||
|
@ -215,6 +217,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.CLIShowEndianInfo;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.output.CLIThreadInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceDumpInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.CLIVersionInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
|
||||
|
@ -408,6 +411,11 @@ public class CommandFactory {
|
|||
return new CLIUnsetSubstitutePath(ctx);
|
||||
}
|
||||
|
||||
/** @since 7.2 */
|
||||
public ICommand<CLIVersionInfo> createCLIVersion(ICommandControlDMContext ctx) {
|
||||
return new CLIVersion(ctx);
|
||||
}
|
||||
|
||||
/** @since 4.0 */
|
||||
public ICommand<MIAddInferiorInfo> createMIAddInferior(ICommandControlDMContext ctx) {
|
||||
return new MIAddInferior(ctx);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2025 John Dallaway and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* John Dallaway - Initial implementation (#1186)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command.commands;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.CLIVersionInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
|
||||
|
||||
/**
|
||||
* CLI 'version' command to report the debugger version where the MI -gdb-version command is not available
|
||||
*
|
||||
* @since 7.2
|
||||
*/
|
||||
public class CLIVersion extends CLICommand<CLIVersionInfo> {
|
||||
|
||||
private static final String VERSION = "version"; //$NON-NLS-1$
|
||||
|
||||
public CLIVersion(ICommandControlDMContext ctx) {
|
||||
super(ctx, VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLIVersionInfo getResult(MIOutput miResult) {
|
||||
return new CLIVersionInfo(miResult);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2025 John Dallaway and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* John Dallaway - Initial implementation (#1186)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command.output;
|
||||
|
||||
/**
|
||||
* CLI 'version' command returns the debugger version.
|
||||
*
|
||||
* sample output:
|
||||
*
|
||||
* (gdb) version
|
||||
* ~"lldb version 20.1.2\n"
|
||||
* ^done
|
||||
*
|
||||
* @since 7.2
|
||||
*/
|
||||
public class CLIVersionInfo extends MIInfo {
|
||||
|
||||
private String fFullOutput;
|
||||
|
||||
public CLIVersionInfo(MIOutput record) {
|
||||
super(record);
|
||||
parse();
|
||||
}
|
||||
|
||||
protected void parse() {
|
||||
if (isDone()) {
|
||||
MIOutput out = getMIOutput();
|
||||
MIOOBRecord[] records = out.getMIOOBRecords();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (MIOOBRecord rec : records) {
|
||||
if (rec instanceof MIConsoleStreamOutput) {
|
||||
MIStreamRecord o = (MIStreamRecord) rec;
|
||||
builder.append(o.getString());
|
||||
}
|
||||
}
|
||||
fFullOutput = builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getFullOutput() {
|
||||
return fFullOutput;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,11 +3,11 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.llvm.dsf.lldb.core;singleton:=true
|
||||
Bundle-Version: 1.102.300.qualifier
|
||||
Bundle-Version: 1.102.400.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-17
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.debug.core;bundle-version="[3.23.0,4)",
|
||||
org.eclipse.cdt.dsf.gdb;bundle-version="[7.1.500,8)",
|
||||
org.eclipse.cdt.dsf.gdb;bundle-version="[7.2.0,8)",
|
||||
org.eclipse.cdt.launch;bundle-version="[11.0.0,12)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.33.0,4)",
|
||||
org.eclipse.cdt.dsf;bundle-version="[2.12.200,3)",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Ericsson.
|
||||
* Copyright (c) 2016, 2025 Ericsson and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -7,16 +7,31 @@
|
|||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
* Contributors:
|
||||
* Ericsson - Initial implementation for LLDB
|
||||
* John Dallaway - Avoid unsupported MI commands (#1186)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.llvm.dsf.lldb.core.internal.launching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
|
||||
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence_7_2;
|
||||
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.CLIVersionInfo;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.llvm.dsf.lldb.core.internal.LLDBCorePlugin;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
/**
|
||||
* A LLDB-specific launch sequence that was initially created to work around the
|
||||
|
@ -24,6 +39,8 @@ import org.eclipse.cdt.dsf.service.DsfSession;
|
|||
*/
|
||||
public class LLDBFinalLaunchSequence extends FinalLaunchSequence_7_2 {
|
||||
|
||||
private IGDBControl fCommandControl;
|
||||
|
||||
/**
|
||||
* Constructs the {@link LLDBFinalLaunchSequence}.
|
||||
*
|
||||
|
@ -39,12 +56,53 @@ public class LLDBFinalLaunchSequence extends FinalLaunchSequence_7_2 {
|
|||
super(session, attributes, rm);
|
||||
}
|
||||
|
||||
@Execute
|
||||
@Override
|
||||
public void stepSetNonStop(RequestMonitor requestMonitor) {
|
||||
// LLDB doesn't support non-stop and target-async cannot be disabled so
|
||||
// do not do anything in this step
|
||||
protected String[] getExecutionOrder(String group) {
|
||||
if (GROUP_TOP_LEVEL.equals(group)) {
|
||||
List<String> orderList = new ArrayList<>(Arrays.asList(super.getExecutionOrder(GROUP_TOP_LEVEL)));
|
||||
|
||||
orderList.add(orderList.indexOf("stepInitializeFinalLaunchSequence_7_2") + 1, //$NON-NLS-1$
|
||||
"stepInitializeLLDBFinalLaunchSequence"); //$NON-NLS-1$
|
||||
|
||||
// Remove or replace steps that are not supported by LLDB-MI
|
||||
orderList.set(orderList.indexOf("stepGDBVersion"), "stepVersion"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
orderList.remove(orderList.indexOf("stepSetNonStop")); //$NON-NLS-1$
|
||||
orderList.remove(orderList.indexOf("stepSetPrintObject")); //$NON-NLS-1$
|
||||
|
||||
return orderList.toArray(new String[orderList.size()]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void stepInitializeLLDBFinalLaunchSequence(RequestMonitor requestMonitor) {
|
||||
BundleContext bundleContext = FrameworkUtil.getBundle(LLDBFinalLaunchSequence.class).getBundleContext();
|
||||
DsfServicesTracker tracker = new DsfServicesTracker(bundleContext, getSession().getId());
|
||||
fCommandControl = tracker.getService(IGDBControl.class);
|
||||
tracker.dispose();
|
||||
if (fCommandControl == null) {
|
||||
requestMonitor.setStatus(
|
||||
new Status(IStatus.ERROR, LLDBCorePlugin.PLUGIN_ID, -1, "Cannot obtain control service", null)); //$NON-NLS-1$
|
||||
requestMonitor.done();
|
||||
return;
|
||||
}
|
||||
requestMonitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the version of LLDB reported by LLDB-MI.
|
||||
*/
|
||||
@Execute
|
||||
public void stepVersion(final RequestMonitor requestMonitor) {
|
||||
fCommandControl.queueCommand(fCommandControl.getCommandFactory().createCLIVersion(fCommandControl.getContext()),
|
||||
new DataRequestMonitor<CLIVersionInfo>(getExecutor(), requestMonitor) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
// Accept failures
|
||||
requestMonitor.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue