使用VSCode远程调试MySQL

源码编译安装MySQL Debug版本

安装依赖包

复制代码
## 5.7
yum -y install ncurses-devel bison openssl-devel cmake centos-release-scl devtoolset-7
scl enable devtoolset-7 bash

## 8.0
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./bootstrap 
make -j 8
make install
yum -y install ncurses-devel bison openssl-devel  centos-release-scl devtoolset-10
scl enable devtoolset-10 bash
复制代码

下载MySQL源码并编译Debug版本

复制代码

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.26.tar.gz

tar zxvf mysql-boost-8.0.26.tar.gz

cd mysql-8.0.26

## 编译为DEBUG版本
cmake . \
-DWITH_DEBUG=1 \
-DWITH_BOOST=./boost/ \
-DCMAKE_INSTALL_PREFIX=/data/mysql/8.0.32/base \
-DFORCE_INSOURCE_BUILD=1

make -j4 && make install

## 初始化并启动MySQL
...
复制代码

配置VSCode

 VSCode安装Remote-SSH、C/C++和扩展插件及GDB 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": [
        
        {
            "name": "Remote-GDB-Attach-MySQL",
            "type": "cppdbg",
            "request": "attach",
            "program": "/data/mysql/8.0.32/base/bin/mysqld",
            "processId": "${command:pickProcess}",
       "miDebuggerPath": "/usr/bin/gdb",
"MIMode": "gdb", "setupCommands": [ { "description": "远程调试MySQL", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "将反汇编风格设置为 Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] }, { "name": "CoreDump", "type": "cppdbg", "request": "launch", "program": "/usr/local/mysql/bin/mysqld", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "coreDumpPath": "/tmp/core-mysqld-6-0-0-30342-1655369975" } ] }    
复制代码

随后就可以使用VSCode远程调试MySQL或分析MySQL Coredump文件。

posted @   吃饭端住碗  阅读(349)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示