美文网首页
Mac + VsCode调试MySql源码

Mac + VsCode调试MySql源码

作者: RalapHao | 来源:发表于2022-10-18 20:01 被阅读0次
  1. 下载源码
    源码地址:https://github.com/mysql/mysql-server. Mac安装环境

    mysql版本:v8.0.31

  2. 环境搭建

  3. vscode

    • 安装扩展:C/C++、C/C++ Clang Command Adapter、CodeLLDB、CMake Tools
    • 配置编译
      mkdir -p cmake-build-debug/{data,etc}
      .vscode.settings.json
      {
        "cmake.buildBeforeRun": true,
        "cmake.buildDirectory": "${workspaceFolder}/cmake-build-debug/build",
        "cmake.configureSettings": {
            "WITH_DEBUG": "1",
            "CMAKE_INSTALL_PREFIX": "${workspaceFolder}/cmake-build-debug",
            "MYSQL_DATADIR": "${workspaceFolder}/cmake-build-debug/data",
            "SYSCONFDIR": "${workspaceFolder}/cmake-build-debug/etc",
            "MYSQL_TCP_PORT": "3307",
            "MYSQL_UNIX_ADDR": "${workspaceFolder}/cmake-build-debug/data/mysql-debug.sock",
            "WITH_BOOST": "${workspaceFolder}/boost",
            "DOWNLOAD_BOOST": "1",
            "DOWNLOAD_BOOST_TIMEOUT": "600"
        },
        "git.ignoreLimitWarning": true
      }
      
    • 编译


      image.png
      image.png
  4. 初始化数据库
    cat > etc/my.cnf <<EOF
    [mysqld]
    port=3307
    socket=mysql.sock
    innodb_file_per_table=1
    EOF
    cmake-build-debug/build/runtime_output_directory/mysqld --initialize-insecure

  1. 配置Debug
    mkdir .vscode.launch.json
    {
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
          {
              "type": "lldb",
              "request": "launch",
              "name": "Debug mysqld",
              "program": "${workspaceFolder}/cmake-build-debug/build/runtime_output_directory/mysqld",
              "args": [
                  "--defaults-file=${workspaceFolder}/cmake-build-debug/etc/my.cnf"
              ],
              "cwd": "${workspaceFolder}"
          },
         {
              "type": "lldb",
              "request": "launch",
              "name": "Debug mysql",
              "program": "${workspaceFolder}/cmake-build-debug/build/client/mysql",
              "args": [
                  "-uroot",
                  "-P3307",
                  "-h127.0.0.1"
              ],
              "cwd": "${workspaceFolder}"
          }
      ]
    }
    

debug运行

参考:

相关文章

网友评论

      本文标题:Mac + VsCode调试MySql源码

      本文链接:https://www.haomeiwen.com/subject/mvfuartx.html