2 # Don't forget to rebuild sparse with uncommented debug options
3 # in the Makefile. Also, gcc 3 is known to screw up with the
4 # cpp macros in the debugging info.
7 # If a gdb_show_* function is running at a non-zero recursion
8 # level, only a short summary is shown, preventing further
9 # recursion. Also note that gdb has only one, global, scope
10 # for variables, so we need to be careful with recursions.
13 set $showing_token = 0
14 set $showing_ident = 0
15 set $showing_symbol = 0
33 set *($entry) = (void *) (~3UL & (unsigned long)$ptr->list[$index])
37 # Ptr list looping skeleton
38 define gdb_ptr_list_for_each
40 set $my_head = (struct ptr_list *) $arg0
41 set $my_list = $my_head
47 while ($my_nr < $my_list->nr)
49 # Put your iterator code here
53 if (($my_list = $my_list->next) == $my_head)
60 # Show symbols in a symbol_list. Non-recursive
61 define gdb_ptr_list_for_each_show_symbol
63 set $my_head = (struct ptr_list *) $arg0
64 set $my_list = $my_head
70 while ($my_nr < ($my_list)->nr)
71 set $my_symbol = (struct symbol *) ((~3UL) & (unsigned long)($my_list)->list[$my_nr])
72 gdb_show_symbol($my_symbol)
77 set $my_list = ($my_list)->next
78 if ($my_list == $my_head)
86 #define gdb_show_statement
92 if ($arg0->modifiers & MOD_AUTO)
95 if ($arg0->modifiers & MOD_REGISTER)
96 printf "MOD_REGISTER "
98 if ($arg0->modifiers & MOD_STATIC)
101 if ($arg0->modifiers & MOD_EXTERN)
104 if ($arg0->modifiers & MOD_CONST)
107 if ($arg0->modifiers & MOD_VOLATILE)
108 printf "MOD_VOLATILE "
110 if ($arg0->modifiers & MOD_RESTRICT)
111 printf "MOD_RESTRICT "
113 if ($arg0->modifiers & MOD_ATOMIC)
116 if ($arg0->modifiers & MOD_SIGNED)
119 if ($arg0->modifiers & MOD_UNSIGNED)
120 printf "MOD_UNSIGNED "
122 if ($arg0->modifiers & MOD_INLINE)
125 if ($arg0->modifiers & MOD_ADDRESSABLE)
126 printf "MOD_ADDRESSABLE "
128 if ($arg0->modifiers & MOD_NOCAST)
131 if ($arg0->modifiers & MOD_NODEREF)
132 printf "MOD_NODEREF "
134 if ($arg0->modifiers & MOD_TOPLEVEL)
135 printf "MOD_TOPLEVEL "
137 if ($arg0->modifiers & MOD_ASSIGNED)
138 printf "MOD_ASSIGNED "
140 if ($arg0->modifiers & MOD_SAFE)
143 if ($arg0->modifiers & MOD_USERTYPE)
144 printf "MOD_USERTYPE "
146 if ($arg0->modifiers & MOD_EXPLICITLY_SIGNED)
147 printf "MOD_EXPLICITLY_SIGNED"
149 if ($arg0->modifiers & MOD_BITWISE)
150 printf "MOD_BITWISE "
152 if (!$arg0->modifiers)
156 printf ", alignment = %d", $arg0->alignment
158 printf ", address_space = %d", $arg0->as
164 if ($arg0->base_type)
166 printf "base_type = "
167 gdb_show_symbol($arg0->base_type)
175 define gdb_show_symbol
176 printf "(%x) type = ", $arg0
178 printf ", namespace = "
179 output $arg0->namespace
181 printf ", ident = %s\n", show_ident($arg0->ident)
183 printf ", ident = NULL\n"
190 call show_symbol($arg0)
193 if ($arg0->namespace == NS_SYMBOL)
196 gdb_show_ctype(&($arg0->ctype))
203 define gdb_show_symbols_next_id
210 gdb_show_symbol($sym)
211 set $sym = $sym->next_id
218 define gdb_show_ident
220 printf "(%p) '%s'\n", $arg0, show_ident($arg0)
225 if (! $showing_ident)
226 set $showing_ident = 1
234 gdb_show_symbols_next_id($ident->symbols)
238 set $showing_ident = 0
242 define gdb_show_token
243 printf "%p: '%s', type = ", $arg0, show_token($arg0)
244 output (enum token_type) ($arg0)->pos.type
247 if (! $showing_token)
248 set $showing_token = 1
253 if ($token->pos.type == TOKEN_IDENT)
256 gdb_show_ident $token.ident
259 if ($token->pos.type == TOKEN_MACRO_ARGUMENT)
261 printf "argnum = %d\n", $token->argnum
264 if ($token->pos.type == TOKEN_SPECIAL)
266 printf "special = \"%s\"\n", show_special($token.special)
270 set $showing_token = 0
275 define gdb_show_tokens
279 while ($t != &eof_token_entry)