Enable HMCL to export jstack dump file 让 HMCL 能够导出游戏运行栈文件 (#2582)

* Enable HMCL to create game thread dump while game is running

* Fix checkstyle

* Hide accessToken

* Code cleanup

* Code cleanup

* Enhance I18N and declare the charset (UTF-8) of output file

* Inline variables

* Update the modifier of org.jackhuang.hmcl.game.GameDumpCreator#writeDumpHeadTo from public to private

* Refactor

* Add license for GameDumpCreator, remove support for Java 8

* Remove unnecessary Arrays.copyOf

* Fix checkstyle

* Use system charset to read the inputstream from JVM

* opt GameDumpCreator

* retry on failed attach to vm

* update GameDumpCreator

* Opt GameDumpCreator

* Fix

* Include BCIG

* Use BCIG to get PID.

* Fix.

* Fix again.

* Code cleanup. Fix bugs.

---------

Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
Burning_TNT
2024-01-08 20:35:46 +08:00
committed by GitHub
parent 4149876e04
commit 5d3660ffb8
13 changed files with 326 additions and 12 deletions

View File

@@ -1,3 +1,5 @@
import kotlin.streams.toList
plugins {
`java-library`
}
@@ -13,4 +15,20 @@ dependencies {
api("org.nanohttpd:nanohttpd:2.3.1")
api("org.apache.commons:commons-compress:1.23.0")
compileOnlyApi("org.jetbrains:annotations:24.0.1")
compileOnlyApi("com.github.burningtnt:BytecodeImplGenerator:b45b6638eeaeb903aa22ea947d37c45e5716a18c")
}
tasks.getByName<JavaCompile>("compileJava") {
val bytecodeClasses = listOf(
"org/jackhuang/hmcl/util/platform/ManagedProcess"
)
doLast {
javaexec {
classpath(project.sourceSets["main"].compileClasspath)
mainClass.set("net.burningtnt.bcigenerator.BytecodeImplGenerator")
System.getProperty("bci.debug.address")?.let { address -> jvmArgs("-agentlib:jdwp=transport=dt_socket,server=n,address=$address,suspend=y") }
args(bytecodeClasses.stream().map { s -> project.layout.buildDirectory.file("classes/java/main/$s.class").get().asFile.path }.toList())
}
}
}