Home Database Mysql Tutorial MySQL源码构建和在Gdb中调试的配置过程

MySQL源码构建和在Gdb中调试的配置过程

Jun 07, 2016 pm 05:06 PM

环境:rhel 5 64-bit 一个快被我用烂了的Linux,但是一直没重装过,因为一直保留有快照,万一不行了还原下,呵呵。网上有用BitKe

通过源码学习C++是我一直以来的习惯,上个月把SGI’s STL源码捣鼓了一下,毕竟是在Win下,配置过程还是很顺利的,这个可以参考侯杰的STL源码,一有空我就深入STL,那个才是基础啊。

但是光有基础是不够的,于是MySQL成了我第三个开源项目的被解剖者,第一个是Myseelite,因为当时要做一个P2P流媒体播放器,是基于那个项目的并且移植到Win下,当然这个是实践性最强的一个项目了。MySQL,STL,Linux这些源码也只能抽空小改改,没有时间完全深入,这个还是很郁闷的,因为白天要上班,项目还是比较紧的那种。

环境:rhel 5 64-bit 一个快被我用烂了的Linux,但是一直没重装过,因为一直保留有快照,万一不行了还原下,,呵呵。

网上有用BitKeeper下MySQL源码,估计是类似是CVS SVN的版本控制,下了没用还只能找到2.0版本的,访问了他提供的地址,连源码都找不到,是不是被撤了也不知道,反正网上能下到源码,干吗还用版本控制。

这个网站能下到源码,有4.1.18还有5.0.18的,我下了前者。

前期准备,gcc,autoconf,automake,m4,make等各种工具,我的rhel 5都装好了。

$ tar zxvf mysql-4.1.18.tar.gz

$ cd mysql-4.1.18

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

$ vim BUILD/compile-generic-debug

将文件设置如下:

#! /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   生成make文件

$make test

如下这步可选,如果你要将MySQL安装到系统目录,那么可以执行

$make install

当然还可以用 $./configure 配置选项

接下来就是最重要的调试了

$cd到mysql-test目录下

$cd t

在t目录下你会发现有很多.test文件,文件内容全是sql语句,是预存在MySQL下提供给我们测试的,当然也可以自己新建一个.test文件,里面写上自己要测试的代码。

测试:

$./mysql-test-run –gdb 测试文件名称(注意不带test)

比如测试drop.test文件,那么命令行便是

$./mysql-test-run –gdb drop

运行后会跳出gdb调试窗口,会跳到mysql_parse()函数中的一个预设断点中。

调试完成后,控制台会提示测试结果。

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles