Postgresql learning notes [1]-debugging postgresql source code in Linux + eclipse + gdb

Source: Internet
Author: User
Tags install perl postgresql version

[Reference The Source: http://blog.csdn.net/bhq2010/article/details/12200533]

The vs debugging pg source code used in the pg kernel source code parsing class. VS is easy to use, but it is a little troublesome to configure the debugging environment. First, you have to install a windows system, preferably xp or win7, which is a little troublesome. You 'd better use vs05, 08 and 10, but it is more troublesome than 05. In addition, you have to install perl, it is better to install cygwin and many other native things on linux. Then the vs project can be generated. If the generated project is not guaranteed, some parameter configuration problems may occur. The key is that pg runs on linux. On windows, code execution related to system calls is different from that on linux, for example, Process Creation. If you don't care about these system calls, we can also study and modify pg source code on windows thanks to the good platform compatibility of pg source code. However, if we modify the source code of pg and want to verify the effect on the server, we have to upload a package to the server to re-compile and run it. Online debugging cannot be performed during running, but logs can only be played.

In view of the above problems, we finally gave up. However, if you use gdb for debugging in linux, you cannot hold it. So use eclipse.

Reference: http://wiki.postgresql.org/wiki/Working_with_Eclipse [1]


My system environment:

Centos6.4 _ x64

Gcc.4.4.7

Eclipse-c/c ++ kepler

Postgresql 9.3


The following is my configuration process:

1. install necessary software

# yum install git readline* zlib* bison flex java-1.7.0*
These software may have been installed on some linux systems.

2. Download pg source code

You can use git to download the source code from pg repository:

[bhq@localhost ~]$ mkdir project[bhq@localhost ~]$ cd project[bhq@localhost ~]$ git clone git://git.postgresql.org/git/postgresql.git
After the download is complete, there will be a postgresql directory under the project directory, which is the pg source code. [1] the PostgreSQL version is relatively old. After downloading it, it is the postgres directory and renamed it pgsql.

You can also directly download: http://www.postgresql.org/ftp/source/ and decompress to the project directory.

3. configure source code

In the terminal:

[bhq@localhost ~]$ cd postgresql[bhq@localhost ~]$ ./configure --prefix=$HOME/project --enable-depend --enable-cassert --enable-debug
$ HOME/project indicates the project directory created when the source code is downloaded. This directory is used to store the files and directories generated after pg compilation. Configure is successful if no error is reported.

4. Configure eclipse

Download Eclipse IDE for C/C ++ Developers from http://www.eclipse.org/downloads.

Open eclipse and import the PostgreSQL project in package explorer. The operation procedure is the same as the Import section in [1. After the import is complete, make is not automatically started in eclipse. Therefore, make manually:

In the eclipse package explorere view, right-click the postgresql project-> make targets-> create. Enter install-> OK. In the package explorere view, right-click the postgresql project-> make targets-> build, and select the new install, OK. At last, you can see "postgreSQL installation complete" on the console, which means that make instal is successful. Make again after each source code modification.

5. initdb in the terminal:
[bhq@localhost ~] $ mkdir ~/pgdata[bhq@localhost ~] $ cd project[bhq@localhost ~] $ ./bin/initdb -D ~/pgdata
The directory after-D is used to store pg configuration files and database files. The owner of this directory must be the user who starts pg and eclipse. (Because the ntfs file system does not support user permissions, do not place this directory on the ntfs partition. If you use Windows linux dual system, this problem may occur)
6. For details about running and debugging pg, see run configuration in eclipse, Add include files, Debugging postgresql from eclipse, debugging with child processes in [1. Do not run it before debugging. Otherwise, the port will be occupied.
Finally, let's take a look at the PostgreSQL documentation.

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.