gdb-int.texinfo: New file, for GDB internals documentation.
[deliverable/binutils-gdb.git] / gdb / doc / gdbint.texinfo
1 GDB Internals documentation
2
3 This needs to be wrapped in texinfo stuff...
4
5 Cleanups
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).
This page took 0.032417 seconds and 5 git commands to generate.