Use xcode and eclipse to compile and debug mysql source code on mac _ MySQL

Source: Internet
Author: User
Using xcode and eclipse to compile and debug mysql source code on mac has recently started to retrieve the mysq source code. I haven't tried this for a long time. I am going to build a compiling and debugging environment on mac using xcode and eclipse. The compiling and debugging environment on mac is mainly to install gcc, g ++, cmake and gdb tools. after xcode is installed, you can compile the c/c ++ program.

Eclipse + cdt for mac and eclipse + cdt for ubuntu build the c ++ compilation and debugging environment basically the same, so the configuration of gdb is slightly different. The main difference between xcode and eclipse is that the parameters in cmake are different. use cmake to generate the xcode code project file (. xcodeproj) from the mysql source code ).

Gdb has always been a pain point. Osx10.9 does not have the gdb tool installed. I use brew to install gdb version 7.7 and cannot use it after testing with eclipse. eclipse is always in the "Launching: refreshing GDB" status. Later, my colleague said that gdb v6.63 can be used for debugging. after replacement, it can be used.

Use xcode to debug mysql source code:

1) use cmake to generate xcode project files

After cmake, A. xcodeproj xocde project file is generated in the source code root directory, which can be opened directly using xcode.

cmake . -G "Xcode" -DWITH_DEBUG=1 -DCMAKE_INSTALL_PREFIX=/Users/sylar/Downloads/mysql-5.6.17/work

2) use xcode to compile and install mysqld

The make and make install processes are completed using xcode, and the generated target file is copied to the directory specified by the "-DCMAKE_INSTALL_PREFIX" cmake parameter.

3) initialize mysql

You need to use mysql_install_db in the command line and specify basedir and datadir. This parameter must be consistent with the running parameter set in xcode.

./scripts/mysql_install_db --user=sylar --basedir=/Users/sylar/Downloads/mysql-5.6.17/work --datadir=/Users/sylar/Downloads/mysql-5.6.17/work/data

4) set the running parameters of mysqld during build and debug.

--user=sylar --basedir=/Users/sylar/Downloads/mysql-5.6.17/work --datadir=/Users/sylar/Downloads/mysql-5.6.17/work/data

In this step, the eclipse configuration is almost the same.

5) run xcode and set the breakpoint debug

After running run, you can find that mysqld runs successfully.

Ps aux | grep mysqld can also detect the mysqld process.

There are many details in the configuration process. below are two errors in the configuration process.

1) when gdb is installed, it is found that the dynamic link library of the readline function library is missing.

Libaray not loaded: @ HOMEBREW_PREFI> @/opt/readline/lib/libreadline ine.6.dylib Reference from:/usr/localbin/gdb

# Install readline. if other dependent libraries are missing, you can install readline in the same way. Brew install readline # if the system prompts that the link is not successful during the installation process, because the permission is insufficient, sudo brew install readline # or manually create a soft link sudo brew link readline

2) the Error with command: gdb-version is prompted in eclipse.

Eclipse cannot find gdb, gdb is not installed, or it has no access permission.

Which gdb

3) after the installation code gdb, use the Keychain Access tool provided by mac to generate a certificate and use codesign for signature.

Sudo codesign-s gdb-cert/usr/bin/gdb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.