diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIPType.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIPType.java new file mode 100644 index 00000000000..1e73e0cf60d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIPType.java @@ -0,0 +1,40 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.core.command; + +import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import org.eclipse.cdt.debug.mi.core.output.MIOutput; +import org.eclipse.cdt.debug.mi.core.output.MIPTypeInfo; + +/** + * + * ptype type + * + */ +public class MIPType extends CLICommand +{ + public MIPType(String var) { + super("ptype " + var); + } + + public MIPTypeInfo getMIPtypeInfo() throws MIException { + return (MIPTypeInfo)getMIInfo(); + } + + public MIInfo getMIInfo() throws MIException { + MIInfo info = null; + MIOutput out = getMIOutput(); + if (out != null) { + info = new MIPTypeInfo(out); + if (info.isError()) { + throw new MIException(info.getErrorMsg()); + } + } + return info; + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java new file mode 100644 index 00000000000..41afefafb9d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MISharedLibrary.java @@ -0,0 +1,25 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.core.command; + +import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import org.eclipse.cdt.debug.mi.core.output.MIInfoSharedLibraryInfo; +import org.eclipse.cdt.debug.mi.core.output.MIOutput; + +/** + * + * sharedlibrary regex + * + */ +public class MISharedLibrary extends CLICommand +{ + public MISharedLibrary(String lib) { + super("sharedlibrary " + lib); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java new file mode 100644 index 00000000000..15ca85b0b4f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIWhatis.java @@ -0,0 +1,40 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.core.command; + +import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import org.eclipse.cdt.debug.mi.core.output.MIOutput; +import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo; + +/** + * + * whatis type + * + */ +public class MIWhatis extends CLICommand +{ + public MIWhatis(String var) { + super("whatis " + var); + } + + public MIWhatisInfo getMIWhatisInfo() throws MIException { + return (MIWhatisInfo)getMIInfo(); + } + + public MIInfo getMIInfo() throws MIException { + MIInfo info = null; + MIOutput out = getMIOutput(); + if (out != null) { + info = new MIWhatisInfo(out); + if (info.isError()) { + throw new MIException(info.getErrorMsg()); + } + } + return info; + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java new file mode 100644 index 00000000000..a21d91c68e3 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIPTypeInfo.java @@ -0,0 +1,48 @@ +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ +package org.eclipse.cdt.debug.mi.core.output; + +/** + * GDB/MI whatis parsing. + */ +public class MIPTypeInfo extends MIInfo { + + String type; + + public MIPTypeInfo(MIOutput out) { + super(out); + parse(); + } + + public String getType() { + return type; + } + + void parse() { + StringBuffer buffer = new StringBuffer(); + if (isDone()) { + MIOutput out = getMIOutput(); + MIOOBRecord[] oobs = out.getMIOOBRecords(); + for (int i = 0; i < oobs.length; i++) { + if (oobs[i] instanceof MIConsoleStreamOutput) { + MIStreamRecord cons = (MIStreamRecord) oobs[i]; + String str = cons.getString(); + // We are interested in the shared info + if (str != null) { + str = str.trim(); + if (str.startsWith ("type")) { + int equal = str.indexOf('='); + if (equal > 0) { + str = str.substring(equal + 1); + } + } + buffer.append(str); + } + } + } + } + type = buffer.toString().trim(); + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java new file mode 100644 index 00000000000..404100e1252 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIWhatisInfo.java @@ -0,0 +1,48 @@ +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ +package org.eclipse.cdt.debug.mi.core.output; + +/** + * GDB/MI whatis parsing. + */ +public class MIWhatisInfo extends MIInfo { + + String type; + + public MIWhatisInfo(MIOutput out) { + super(out); + parse(); + } + + public String getType() { + return type; + } + + void parse() { + StringBuffer buffer = new StringBuffer(); + if (isDone()) { + MIOutput out = getMIOutput(); + MIOOBRecord[] oobs = out.getMIOOBRecords(); + for (int i = 0; i < oobs.length; i++) { + if (oobs[i] instanceof MIConsoleStreamOutput) { + MIStreamRecord cons = (MIStreamRecord) oobs[i]; + String str = cons.getString(); + // We are interested in the shared info + if (str != null) { + str = str.trim(); + if (str.startsWith ("type")) { + int equal = str.indexOf('='); + if (equal > 0) { + str = str.substring(equal + 1); + } + } + buffer.append(str); + } + } + } + } + type = buffer.toString().trim(); + } +}