MySQL source code construction and configuration debugging in Gdb

Source: Internet
Author: User

I have always been used to learning C ++ through source code. Last month, I made a fuss about the SGI's STL source code. After all, the configuration process was smooth under Win, you can refer to the STL source code of Hou Jie. I will go deep into STL as soon as I have time. That is the foundation.

However, it is not enough to have a foundation. MySQL became the first developer of my third open-source project, and Myseelite was the first one. At that time, I wanted to build a P2P streaming media player, it is based on that project and transplanted to Win, of course, this is the most practical project. MySQL, STL, Linux, and other source code can only be modified in a short time without full time. This is still depressing, because the project is tight to work during the day.

Environment: rhel 5 64-bit: I am using a Linux system that will soon be corrupted, but it has never been reinstalled because snapshots have been retained. In case it cannot be restored, huh, huh.

The MySQL source code under BitKeeper is useful on the Internet. It is estimated that it is similar to Version Control of cvs svn. If it is useless, it can only find version 2.0. After accessing the address provided by him, the source code cannot be found, I don't know if it is removed. I can download the source code on the Internet. Why do I still use version control.

This website can go to the source code, 4.1.18 and 5.0.18.

Preparations: gcc, autoconf, automake, m4, make, and other tools have been installed on rhel 5.

$ Tar zxvf mysql-4.1.18.tar.gz

$ Mysql-4.1.18 cd

$ Cp BUILD/compile-pentium-debug BUILD/compile-generic-debug

$ Vim BUILD/compile-generic-debug

Set the file as follows:

#! /Bin/sh

 

Path = 'dirname $0'

. "$ Path/SETUP. sh"

 

Extra_flags = "-g $ debug_cflags"

C_warnings = "$ c_warnings $ debug_extra_warnings"

Cxx_warnings = "$ cxx_warnings $ debug_extra_warnings"

Extra_configs = ""

 

. "$ Path/FINISH. sh"

 

$ BUILD/compile-generic-debug to generate the make File

$ Make test

This step is optional. If you want to install MySQL to the system directory, You can execute

$ Make install

Of course, you can also use the $./configure configuration option.

Next is the most important debugging.

$ Cd to the mysql-test directory

$ Cd t

In the t directory, you will find many. test file, the file content is all SQL statements, is provided to us for testing under the pre-existing MySQL, of course, you can also create a new. test file, which contains the code you want to test.

Test:

$./Mysql-test-run-gdb test file name (note that test is not included)

For example, to test the drop. test file, the command line is

$./Mysql-test-run-gdb drop

After running, the gdb debugging window will pop out and jump to a preset breakpoint in the mysql_parse () function.

After debugging, the console displays the test result.

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.