mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Bug 488660 - Refresh reverse toggle on console changes with GDB 7.10
The patch implements the event handler which queries the trace method and triggers the necessary update in the command handler. Change-Id: I9c1827deb56dce099b7f455e942d1b6735a80643 Signed-off-by: raddepal <ravitheja.addepally@intel.com> Signed-off-by: ravitheja.addepally <ravitheja.addepally@intel.com>
This commit is contained in:
parent
76dee8f4d1
commit
4a54e2269f
4 changed files with 149 additions and 2 deletions
|
@ -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<String,String>());
|
||||
|
@ -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<CLIInfoRecordInfo>(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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CLIInfoRecordInfo> createCLIInfoRecord(ICommandControlDMContext ctx) {
|
||||
return new CLIInfoRecord(ctx);
|
||||
}
|
||||
|
||||
public ICommand<CLIInfoSharedLibraryInfo> createCLIInfoSharedLibrary(ISymbolDMContext ctx) {
|
||||
return new CLIInfoSharedLibrary(ctx);
|
||||
}
|
||||
|
|
|
@ -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<CLIInfoRecordInfo> {
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue