It applies only on Linux :p
Clone source tree from GitHub
git clone git@github.com:mysql/mysql-server.git
Wait with coffee :)
switch branch if you want
cd mysql-server/
git checkout 5.6
Build
Prepare build directory
mkdir /path/to/mysql-server-build/
cd /path/to/mysql-server-build/
Do build
cmake -DWITH_DEBUG=1 /path/to/mysql-server/
make -j8
make test
Debug run
Prepare a test query case
cd mysql-test/
mkdir t/
echo "select 1;" > t/example.test
# initiate database
./mysql-test-run.pl --record example
# debug run (need X11 forwarding: xterm opens)
./mysql-test-run.pl --gdb example
Debugging
- At the beginning of debugging, there is only one breakpoint at
main()
(i b
). - Repeatedly run
c
and it terminates once, xterm resides. - Rerun the server by
r
in the xterm shell. - Make a breakpoint at
mysql_parse
byb mysql_parse
. - Run
c
and the server starts to wait for a connection
Version: '5.6.26-debug-log' socket: '/path/to/mysql-test/var/tmp/mysqld.1.sock' port: 13000 Source distribution
- You can connect to this instance via 13000/tcp
127.0.0.1
(notlocalhost
).
mysql -uroot -h 127.0.0.1 --port 13000 test