Add a C++ wrapper for GCC C plug-in
[external/binutils.git] / gdb / compile / compile-c-symbols.c
1 /* Convert symbols from GDB to GCC
2
3    Copyright (C) 2014-2018 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20
21 #include "defs.h"
22 #include "compile-internal.h"
23 #include "compile-c.h"
24 #include "symtab.h"
25 #include "parser-defs.h"
26 #include "block.h"
27 #include "objfiles.h"
28 #include "compile.h"
29 #include "value.h"
30 #include "exceptions.h"
31 #include "gdbtypes.h"
32 #include "dwarf2loc.h"
33
34 \f
35
36 /* Object of this type are stored in the compiler's symbol_err_map.  */
37
38 struct symbol_error
39 {
40   /* The symbol.  */
41
42   const struct symbol *sym;
43
44   /* The error message to emit.  This is malloc'd and owned by the
45      hash table.  */
46
47   char *message;
48 };
49
50 /* Hash function for struct symbol_error.  */
51
52 static hashval_t
53 hash_symbol_error (const void *a)
54 {
55   const struct symbol_error *se = (const struct symbol_error *) a;
56
57   return htab_hash_pointer (se->sym);
58 }
59
60 /* Equality function for struct symbol_error.  */
61
62 static int
63 eq_symbol_error (const void *a, const void *b)
64 {
65   const struct symbol_error *sea = (const struct symbol_error *) a;
66   const struct symbol_error *seb = (const struct symbol_error *) b;
67
68   return sea->sym == seb->sym;
69 }
70
71 /* Deletion function for struct symbol_error.  */
72
73 static void
74 del_symbol_error (void *a)
75 {
76   struct symbol_error *se = (struct symbol_error *) a;
77
78   xfree (se->message);
79   xfree (se);
80 }
81
82 /* Associate SYMBOL with some error text.  */
83
84 static void
85 insert_symbol_error (htab_t hash, const struct symbol *sym, const char *text)
86 {
87   struct symbol_error e;
88   void **slot;
89
90   e.sym = sym;
91   slot = htab_find_slot (hash, &e, INSERT);
92   if (*slot == NULL)
93     {
94       struct symbol_error *e = XNEW (struct symbol_error);
95
96       e->sym = sym;
97       e->message = xstrdup (text);
98       *slot = e;
99     }
100 }
101
102 /* Emit the error message corresponding to SYM, if one exists, and
103    arrange for it not to be emitted again.  */
104
105 static void
106 error_symbol_once (struct compile_c_instance *context,
107                    const struct symbol *sym)
108 {
109   struct symbol_error search;
110   struct symbol_error *err;
111
112   if (context->symbol_err_map == NULL)
113     return;
114
115   search.sym = sym;
116   err = (struct symbol_error *) htab_find (context->symbol_err_map, &search);
117   if (err == NULL || err->message == NULL)
118     return;
119
120   gdb::unique_xmalloc_ptr<char> message (err->message);
121   err->message = NULL;
122   error (_("%s"), message.get ());
123 }
124
125 \f
126
127 /* Compute the name of the pointer representing a local symbol's
128    address.  */
129
130 static gdb::unique_xmalloc_ptr<char>
131 c_symbol_substitution_name (struct symbol *sym)
132 {
133   return gdb::unique_xmalloc_ptr<char>
134     (concat ("__", SYMBOL_NATURAL_NAME (sym), "_ptr", (char *) NULL));
135 }
136
137 /* Convert a given symbol, SYM, to the compiler's representation.
138    CONTEXT is the compiler instance.  IS_GLOBAL is true if the
139    symbol came from the global scope.  IS_LOCAL is true if the symbol
140    came from a local scope.  (Note that the two are not strictly
141    inverses because the symbol might have come from the static
142    scope.)  */
143
144 static void
145 convert_one_symbol (struct compile_c_instance *context,
146                     struct block_symbol sym,
147                     int is_global,
148                     int is_local)
149 {
150   gcc_type sym_type;
151   const char *filename = symbol_symtab (sym.symbol)->filename;
152   unsigned short line = SYMBOL_LINE (sym.symbol);
153
154   error_symbol_once (context, sym.symbol);
155
156   if (SYMBOL_CLASS (sym.symbol) == LOC_LABEL)
157     sym_type = 0;
158   else
159     sym_type = convert_type (context, SYMBOL_TYPE (sym.symbol));
160
161   if (SYMBOL_DOMAIN (sym.symbol) == STRUCT_DOMAIN)
162     {
163       /* Binding a tag, so we don't need to build a decl.  */
164       context->c_plugin->tagbind (SYMBOL_NATURAL_NAME (sym.symbol),
165                                   sym_type, filename, line);
166     }
167   else
168     {
169       gcc_decl decl;
170       enum gcc_c_symbol_kind kind;
171       CORE_ADDR addr = 0;
172       gdb::unique_xmalloc_ptr<char> symbol_name;
173
174       switch (SYMBOL_CLASS (sym.symbol))
175         {
176         case LOC_TYPEDEF:
177           kind = GCC_C_SYMBOL_TYPEDEF;
178           break;
179
180         case LOC_LABEL:
181           kind = GCC_C_SYMBOL_LABEL;
182           addr = SYMBOL_VALUE_ADDRESS (sym.symbol);
183           break;
184
185         case LOC_BLOCK:
186           kind = GCC_C_SYMBOL_FUNCTION;
187           addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
188           if (is_global && TYPE_GNU_IFUNC (SYMBOL_TYPE (sym.symbol)))
189             addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
190           break;
191
192         case LOC_CONST:
193           if (TYPE_CODE (SYMBOL_TYPE (sym.symbol)) == TYPE_CODE_ENUM)
194             {
195               /* Already handled by convert_enum.  */
196               return;
197             }
198           context->c_plugin->build_constant
199             (sym_type, SYMBOL_NATURAL_NAME (sym.symbol),
200              SYMBOL_VALUE (sym.symbol),
201              filename, line);
202           return;
203
204         case LOC_CONST_BYTES:
205           error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."),
206                  SYMBOL_PRINT_NAME (sym.symbol));
207
208         case LOC_UNDEF:
209           internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."),
210                           SYMBOL_PRINT_NAME (sym.symbol));
211
212         case LOC_COMMON_BLOCK:
213           error (_("Fortran common block is unsupported for compilation "
214                    "evaluaton of symbol \"%s\"."),
215                  SYMBOL_PRINT_NAME (sym.symbol));
216
217         case LOC_OPTIMIZED_OUT:
218           error (_("Symbol \"%s\" cannot be used for compilation evaluation "
219                    "as it is optimized out."),
220                  SYMBOL_PRINT_NAME (sym.symbol));
221
222         case LOC_COMPUTED:
223           if (is_local)
224             goto substitution;
225           /* Probably TLS here.  */
226           warning (_("Symbol \"%s\" is thread-local and currently can only "
227                      "be referenced from the current thread in "
228                      "compiled code."),
229                    SYMBOL_PRINT_NAME (sym.symbol));
230           /* FALLTHROUGH */
231         case LOC_UNRESOLVED:
232           /* 'symbol_name' cannot be used here as that one is used only for
233              local variables from compile_dwarf_expr_to_c.
234              Global variables can be accessed by GCC only by their address, not
235              by their name.  */
236           {
237             struct value *val;
238             struct frame_info *frame = NULL;
239
240             if (symbol_read_needs_frame (sym.symbol))
241               {
242                 frame = get_selected_frame (NULL);
243                 if (frame == NULL)
244                   error (_("Symbol \"%s\" cannot be used because "
245                            "there is no selected frame"),
246                          SYMBOL_PRINT_NAME (sym.symbol));
247               }
248
249             val = read_var_value (sym.symbol, sym.block, frame);
250             if (VALUE_LVAL (val) != lval_memory)
251               error (_("Symbol \"%s\" cannot be used for compilation "
252                        "evaluation as its address has not been found."),
253                      SYMBOL_PRINT_NAME (sym.symbol));
254
255             kind = GCC_C_SYMBOL_VARIABLE;
256             addr = value_address (val);
257           }
258           break;
259
260
261         case LOC_REGISTER:
262         case LOC_ARG:
263         case LOC_REF_ARG:
264         case LOC_REGPARM_ADDR:
265         case LOC_LOCAL:
266         substitution:
267           kind = GCC_C_SYMBOL_VARIABLE;
268           symbol_name = c_symbol_substitution_name (sym.symbol);
269           break;
270
271         case LOC_STATIC:
272           kind = GCC_C_SYMBOL_VARIABLE;
273           addr = SYMBOL_VALUE_ADDRESS (sym.symbol);
274           break;
275
276         case LOC_FINAL_VALUE:
277         default:
278           gdb_assert_not_reached ("Unreachable case in convert_one_symbol.");
279
280         }
281
282       /* Don't emit local variable decls for a raw expression.  */
283       if (context->base.scope != COMPILE_I_RAW_SCOPE
284           || symbol_name == NULL)
285         {
286           decl = context->c_plugin->build_decl
287             (SYMBOL_NATURAL_NAME (sym.symbol),
288              kind,
289              sym_type,
290              symbol_name.get (), addr,
291              filename, line);
292
293           context->c_plugin->bind (decl, is_global);
294         }
295     }
296 }
297
298 /* Convert a full symbol to its gcc form.  CONTEXT is the compiler to
299    use, IDENTIFIER is the name of the symbol, SYM is the symbol
300    itself, and DOMAIN is the domain which was searched.  */
301
302 static void
303 convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
304                     struct block_symbol sym, domain_enum domain)
305 {
306   const struct block *static_block;
307   int is_local_symbol;
308
309   /* If we found a symbol and it is not in the  static or global
310      scope, then we should first convert any static or global scope
311      symbol of the same name.  This lets this unusual case work:
312
313      int x; // Global.
314      int func(void)
315      {
316      int x;
317      // At this spot, evaluate "extern int x; x"
318      }
319   */
320
321   static_block = block_static_block (sym.block);
322   /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block.  */
323   is_local_symbol = (sym.block != static_block && static_block != NULL);
324   if (is_local_symbol)
325     {
326       struct block_symbol global_sym;
327
328       global_sym = lookup_symbol (identifier, NULL, domain, NULL);
329       /* If the outer symbol is in the static block, we ignore it, as
330          it cannot be referenced.  */
331       if (global_sym.symbol != NULL
332           && global_sym.block != block_static_block (global_sym.block))
333         {
334           if (compile_debug)
335             fprintf_unfiltered (gdb_stdlog,
336                                 "gcc_convert_symbol \"%s\": global symbol\n",
337                                 identifier);
338           convert_one_symbol (context, global_sym, 1, 0);
339         }
340     }
341
342   if (compile_debug)
343     fprintf_unfiltered (gdb_stdlog,
344                         "gcc_convert_symbol \"%s\": local symbol\n",
345                         identifier);
346   convert_one_symbol (context, sym, 0, is_local_symbol);
347 }
348
349 /* Convert a minimal symbol to its gcc form.  CONTEXT is the compiler
350    to use and BMSYM is the minimal symbol to convert.  */
351
352 static void
353 convert_symbol_bmsym (struct compile_c_instance *context,
354                       struct bound_minimal_symbol bmsym)
355 {
356   struct minimal_symbol *msym = bmsym.minsym;
357   struct objfile *objfile = bmsym.objfile;
358   struct type *type;
359   enum gcc_c_symbol_kind kind;
360   gcc_type sym_type;
361   gcc_decl decl;
362   CORE_ADDR addr;
363
364   addr = MSYMBOL_VALUE_ADDRESS (objfile, msym);
365
366   /* Conversion copied from write_exp_msymbol.  */
367   switch (MSYMBOL_TYPE (msym))
368     {
369     case mst_text:
370     case mst_file_text:
371     case mst_solib_trampoline:
372       type = objfile_type (objfile)->nodebug_text_symbol;
373       kind = GCC_C_SYMBOL_FUNCTION;
374       break;
375
376     case mst_text_gnu_ifunc:
377       type = objfile_type (objfile)->nodebug_text_gnu_ifunc_symbol;
378       kind = GCC_C_SYMBOL_FUNCTION;
379       addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
380       break;
381
382     case mst_data:
383     case mst_file_data:
384     case mst_bss:
385     case mst_file_bss:
386       type = objfile_type (objfile)->nodebug_data_symbol;
387       kind = GCC_C_SYMBOL_VARIABLE;
388       break;
389
390     case mst_slot_got_plt:
391       type = objfile_type (objfile)->nodebug_got_plt_symbol;
392       kind = GCC_C_SYMBOL_FUNCTION;
393       break;
394
395     default:
396       type = objfile_type (objfile)->nodebug_unknown_symbol;
397       kind = GCC_C_SYMBOL_VARIABLE;
398       break;
399     }
400
401   sym_type = convert_type (context, type);
402   decl = context->c_plugin->build_decl (MSYMBOL_NATURAL_NAME (msym),
403                                         kind, sym_type, NULL, addr,
404                                         NULL, 0);
405   context->c_plugin->bind (decl, 1 /* is_global */);
406 }
407
408 /* See compile-internal.h.  */
409
410 void
411 gcc_convert_symbol (void *datum,
412                     struct gcc_c_context *gcc_context,
413                     enum gcc_c_oracle_request request,
414                     const char *identifier)
415 {
416   struct compile_c_instance *context = (struct compile_c_instance *) datum;
417   domain_enum domain;
418   int found = 0;
419
420   switch (request)
421     {
422     case GCC_C_ORACLE_SYMBOL:
423       domain = VAR_DOMAIN;
424       break;
425     case GCC_C_ORACLE_TAG:
426       domain = STRUCT_DOMAIN;
427       break;
428     case GCC_C_ORACLE_LABEL:
429       domain = LABEL_DOMAIN;
430       break;
431     default:
432       gdb_assert_not_reached ("Unrecognized oracle request.");
433     }
434
435   /* We can't allow exceptions to escape out of this callback.  Safest
436      is to simply emit a gcc error.  */
437   TRY
438     {
439       struct block_symbol sym;
440
441       sym = lookup_symbol (identifier, context->base.block, domain, NULL);
442       if (sym.symbol != NULL)
443         {
444           convert_symbol_sym (context, identifier, sym, domain);
445           found = 1;
446         }
447       else if (domain == VAR_DOMAIN)
448         {
449           struct bound_minimal_symbol bmsym;
450
451           bmsym = lookup_minimal_symbol (identifier, NULL, NULL);
452           if (bmsym.minsym != NULL)
453             {
454               convert_symbol_bmsym (context, bmsym);
455               found = 1;
456             }
457         }
458     }
459
460   CATCH (e, RETURN_MASK_ALL)
461     {
462       context->c_plugin->error (e.message);
463     }
464   END_CATCH
465
466   if (compile_debug && !found)
467     fprintf_unfiltered (gdb_stdlog,
468                         "gcc_convert_symbol \"%s\": lookup_symbol failed\n",
469                         identifier);
470   return;
471 }
472
473 /* See compile-internal.h.  */
474
475 gcc_address
476 gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
477                     const char *identifier)
478 {
479   struct compile_c_instance *context = (struct compile_c_instance *) datum;
480   gcc_address result = 0;
481   int found = 0;
482
483   /* We can't allow exceptions to escape out of this callback.  Safest
484      is to simply emit a gcc error.  */
485   TRY
486     {
487       struct symbol *sym;
488
489       /* We only need global functions here.  */
490       sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol;
491       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK)
492         {
493           if (compile_debug)
494             fprintf_unfiltered (gdb_stdlog,
495                                 "gcc_symbol_address \"%s\": full symbol\n",
496                                 identifier);
497           result = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
498           if (TYPE_GNU_IFUNC (SYMBOL_TYPE (sym)))
499             result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
500           found = 1;
501         }
502       else
503         {
504           struct bound_minimal_symbol msym;
505
506           msym = lookup_bound_minimal_symbol (identifier);
507           if (msym.minsym != NULL)
508             {
509               if (compile_debug)
510                 fprintf_unfiltered (gdb_stdlog,
511                                     "gcc_symbol_address \"%s\": minimal "
512                                     "symbol\n",
513                                     identifier);
514               result = BMSYMBOL_VALUE_ADDRESS (msym);
515               if (MSYMBOL_TYPE (msym.minsym) == mst_text_gnu_ifunc)
516                 result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
517               found = 1;
518             }
519         }
520     }
521
522   CATCH (e, RETURN_MASK_ERROR)
523     {
524       context->c_plugin->error (e.message);
525     }
526   END_CATCH
527
528   if (compile_debug && !found)
529     fprintf_unfiltered (gdb_stdlog,
530                         "gcc_symbol_address \"%s\": failed\n",
531                         identifier);
532   return result;
533 }
534
535 \f
536
537 /* A hash function for symbol names.  */
538
539 static hashval_t
540 hash_symname (const void *a)
541 {
542   const struct symbol *sym = (const struct symbol *) a;
543
544   return htab_hash_string (SYMBOL_NATURAL_NAME (sym));
545 }
546
547 /* A comparison function for hash tables that just looks at symbol
548    names.  */
549
550 static int
551 eq_symname (const void *a, const void *b)
552 {
553   const struct symbol *syma = (const struct symbol *) a;
554   const struct symbol *symb = (const struct symbol *) b;
555
556   return strcmp (SYMBOL_NATURAL_NAME (syma), SYMBOL_NATURAL_NAME (symb)) == 0;
557 }
558
559 /* If a symbol with the same name as SYM is already in HASHTAB, return
560    1.  Otherwise, add SYM to HASHTAB and return 0.  */
561
562 static int
563 symbol_seen (htab_t hashtab, struct symbol *sym)
564 {
565   void **slot;
566
567   slot = htab_find_slot (hashtab, sym, INSERT);
568   if (*slot != NULL)
569     return 1;
570
571   *slot = sym;
572   return 0;
573 }
574
575 /* Generate C code to compute the length of a VLA.  */
576
577 static void
578 generate_vla_size (struct compile_c_instance *compiler,
579                    string_file &stream,
580                    struct gdbarch *gdbarch,
581                    unsigned char *registers_used,
582                    CORE_ADDR pc,
583                    struct type *type,
584                    struct symbol *sym)
585 {
586   type = check_typedef (type);
587
588   if (TYPE_IS_REFERENCE (type))
589     type = check_typedef (TYPE_TARGET_TYPE (type));
590
591   switch (TYPE_CODE (type))
592     {
593     case TYPE_CODE_RANGE:
594       {
595         if (TYPE_HIGH_BOUND_KIND (type) == PROP_LOCEXPR
596             || TYPE_HIGH_BOUND_KIND (type) == PROP_LOCLIST)
597           {
598             const struct dynamic_prop *prop = &TYPE_RANGE_DATA (type)->high;
599             std::string name = c_get_range_decl_name (prop);
600
601             dwarf2_compile_property_to_c (stream, name.c_str (),
602                                           gdbarch, registers_used,
603                                           prop, pc, sym);
604           }
605       }
606       break;
607
608     case TYPE_CODE_ARRAY:
609       generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
610                          TYPE_INDEX_TYPE (type), sym);
611       generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
612                          TYPE_TARGET_TYPE (type), sym);
613       break;
614
615     case TYPE_CODE_UNION:
616     case TYPE_CODE_STRUCT:
617       {
618         int i;
619
620         for (i = 0; i < TYPE_NFIELDS (type); ++i)
621           if (!field_is_static (&TYPE_FIELD (type, i)))
622             generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
623                                TYPE_FIELD_TYPE (type, i), sym);
624       }
625       break;
626     }
627 }
628
629 /* Generate C code to compute the address of SYM.  */
630
631 static void
632 generate_c_for_for_one_variable (struct compile_c_instance *compiler,
633                                  string_file &stream,
634                                  struct gdbarch *gdbarch,
635                                  unsigned char *registers_used,
636                                  CORE_ADDR pc,
637                                  struct symbol *sym)
638 {
639
640   TRY
641     {
642       if (is_dynamic_type (SYMBOL_TYPE (sym)))
643         {
644           /* We need to emit to a temporary buffer in case an error
645              occurs in the middle.  */
646           string_file local_file;
647
648           generate_vla_size (compiler, local_file, gdbarch, registers_used, pc,
649                              SYMBOL_TYPE (sym), sym);
650
651           stream.write (local_file.c_str (), local_file.size ());
652         }
653
654       if (SYMBOL_COMPUTED_OPS (sym) != NULL)
655         {
656           gdb::unique_xmalloc_ptr<char> generated_name
657             = c_symbol_substitution_name (sym);
658           /* We need to emit to a temporary buffer in case an error
659              occurs in the middle.  */
660           string_file local_file;
661
662           SYMBOL_COMPUTED_OPS (sym)->generate_c_location (sym, local_file,
663                                                           gdbarch,
664                                                           registers_used,
665                                                           pc,
666                                                           generated_name.get ());
667           stream.write (local_file.c_str (), local_file.size ());
668         }
669       else
670         {
671           switch (SYMBOL_CLASS (sym))
672             {
673             case LOC_REGISTER:
674             case LOC_ARG:
675             case LOC_REF_ARG:
676             case LOC_REGPARM_ADDR:
677             case LOC_LOCAL:
678               error (_("Local symbol unhandled when generating C code."));
679
680             case LOC_COMPUTED:
681               gdb_assert_not_reached (_("LOC_COMPUTED variable "
682                                         "missing a method."));
683
684             default:
685               /* Nothing to do for all other cases, as they don't represent
686                  local variables.  */
687               break;
688             }
689         }
690     }
691
692   CATCH (e, RETURN_MASK_ERROR)
693     {
694       if (compiler->symbol_err_map == NULL)
695         compiler->symbol_err_map = htab_create_alloc (10,
696                                                       hash_symbol_error,
697                                                       eq_symbol_error,
698                                                       del_symbol_error,
699                                                       xcalloc,
700                                                       xfree);
701       insert_symbol_error (compiler->symbol_err_map, sym, e.message);
702     }
703   END_CATCH
704 }
705
706 /* See compile-c.h.  */
707
708 gdb::unique_xmalloc_ptr<unsigned char>
709 generate_c_for_variable_locations (struct compile_c_instance *compiler,
710                                    string_file &stream,
711                                    struct gdbarch *gdbarch,
712                                    const struct block *block,
713                                    CORE_ADDR pc)
714 {
715   const struct block *static_block = block_static_block (block);
716
717   /* If we're already in the static or global block, there is nothing
718      to write.  */
719   if (static_block == NULL || block == static_block)
720     return NULL;
721
722   gdb::unique_xmalloc_ptr<unsigned char> registers_used
723     (XCNEWVEC (unsigned char, gdbarch_num_regs (gdbarch)));
724
725   /* Ensure that a given name is only entered once.  This reflects the
726      reality of shadowing.  */
727   htab_up symhash (htab_create_alloc (1, hash_symname, eq_symname, NULL,
728                                       xcalloc, xfree));
729
730   while (1)
731     {
732       struct symbol *sym;
733       struct block_iterator iter;
734
735       /* Iterate over symbols in this block, generating code to
736          compute the location of each local variable.  */
737       for (sym = block_iterator_first (block, &iter);
738            sym != NULL;
739            sym = block_iterator_next (&iter))
740         {
741           if (!symbol_seen (symhash.get (), sym))
742             generate_c_for_for_one_variable (compiler, stream, gdbarch,
743                                              registers_used.get (), pc, sym);
744         }
745
746       /* If we just finished the outermost block of a function, we're
747          done.  */
748       if (BLOCK_FUNCTION (block) != NULL)
749         break;
750       block = BLOCK_SUPERBLOCK (block);
751     }
752
753   return registers_used;
754 }