JVM與Java應(yīng)用層雙重調(diào)試
安裝依賴
brew install ccache
編譯出現(xiàn)xcodebuild錯(cuò)誤
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
openjdk16二進(jìn)制文件
http://jdk.java.net/16/
openjdk源碼
https://github.com/openjdk/jdk
jdk目錄

bash configure --with-debug-level=slowdebug --enable-dtrace --with-jvm-variants=server --with-target-bits=64 --enable-ccache --with-num-cores=8 --with-memory-size=8000? --disable-warnings-as-errors
make images
./build/macosx-x86_64-server-slowdebug/jdk/bin/java --version

調(diào)試



process handle SIGSEGV SIGBUS -s false
process handle --pass true --stop false --notify true SIGSEGV
入口函數(shù)
src/java.base/share/native/launcher/main.c


there is no registered task type 'Java'. Did you miss to install an extension that provides a corresponding task provider?
等待
Java的debug配置
{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "Debug (Launch) - Current File",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "${file}"
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "Debug (Launch)-DemoApplication<demo>",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.example.demo.DemoApplication",
? ? ? ? ? ? "projectName": "demo"
? ? ? ? }
? ? ]
}
vscode 隨機(jī)字符串classpath配置
{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "CodeLens (Launch) - App",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.opendev.App",
? ? ? ? ? ? "projectName": "demo"
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "lldb",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "name": "JvmDebug",
? ? ? ? ? ? "program": "${workspaceFolder}/../build/macosx-x86_64-server-release/images/jdk/bin/java",
? ? ? ? ? ? "args": [
? ? ? ? ? ? ? ? "@/var/folders/f7/h5k23k254y14yl9frqxjmjzh0000gn/T/cp_bde6uiawzxdp218zn84n148vd.argfile",
? ? ? ? ? ? ? ? "com.opendev.App"
? ? ? ? ? ? ],
? ? ? ? ? ? "cwd": "${workspaceFolder}"
? ? ? ? },
? ? ? ??
? ? ]
}

外置jar包的classpath配置

{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "CodeLens (Launch) - App",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.opendev.App",
? ? ? ? ? ? "projectName": "demo"
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "lldb",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "name": "JvmDebug",
? ? ? ? ? ? "program": "${workspaceFolder}/../build/macosx-x86_64-server-release/images/jdk/bin/java",
? ? ? ? ? ? "args": [
? ? ? ? ? ? ? ? "-classpath",
? ? ? ? ? ? ? ? "/Users/virtualman/.m2/repository/jfree/jfreechart/1.0.0/jfreechart-1.0.0.jar:/Users/virtualman/.m2/repository/jfree/jcommon/1.0.0/jcommon-1.0.0.jar:./temp/demo/target/classes",
? ? ? ? ? ??
? ? ? ? ? ? ? ? "com.opendev.App"
? ? ? ? ? ? ],
? ? ? ? ? ? "cwd": "${workspaceFolder}"
? ? ? ? },
? ? ? ??
? ? ]
}
雙重調(diào)試

{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "CodeLens (Launch) - App",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.opendev.App",
? ? ? ? ? ? "projectName": "demo"
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "lldb",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "name": "JvmDebug",
? ? ? ? ? ? "program": "${workspaceFolder}/../build/macosx-x86_64-server-release/images/jdk/bin/java",
? ? ? ? ? ? "args": [
? ? ? ? ? ? ? ? "-Xdebug",
? ? ? ? ? ? ? ? "-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8086",? ? ?
? ? ? ? ? ? ? ? "-classpath",
? ? ? ? ? ? ? ? "/Users/virtualman/.m2/repository/jfree/jfreechart/1.0.0/jfreechart-1.0.0.jar:/Users/virtualman/.m2/repository/jfree/jcommon/1.0.0/jcommon-1.0.0.jar:./temp/demo/target/classes",
? ? ? ? ? ? ? ? "com.opendev.demo"
? ? ? ? ? ? ],
? ? ? ? ? ? "cwd": "${workspaceFolder}"
? ? ? ? },
? ? ? ??
? ? ]
}
遠(yuǎn)程調(diào)試
{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ?{
? ? ? ? ? ?"type": "java",
? ? ? ? ? ?"name": "Debug (Attach)",
? ? ? ? ? ?"request": "attach",
? ? ? ? ? ?"hostName": "localhost",
? ? ? ? ? ?"port": 8086,
? ? ??
? ? ? ? ? ?"debugServer": 8086,
? ? ? ? ? ?
? ? ? ?},
? ? ?
? ? ??
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "CodeLens (Launch) - App",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.opendev.App",
? ? ? ? ? ? "projectName": "demo01",
? ? ? ? ? ? "debugServer": 8086,
? ? ? ? ? ??
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "lldb",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "name": "Debug",
? ? ? ? ? ? "program": "${workspaceFolder}/build/macosx-x86_64-server-release/images/jdk/bin/java",
? ? ? ? ? ? "args": [
? ? ? ? ? ? ? ? "-Xdebug",
? ? ? ? ? ? ? ? "-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8086",? ? ?
? ? ? ? ? ? ? ? "-classpath",
? ? ? ? ? ? ? ? "/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/charsets.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/deploy.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/javaws.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/jce.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/jfr.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/jfxswt.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/jsse.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/management-agent.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/plugin.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/resources.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/jre/lib/rt.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/ant-javafx.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/dt.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/javafx-mx.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/jconsole.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/packager.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/sa-jdi.jar:/Users/virtualman/Downloads/MySource/jdk1.8.0_181.jdk/Contents/Home/lib/tools.jar:/Users/virtualman/IntelliJ IDEA Projects/ImoocProj/out/production/ImoocProj:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar",
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? "com.imooc.bank.Test"
? ? ? ? ? ? ],
? ? ? ? ? ? "cwd": "/Users/virtualman/IntelliJ IDEA Projects/ImoocProj/out/production/ImoocProj"
? ? ? ? }
? ? ]
}
vscode單獨(dú)調(diào)試
{
? ? // Use IntelliSense to learn about possible attributes.
? ? // Hover to view descriptions of existing attributes.
? ? // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
? ? "version": "0.2.0",
? ? "configurations": [
? ? ? ? {
? ? ? ? ? ? "type": "java",
? ? ? ? ? ? "name": "CodeLens (Launch) - App",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "mainClass": "com.opendev.App",
? ? ? ? ? ? "projectName": "demo01"
? ? ? ? },
? ? ? ? {
? ? ? ? ? ? "type": "lldb",
? ? ? ? ? ? "request": "launch",
? ? ? ? ? ? "name": "Debug",
? ? ? ? ? ? "program": "${workspaceFolder}/build/macosx-x86_64-server-release/images/jdk/bin/java",
? ? ? ? ? ? "args": [
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? "com.opendev.App"
? ? ? ? ? ? ],
? ? ? ? ? ? "cwd": "${workspaceFolder}/temp/demo01/target/classes"
? ? ? ? }
? ? ]
}



路徑不要有空格
路徑正常
jvm調(diào)試時(shí)
jdk版本最好使用編譯的
因?yàn)檎{(diào)試無法知道源,會(huì)顯示匯編代碼。
編譯的時(shí)候調(diào)試相關(guān)的目錄源文件已經(jīng)硬編碼
