Skip to content

Commit 3b3a41c

Browse files
artemmukhinyopox
authored andcommitted
intellij-rust#7727: Fix DTrace profiler integration with CLion 2021.2
1 parent bf0f31f commit 3b3a41c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clion/src/main/kotlin/org/rust/clion/profiler/dtrace/RsDTraceProfilerProcess.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
package org.rust.clion.profiler.dtrace
77

8+
import com.intellij.openapi.application.ApplicationInfo
89
import com.intellij.openapi.progress.PerformInBackgroundOption
910
import com.intellij.openapi.project.Project
11+
import com.intellij.openapi.util.BuildNumber
1012
import com.intellij.profiler.DummyCallTreeBuilder
1113
import com.intellij.profiler.api.*
1214
import com.intellij.profiler.dtrace.DTraceProfilerProcessBase
@@ -38,7 +40,12 @@ class RsDTraceProfilerProcess private constructor(
3840

3941
override fun createDumpParser(): FullDumpParser<BaseCallStackElement> {
4042
val cachingStackElementReader = RsCachingStackElementReader.getInstance(project)
41-
return FullDumpParser(NativeThread.Companion::fromId, cachingStackElementReader::parseStackElement)
43+
// BACKCOMPAT: 2021.1. Since 2021.2, CLion does not show the thread id, so it should be specified as a thread name
44+
val shouldSpecifyThreadName = ApplicationInfo.getInstance().build >= BUILD_212
45+
return FullDumpParser(
46+
{ if (shouldSpecifyThreadName) NativeThread(it, "thread with id $it") else NativeThread(it, "") },
47+
cachingStackElementReader::parseStackElement
48+
)
4249
}
4350

4451
override fun createDumpWriter(data: NewCallTreeOnlyProfilerData): ProfilerDumpWriter =
@@ -86,3 +93,6 @@ class RsDTraceProfilerProcess private constructor(
8693
}
8794
}
8895
}
96+
97+
// BACKCOMPAT: 2021.1
98+
private val BUILD_212: BuildNumber = BuildNumber.fromString("212")!!

0 commit comments

Comments
 (0)