1 vscode 需要安装remote-ssh插件
安装成功后,登录:
默认远程服务器的登录
ssh root@ip
注意,Linux需要设置root远程登录;
2 安装debug扩展
C\C++ extemsion Pack
C\C++
gdb debugger beyond用于进程attach
3 设置Attach进程
{
// 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": "by-gdb",
"request": "attach",
"name": "Attach(gdb)",
"program": "${fileBasenameNoExtension}",
"cwd": "${workspaceRoot}",
"processId": 199182
}
]
}
这里
"processId": "${command:pickRemoteProcess}",
填写mysql的进程ID;
# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 199182 mysql 17u IPv6 1323770 0t0 TCP *:mysql (LISTEN)
#
4 断点
sql_parse.cc文件
函数:
int mysql_execute_command(THD *thd, bool first_level = false);
(备注,mysql必须是debug版本)
MySQL客户端登录,执行命令:
# mysql -h localhost -uroot -P3306 -p12345678
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.42-debug Source distribution
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
(断点)