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_SIGNED)
113 if ($arg0->modifiers & MOD_UNSIGNED)
114 printf "MOD_UNSIGNED "
116 if ($arg0->modifiers & MOD_CHAR)
119 if ($arg0->modifiers & MOD_SHORT)
122 if ($arg0->modifiers & MOD_LONG)
125 if ($arg0->modifiers & MOD_LONGLONG)
126 printf "MOD_LONGLONG "
128 if ($arg0->modifiers & MOD_LONGLONGLONG)
129 printf "MOD_LONGLONGLONG "
131 if ($arg0->modifiers & MOD_TYPEDEF)
132 printf "MOD_TYPEDEF "
134 if ($arg0->modifiers & MOD_INLINE)
137 if ($arg0->modifiers & MOD_ADDRESSABLE)
138 printf "MOD_ADDRESSABLE "
140 if ($arg0->modifiers & MOD_NOCAST)
143 if ($arg0->modifiers & MOD_NODEREF)
144 printf "MOD_NODEREF "
146 if ($arg0->modifiers & MOD_ACCESSED)
147 printf "MOD_ACCESSED "
149 if ($arg0->modifiers & MOD_TOPLEVEL)
150 printf "MOD_TOPLEVEL "
152 if ($arg0->modifiers & MOD_ASSIGNED)
153 printf "MOD_ASSIGNED "
155 if ($arg0->modifiers & MOD_TYPE)
158 if ($arg0->modifiers & MOD_SAFE)
161 if ($arg0->modifiers & MOD_USERTYPE)
162 printf "MOD_USERTYPE "
164 if ($arg0->modifiers & MOD_EXPLICITLY_SIGNED)
165 printf "MOD_EXPLICITLY_SIGNED"
167 if ($arg0->modifiers & MOD_BITWISE)
168 printf "MOD_BITWISE "
170 if (!$arg0->modifiers)
174 printf ", alignment = %d", $arg0->alignment
176 printf ", address_space = %d", $arg0->as
182 if ($arg0->base_type)
184 printf "base_type = "
185 gdb_show_symbol($arg0->base_type)
193 define gdb_show_symbol
194 printf "(%x) type = ", $arg0
196 printf ", namespace = "
197 output $arg0->namespace
199 printf ", ident = %s\n", show_ident($arg0->ident)
201 printf ", ident = NULL\n"
208 call show_symbol($arg0)
211 if ($arg0->namespace == NS_SYMBOL)
214 gdb_show_ctype(&($arg0->ctype))
221 define gdb_show_symbols_next_id
228 gdb_show_symbol($sym)
229 set $sym = $sym->next_id
236 define gdb_show_ident
238 printf "(%p) '%s'\n", $arg0, show_ident($arg0)
243 if (! $showing_ident)
244 set $showing_ident = 1
252 gdb_show_symbols_next_id($ident->symbols)
256 set $showing_ident = 0
260 define gdb_show_token
261 printf "%p: '%s', type = ", $arg0, show_token($arg0)
262 output (enum token_type) ($arg0)->pos.type
265 if (! $showing_token)
266 set $showing_token = 1
271 if ($token->pos.type == TOKEN_IDENT)
274 gdb_show_ident $token.ident
277 if ($token->pos.type == TOKEN_MACRO_ARGUMENT)
279 printf "argnum = %d\n", $token->argnum
282 if ($token->pos.type == TOKEN_SPECIAL)
284 printf "special = \"%s\"\n", show_special($token.special)
288 set $showing_token = 0
293 define gdb_show_tokens
297 while ($t != &eof_token_entry)