Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdbint / Getting-Started.html
blobcfd69eeac6756f90eb794376845b74466c53a115
1 <html lang="en">
2 <head>
3 <title>GDB Internals</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="GDB Internals">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Getting%20Started">Getting Started</a>,
13 Up:<a rel="up" accesskey="u" href="Hints.html#Hints">Hints</a>
14 <hr><br>
15 </div>
17 <h3 class="section">Getting Started</h3>
19 GDB is a large and complicated program, and if you first starting to
20 work on it, it can be hard to know where to start. Fortunately, if you
21 know how to go about it, there are ways to figure out what is going on.
23 <p>This manual, the GDB Internals manual, has information which applies
24 generally to many parts of GDB.
26 <p>Information about particular functions or data structures are located in
27 comments with those functions or data structures. If you run across a
28 function or a global variable which does not have a comment correctly
29 explaining what is does, this can be thought of as a bug in GDB; feel
30 free to submit a bug report, with a suggested comment if you can figure
31 out what the comment should say. If you find a comment which is
32 actually wrong, be especially sure to report that.
34 <p>Comments explaining the function of macros defined in host, target, or
35 native dependent files can be in several places. Sometimes they are
36 repeated every place the macro is defined. Sometimes they are where the
37 macro is used. Sometimes there is a header file which supplies a
38 default definition of the macro, and the comment is there. This manual
39 also documents all the available macros.
41 <p>Start with the header files. Once you have some idea of how
42 GDB's internal symbol tables are stored (see <code>symtab.h</code>,
43 <code>gdbtypes.h</code>), you will find it much easier to understand the
44 code which uses and creates those symbol tables.
46 <p>You may wish to process the information you are getting somehow, to
47 enhance your understanding of it. Summarize it, translate it to another
48 language, add some (perhaps trivial or non-useful) feature to GDB, use
49 the code to predict what a test case would do and write the test case
50 and verify your prediction, etc. If you are reading code and your eyes
51 are starting to glaze over, this is a sign you need to use a more active
52 approach.
54 <p>Once you have a part of GDB to start with, you can find more
55 specifically the part you are looking for by stepping through each
56 function with the <code>next</code> command. Do not use <code>step</code> or you
57 will quickly get distracted; when the function you are stepping through
58 calls another function try only to get a big-picture understanding
59 (perhaps using the comment at the beginning of the function being
60 called) of what it does. This way you can identify which of the
61 functions being called by the function you are stepping through is the
62 one which you are interested in. You may need to examine the data
63 structures generated at each stage, with reference to the comments in
64 the header files explaining what the data structures are supposed to
65 look like.
67 <p>Of course, this same technique can be used if you are just reading the
68 code, rather than actually stepping through it. The same general
69 principle applies--when the code you are looking at calls something
70 else, just try to understand generally what the code being called does,
71 rather than worrying about all its details.
73 <p>A good place to start when tracking down some particular area is with
74 a command which invokes that feature. Suppose you want to know how
75 single-stepping works. As a GDB user, you know that the
76 <code>step</code> command invokes single-stepping. The command is invoked
77 via command tables (see <code>command.h</code>); by convention the function
78 which actually performs the command is formed by taking the name of
79 the command and adding <code>_command</code>, or in the case of an
80 <code>info</code> subcommand, <code>_info</code>. For example, the <code>step</code>
81 command invokes the <code>step_command</code> function and the <code>info
82 display</code> command invokes <code>display_info</code>. When this convention is
83 not followed, you might have to use <code>grep</code> or <kbd>M-x
84 tags-search</kbd> in emacs, or run GDB on itself and set a
85 breakpoint in <code>execute_command</code>.
87 <p>If all of the above fail, it may be appropriate to ask for information
88 on <code>bug-gdb</code>. But <em>never</em> post a generic question like "I was
89 wondering if anyone could give me some tips about understanding
90 GDB"--if we had some magic secret we would put it in this manual.
91 Suggestions for improving the manual are always welcome, of course.
93 </body></html>