📓 Archive

BUILD

FGJ: Create:2023/12/14 Update: (2024-10-24)

编译JDK #

  • build #

    # 下载xcodeapp[(~7G), OS version [13.3.1 (22E261)]
    wget -c https://download.developer.apple.com/Developer_Tools/Xcode_14.3.1/Xcode_14.3.1.xip
    # 切换xcode 到xcodeapp
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -license
    
    # 配置
    # disable-warnings-as-errors选项是禁止把warning 当成error
    # --with-debug-level=slowdebug。用来设置编译的级别,可选值为release、fastdebug、slowde-bug,越往后进行的优化措施就越少,带的调试信息就越多。默认值为release。slowdebug 含有最丰富的调试信息,没有这些信息,很多执行可能被优化掉,我们单步执行时,可能看不到一些变量的值。所以最好指定slowdebug 为编译级别。
    # with-jvm-variants 编译特定模式的HotSpot虚拟机,可选值:server、client、minimal、core、zero、custom
    # configure 命令承担了依赖项检查、参数配置和构建输出目录结构等多项职责,如果编译过程中需要的工具链或者依赖项有缺失,命令执行后会得到明确的提示,并给出该依赖的安装命令。
    bash configure --disable-warnings-as-errors --with-debug-level=slowdebug --with-jvm-variants=server
    # 编译
    make images
    
    # 生成compile_commands.json文件
    make compile-commands
    
  • loaded to clion #

  • debug #

    使用lldb debug的时候会出现 Signal: SIGSEGV (signal SIGSEGV) ,目前切换到gdb断点不生效,未解决。
    可以 参考添加下列代码解决。如果是gdb的话, 参考

    # ~/.lldbinit 文件内容
    # break set -n main -C "process handle --pass true --stop false SIGSEGV" -C "process handle --pass true --stop false SIGBUS"
    br set -n main -o true -G true -C "pro hand -p true -s false SIGSEGV SIGBUS"
    
    # ~/.gdbinit
    handle SIGSEGV pass noprint nostop
    handle SIGBUS pass noprint nostop
    

  • debug with java #

    保证两边代码一致,如果有修改变动,记得重新编译代码。
    可以使用clion自带的功能,在运行之前进行处理。before launch

    //测试java代码
    package org.example;
    
    public class Main {
        public static void main(String[] args) {
            for (int i = 0; i < 5; i++) {
                System.out.println("Hello world!");
            }
            Main main = new Main();
            String name = main.getClass().getName();
            System.out.println(name);
        }
    }
    
    # idea 配置
    Remote JVM Debug: localhost 13328
    # clion 配置
    Program arguments: -agentlib:jdwp=transport=dt_socket,server=n,address=localhost:13328,suspend=y org.example.Main
    Working directory: /Users/stevenobelia/Documents/project_idea_test/test-jdk/target/classes
    

Reference #


comments powered by Disqus