diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_10.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_10.java index 771dc92b573..6edaf21723a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_10.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_10.java @@ -16,12 +16,15 @@ import org.eclipse.cdt.debug.core.model.IChangeReverseMethodHandler.ReverseTrace import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.dsf.gdb.service.IReverseRunControl2; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoRecordInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MINotifyAsyncOutput; +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.service.DsfSession; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -60,7 +63,7 @@ public class GDBRunControl_7_10 extends GDBRunControl_7_6 implements IReverseRun return; } - fCommandControl.addEventListener(this); + // Don't register as an event listener because our base class does it already register(new String[]{ IReverseRunControl2.class.getName() }, new Hashtable()); @@ -134,4 +137,41 @@ public class GDBRunControl_7_10 extends GDBRunControl_7_6 implements IReverseRun } }); } + + + @Override + public void eventReceived(Object output) { + if (output instanceof MIOutput) { + MIOOBRecord[] records = ((MIOutput)output).getMIOOBRecords(); + for (MIOOBRecord r : records) { + if (r instanceof MINotifyAsyncOutput) { + MINotifyAsyncOutput notifyOutput = (MINotifyAsyncOutput)r; + String asyncClass = notifyOutput.getAsyncClass(); + // These events have been added with GDB 7.6 + if ("record-started".equals(asyncClass) || //$NON-NLS-1$ + "record-stopped".equals(asyncClass)) { //$NON-NLS-1$ + if ("record-stopped".equals(asyncClass)) { //$NON-NLS-1$ + fReverseTraceMethod = ReverseTraceMethod.STOP_TRACE; + setReverseModeEnabled(false); + } else { + getConnection().queueCommand( + fCommandFactory.createCLIInfoRecord(getConnection().getContext()), + new DataRequestMonitor(getExecutor(), null) { + @Override + public void handleCompleted() { + if (isSuccess()) { + fReverseTraceMethod = getData().getReverseMethod(); + } else { + // Use a default value in case of error + fReverseTraceMethod = ReverseTraceMethod.FULL_TRACE; + } + setReverseModeEnabled(true); + } + }); + } + } + } + } + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java index ca4473b2627..0c5c5324719 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java @@ -54,6 +54,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.CLIDetach; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIExecAbort; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoBreak; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoProgram; +import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoRecord; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoSharedLibrary; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoThreads; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIJump; @@ -238,6 +239,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIVarSetFormatInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIVarShowAttributesInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIVarShowFormatInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIVarUpdateInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoRecordInfo; import org.eclipse.cdt.debug.core.model.IChangeReverseMethodHandler.ReverseTraceMethod; /** @@ -288,6 +290,11 @@ public class CommandFactory { return new CLIInfoProgram(ctx); } + /** @since 5.0*/ + public ICommand createCLIInfoRecord(ICommandControlDMContext ctx) { + return new CLIInfoRecord(ctx); + } + public ICommand createCLIInfoSharedLibrary(ISymbolDMContext ctx) { return new CLIInfoSharedLibrary(ctx); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIInfoRecord.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIInfoRecord.java new file mode 100644 index 00000000000..770840166c0 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIInfoRecord.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015 Intel Corporation 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: + * Intel Corporation - Added Reverse Debugging BTrace support + *******************************************************************************/ +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.MIInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoRecordInfo; + +/** + * @since 5.0 + */ +public class CLIInfoRecord extends MIInterpreterExecConsole { + private static final String COMMAND = "info record"; //$NON-NLS-1$ + + public CLIInfoRecord(ICommandControlDMContext ctx) { + super(ctx, COMMAND); + } + + @Override + public MIInfo getResult(MIOutput out) { + return new CLIInfoRecordInfo(out); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoRecordInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoRecordInfo.java new file mode 100644 index 00000000000..a223ebd166f --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoRecordInfo.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2015 Intel Corporation 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: + * Intel Corporation - Added Reverse Debugging BTrace support + *******************************************************************************/ +package org.eclipse.cdt.dsf.mi.service.command.output; + +import org.eclipse.cdt.debug.core.model.IChangeReverseMethodHandler.ReverseTraceMethod; + +/** + * 'info record' returns the selected reverse trace method. + * + * sample output: + * + * (gdb) info record + * ~ Active record target: record-btrace + * ~ Recording format: Branch Trace Store. + * ~ Buffer size: 64kB. + * ~ Recorded 0 instructions in 0 functions (0 gaps) for thread 1 (process 24645). + * + * @since 5.0 + */ + +public class CLIInfoRecordInfo extends MIInfo { + + private ReverseTraceMethod fReverseMethod; + + public CLIInfoRecordInfo(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()); + } + } + parseReverseMethod(builder.toString()); + } + } + + protected void parseReverseMethod(String output) { + if (output.contains("Processor")) { //$NON-NLS-1$ + fReverseMethod = ReverseTraceMethod.PROCESSOR_TRACE; + } else if (output.contains("Branch")) { //$NON-NLS-1$ + fReverseMethod = ReverseTraceMethod.BRANCH_TRACE; + } else if (output.contains("full")) { //$NON-NLS-1$ + fReverseMethod = ReverseTraceMethod.FULL_TRACE; + } else { + fReverseMethod = ReverseTraceMethod.STOP_TRACE; + } + } + + public ReverseTraceMethod getReverseMethod() { + return fReverseMethod; + } +}