当前位置:   article > 正文

vscode调试mysql5.7.37教程_mysql 源码调试 vscode

mysql 源码调试 vscode

前一篇用的是launch,这一篇更改为attach。

1.启动数据库

/usr/local/mysql/support-files/mysql.server start
  • 1

在这里插入图片描述

2.进入数据库

mysql -uroot -p
  • 1

我在/etc/my.cnf 加了skip-grant tables
免密登录(问也是空密码)
在这里插入图片描述
顺便查了一下版本
在这里插入图片描述

3.改了配置文件

{
    // 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": "openGauss-debug",
            "type": "cppdbg",
            "request": "attach",
            "program": "/usr/local/mysql/bin/mysqld",
            "args": ["--user=mysql --datadir=/usr/local/mysql/data"],
            "processId": "${command:pickProcess}",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

原来版本

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "MySQL-debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "/usr/local/mysql/bin/mysqld",
            "args": ["--user=mysql --datadir=/usr/local/mysql/data"],
            "stopAtEntry": true,
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "gdb",
            "miDebuggerArgs": "gdb",
            "linux": {
                "MIMode": "gdb",
                "miDebuggerPath": "/usr/bin/gdb"
            },
            "logging": {
                "moduleLoad": false,
                "engineLogging": false,
                "trace": false
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "cwd": "${workspaceFolder}",
        }
    ]
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

4.调试

以时间函数Item_time_literal()为例:
先打好断点,我打在了1041行,通过命令查看进程号

ps aux | grep mysql
  • 1

在这里插入图片描述
打好
打好断点就run->start debugging
选择attach 12430

  • 终端进入数据库输入查询语句敲enter
    在这里插入图片描述
    与此同时,vscode图形化界面就会开始调试!
    在这里插入图片描述
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/832253
推荐阅读
相关标签
  

闽ICP备14008679号