Enable light debug information (#4085)

Co-authored-by: Svyatoslav Scherbina <svyatoslav.scherbina@jetbrains.com>
This commit is contained in:
LepilkinaElena
2020-04-10 14:08:25 +03:00
committed by GitHub
parent 1745a95f57
commit c11bf26d97
6 changed files with 56 additions and 17 deletions
+6 -6
View File
@@ -9,21 +9,21 @@ symbolication turns machine code addresses into human-readable source locations.
The document below describes some specific details of symbolicating crash reports The document below describes some specific details of symbolicating crash reports
from iOS applications using Kotlin. from iOS applications using Kotlin.
## Enable .dSYM for release Kotlin binaries ## Producing .dSYM for release Kotlin binaries
To symbolicate addresses in Kotlin code (e.g. for stack trace elements To symbolicate addresses in Kotlin code (e.g. for stack trace elements
corresponding to Kotlin code) `.dSYM` bundle for Kotlin code is required. corresponding to Kotlin code) `.dSYM` bundle for Kotlin code is required.
By default Kotlin/Native compiler doesn't produce `.dSYM` for release By default Kotlin/Native compiler produces `.dSYM` for release
(i.e. optimized) binaries. This can be changed with `-Xg0` experimental (i.e. optimized) binaries on Darwin platforms. This can be disabled with `-Xadd-light-debug=disable`
compiler flag: it enables debug info and `.dSYM` bundle generation for produced compiler flag. At the same time this option is disabled by default for other platforms, to enable it use `-Xadd-light-debug=enable`.
release binaries. To enable it in Gradle, use To control option in Gradle, use
```kotlin ```kotlin
kotlin { kotlin {
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> { targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
binaries.all { binaries.all {
freeCompilerArgs += "-Xg0" freeCompilerArgs += "-Xadd-light-debug={enable|disable}"
} }
} }
} }
@@ -152,7 +152,21 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
put(LIST_TARGETS, arguments.listTargets) put(LIST_TARGETS, arguments.listTargets)
put(OPTIMIZATION, arguments.optimization) put(OPTIMIZATION, arguments.optimization)
put(DEBUG, arguments.debug) put(DEBUG, arguments.debug)
put(LIGHT_DEBUG, arguments.lightDebug) // TODO: remove after 1.4 release.
if (arguments.lightDebugDeprecated) {
configuration.report(WARNING,
"-Xg0 is now deprecated and skipped by compiler. Light debug information is enabled by default for Darwin platforms." +
" For other targets, please, use `-Xadd-light-debug=enable` instead.")
}
putIfNotNull(LIGHT_DEBUG, when (val it = arguments.lightDebugString) {
"enable" -> true
"disable" -> false
null -> null
else -> {
configuration.report(ERROR, "Unsupported -Xadd-light-debug= value: $it. Possible values are 'enable'/'disable'")
null
}
})
put(STATIC_FRAMEWORK, selectFrameworkType(configuration, arguments, outputKind)) put(STATIC_FRAMEWORK, selectFrameworkType(configuration, arguments, outputKind))
put(OVERRIDE_CLANG_OPTIONS, arguments.clangOptions.toNonNullList()) put(OVERRIDE_CLANG_OPTIONS, arguments.clangOptions.toNonNullList())
put(ALLOCATION_MODE, arguments.allocator) put(ALLOCATION_MODE, arguments.allocator)
@@ -152,8 +152,18 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
) )
var frameworkImportHeaders: Array<String>? = null var frameworkImportHeaders: Array<String>? = null
@Argument(value = "-Xg0", description = "Add light debug information") @Argument(
var lightDebug: Boolean = false value = "-Xadd-light-debug",
valueDescription = "{disable|enable}",
description = "Add light debug information for optimized builds. This option is skipped in debug builds.\n" +
"It's enabled by default on Darwin platforms where collected debug information is stored in .dSYM file.\n" +
"Currently option is disabled by default on other platforms."
)
var lightDebugString: String? = null
// TODO: remove after 1.4 release.
@Argument(value = "-Xg0", description = "Add light debug information. Deprecated option. Please use instead -Xadd-light-debug=enable")
var lightDebugDeprecated: Boolean = false
@Argument( @Argument(
value = MAKE_CACHE, value = MAKE_CACHE,
@@ -37,7 +37,8 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
// TODO: debug info generation mode and debug/release variant selection probably requires some refactoring. // TODO: debug info generation mode and debug/release variant selection probably requires some refactoring.
val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG) val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG)
val lightDebug: Boolean get() = configuration.getBoolean(KonanConfigKeys.LIGHT_DEBUG) val lightDebug: Boolean = configuration.get(KonanConfigKeys.LIGHT_DEBUG)
?: target.family.isAppleFamily // Default is true for Apple targets.
val memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!! val memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!!
@@ -52,7 +52,7 @@ class KonanConfigKeys {
= CompilerConfigurationKey.create("library file paths") = CompilerConfigurationKey.create("library file paths")
val LIBRARY_VERSION: CompilerConfigurationKey<String?> val LIBRARY_VERSION: CompilerConfigurationKey<String?>
= CompilerConfigurationKey.create("library version") = CompilerConfigurationKey.create("library version")
val LIGHT_DEBUG: CompilerConfigurationKey<Boolean> val LIGHT_DEBUG: CompilerConfigurationKey<Boolean?>
= CompilerConfigurationKey.create("add light debug information") = CompilerConfigurationKey.create("add light debug information")
val LINKER_ARGS: CompilerConfigurationKey<List<String>> val LINKER_ARGS: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("additional linker arguments") = CompilerConfigurationKey.create("additional linker arguments")
+20 -6
View File
@@ -37,10 +37,26 @@ task clean {
defaultTasks 'konanRun' defaultTasks 'konanRun'
private static String getAnalyzerTargetName() {
// Copy-pasted from tools/benchmarksAnalyzer/build.gradle.
String target = System.getProperty("os.name")
if (target == 'Linux') return 'linux'
if (target.startsWith('Windows')) return 'windows'
if (target.startsWith('Mac')) return 'macos'
return 'unknown'
}
private String findAnalyzerBinary() {
String result = "${rootProject.projectDir}/${analyzerToolDirectory}/${getAnalyzerTargetName()}/" +
"${analyzerTool}ReleaseExecutable/${analyzerTool}${MPPTools.getNativeProgramExtension()}"
if (file(result).exists()) return result
else return null
}
// Produce and send slack report. // Produce and send slack report.
task slackReport(type: RegressionsReporter) { task slackReport(type: RegressionsReporter) {
def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}", def analyzerBinary = findAnalyzerBinary()
"${rootBuildDirectory}/${analyzerToolDirectory}")
def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE") def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")
if (teamcityConfig && analyzerBinary != null) { if (teamcityConfig && analyzerBinary != null) {
// Create folder for report (root Kotlin project settings make create report in separate folder). // Create folder for report (root Kotlin project settings make create report in separate folder).
@@ -143,8 +159,7 @@ task registerExternalBenchmarks {
} }
task registerBuild(type: BuildRegister) { task registerBuild(type: BuildRegister) {
def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}", def analyzerBinary = findAnalyzerBinary()
"${rootBuildDirectory}/${analyzerToolDirectory}")
if (analyzerBinary != null) { if (analyzerBinary != null) {
onlyBranch = project.findProperty('kotlin.register.branch') onlyBranch = project.findProperty('kotlin.register.branch')
// Get bundle size. // Get bundle size.
@@ -194,8 +209,7 @@ subprojects.each {
} }
task teamCityStat(type:Exec) { task teamCityStat(type:Exec) {
def extension = MPPTools.getNativeProgramExtension() def analyzer = findAnalyzerBinary()
def analyzer = MPPTools.findFile("${analyzerTool}${extension}", "${rootBuildDirectory}/${analyzerToolDirectory}")
if (analyzer != null) { if (analyzer != null) {
commandLine "${analyzer}", "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}" commandLine "${analyzer}", "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}"
} else { } else {