@@ -15,10 +15,17 @@ public static ParallelStack Build(ClrRuntime runtime)
1515 foreach ( var thread in runtime . Threads )
1616 {
1717 stackFrames . Clear ( ) ;
18-
18+ #if ClrMD1
1919 foreach ( var stackFrame in thread . StackTrace . Reverse ( ) )
20+ #else
21+ foreach ( var stackFrame in thread . EnumerateStackTrace ( ) . Reverse ( ) )
22+ #endif
2023 {
24+ #if ClrMD1
2125 if ( stackFrame . Kind != ClrStackFrameType . ManagedMethod )
26+ #else
27+ if ( ( stackFrame . Kind != ClrStackFrameKind . ManagedMethod ) || ( stackFrame . Method == null ) )
28+ #endif
2229 continue ;
2330
2431 stackFrames . Add ( stackFrame ) ;
@@ -39,6 +46,7 @@ public static ParallelStack Build(string dumpFile, string dacFilePath)
3946 ParallelStack ps = null ;
4047 try
4148 {
49+ #if ClrMD1
4250 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
4351 {
4452 dataTarget = DataTarget . LoadCrashDump ( dumpFile ) ;
@@ -47,6 +55,15 @@ public static ParallelStack Build(string dumpFile, string dacFilePath)
4755 {
4856 dataTarget = DataTarget . LoadCoreDump ( dumpFile ) ;
4957 }
58+ #else
59+ if (
60+ ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ) ||
61+ ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
62+ )
63+ {
64+ dataTarget = DataTarget . LoadDump ( dumpFile ) ;
65+ }
66+ #endif
5067 else
5168 {
5269 throw new InvalidOperationException ( "Unsupported platform..." ) ;
@@ -74,6 +91,7 @@ public static ParallelStack Build(int pid, string dacFilePath)
7491 ParallelStack ps = null ;
7592 try
7693 {
94+ #if ClrMD1
7795 const uint msecTimeout = 2000 ;
7896
7997 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
@@ -86,6 +104,18 @@ public static ParallelStack Build(int pid, string dacFilePath)
86104 // ClrMD implementation for Linux is available only for Passive
87105 dataTarget = DataTarget . AttachToProcess ( pid , msecTimeout , AttachFlag . Passive ) ;
88106 }
107+ #else
108+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
109+ {
110+ dataTarget = DataTarget . AttachToProcess ( pid , true ) ;
111+ }
112+ else
113+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
114+ {
115+ // ClrMD implementation for Linux is available only for Passive
116+ dataTarget = DataTarget . AttachToProcess ( pid , true ) ;
117+ }
118+ #endif
89119 else
90120 {
91121 throw new InvalidOperationException ( "Unsupported platform..." ) ;
@@ -110,7 +140,11 @@ public static ParallelStack Build(int pid, string dacFilePath)
110140 private static ClrRuntime CreateRuntime ( DataTarget dataTarget , string dacFilePath )
111141 {
112142 // check bitness first
143+ #if ClrMD1
113144 bool isTarget64Bit = ( dataTarget . PointerSize == 8 ) ;
145+ #else
146+ bool isTarget64Bit = ( dataTarget . DataReader . PointerSize == 8 ) ;
147+ #endif
114148 if ( Environment . Is64BitProcess != isTarget64Bit )
115149 {
116150 throw new InvalidOperationException (
@@ -138,7 +172,11 @@ private ParallelStack(ClrStackFrame frame = null)
138172 private void AddStack ( uint threadId , ClrStackFrame [ ] frames , int index = 0 )
139173 {
140174 ThreadIds . Add ( threadId ) ;
175+ #if ClrMD1
141176 var firstFrame = frames [ index ] . DisplayString ;
177+ #else
178+ var firstFrame = frames [ index ] . Method ? . Signature ;
179+ #endif
142180 var callstack = Stacks . FirstOrDefault ( s => s . Frame . Text == firstFrame ) ;
143181 if ( callstack == null )
144182 {
0 commit comments