xref: /netbsd-src/external/gpl3/gcc/dist/gcc/doc/gty.texi (revision a45db23f655e22f0c2354600d3b3c2cb98abf2dc)
1@c Copyright (C) 2002-2022 Free Software Foundation, Inc.
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@node Type Information
6@chapter Memory Management and Type Information
7@cindex GGC
8@findex GTY
9
10GCC uses some fairly sophisticated memory management techniques, which
11involve determining information about GCC's data structures from GCC's
12source code and using this information to perform garbage collection and
13implement precompiled headers.
14
15A full C++ parser would be too complicated for this task, so a limited
16subset of C++ is interpreted and special markers are used to determine
17what parts of the source to look at.  All @code{struct}, @code{union}
18and @code{template} structure declarations that define data structures
19that are allocated under control of the garbage collector must be
20marked.  All global variables that hold pointers to garbage-collected
21memory must also be marked.  Finally, all global variables that need
22to be saved and restored by a precompiled header must be marked.  (The
23precompiled header mechanism can only save static variables if they're
24scalar. Complex data structures must be allocated in garbage-collected
25memory to be saved in a precompiled header.)
26
27The full format of a marker is
28@smallexample
29GTY (([@var{option}] [(@var{param})], [@var{option}] [(@var{param})] @dots{}))
30@end smallexample
31@noindent
32but in most cases no options are needed.  The outer double parentheses
33are still necessary, though: @code{GTY(())}.  Markers can appear:
34
35@itemize @bullet
36@item
37In a structure definition, before the open brace;
38@item
39In a global variable declaration, after the keyword @code{static} or
40@code{extern}; and
41@item
42In a structure field definition, before the name of the field.
43@end itemize
44
45Here are some examples of marking simple data structures and globals.
46
47@smallexample
48struct GTY(()) @var{tag}
49@{
50  @var{fields}@dots{}
51@};
52
53typedef struct GTY(()) @var{tag}
54@{
55  @var{fields}@dots{}
56@} *@var{typename};
57
58static GTY(()) struct @var{tag} *@var{list};   /* @r{points to GC memory} */
59static GTY(()) int @var{counter};        /* @r{save counter in a PCH} */
60@end smallexample
61
62The parser understands simple typedefs such as
63@code{typedef struct @var{tag} *@var{name};} and
64@code{typedef int @var{name};}.
65These don't need to be marked.
66
67However, in combination with GTY, avoid using typedefs such as
68@code{typedef int_hash<@dots{}> @var{name};}
69for these generate infinite-recursion code.
70See @uref{https://gcc.gnu.org/PR103157,PR103157}.
71Instead, you may use
72@code{struct @var{name} : int_hash<@dots{}> @{@};},
73for example.
74
75Since @code{gengtype}'s understanding of C++ is limited, there are
76several constructs and declarations that are not supported inside
77classes/structures marked for automatic GC code generation.  The
78following C++ constructs produce a @code{gengtype} error on
79structures/classes marked for automatic GC code generation:
80
81@itemize @bullet
82@item
83Type definitions inside classes/structures are not supported.
84@item
85Enumerations inside classes/structures are not supported.
86@end itemize
87
88If you have a class or structure using any of the above constructs,
89you need to mark that class as @code{GTY ((user))} and provide your
90own marking routines (see section @ref{User GC} for details).
91
92It is always valid to include function definitions inside classes.
93Those are always ignored by @code{gengtype}, as it only cares about
94data members.
95
96@menu
97* GTY Options::         What goes inside a @code{GTY(())}.
98* Inheritance and GTY:: Adding GTY to a class hierarchy.
99* User GC::		Adding user-provided GC marking routines.
100* GGC Roots::           Making global variables GGC roots.
101* Files::               How the generated files work.
102* Invoking the garbage collector::   How to invoke the garbage collector.
103* Troubleshooting::     When something does not work as expected.
104@end menu
105
106@node GTY Options
107@section The Inside of a @code{GTY(())}
108
109Sometimes the C code is not enough to fully describe the type
110structure.  Extra information can be provided with @code{GTY} options
111and additional markers.  Some options take a parameter, which may be
112either a string or a type name, depending on the parameter.  If an
113option takes no parameter, it is acceptable either to omit the
114parameter entirely, or to provide an empty string as a parameter.  For
115example, @code{@w{GTY ((skip))}} and @code{@w{GTY ((skip ("")))}} are
116equivalent.
117
118When the parameter is a string, often it is a fragment of C code.  Four
119special escapes may be used in these strings, to refer to pieces of
120the data structure being marked:
121
122@cindex % in GTY option
123@table @code
124@item %h
125The current structure.
126@item %1
127The structure that immediately contains the current structure.
128@item %0
129The outermost structure that contains the current structure.
130@item %a
131A partial expression of the form @code{[i1][i2]@dots{}} that indexes
132the array item currently being marked.
133@end table
134
135For instance, suppose that you have a structure of the form
136@smallexample
137struct A @{
138  @dots{}
139@};
140struct B @{
141  struct A foo[12];
142@};
143@end smallexample
144@noindent
145and @code{b} is a variable of type @code{struct B}.  When marking
146@samp{b.foo[11]}, @code{%h} would expand to @samp{b.foo[11]},
147@code{%0} and @code{%1} would both expand to @samp{b}, and @code{%a}
148would expand to @samp{[11]}.
149
150As in ordinary C, adjacent strings will be concatenated; this is
151helpful when you have a complicated expression.
152@smallexample
153@group
154GTY ((chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE"
155                  " ? TYPE_NEXT_VARIANT (&%h.generic)"
156                  " : TREE_CHAIN (&%h.generic)")))
157@end group
158@end smallexample
159
160The available options are:
161
162@table @code
163@findex length
164@item length ("@var{expression}")
165
166There are two places the type machinery will need to be explicitly told
167the length of an array of non-atomic objects.  The first case is when a
168structure ends in a variable-length array, like this:
169@smallexample
170struct GTY(()) rtvec_def @{
171  int num_elem;         /* @r{number of elements} */
172  rtx GTY ((length ("%h.num_elem"))) elem[1];
173@};
174@end smallexample
175
176In this case, the @code{length} option is used to override the specified
177array length (which should usually be @code{1}).  The parameter of the
178option is a fragment of C code that calculates the length.
179
180The second case is when a structure or a global variable contains a
181pointer to an array, like this:
182@smallexample
183struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
184@end smallexample
185In this case, @code{iter} has been allocated by writing something like
186@smallexample
187  x->iter = ggc_alloc_cleared_vec_gimple_omp_for_iter (collapse);
188@end smallexample
189and the @code{collapse} provides the length of the field.
190
191This second use of @code{length} also works on global variables, like:
192@verbatim
193static GTY((length("reg_known_value_size"))) rtx *reg_known_value;
194@end verbatim
195
196Note that the @code{length} option is only meant for use with arrays of
197non-atomic objects, that is, objects that contain pointers pointing to
198other GTY-managed objects.  For other GC-allocated arrays and strings
199you should use @code{atomic}.
200
201@findex skip
202@item skip
203
204If @code{skip} is applied to a field, the type machinery will ignore it.
205This is somewhat dangerous; the only safe use is in a union when one
206field really isn't ever used.
207
208@findex callback
209@item callback
210
211@code{callback} should be applied to fields with pointer to function type
212and causes the field to be ignored similarly to @code{skip}, except when
213writing PCH and the field is non-NULL it will remember the field's address
214for relocation purposes if the process writing PCH has different load base
215from a process reading PCH.
216
217@findex for_user
218@item for_user
219
220Use this to mark types that need to be marked by user gc routines, but are not
221refered to in a template argument.  So if you have some user gc type T1 and a
222non user gc type T2 you can give T2 the for_user option so that the marking
223functions for T1 can call non mangled functions to mark T2.
224
225@findex desc
226@findex tag
227@findex default
228@item desc ("@var{expression}")
229@itemx tag ("@var{constant}")
230@itemx default
231
232The type machinery needs to be told which field of a @code{union} is
233currently active.  This is done by giving each field a constant
234@code{tag} value, and then specifying a discriminator using @code{desc}.
235The value of the expression given by @code{desc} is compared against
236each @code{tag} value, each of which should be different.  If no
237@code{tag} is matched, the field marked with @code{default} is used if
238there is one, otherwise no field in the union will be marked.
239
240In the @code{desc} option, the ``current structure'' is the union that
241it discriminates.  Use @code{%1} to mean the structure containing it.
242There are no escapes available to the @code{tag} option, since it is a
243constant.
244
245For example,
246@smallexample
247struct GTY(()) tree_binding
248@{
249  struct tree_common common;
250  union tree_binding_u @{
251    tree GTY ((tag ("0"))) scope;
252    struct cp_binding_level * GTY ((tag ("1"))) level;
253  @} GTY ((desc ("BINDING_HAS_LEVEL_P ((tree)&%0)"))) xscope;
254  tree value;
255@};
256@end smallexample
257
258In this example, the value of BINDING_HAS_LEVEL_P when applied to a
259@code{struct tree_binding *} is presumed to be 0 or 1.  If 1, the type
260mechanism will treat the field @code{level} as being present and if 0,
261will treat the field @code{scope} as being present.
262
263The @code{desc} and @code{tag} options can also be used for inheritance
264to denote which subclass an instance is.  See @ref{Inheritance and GTY}
265for more information.
266
267@findex cache
268@item cache
269
270When the @code{cache} option is applied to a global variable gt_cleare_cache is
271called on that variable between the mark and sweep phases of garbage
272collection.  The gt_clear_cache function is free to mark blocks as used, or to
273clear pointers in the variable.
274
275@findex deletable
276@item deletable
277
278@code{deletable}, when applied to a global variable, indicates that when
279garbage collection runs, there's no need to mark anything pointed to
280by this variable, it can just be set to @code{NULL} instead.  This is used
281to keep a list of free structures around for re-use.
282
283@findex maybe_undef
284@item maybe_undef
285
286When applied to a field, @code{maybe_undef} indicates that it's OK if
287the structure that this fields points to is never defined, so long as
288this field is always @code{NULL}.  This is used to avoid requiring
289backends to define certain optional structures.  It doesn't work with
290language frontends.
291
292@findex nested_ptr
293@item nested_ptr (@var{type}, "@var{to expression}", "@var{from expression}")
294
295The type machinery expects all pointers to point to the start of an
296object.  Sometimes for abstraction purposes it's convenient to have
297a pointer which points inside an object.  So long as it's possible to
298convert the original object to and from the pointer, such pointers
299can still be used.  @var{type} is the type of the original object,
300the @var{to expression} returns the pointer given the original object,
301and the @var{from expression} returns the original object given
302the pointer.  The pointer will be available using the @code{%h}
303escape.
304
305@findex chain_next
306@findex chain_prev
307@findex chain_circular
308@item chain_next ("@var{expression}")
309@itemx chain_prev ("@var{expression}")
310@itemx chain_circular ("@var{expression}")
311
312It's helpful for the type machinery to know if objects are often
313chained together in long lists; this lets it generate code that uses
314less stack space by iterating along the list instead of recursing down
315it.  @code{chain_next} is an expression for the next item in the list,
316@code{chain_prev} is an expression for the previous item.  For singly
317linked lists, use only @code{chain_next}; for doubly linked lists, use
318both.  The machinery requires that taking the next item of the
319previous item gives the original item.  @code{chain_circular} is similar
320to @code{chain_next}, but can be used for circular single linked lists.
321
322@findex reorder
323@item reorder ("@var{function name}")
324
325Some data structures depend on the relative ordering of pointers.  If
326the precompiled header machinery needs to change that ordering, it
327will call the function referenced by the @code{reorder} option, before
328changing the pointers in the object that's pointed to by the field the
329option applies to.  The function must take four arguments, with the
330signature @samp{@w{void *, void *, gt_pointer_operator, void *}}.
331The first parameter is a pointer to the structure that contains the
332object being updated, or the object itself if there is no containing
333structure.  The second parameter is a cookie that should be ignored.
334The third parameter is a routine that, given a pointer, will update it
335to its correct new value.  The fourth parameter is a cookie that must
336be passed to the second parameter.
337
338PCH cannot handle data structures that depend on the absolute values
339of pointers.  @code{reorder} functions can be expensive.  When
340possible, it is better to depend on properties of the data, like an ID
341number or the hash of a string instead.
342
343@findex atomic
344@item atomic
345
346The @code{atomic} option can only be used with pointers.  It informs
347the GC machinery that the memory that the pointer points to does not
348contain any pointers, and hence it should be treated by the GC and PCH
349machinery as an ``atomic'' block of memory that does not need to be
350examined when scanning memory for pointers.  In particular, the
351machinery will not scan that memory for pointers to mark them as
352reachable (when marking pointers for GC) or to relocate them (when
353writing a PCH file).
354
355The @code{atomic} option differs from the @code{skip} option.
356@code{atomic} keeps the memory under Garbage Collection, but makes the
357GC ignore the contents of the memory.  @code{skip} is more drastic in
358that it causes the pointer and the memory to be completely ignored by
359the Garbage Collector.  So, memory marked as @code{atomic} is
360automatically freed when no longer reachable, while memory marked as
361@code{skip} is not.
362
363The @code{atomic} option must be used with great care, because all
364sorts of problem can occur if used incorrectly, that is, if the memory
365the pointer points to does actually contain a pointer.
366
367Here is an example of how to use it:
368@smallexample
369struct GTY(()) my_struct @{
370  int number_of_elements;
371  unsigned int * GTY ((atomic)) elements;
372@};
373@end smallexample
374In this case, @code{elements} is a pointer under GC, and the memory it
375points to needs to be allocated using the Garbage Collector, and will
376be freed automatically by the Garbage Collector when it is no longer
377referenced.  But the memory that the pointer points to is an array of
378@code{unsigned int} elements, and the GC must not try to scan it to
379find pointers to mark or relocate, which is why it is marked with the
380@code{atomic} option.
381
382Note that, currently, global variables cannot be marked with
383@code{atomic}; only fields of a struct can.  This is a known
384limitation.  It would be useful to be able to mark global pointers
385with @code{atomic} to make the PCH machinery aware of them so that
386they are saved and restored correctly to PCH files.
387
388@findex special
389@item special ("@var{name}")
390
391The @code{special} option is used to mark types that have to be dealt
392with by special case machinery.  The parameter is the name of the
393special case.  See @file{gengtype.cc} for further details.  Avoid
394adding new special cases unless there is no other alternative.
395
396@findex user
397@item user
398
399The @code{user} option indicates that the code to mark structure
400fields is completely handled by user-provided routines.  See section
401@ref{User GC} for details on what functions need to be provided.
402@end table
403
404@node Inheritance and GTY
405@section Support for inheritance
406gengtype has some support for simple class hierarchies.  You can use
407this to have gengtype autogenerate marking routines, provided:
408
409@itemize @bullet
410@item
411There must be a concrete base class, with a discriminator expression
412that can be used to identify which subclass an instance is.
413@item
414Only single inheritance is used.
415@item
416None of the classes within the hierarchy are templates.
417@end itemize
418
419If your class hierarchy does not fit in this pattern, you must use
420@ref{User GC} instead.
421
422The base class and its discriminator must be identified using the ``desc''
423option.  Each concrete subclass must use the ``tag'' option to identify
424which value of the discriminator it corresponds to.
425
426Every class in the hierarchy must have a @code{GTY(())} marker, as
427gengtype will only attempt to parse classes that have such a marker
428@footnote{Classes lacking such a marker will not be identified as being
429part of the hierarchy, and so the marking routines will not handle them,
430leading to a assertion failure within the marking routines due to an
431unknown tag value (assuming that assertions are enabled).}.
432
433@smallexample
434class GTY((desc("%h.kind"), tag("0"))) example_base
435@{
436public:
437    int kind;
438    tree a;
439@};
440
441class GTY((tag("1"))) some_subclass : public example_base
442@{
443public:
444    tree b;
445@};
446
447class GTY((tag("2"))) some_other_subclass : public example_base
448@{
449public:
450    tree c;
451@};
452@end smallexample
453
454The generated marking routines for the above will contain a ``switch''
455on ``kind'', visiting all appropriate fields.  For example, if kind is
4562, it will cast to ``some_other_subclass'' and visit fields a, b, and c.
457
458@node User GC
459@section Support for user-provided GC marking routines
460@cindex user gc
461The garbage collector supports types for which no automatic marking
462code is generated.  For these types, the user is required to provide
463three functions: one to act as a marker for garbage collection, and
464two functions to act as marker and pointer walker for pre-compiled
465headers.
466
467Given a structure @code{struct GTY((user)) my_struct}, the following functions
468should be defined to mark @code{my_struct}:
469
470@smallexample
471void gt_ggc_mx (my_struct *p)
472@{
473  /* This marks field 'fld'.  */
474  gt_ggc_mx (p->fld);
475@}
476
477void gt_pch_nx (my_struct *p)
478@{
479  /* This marks field 'fld'.  */
480  gt_pch_nx (tp->fld);
481@}
482
483void gt_pch_nx (my_struct *p, gt_pointer_operator op, void *cookie)
484@{
485  /* For every field 'fld', call the given pointer operator.  */
486  op (&(tp->fld), NULL, cookie);
487@}
488@end smallexample
489
490In general, each marker @code{M} should call @code{M} for every
491pointer field in the structure.  Fields that are not allocated in GC
492or are not pointers must be ignored.
493
494For embedded lists (e.g., structures with a @code{next} or @code{prev}
495pointer), the marker must follow the chain and mark every element in
496it.
497
498Note that the rules for the pointer walker @code{gt_pch_nx (my_struct
499*, gt_pointer_operator, void *)} are slightly different.  In this
500case, the operation @code{op} must be applied to the @emph{address} of
501every pointer field.
502
503@subsection User-provided marking routines for template types
504When a template type @code{TP} is marked with @code{GTY}, all
505instances of that type are considered user-provided types.  This means
506that the individual instances of @code{TP} do not need to be marked
507with @code{GTY}.  The user needs to provide template functions to mark
508all the fields of the type.
509
510The following code snippets represent all the functions that need to
511be provided. Note that type @code{TP} may reference to more than one
512type. In these snippets, there is only one type @code{T}, but there
513could be more.
514
515@smallexample
516template<typename T>
517void gt_ggc_mx (TP<T> *tp)
518@{
519  extern void gt_ggc_mx (T&);
520
521  /* This marks field 'fld' of type 'T'.  */
522  gt_ggc_mx (tp->fld);
523@}
524
525template<typename T>
526void gt_pch_nx (TP<T> *tp)
527@{
528  extern void gt_pch_nx (T&);
529
530  /* This marks field 'fld' of type 'T'.  */
531  gt_pch_nx (tp->fld);
532@}
533
534template<typename T>
535void gt_pch_nx (TP<T *> *tp, gt_pointer_operator op, void *cookie)
536@{
537  /* For every field 'fld' of 'tp' with type 'T *', call the given
538     pointer operator.  */
539  op (&(tp->fld), NULL, cookie);
540@}
541
542template<typename T>
543void gt_pch_nx (TP<T> *tp, gt_pointer_operator, void *cookie)
544@{
545  extern void gt_pch_nx (T *, gt_pointer_operator, void *);
546
547  /* For every field 'fld' of 'tp' with type 'T', call the pointer
548     walker for all the fields of T.  */
549  gt_pch_nx (&(tp->fld), op, cookie);
550@}
551@end smallexample
552
553Support for user-defined types is currently limited. The following
554restrictions apply:
555
556@enumerate
557@item Type @code{TP} and all the argument types @code{T} must be
558marked with @code{GTY}.
559
560@item Type @code{TP} can only have type names in its argument list.
561
562@item The pointer walker functions are different for @code{TP<T>} and
563@code{TP<T *>}. In the case of @code{TP<T>}, references to
564@code{T} must be handled by calling @code{gt_pch_nx} (which
565will, in turn, walk all the pointers inside fields of @code{T}).
566In the case of @code{TP<T *>}, references to @code{T *} must be
567handled by calling the @code{op} function on the address of the
568pointer (see the code snippets above).
569@end enumerate
570
571@node GGC Roots
572@section Marking Roots for the Garbage Collector
573@cindex roots, marking
574@cindex marking roots
575
576In addition to keeping track of types, the type machinery also locates
577the global variables (@dfn{roots}) that the garbage collector starts
578at.  Roots must be declared using one of the following syntaxes:
579
580@itemize @bullet
581@item
582@code{extern GTY(([@var{options}])) @var{type} @var{name};}
583@item
584@code{static GTY(([@var{options}])) @var{type} @var{name};}
585@end itemize
586@noindent
587The syntax
588@itemize @bullet
589@item
590@code{GTY(([@var{options}])) @var{type} @var{name};}
591@end itemize
592@noindent
593is @emph{not} accepted.  There should be an @code{extern} declaration
594of such a variable in a header somewhere---mark that, not the
595definition.  Or, if the variable is only used in one file, make it
596@code{static}.
597
598@node Files
599@section Source Files Containing Type Information
600@cindex generated files
601@cindex files, generated
602
603Whenever you add @code{GTY} markers to a source file that previously
604had none, or create a new source file containing @code{GTY} markers,
605there are three things you need to do:
606
607@enumerate
608@item
609You need to add the file to the list of source files the type
610machinery scans.  There are four cases:
611
612@enumerate a
613@item
614For a back-end file, this is usually done
615automatically; if not, you should add it to @code{target_gtfiles} in
616the appropriate port's entries in @file{config.gcc}.
617
618@item
619For files shared by all front ends, add the filename to the
620@code{GTFILES} variable in @file{Makefile.in}.
621
622@item
623For files that are part of one front end, add the filename to the
624@code{gtfiles} variable defined in the appropriate
625@file{config-lang.in}.
626Headers should appear before non-headers in this list.
627
628@item
629For files that are part of some but not all front ends, add the
630filename to the @code{gtfiles} variable of @emph{all} the front ends
631that use it.
632@end enumerate
633
634@item
635If the file was a header file, you'll need to check that it's included
636in the right place to be visible to the generated files.  For a back-end
637header file, this should be done automatically.  For a front-end header
638file, it needs to be included by the same file that includes
639@file{gtype-@var{lang}.h}.  For other header files, it needs to be
640included in @file{gtype-desc.cc}, which is a generated file, so add it to
641@code{ifiles} in @code{open_base_file} in @file{gengtype.cc}.
642
643For source files that aren't header files, the machinery will generate a
644header file that should be included in the source file you just changed.
645The file will be called @file{gt-@var{path}.h} where @var{path} is the
646pathname relative to the @file{gcc} directory with slashes replaced by
647@verb{|-|}, so for example the header file to be included in
648@file{cp/parser.cc} is called @file{gt-cp-parser.h}.  The
649generated header file should be included after everything else in the
650source file.
651
652@end enumerate
653
654For language frontends, there is another file that needs to be included
655somewhere.  It will be called @file{gtype-@var{lang}.h}, where
656@var{lang} is the name of the subdirectory the language is contained in.
657
658Plugins can add additional root tables.  Run the @code{gengtype}
659utility in plugin mode as @code{gengtype -P pluginout.h @var{source-dir}
660@var{file-list} @var{plugin*.c}} with your plugin files
661@var{plugin*.c} using @code{GTY} to generate the @var{pluginout.h} file.
662The GCC build tree is needed to be present in that mode.
663
664
665@node Invoking the garbage collector
666@section How to invoke the garbage collector
667@cindex garbage collector, invocation
668@findex ggc_collect
669
670The GCC garbage collector GGC is only invoked explicitly. In contrast
671with many other garbage collectors, it is not implicitly invoked by
672allocation routines when a lot of memory has been consumed. So the
673only way to have GGC reclaim storage is to call the @code{ggc_collect}
674function explicitly.
675With @var{mode} @code{GGC_COLLECT_FORCE} or otherwise (default
676@code{GGC_COLLECT_HEURISTIC}) when the internal heuristic decides to
677collect, this call is potentially an expensive operation, as it may
678have to scan the entire heap.  Beware that local variables (on the GCC
679call stack) are not followed by such an invocation (as many other
680garbage collectors do): you should reference all your data from static
681or external @code{GTY}-ed variables, and it is advised to call
682@code{ggc_collect} with a shallow call stack.  The GGC is an exact mark
683and sweep garbage collector (so it does not scan the call stack for
684pointers).  In practice GCC passes don't often call @code{ggc_collect}
685themselves, because it is called by the pass manager between passes.
686
687At the time of the @code{ggc_collect} call all pointers in the GC-marked
688structures must be valid or @code{NULL}.  In practice this means that
689there should not be uninitialized pointer fields in the structures even
690if your code never reads or writes those fields at a particular
691instance.  One way to ensure this is to use cleared versions of
692allocators unless all the fields are initialized manually immediately
693after allocation.
694
695@node Troubleshooting
696@section Troubleshooting the garbage collector
697@cindex garbage collector, troubleshooting
698
699With the current garbage collector implementation, most issues should
700show up as GCC compilation errors.  Some of the most commonly
701encountered issues are described below.
702
703@itemize @bullet
704@item Gengtype does not produce allocators for a @code{GTY}-marked type.
705Gengtype checks if there is at least one possible path from GC roots to
706at least one instance of each type before outputting allocators.  If
707there is no such path, the @code{GTY} markers will be ignored and no
708allocators will be output.  Solve this by making sure that there exists
709at least one such path.  If creating it is unfeasible or raises a ``code
710smell'', consider if you really must use GC for allocating such type.
711
712@item Link-time errors about undefined @code{gt_ggc_r_foo_bar} and
713similarly-named symbols.  Check if your @file{foo_bar} source file has
714@code{#include "gt-foo_bar.h"} as its very last line.
715
716@end itemize
717