mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Deal with Shared Lib Events from GDB
This commit is contained in:
parent
551a927cf2
commit
081b8cd7ca
2 changed files with 59 additions and 25 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MIInferiorSignalExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISharedLibEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
|
||||
|
@ -65,8 +66,7 @@ public class RxThread extends Thread {
|
|||
* search for the corresponding token in rxQueue for the ResultRecord.
|
||||
*/
|
||||
public void run() {
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(session.getChannelInputStream()));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(session.getChannelInputStream()));
|
||||
try {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
@ -125,8 +125,7 @@ public class RxThread extends Thread {
|
|||
|
||||
// Clear the accumulate oobList on each new Result Command
|
||||
// response.
|
||||
MIOOBRecord [] oobRecords =
|
||||
(MIOOBRecord[])oobList.toArray(new MIOOBRecord[0]);
|
||||
MIOOBRecord[] oobRecords = (MIOOBRecord[]) oobList.toArray(new MIOOBRecord[0]);
|
||||
oobList.clear();
|
||||
|
||||
// Check if the state changed.
|
||||
|
@ -227,6 +226,23 @@ public class RxThread extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
// GDB does not have reason when stopping on shared, hopefully
|
||||
// this will be fix in newer version meanwhile, we will use a hack
|
||||
// to cope. On most platform we can detect by looking at the
|
||||
// console stream for phrase:
|
||||
// ~"Stopped due to shared library event\n"
|
||||
//
|
||||
// Althought it is a _real_ bad idea to do this, we do not have
|
||||
// any other alternatives.
|
||||
String[] logs = getStreamRecords();
|
||||
for (int i = 0; i < logs.length; i++) {
|
||||
if (logs[i].equalsIgnoreCase("Stopped due to shared library event")) {
|
||||
session.getMIInferior().setSuspended();
|
||||
e = new MISharedLibEvent(exec);
|
||||
list.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
// We were stopped for some unknown reason, for example
|
||||
// GDB for temporary breakpoints will not send the
|
||||
// "reason" ??? still fire a stopped event.
|
||||
|
@ -330,9 +346,10 @@ public class RxThread extends Thread {
|
|||
event = new MIBreakpointHitEvent(rr);
|
||||
}
|
||||
session.getMIInferior().setSuspended();
|
||||
} else if ("watchpoint-trigger".equals(reason) ||
|
||||
"read-watchpoint-trigger".equals(reason) ||
|
||||
"access-watchpoint-trigger".equals(reason)) {
|
||||
} else if (
|
||||
"watchpoint-trigger".equals(reason)
|
||||
|| "read-watchpoint-trigger".equals(reason)
|
||||
|| "access-watchpoint-trigger".equals(reason)) {
|
||||
if (exec != null) {
|
||||
event = new MIWatchpointTriggerEvent(exec);
|
||||
} else if (rr != null) {
|
||||
|
@ -374,8 +391,7 @@ public class RxThread extends Thread {
|
|||
event = new MIFunctionFinishedEvent(rr);
|
||||
}
|
||||
session.getMIInferior().setSuspended();
|
||||
} else if ("exited-normally".equals(reason) ||
|
||||
"exited".equals(reason)) {
|
||||
} else if ("exited-normally".equals(reason) || "exited".equals(reason)) {
|
||||
if (exec != null) {
|
||||
event = new MIInferiorExitEvent(exec);
|
||||
} else if (rr != null) {
|
||||
|
@ -393,4 +409,18 @@ public class RxThread extends Thread {
|
|||
return event;
|
||||
}
|
||||
|
||||
String[] getStreamRecords() {
|
||||
List streamRecords = new ArrayList();
|
||||
MIOOBRecord[] oobRecords = (MIOOBRecord[]) oobList.toArray(new MIOOBRecord[0]);
|
||||
for (int i = 0; i < oobRecords.length; i++) {
|
||||
if (oobRecords[i] instanceof MIStreamRecord) {
|
||||
String s = ((MIStreamRecord) oobRecords[i]).getString().trim();
|
||||
if (s != null && s.length() > 0) {
|
||||
streamRecords.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (String[]) streamRecords.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.BreakpointHit;
|
|||
import org.eclipse.cdt.debug.mi.core.cdi.EndSteppingRange;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.ErrorInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.SignalReceived;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.WatchpointScope;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.WatchpointTrigger;
|
||||
|
@ -21,6 +22,7 @@ import org.eclipse.cdt.debug.mi.core.event.MIErrorEvent;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISharedLibEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
|
@ -56,6 +58,8 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
|||
return new EndSteppingRange(session);
|
||||
} else if (event instanceof MIErrorEvent) {
|
||||
return new ErrorInfo(session, (MIErrorEvent)event);
|
||||
} else if (event instanceof MISharedLibEvent) {
|
||||
return new SharedLibraryEvent(session);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue