LoginSignup
0
0

More than 5 years have passed since last update.

Instruction to debug MySQL server from source tree build

Last updated at Posted at 2015-09-14

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 by b 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 (not localhost).
mysql -uroot -h 127.0.0.1 --port 13000 test
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0