mysql调试环境建立

之前已经一步步从源码编译完成了mysql,参考链接mysql编译安装全过程,现在开始对mysql做调试,了解内部的运行细节

学习gdb的使用

如果对gdb不是很熟悉,先初步了解gdb的使用

准备环境

gcc5.5安装,gdb安装,以及LD_LIBRARY_PATH设置

export LD_LIBRARY_PATH=/usr/local/gcc-5.5.0/lib64

开始调试

# gdb  mysqld
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/mysql8017/bin/mysqld...done.
(gdb) l
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License, version 2.0, for more details.
18  
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22  
23  extern int mysqld_main(int argc, char **argv);
24  
25  int main(int argc, char **argv) { return mysqld_main(argc, argv); }

运行mysqld

#(gdb) r --defaults-file=/data/mysql8017/my.cnf  --user=mysql

如果我们不设置任何断点,就和普通的mysql运行没有区别,也可以使用mysql客户端登录并执行操作。那为了明确代码细节,先设置断点看看

设置断点

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。