Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Language independent support for printing types for GDB, the GNU debugger. |
e2882c85 | 2 | Copyright (C) 1986-2018 Free Software Foundation, Inc. |
c906108c | 3 | |
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 9 | (at your option) any later version. |
c906108c | 10 | |
c5aa993b JM |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
c906108c | 15 | |
c5aa993b | 16 | You should have received a copy of the GNU General Public License |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 18 | |
17732724 AC |
19 | #ifndef TYPEPRINT_H |
20 | #define TYPEPRINT_H | |
21 | ||
c819b2c0 TT |
22 | #include "gdb_obstack.h" |
23 | ||
94af9270 | 24 | enum language; |
da3331ec | 25 | struct ui_file; |
bd69fc68 | 26 | struct typedef_hash_table; |
6dddc817 | 27 | struct ext_lang_type_printers; |
da3331ec | 28 | |
7c161838 SDJ |
29 | struct print_offset_data |
30 | { | |
31 | /* The offset to be applied to bitpos when PRINT_OFFSETS is true. | |
32 | This is needed for when we are printing nested structs and want | |
33 | to make sure that the printed offset for each field carries over | |
34 | the offset of the outter struct. */ | |
35 | unsigned int offset_bitpos = 0; | |
36 | ||
37 | /* END_BITPOS is the one-past-the-end bit position of the previous | |
38 | field (where we expect the current field to be if there is no | |
39 | hole). */ | |
40 | unsigned int end_bitpos = 0; | |
41 | }; | |
42 | ||
79d43c61 TT |
43 | struct type_print_options |
44 | { | |
45 | /* True means that no special printing flags should apply. */ | |
46 | unsigned int raw : 1; | |
53342f27 TT |
47 | |
48 | /* True means print methods in a class. */ | |
49 | unsigned int print_methods : 1; | |
50 | ||
51 | /* True means print typedefs in a class. */ | |
52 | unsigned int print_typedefs : 1; | |
bd69fc68 | 53 | |
7c161838 SDJ |
54 | /* True means to print offsets, a la 'pahole'. */ |
55 | unsigned int print_offsets : 1; | |
56 | ||
883fd55a KS |
57 | /* The number of nested type definitions to print. -1 == all. */ |
58 | int print_nested_type_limit; | |
59 | ||
bd69fc68 TT |
60 | /* If not NULL, a local typedef hash table used when printing a |
61 | type. */ | |
c819b2c0 | 62 | typedef_hash_table *local_typedefs; |
18a9fc12 TT |
63 | |
64 | /* If not NULL, a global typedef hash table used when printing a | |
65 | type. */ | |
c819b2c0 | 66 | typedef_hash_table *global_typedefs; |
18a9fc12 TT |
67 | |
68 | /* The list of type printers associated with the global typedef | |
69 | table. This is intentionally opaque. */ | |
6dddc817 | 70 | struct ext_lang_type_printers *global_printers; |
79d43c61 TT |
71 | }; |
72 | ||
73 | extern const struct type_print_options type_print_raw_options; | |
74 | ||
c819b2c0 TT |
75 | /* A hash table holding typedef_field objects. This is more |
76 | complicated than an ordinary hash because it must also track the | |
77 | lifetime of some -- but not all -- of the contained objects. */ | |
78 | ||
79 | class typedef_hash_table | |
80 | { | |
81 | public: | |
82 | ||
83 | /* Create a new typedef-lookup hash table. */ | |
84 | typedef_hash_table (); | |
85 | ||
86 | ~typedef_hash_table (); | |
87 | ||
88 | /* Copy a typedef hash. */ | |
89 | typedef_hash_table (const typedef_hash_table &); | |
bd69fc68 | 90 | |
c819b2c0 | 91 | typedef_hash_table &operator= (const typedef_hash_table &) = delete; |
bd69fc68 | 92 | |
c819b2c0 TT |
93 | /* Add typedefs from T to the hash table TABLE. */ |
94 | void recursively_update (struct type *); | |
bd69fc68 | 95 | |
c819b2c0 TT |
96 | /* Add template parameters from T to the typedef hash TABLE. */ |
97 | void add_template_parameters (struct type *t); | |
bd69fc68 | 98 | |
c819b2c0 TT |
99 | /* Look up the type T in the typedef hash tables contained in FLAGS. |
100 | The local table is searched first, then the global table (either | |
101 | table can be NULL, in which case it is skipped). If T is in a | |
102 | table, return its short (class-relative) typedef name. Otherwise | |
103 | return NULL. */ | |
104 | static const char *find_typedef (const struct type_print_options *flags, | |
105 | struct type *t); | |
bd69fc68 | 106 | |
c819b2c0 TT |
107 | private: |
108 | ||
109 | static const char *find_global_typedef (const struct type_print_options *flags, | |
110 | struct type *t); | |
111 | ||
112 | ||
113 | /* The actual hash table. */ | |
114 | htab_t m_table; | |
115 | ||
116 | /* Storage for typedef_field objects that must be synthesized. */ | |
117 | auto_obstack m_storage; | |
118 | }; | |
bd69fc68 | 119 | |
bd69fc68 | 120 | |
d9fcf2fb | 121 | void print_type_scalar (struct type * type, LONGEST, struct ui_file *); |
c906108c | 122 | |
d9fcf2fb | 123 | void c_type_print_varspec_suffix (struct type *, struct ui_file *, int, |
79d43c61 TT |
124 | int, int, const struct type_print_options *); |
125 | ||
126 | void c_type_print_args (struct type *, struct ui_file *, int, enum language, | |
127 | const struct type_print_options *); | |
94af9270 | 128 | |
7022349d PA |
129 | /* Print <unknown return type> to stream STREAM. */ |
130 | ||
131 | void type_print_unknown_return_type (struct ui_file *stream); | |
132 | ||
46a4882b PA |
133 | /* Throw an error indicating that the user tried to use a symbol that |
134 | has unknown type. SYM_PRINT_NAME is the name of the symbol, to be | |
135 | included in the error message. */ | |
136 | extern void error_unknown_type (const char *sym_print_name); | |
137 | ||
3f2f83dd KB |
138 | extern void val_print_not_allocated (struct ui_file *stream); |
139 | ||
140 | extern void val_print_not_associated (struct ui_file *stream); | |
141 | ||
17732724 | 142 | #endif |