From 55dcaf643eccb50f2d614f863fc1803df97953bb Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 5 Dec 2002 16:00:50 +0000 Subject: [PATCH] get the log messages also --- .../cdt/debug/mi/core/MIException.java | 11 ++++ .../cdt/debug/mi/core/cdi/ErrorInfo.java | 7 +++ .../cdt/debug/mi/core/command/Command.java | 15 ++++- .../cdt/debug/mi/core/event/MIErrorEvent.java | 60 +++++++++++-------- 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIException.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIException.java index 51d7e2d9a53..8a4557b4944 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIException.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIException.java @@ -12,7 +12,18 @@ package org.eclipse.cdt.debug.mi.core; * */ public class MIException extends Exception { + String log = ""; + public MIException(String s) { super(s); } + + public MIException(String s, String l) { + super(s); + log = l; + } + + public String getLogMessage() { + return log; + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ErrorInfo.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ErrorInfo.java index 3a1665a8e4a..e4a43919773 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ErrorInfo.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ErrorInfo.java @@ -21,4 +21,11 @@ public class ErrorInfo extends SessionObject implements ICDIErrorInfo { return event.getMessage(); } + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo#getDetailMessage() + */ + public String getDetailMessage() { + return event.getLogMessage(); + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java index 6782f2bd337..b83d213393e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java @@ -8,7 +8,10 @@ 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.MILogStreamOutput; +import org.eclipse.cdt.debug.mi.core.output.MIOOBRecord; import org.eclipse.cdt.debug.mi.core.output.MIOutput; +import org.eclipse.cdt.debug.mi.core.output.MIStreamRecord; /** * A base class for all mi requests. @@ -67,8 +70,16 @@ public abstract class Command if (out != null) { info = new MIInfo(out); if (info.isError()) { - String s = info.getErrorMsg(); - throw new MIException(s); + String mesg = info.getErrorMsg(); + StringBuffer sb = new StringBuffer(); + MIOOBRecord[] oobs = out.getMIOOBRecords(); + for (int i = 0; i < oobs.length; i++) { + if (oobs[i] instanceof MILogStreamOutput) { + MIStreamRecord o = (MIStreamRecord) oobs[i]; + sb.append(o.getString()); + } + } + throw new MIException(mesg, sb.toString()); } } return info; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java index a0d2feaa351..d4ddf07b6a2 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java @@ -6,9 +6,11 @@ package org.eclipse.cdt.debug.mi.core.event; import org.eclipse.cdt.debug.mi.core.output.MIConst; -import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; +import org.eclipse.cdt.debug.mi.core.output.MILogStreamOutput; +import org.eclipse.cdt.debug.mi.core.output.MIOOBRecord; import org.eclipse.cdt.debug.mi.core.output.MIResult; import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; +import org.eclipse.cdt.debug.mi.core.output.MIStreamRecord; import org.eclipse.cdt.debug.mi.core.output.MIValue; @@ -22,14 +24,12 @@ import org.eclipse.cdt.debug.mi.core.output.MIValue; public class MIErrorEvent extends MIStoppedEvent { String msg = ""; + String log = ""; + MIOOBRecord[] oobs; - public MIErrorEvent(MIExecAsyncOutput async) { - super(async); - parse(); - } - - public MIErrorEvent(MIResultRecord record) { - super(record); + public MIErrorEvent(MIResultRecord rr, MIOOBRecord[] o) { + super(rr); + oobs = o; parse(); } @@ -37,29 +37,37 @@ public class MIErrorEvent extends MIStoppedEvent { return msg; } + public String getLogMessage() { + return log; + } + void parse () { - MIResult[] results = null; - MIExecAsyncOutput exec = getMIExecAsyncOutput(); MIResultRecord rr = getMIResultRecord(); + if (rr != null) { + MIResult[] results = rr.getMIResults(); + if (results != null) { + for (int i = 0; i < results.length; i++) { + String var = results[i].getVariable(); + MIValue value = results[i].getMIValue(); + String str = ""; + if (value instanceof MIConst) { + str = ((MIConst)value).getString(); + } - if (exec != null) { - results = exec.getMIResults(); - } else if (rr != null) { - results = rr.getMIResults(); - } - - if (results != null) { - for (int i = 0; i < results.length; i++) { - String var = results[i].getVariable(); - MIValue value = results[i].getMIValue(); - String str = ""; - if (value instanceof MIConst) { - str = ((MIConst)value).getString(); + if (var.equals("msg")) { + msg = str; + } } - - if (var.equals("msg")) { - msg = str; + } + if (oobs != null) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < oobs.length; i++) { + if (oobs[i] instanceof MILogStreamOutput) { + MIStreamRecord o = (MIStreamRecord)oobs[i]; + sb.append(o.getString()); + } } + log = sb.toString(); } } }