Skip to content

Commit 9be63ec

Browse files
author
David Karlaš
authored
Merge pull request #1781 from JetBrains/corDebugFixes3
Cor debug fixes #3
2 parents e3fc88f + e1c7bdd commit 9be63ec

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

Mono.Debugging.Win32/CorDebuggerBacktrace.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,14 @@ public static SequencePoint GetSequencePoint(CorDebuggerSession session, CorFram
175175

176176
internal static StackFrame CreateFrame (CorDebuggerSession session, CorFrame frame)
177177
{
178-
// TODO: Fix remaining.
179178
uint address = 0;
180-
//string typeFQN;
181-
//string typeFullName;
182179
string addressSpace = "";
183180
string file = "";
184181
int line = 0;
185182
int endLine = 0;
186183
int column = 0;
187184
int endColumn = 0;
188-
string method = "";
185+
string method = "[Unknown]";
189186
string lang = "";
190187
string module = "";
191188
string type = "";
@@ -198,8 +195,15 @@ internal static StackFrame CreateFrame (CorDebuggerSession session, CorFrame fra
198195
module = frame.Function.Module.Name;
199196
CorMetadataImport importer = new CorMetadataImport (frame.Function.Module);
200197
MethodInfo mi = importer.GetMethodInfo (frame.Function.Token);
201-
method = mi.DeclaringType.FullName + "." + mi.Name;
202-
type = mi.DeclaringType.FullName;
198+
var declaringType = mi.DeclaringType;
199+
if (declaringType != null) {
200+
method = declaringType.FullName + "." + mi.Name;
201+
type = declaringType.FullName;
202+
}
203+
else {
204+
method = mi.Name;
205+
}
206+
203207
addressSpace = mi.Name;
204208

205209
var sp = GetSequencePoint (session, frame);
@@ -230,7 +234,7 @@ v is System.Diagnostics.DebuggerHiddenAttribute ||
230234
hasDebugInfo = true;
231235
} else if (frame.FrameType == CorFrameType.NativeFrame) {
232236
frame.GetNativeIP (out address);
233-
method = "<Unknown>";
237+
method = "[Native frame]";
234238
lang = "Native";
235239
} else if (frame.FrameType == CorFrameType.InternalFrame) {
236240
switch (frame.InternalFrameType) {
@@ -252,11 +256,8 @@ v is System.Diagnostics.DebuggerHiddenAttribute ||
252256
}
253257
}
254258

255-
if (method == null)
256-
method = "<Unknown>";
257-
258259
var loc = new SourceLocation (method, file, line, column, endLine, endColumn);
259-
return new StackFrame ((long)address, addressSpace, loc, lang, external, hasDebugInfo, hidden, null, null);
260+
return new StackFrame (address, addressSpace, loc, lang, external, hasDebugInfo, hidden, module, type);
260261
}
261262

262263
#endregion

Mono.Debugging.Win32/CorDebuggerSession.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CorDebuggerSession: DebuggerSession
3939

4040
static int evaluationTimestamp;
4141

42-
readonly SymbolBinder symbolBinder = new SymbolBinder ();
42+
readonly SymbolBinder symbolBinder = MtaThread.Run (() => new SymbolBinder ());
4343
readonly object appDomainsLock = new object ();
4444

4545
Dictionary<int, AppDomainInfo> appDomains = new Dictionary<int, AppDomainInfo> ();
@@ -1138,8 +1138,8 @@ protected override BreakEventInfo OnInsertBreakEvent (BreakEvent be)
11381138

11391139
private static void HandleBreakpointException (BreakEventInfo binfo, COMException e)
11401140
{
1141-
if (Enum.IsDefined (typeof(HResult), e.ErrorCode)) {
1142-
var code = (HResult) e.ErrorCode;
1141+
var code = e.ToHResult<HResult> ();
1142+
if (code != null) {
11431143
switch (code) {
11441144
case HResult.CORDBG_E_UNABLE_TO_SET_BREAKPOINT:
11451145
binfo.SetStatus (BreakEventStatus.Invalid, "Invalid breakpoint position");
@@ -1179,6 +1179,7 @@ protected override void OnNextLine ( )
11791179
void Step (bool into)
11801180
{
11811181
try {
1182+
ObjectAdapter.CancelAsyncOperations ();
11821183
if (stepper != null) {
11831184
CorFrame frame = activeThread.ActiveFrame;
11841185
ISymbolReader reader = GetReaderForModule (frame.Function.Module);
@@ -1222,7 +1223,7 @@ void Step (bool into)
12221223
process.Continue (false);
12231224
}
12241225
} catch (Exception e) {
1225-
OnDebuggerOutput (true, e.ToString ());
1226+
DebuggerLoggingService.LogError ("Exception on Step()", e);
12261227
}
12271228
}
12281229

Mono.Debugging.Win32/CorObjectAdaptor.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,16 @@ public override IStringAdaptor CreateStringAdaptor (EvaluationContext ctx, objec
851851

852852
public static CorValue GetRealObject (EvaluationContext cctx, object objr)
853853
{
854-
if (objr == null || ((CorValRef)objr).Val == null)
854+
if (objr == null)
855855
return null;
856856

857-
return GetRealObject (cctx, ((CorValRef)objr).Val);
857+
var corValue = objr as CorValue;
858+
if (corValue != null)
859+
return GetRealObject (cctx, corValue);
860+
var valRef = objr as CorValRef;
861+
if (valRef != null)
862+
return GetRealObject (cctx, valRef.Val);
863+
return null;
858864
}
859865

860866
public static CorValue GetRealObject (EvaluationContext ctx, CorValue obj)

0 commit comments

Comments
 (0)