调试MySQL

1.安装

首先在configure时:sudo ./configure --prefix=/usr/local/mysql --with-debug

sudo make

sudo make install

2.启动

1)启动mysqld

./mysqld --debug

2)找到mysqld的进程ID:ps -A | grep mysql

20504 pts/0 00:00:00 mysqld

3)使用attach进行gdb的关联,gdb要有root权限:

sudo gdb

Copyright (C) 2010 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later

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 "i686-linux-gnu".

For bug reporting instructions, please see:

.

(gdb) attach 20504

Attaching to process 20504

Reading symbols from /usr/local/mysql/libexec/mysqld...done.

Reading symbols from /lib/i386-linux-gnu/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libpthread-2.13.so...done.

[Thread debugging using libthread_db enabled]

[New Thread 0xb70ceb70 (LWP 20506)]

done.

Loaded symbols for /lib/i386-linux-gnu/libpthread.so.0

Reading symbols from /lib/i386-linux-gnu/libz.so.1...(no debugging symbols found)...done.

Loaded symbols for /lib/i386-linux-gnu/libz.so.1

……

……

……

……

在attach后,就可以直接设置断点了。!!!,例如:

(gdb) break sql_show.cc:207

Breakpoint 1 at 0x82cf7b4: file sql_show.cc, line 207.

(gdb) continue

Continuing.

然后在另外一个终端启动mysql

root@iMac:/usr/local/mysql/bin# ./mysql

Welcome to the MySQL monitor. Commands end with ; or /g.

Your MySQL connection id is 6

Server version: 5.1.34-debug Source distribution

Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.

mysql> show authors

这时候在gdb中会出现调试信息:

[New Thread 0xb70adb70 (LWP 20851)]

[Thread 0xb70adb70 (LWP 20851) exited]

[New Thread 0xb70adb70 (LWP 20854)]

[Thread 0xb70adb70 (LWP 20854) exited]

[New Thread 0xb70adb70 (LWP 20858)]

[Thread 0xb70adb70 (LWP 20858) exited]

[New Thread 0xb70adb70 (LWP 20870)]

[Thread 0xb70adb70 (LWP 20870) exited]

[New Thread 0xb70adb70 (LWP 20883)]

[Thread 0xb70adb70 (LWP 20883) exited]

[New Thread 0xb70adb70 (LWP 20886)]

[Switching to Thread 0xb70adb70 (LWP 20886)]

Breakpoint 1, mysqld_show_authors (thd=0x8c0f380) at sql_show.cc:213

213 {

(gdb)

Continuing.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值