mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Bug 69522. Changes to accommodate Apple's gdb: Added gdb/mi command factory for Mac OS. Reviewed and applied Greg's patch that beefs up support for MI results containing tuples. Added one additional change in MIVarUpdateInfo. Debug sessions now startup and variables display correctly on Mac OS 10.4.6 with latest dev tools.
Ran before and after tests on Windows and saw no ill effects or changes in behavior for variable display.
This commit is contained in:
parent
9aacb5a271
commit
e99188230e
11 changed files with 183 additions and 19 deletions
|
@ -0,0 +1,30 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2006 Nokia 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:
|
||||
* Nokia - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.command.factories.macos;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
|
||||
|
||||
public class MacOSMIEnvironmentCD extends MIEnvironmentCD {
|
||||
|
||||
public MacOSMIEnvironmentCD(String miVersion, String path) {
|
||||
super(miVersion, path);
|
||||
this.setOperation("cd");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected String parametersToString() {
|
||||
String[] parameters = getParameters();
|
||||
if (parameters != null && parameters.length == 1) {
|
||||
return '"' + parameters[0] + '"';
|
||||
}
|
||||
return super.parametersToString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2006 Nokia 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:
|
||||
* Nokia - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.core.command.factories.macos;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
|
||||
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
|
||||
|
||||
public class StandardMacOSCommandFactory extends StandardCommandFactory {
|
||||
|
||||
/**
|
||||
* Constructor for StandardMacOSCommandFactory.
|
||||
*/
|
||||
public StandardMacOSCommandFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for StandardMacOSCommandFactory.
|
||||
*/
|
||||
public StandardMacOSCommandFactory( String miVersion ) {
|
||||
super( miVersion );
|
||||
}
|
||||
|
||||
public MIEnvironmentCD createMIEnvironmentCD(String pathdir) {
|
||||
return new MacOSMIEnvironmentCD(getMIVersion(), pathdir);
|
||||
}
|
||||
|
||||
}
|
|
@ -63,6 +63,33 @@ public class MIArg {
|
|||
return ((MIArg[])aList.toArray(new MIArg[aList.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing a MITuple of the form:
|
||||
* {{name="xxx",value="yyy"},{name="xxx",value="yyy"},..}
|
||||
* {name="xxx",name="xxx",..}
|
||||
* {{name="xxx"},{name="xxx"}}
|
||||
*/
|
||||
public static MIArg[] getMIArgs(MITuple miTuple) {
|
||||
List aList = new ArrayList();
|
||||
MIValue[] values = miTuple.getMIValues();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] instanceof MITuple) {
|
||||
MIArg arg = getMIArg((MITuple)values[i]);
|
||||
if (arg != null) {
|
||||
aList.add(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
MIResult[] results = miTuple.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst)value).getCString();
|
||||
aList.add(new MIArg(str, "")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return ((MIArg[])aList.toArray(new MIArg[aList.size()]));
|
||||
}
|
||||
/**
|
||||
* Parsing a MITuple of the form:
|
||||
* {name="xxx",value="yyy"}
|
||||
|
|
|
@ -125,6 +125,8 @@ public class MIFrame {
|
|||
} else if (var.equals("args")) { //$NON-NLS-1$
|
||||
if (value instanceof MIList) {
|
||||
args = MIArg.getMIArgs((MIList)value);
|
||||
} else if (value instanceof MITuple) {
|
||||
args = MIArg.getMIArgs((MITuple)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,18 +326,31 @@ public class MIParser {
|
|||
*/
|
||||
private MIValue processMITuple(FSB buffer) {
|
||||
MITuple tuple = new MITuple();
|
||||
MIResult[] results = null;
|
||||
List valueList = new ArrayList();
|
||||
List resultList = new ArrayList();
|
||||
// Catch closing '}'
|
||||
while (buffer.length() > 0 && buffer.charAt(0) != '}') {
|
||||
results = processMIResults(buffer);
|
||||
// Try for the MIValue first
|
||||
MIValue value = processMIValue(buffer);
|
||||
if (value != null) {
|
||||
valueList.add(value);
|
||||
} else {
|
||||
MIResult result = processMIResult(buffer);
|
||||
if (result != null) {
|
||||
resultList.add(result);
|
||||
}
|
||||
}
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == ',') {
|
||||
buffer.deleteCharAt(0);
|
||||
}
|
||||
}
|
||||
if (buffer.length() > 0 && buffer.charAt(0) == '}') {
|
||||
buffer.deleteCharAt(0);
|
||||
}
|
||||
if (results == null) {
|
||||
results = new MIResult[0];
|
||||
}
|
||||
tuple.setMIResults(results);
|
||||
MIValue[] values = (MIValue[]) valueList.toArray(new MIValue[valueList.size()]);
|
||||
MIResult[] res = (MIResult[]) resultList.toArray(new MIResult[resultList.size()]);
|
||||
tuple.setMIValues(values);
|
||||
tuple.setMIResults(res);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ public class MIStackListArgumentsInfo extends MIInfo {
|
|||
MIValue val = results[i].getMIValue();
|
||||
if (val instanceof MIList) {
|
||||
parseStack((MIList)val, aList);
|
||||
} else if (val instanceof MITuple) {
|
||||
parseStack((MITuple)val, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,4 +68,16 @@ public class MIStackListArgumentsInfo extends MIInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
void parseStack(MITuple miTuple, List aList) {
|
||||
MIResult[] results = miTuple.getMIResults();
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
if (var.equals("frame")) { //$NON-NLS-1$
|
||||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MITuple) {
|
||||
aList.add (new MIFrame((MITuple)value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
* GDB/MI stack list locals parsing.
|
||||
* -stack-list-locals 1
|
||||
* ^done,locals=[{name="p",value="0x8048600 \"ghislaine\""},{name="buf",value="\"'\", 'x' <repeats 24 times>, \"i,xxxxxxxxx\", 'a' <repeats 24 times>"},{name="buf2",value="\"\\\"?'\\\\()~\""},{name="buf3",value="\"alain\""},{name="buf4",value="\"\\t\\t\\n\\f\\r\""},{name="i",value="0"}]
|
||||
*
|
||||
* On MacOS X 10.4 this returns a tuple:
|
||||
* ^done,locals={{name="p",value="0x8048600 \"ghislaine\""},{name="buf",value="\"'\", 'x' <repeats 24 times>, \"i,xxxxxxxxx\", 'a' <repeats 24 times>"},{name="buf2",value="\"\\\"?'\\\\()~\""},{name="buf3",value="\"alain\""},{name="buf4",value="\"\\t\\t\\n\\f\\r\""},{name="i",value="0"}}
|
||||
*/
|
||||
public class MIStackListLocalsInfo extends MIInfo {
|
||||
|
||||
|
@ -46,6 +49,8 @@ public class MIStackListLocalsInfo extends MIInfo {
|
|||
MIValue value = results[i].getMIValue();
|
||||
if (value instanceof MIList) {
|
||||
locals = MIArg.getMIArgs((MIList)value);
|
||||
} else if (value instanceof MITuple) {
|
||||
locals = MIArg.getMIArgs((MITuple)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
public class MITuple extends MIValue {
|
||||
|
||||
final static MIResult[] nullResults = new MIResult[0];
|
||||
final static MIValue[] nullValues = new MIValue[0];
|
||||
MIResult[] results = nullResults;
|
||||
MIValue[] values = nullValues;
|
||||
|
||||
public MIResult[] getMIResults() {
|
||||
return results;
|
||||
|
@ -26,6 +28,14 @@ public class MITuple extends MIValue {
|
|||
results = res;
|
||||
}
|
||||
|
||||
public MIValue[] getMIValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setMIValues(MIValue[] vals) {
|
||||
values = vals;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append('{');
|
||||
|
@ -35,6 +45,12 @@ public class MITuple extends MIValue {
|
|||
}
|
||||
buffer.append(results[i].toString());
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (i != 0) {
|
||||
buffer.append(',');
|
||||
}
|
||||
buffer.append(values[i].toString());
|
||||
}
|
||||
buffer.append('}');
|
||||
return buffer.toString();
|
||||
}
|
||||
|
|
|
@ -76,21 +76,27 @@ public class MIVarUpdateInfo extends MIInfo {
|
|||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
MIValue value = results[i].getMIValue();
|
||||
String str = ""; //$NON-NLS-1$
|
||||
if (value instanceof MIConst) {
|
||||
str = ((MIConst)value).getString();
|
||||
if (value instanceof MITuple) {
|
||||
parseChangeList((MITuple)value, aList);
|
||||
}
|
||||
if (var.equals("name")) { //$NON-NLS-1$
|
||||
change = new MIVarChange(str);
|
||||
aList.add(change);
|
||||
} else if (var.equals("in_scope")) { //$NON-NLS-1$
|
||||
if (change != null) {
|
||||
change.setInScope("true".equals(str)); //$NON-NLS-1$
|
||||
}
|
||||
} else if (var.equals("type_changed")) { //$NON-NLS-1$
|
||||
if (change != null) {
|
||||
change.setChanged("true".equals(str)); //$NON-NLS-1$
|
||||
else
|
||||
{
|
||||
String str = ""; //$NON-NLS-1$
|
||||
if (value instanceof MIConst) {
|
||||
str = ((MIConst)value).getString();
|
||||
}
|
||||
if (var.equals("name")) { //$NON-NLS-1$
|
||||
change = new MIVarChange(str);
|
||||
aList.add(change);
|
||||
} else if (var.equals("in_scope")) { //$NON-NLS-1$
|
||||
if (change != null) {
|
||||
change.setInScope("true".equals(str)); //$NON-NLS-1$
|
||||
}
|
||||
} else if (var.equals("type_changed")) { //$NON-NLS-1$
|
||||
if (change != null) {
|
||||
change.setChanged("true".equals(str)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@ GDBMIDebugger.name=gdb/mi
|
|||
StandardCommandFactory.name=Standard
|
||||
StandardLinuxCommandFactory.name=Standard (Linux)
|
||||
StandardWindowsCommandFactory.name=Standard (Windows)
|
||||
StandardMacOSCommandFactory.name=Standard (Mac OS)
|
||||
CygWinCommandFactory.name=CygWin
|
||||
|
|
|
@ -64,6 +64,13 @@
|
|||
miVersions="mi,mi1,mi2"
|
||||
name="%StandardLinuxCommandFactory.name"
|
||||
platforms="linux"/>
|
||||
<commandFactory
|
||||
class="org.eclipse.cdt.debug.mi.core.command.factories.macos.StandardMacOSCommandFactory"
|
||||
debuggerID="org.eclipse.cdt.debug.mi.core.CDebuggerNew"
|
||||
id="org.eclipse.cdt.debug.mi.core.standardMacOSCommandFactory"
|
||||
miVersions="mi,mi1,mi2"
|
||||
name="%StandardMacOSCommandFactory.name"
|
||||
platforms="macosx"/>
|
||||
<commandFactory
|
||||
class="org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory"
|
||||
debuggerID="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger"
|
||||
|
@ -92,6 +99,13 @@
|
|||
miVersions="mi,mi1,mi2"
|
||||
name="%StandardLinuxCommandFactory.name"
|
||||
platforms="linux"/>
|
||||
<commandFactory
|
||||
class="org.eclipse.cdt.debug.mi.core.command.factories.macos.StandardMacOSCommandFactory"
|
||||
debuggerID="org.eclipse.cdt.debug.mi.core.GDBServerCDebugger"
|
||||
id="org.eclipse.cdt.debug.mi.core.standardMacOSCommandFactory"
|
||||
miVersions="mi,mi1,mi2"
|
||||
name="%StandardMacOSCommandFactory.name"
|
||||
platforms="macosx"/>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
Loading…
Add table
Reference in a new issue