1
1
using MemoScope . Core ;
2
2
using MemoScope . Modules . StackTrace ;
3
3
using Microsoft . Diagnostics . Runtime ;
4
- using System . Linq ;
5
4
using System . Collections . Generic ;
5
+ using MemoScope . Core . Helpers ;
6
6
7
7
namespace MemoScope . Modules . ThreadException
8
8
{
9
9
public partial class ThreadExceptionModule : UIClrDumpModule
10
10
{
11
- public ClrException Exception { get ; private set ; }
11
+ public List < ClrExceptionInformation > Exceptions { get ; private set ; }
12
12
private ClrThread ClrThread { get ; set ; }
13
13
private string Message { get ; set ; }
14
14
private List < StackFrameInformation > StackFrames { get ; set ; }
@@ -17,6 +17,7 @@ public ThreadExceptionModule()
17
17
{
18
18
InitializeComponent ( ) ;
19
19
dlvStackTrace . InitColumns < StackFrameInformation > ( ) ;
20
+ dlvExceptions . InitColumns < ClrExceptionInformation > ( ) ;
20
21
}
21
22
22
23
public void Setup ( ClrDump clrDump , ClrThread clrThread )
@@ -30,17 +31,36 @@ public void Setup(ClrDump clrDump, ClrThread clrThread)
30
31
public override void PostInit ( )
31
32
{
32
33
base . PostInit ( ) ;
33
- Summary = $ "Id: { ClrThread . ManagedThreadId } : { Message } ";
34
- tbExceptionType . Text = Exception . Type . Name ;
35
- tbMessage . Text = Message ;
36
- dlvStackTrace . Objects = StackFrames ;
34
+ Summary = $ "Id: { ClrThread . ManagedThreadId } : { Exceptions . Count } exceptions";
37
35
}
38
36
39
37
public override void Init ( )
40
38
{
41
- Exception = ClrDump . Eval ( ( ) => ClrThread . CurrentException ) ;
42
- Message = ClrDump . Eval ( ( ) => Exception . Message ) ;
43
- StackFrames = ClrDump . Eval ( ( ) => Exception . StackTrace . Select ( frame => new StackFrameInformation ( ClrDump , frame ) ) ) . ToList ( ) ;
39
+ Exceptions = new List < ClrExceptionInformation > ( ) ;
40
+ ClrException exception = ClrDump . Eval ( ( ) => ClrThread . CurrentException ) ;
41
+ while ( exception != null )
42
+ {
43
+ Exceptions . Add ( new ClrExceptionInformation ( ClrDump , exception ) ) ;
44
+ exception = ClrDump . Eval ( ( ) => exception . Inner ) ;
45
+ }
46
+
47
+ dlvExceptions . Objects = Exceptions ;
48
+ }
49
+
50
+ private void dlvExceptions_SelectedIndexChanged ( object sender , System . EventArgs e )
51
+ {
52
+ var exception = dlvExceptions . SelectedObject < ClrExceptionInformation > ( ) ;
53
+ if ( exception != null )
54
+ {
55
+ Init ( exception ) ;
56
+ }
57
+ }
58
+
59
+ private void Init ( ClrExceptionInformation exception )
60
+ {
61
+ tbExceptionType . Text = exception . TypeName ;
62
+ tbMessage . Text = exception . Message ;
63
+ dlvStackTrace . Objects = exception . StackFrames ;
44
64
}
45
65
}
46
66
}
0 commit comments