在编译安装完mysql后,就可以使用gdb来跟踪mysql服务器的执行了。
在编译安装完mysql后,,就可以使用gdb来跟踪mysql服务器的执行了。
gdb --args /usr/local/mysql/libexec/mysqld
(gdb) b mysql_select
breakpoint 1 at 0x8228b7d: file sql_select.cc, line 2315.
(gdb) b my_net_read
breakpoint 2 at 0x81a13e4: file net_serv.cc, line 993.
(gdb) run
starting program: /usr/local/mysql/libexec/mysqld
[thread debugging using libthread_db enabled]
[new thread 0xb7feeb70 (lwp 1373)]
[thread 0xb7feeb70 (lwp 1373) exited]
[new thread 0xb77edb70 (lwp 1374)]
110225 22:36:33 [note] event scheduler: loaded 0 events
110225 22:36:33 [note] /usr/local/mysql/libexec/mysqld: ready for connections.
version: '5.1.34-debug' socket: '/tmp/mysql.sock' port: 3306 source distribution
此时在登陆客户端,通过另外一个shelll运行mysql客户端
gdb会出现如下信息:
[new thread 0xb77ccb70 (lwp 1410)]
[switching to thread 0xb77ccb70 (lwp 1410)]
breakpoint 2, my_net_read (net=0x85610bc) at net_serv.cc:993
993 if (!net->compress)
(gdb)
表明设置断点成功。