about reading Open source project Source thinking method: "Do not like to spray"
generally open source projects, if you are familiar with this project often use, then you directly from main start no problem.
If you are unfamiliar or have a large amount of code, it is best to start with code example code or client code. The code directly into the GDB can be debugged run, the client's function is clear, will use, the fear of the drop down, and then look at the server is easy.
Look at the C code to focus on the main body of the struct, the entire server, the client may be around the entire struct run, the struct's pointer came to pass. Looking at Java code, you need to focus on the main interface, through interface
Look at the inheritance class.
Some people like microscopic from main start to see, some like macro first look at data structure (interface), this can.
In addition to look at the network code, the most attention is when listen, when accept, Epoll_ctl injected several functions who, corresponding to Java is selector after several read and write functions. To find these functions, the basic network framework understands that the net The network model is just a few.
look at the network protocol packet handler function to give you a better understanding of the dry protocol.
See the Help function to know how to use it faster.
If the code is not debugging, depending on the log output run by the program, it is also a method to find the log output point in the code.
Write yourself a cscope.sh script, put it in the path, download the code and run it in the main directory to open it.
find.-name "*.h"-o-name "*.c"-o-name "*.py"-o-name "*.lua"-o-name "*.erl"-o-name "*.hrl"-name "*.java" &G T;> Cscope.files
cscope-bkq-i cscope.files
ctags-r
ctags-i __throw--langmap=c:+.h--languages=c--c-kinds=+p--if0=yes--exclude=java--file-scope=yes-f systemtags/ usr/include/*/usr/include/sys/*
Look at the code with GDB, repeatedly go out, write a macro file is also good
B Main
r--user=mysql--gdb--basedir=/usr/local/mysql--datadir=/usr/local/mysql/var--log-error=/usr/local/mysql/var /hoterran-laptop.err--pid-file=/usr/local/mysql/var/hoterran-laptop.pid
set Scheduler-locking off
Gdb-x Macro-file Libexec/mysqld
GdB--args very useful, many people like to input parameters in gdb more trouble.
Vim Ctags, CSCOP can only use the symbol to find or weak point, with Eclipse to see Java is more convenient, look at the extension class, see the call relationship is a right button can be done. The Java project can use MAVEN to bring down the source of the dependent jar.
I'm generally used to the left display code (VIM, Eclipse). On the right I usually open a xmind, dia or Luchidchart, griffly draw the UML process sequence diagram what. Especially multi-threaded programs, various lock and queue calls, you do not have a diagram more difficult to understand the idea. Paper pens are sometimes more effective.
personally think the code than reading should have output, we can see deliberate come sweep, see the code is best to take notes, draw a picture. Easy to recall, convenient continued. if you want to protect your source project source code is not reversed , learn more, love encryption teaches you how Android apps prevent two packs of http://www.ijiami.cn/ newsinfo?id=280&v=3
Sharing: A source-thinking approach to reading open source projects