Skip to content

Commit 189fdd5

Browse files
insert corFunctionBreakpoints in several app domains
1 parent 26098ba commit 189fdd5

File tree

1 file changed

+42
-27
lines changed

1 file changed

+42
-27
lines changed

Mono.Debugging.Win32/CorDebuggerSession.cs

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -888,13 +888,15 @@ protected override void OnEnableBreakEvent (BreakEventInfo binfo, bool enable)
888888
{
889889
MtaThread.Run (delegate
890890
{
891-
CorBreakpoint bp = binfo.Handle as CorFunctionBreakpoint;
892-
if (bp != null) {
893-
try {
894-
bp.Activate (enable);
895-
}
896-
catch (COMException e) {
897-
HandleBreakpointException (binfo, e);
891+
var bpList = binfo.Handle as List<CorFunctionBreakpoint>;
892+
if (bpList != null) {
893+
foreach (var bp in bpList) {
894+
try {
895+
bp.Activate (enable);
896+
}
897+
catch (COMException e) {
898+
HandleBreakpointException (binfo, e);
899+
}
898900
}
899901
}
900902
});
@@ -1040,16 +1042,21 @@ protected override BreakEventInfo OnInsertBreakEvent (BreakEvent be)
10401042
// FIXME: implement breaking on function name
10411043
binfo.SetStatus (BreakEventStatus.Invalid, "Function breakpoint is not implemented");
10421044
return binfo;
1043-
} else {
1044-
DocInfo doc = null;
1045+
}
1046+
else {
1047+
var docInfos = new List<DocInfo> ();
10451048
lock (appDomainsLock) {
10461049
foreach (var appDomainInfo in appDomains) {
10471050
var documents = appDomainInfo.Value.Documents;
1048-
if (documents.TryGetValue (Path.GetFullPath (bp.FileName), out doc)) {
1049-
break;
1051+
DocInfo docInfo = null;
1052+
if (documents.TryGetValue (Path.GetFullPath (bp.FileName), out docInfo)) {
1053+
docInfos.Add (docInfo);
10501054
}
10511055
}
10521056
}
1057+
1058+
var doc = docInfos.FirstOrDefault (); //get info about source position using SymbolReader of first DocInfo
1059+
10531060
if (doc == null) {
10541061
binfo.SetStatus (BreakEventStatus.NotBound, string.Format("{0} is not found among the loaded symbol documents", bp.FileName));
10551062
return binfo;
@@ -1145,16 +1152,22 @@ protected override BreakEventInfo OnInsertBreakEvent (BreakEvent be)
11451152
return binfo;
11461153
}
11471154

1148-
CorFunction func = doc.ModuleInfo.Module.GetFunctionFromToken (bestMethod.Token.GetToken ());
1149-
try {
1150-
CorFunctionBreakpoint corBp = func.ILCode.CreateBreakpoint (bestSp.Offset);
1151-
breakpoints[corBp] = binfo;
1152-
binfo.Handle = corBp;
1153-
corBp.Activate (bp.Enabled);
1154-
binfo.SetStatus (BreakEventStatus.Bound, null);
1155-
}
1156-
catch (COMException e) {
1157-
HandleBreakpointException (binfo, e);
1155+
foreach (var docInfo in docInfos) {
1156+
CorFunction func = docInfo.ModuleInfo.Module.GetFunctionFromToken (bestMethod.Token.GetToken ());
1157+
1158+
try {
1159+
CorFunctionBreakpoint corBp = func.ILCode.CreateBreakpoint (bestSp.Offset);
1160+
breakpoints[corBp] = binfo;
1161+
1162+
if (binfo.Handle == null)
1163+
binfo.Handle = new List<CorFunctionBreakpoint> ();
1164+
(binfo.Handle as List<CorFunctionBreakpoint>).Add (corBp);
1165+
corBp.Activate (bp.Enabled);
1166+
binfo.SetStatus (BreakEventStatus.Bound, null);
1167+
}
1168+
catch (COMException e) {
1169+
HandleBreakpointException (binfo, e);
1170+
}
11581171
}
11591172
return binfo;
11601173
}
@@ -1298,12 +1311,14 @@ protected override void OnRemoveBreakEvent (BreakEventInfo bi)
12981311

12991312
MtaThread.Run (delegate
13001313
{
1301-
CorFunctionBreakpoint corBp = (CorFunctionBreakpoint)bi.Handle;
1302-
try {
1303-
corBp.Activate (false);
1304-
}
1305-
catch (COMException e) {
1306-
HandleBreakpointException (bi, e);
1314+
var corBpList = (List<CorFunctionBreakpoint>)bi.Handle;
1315+
foreach (var corBp in corBpList) {
1316+
try {
1317+
corBp.Activate (false);
1318+
}
1319+
catch (COMException e) {
1320+
HandleBreakpointException (bi, e);
1321+
}
13071322
}
13081323
});
13091324
}

0 commit comments

Comments
 (0)