mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 455408 - Show GDB version at startup
Change-Id: Ib22d98d31ed2c03c3ef3a0b5a22f8a22c6ee3e50 Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/38387 Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
parent
5aa10c7fc0
commit
c631da77c6
4 changed files with 142 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 Ericsson and others.
|
||||
* Copyright (c) 2008, 2014 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
|
||||
|
@ -15,6 +15,7 @@
|
|||
* Mathias Kunter - Support for different charsets (bug 370462)
|
||||
* Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536)
|
||||
* Xavier Raynaud (Kalray) - Avoid duplicating fields in sub-classes (add protected accessors)
|
||||
* Marc Khouzam (Ericsson) - Output the version of GDB at startup (Bug 455408)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.launching;
|
||||
|
||||
|
@ -45,6 +46,7 @@ import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
|||
import org.eclipse.cdt.dsf.mi.service.CSourceLookup;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBVersionInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
|
@ -100,6 +102,7 @@ public class FinalLaunchSequence extends ReflectionSequence {
|
|||
return new String[] {
|
||||
"stepInitializeFinalLaunchSequence", //$NON-NLS-1$
|
||||
// Global GDB settings
|
||||
"stepGDBVersion", //$NON-NLS-1$
|
||||
"stepSetEnvironmentDirectory", //$NON-NLS-1$
|
||||
"stepSetBreakpointPending", //$NON-NLS-1$
|
||||
"stepEnablePrettyPrinting", //$NON-NLS-1$
|
||||
|
@ -176,6 +179,23 @@ public class FinalLaunchSequence extends ReflectionSequence {
|
|||
requestMonitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the version of GDB.
|
||||
* @since 4.6
|
||||
*/
|
||||
@Execute
|
||||
public void stepGDBVersion(final RequestMonitor requestMonitor) {
|
||||
fCommandControl.queueCommand(
|
||||
fCommandFactory.createMIGDBVersion(fCommandControl.getContext()),
|
||||
new DataRequestMonitor<MIGDBVersionInfo>(getExecutor(), requestMonitor) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
// Accept failures
|
||||
requestMonitor.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify GDB's working directory.
|
||||
* @since 4.0
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* Dmitry Kozlov (Mentor Graphics) - New trace-related methods (Bug 390827)
|
||||
* Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Support 16 bit addressable size (Bug 426730)
|
||||
* Marc Khouzam (Ericsson) - Support for dynamic printf (Bug 400638)
|
||||
* Marc Khouzam (Ericsson) - Support for -gdb-version (Bug 455408)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command;
|
||||
|
@ -137,6 +138,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTraceNotes;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTraceUser;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBShowExitCode;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBShowLanguage;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBVersion;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIInferiorTTYSet;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIInfoOs;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIInterpreterExec;
|
||||
|
@ -205,6 +207,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIDataReadMemoryInfo;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.output.MIDataWriteMemoryInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBShowExitCodeInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBShowLanguageInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBVersionInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfoOsInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIListFeaturesInfo;
|
||||
|
@ -823,6 +826,11 @@ public class CommandFactory {
|
|||
return new MIGDBShowLanguage(ctx);
|
||||
}
|
||||
|
||||
/** @since 4.6 */
|
||||
public ICommand<MIGDBVersionInfo> createMIGDBVersion(ICommandControlDMContext ctx) {
|
||||
return new MIGDBVersion(ctx);
|
||||
}
|
||||
|
||||
/** @since 4.0 */
|
||||
public ICommand<MIInfo> createMIInferiorTTYSet(IMIContainerDMContext dmc, String tty) {
|
||||
return new MIInferiorTTYSet(dmc, tty);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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:
|
||||
* Marc Khouzam (Ericsson) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.MIGDBVersionInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* -gdb-version
|
||||
*
|
||||
* @since 4.6
|
||||
*
|
||||
*/
|
||||
public class MIGDBVersion extends MICommand<MIGDBVersionInfo> {
|
||||
private static final String COMMAND = "-gdb-version"; //$NON-NLS-1$
|
||||
|
||||
public MIGDBVersion(ICommandControlDMContext ctx) {
|
||||
super(ctx, COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MIInfo getResult(MIOutput out) {
|
||||
return new MIGDBVersionInfo(out);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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:
|
||||
* Marc Khouzam (Ericsson) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command.output;
|
||||
|
||||
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIConsoleStreamOutput;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIOOBRecord;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIStreamRecord;
|
||||
|
||||
/**
|
||||
* '-gdb-version' Show version information for gdb.
|
||||
*
|
||||
* sample output:
|
||||
*
|
||||
* -gdb-version
|
||||
* ~"GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7\n"
|
||||
* ~"Copyright (C) 2014 Free Software Foundation, Inc.\n"
|
||||
* ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\nand \"show warranty\" for details.\n"
|
||||
* ~"This GDB was configured as \"x86_64-linux-gnu\".\nType \"show configuration\" for configuration details."
|
||||
* ~"\nFor bug reporting instructions, please see:\n"
|
||||
* ~"<http://www.gnu.org/software/gdb/bugs/>.\n"
|
||||
* ~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
|
||||
* ~"For help, type \"help\".\n"
|
||||
* ~"Type \"apropos word\" to search for commands related to \"word\".\n"
|
||||
* ^done
|
||||
*
|
||||
* @since 4.6
|
||||
*/
|
||||
public class MIGDBVersionInfo extends MIInfo {
|
||||
|
||||
private String fVersion;
|
||||
private String fFullOutput;
|
||||
|
||||
public MIGDBVersionInfo(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();
|
||||
fVersion = parseVersion(fFullOutput);
|
||||
}
|
||||
}
|
||||
|
||||
protected String parseVersion(String output) {
|
||||
return LaunchUtils.getGDBVersionFromText(output);
|
||||
}
|
||||
|
||||
public String getFullOutput() {
|
||||
return fFullOutput;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return fVersion;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue