BIND9 Source Learning Note 1---gdb debug Chapter

Source: Internet
Author: User

Before you learn bind9 source code, you must first know how to debug bind with GDB. BIND9 source I was to see the code first to understand its architecture, such as what Event-drive,epoll,

Then look at its business process. Look at the business process to track its data flow and processing process, so with GDB is better, of course, the combination of their own log and BIND9 own log is not

OK, just think it's clearer.

Compile bind when the addition of the G and-O2 options, the former needless to say, the latter is a pit daddy, debugging with GDB will find the actual execution order of code will change, this is the compiler optimization.

Compiler optimization has three levels,-o2 is the meaning of the two-level optimization, pull away, in short, is to remove the better, I myself debugging is not going to, accustomed to.

Step by step:

1.gdb named

Gdb>set args-g-n1-d5

Set Args is the setting of the program's operating parameters,-G that is, the foreground run, you can see the print logs and other information,-n refers to the number of worker threads (this if you do not understand to see another article, BIND9

Architecture and mechanism (-_-...)), this is very important, the original work is carried out in sequence, then the printed log must be printed in order, one match, such as A->b->c->d,

If the number of worker threads is greater than 1, then it is likely that the other thread will first print the log, and at this time B may not print in the execution log, see the log sequence and the business processing

The logical order is different, and the log order you might see is confusing. -D is the bind's own debug record, 5 is the level, bind log I do not see, there are many macros such as Ctrace,ftrace,

function Ns_client_log (do not know whether this, or may be mistaken), 5 should be satisfied with all levels of requirements, the internal printing will print out. Most are printed at the beginning or end of the function.

Gdb>b Client_request

This is set breakpoint, the breakpoint is client_request, the reason is set this is because bind is event-driven, and is subject to query or other (notify, etc.) messages, the first function executed is to do this,

That is, all DNS messages are processed at the Client_request gate.

Gdb>r

Then the program will begin.

2.set print pretty on, set the printing structure body, look good ....

print/x # # #打印比如sockaddr_in这种, because of the different byte order, look at the decimal number than the 16 binary.

Everything else is the basic operation of GDB.

BIND9 Source Learning Note 1---gdb debug Chapter

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.