Commit | Line | Data |
---|---|---|
cfddbd02 | 1 | GDB Internals documentation |
f222d23d | 2 | |
cfddbd02 JG |
3 | This needs to be wrapped in texinfo stuff... |
4 | ||
bbb5013f | 5 | Cleanups |
cfddbd02 JG |
6 | |
7 | Cleanups are a structured way to deal with things that need to be done | |
8 | later. When your code does something (like malloc some memory, or open | |
9 | a file) that needs to be undone later (e.g. free the memory or close | |
10 | the file), it can make a cleanup. The cleanup will be done at some | |
11 | future point: when the command is finished, when an error occurs, or | |
12 | when your code decides it's time to do cleanups. | |
13 | ||
14 | You can also discard cleanups, that is, throw them away without doing | |
15 | what they say. This is only done if you ask that it be done. | |
16 | ||
17 | Syntax: | |
18 | ||
19 | old_chain = make_cleanup (function, arg); | |
20 | ||
21 | This makes a cleanup which will cause FUNCTION to be called with ARG | |
22 | (a char *) later. The result, OLD_CHAIN, is a handle that can be | |
23 | passed to do_cleanups or discard_cleanups later. Unless you are | |
24 | going to call do_cleanups or discard_cleanups yourself, | |
25 | you can ignore the result from make_cleanup. | |
26 | ||
27 | do_cleanups (old_chain); | |
28 | ||
29 | Performs all cleanups done since make_cleanup returned OLD_CHAIN. | |
30 | E.g.: make_cleanup (a, 0); old = make_cleanup (b, 0); do_cleanups (old); | |
31 | will call b() but will not call a(). The cleanup that calls a() will remain | |
32 | in the cleanup chain, and will be done later unless otherwise discarded. | |
33 | ||
34 | discard_cleanups (old_chain); | |
35 | ||
36 | Same as do_cleanups except that it just removes the cleanups from the | |
37 | chain and does not call the specified functions. | |
38 | ||
39 | ||
40 | Some functions, e.g. fputs_filtered() or error(), specify that they | |
41 | "should not be called when cleanups are not in place". This means | |
42 | that any actions you need to reverse in the case of an error or | |
43 | interruption must be on the cleanup chain before you call these functions, | |
44 | since they might never return to your code (they "longjmp" instead). | |
7f27984e JG |
45 | |
46 | ||
47 | ||
bbb5013f JG |
48 | Wrapping output lines |
49 | ||
50 | Output that goes through printf_filtered or fputs_filtered or | |
51 | fputs_demangled needs only to have calls to wrap_here() added | |
52 | in places that would be good breaking points. The utility routines | |
53 | will take care of actually wrapping if the line width is exceeded. | |
54 | ||
55 | The argument to wrap_here() is an indentation string which is printed | |
56 | ONLY if the line breaks there. This argument is saved away and used | |
57 | later. It must remain valid until the next call to wrap_here() or | |
58 | until a newline has been printed through the *_filtered functions. | |
59 | Don't pass in a local variable and then return! | |
60 | ||
61 | It is usually best to call wrap_here() after printing a comma or space. | |
62 | If you call it before printing a space, make sure that your indentation | |
63 | properly accounts for the leading space that will print if the line wraps | |
64 | there. | |
65 | ||
66 | ||
67 | ||
68 | ||
7f27984e JG |
69 | Configuring GDB for release |
70 | ||
71 | ||
72 | GDB should be released after doing "config.gdb none" in the top level | |
73 | directory. This will leave a makefile there, but no tm- or xm- files. | |
74 | The makefile is needed, for example, for "make gdb.tar.Z"... If you | |
75 | have tm- or xm-files in the main source directory, C's include rules | |
76 | cause them to be used in preference to tm- and xm-files in the | |
77 | subdirectories where the user will actually configure and build the | |
78 | binaries. | |
79 | ||
80 | "config.gdb none" is also a good way to rebuild the top level Makefile | |
81 | after changing Makefile.dist, alldeps.mak, etc. | |
82 | ||
83 | ||
84 | ||
85 | ||
86 | The README file | |
87 | ||
88 | ||
89 | Check the README file, it often has useful information that does not | |
90 | appear anywhere else in the directory. |