xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/compile/compile-c.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17f2ac410Schristos /* Header file for GDB compile C-language support.
2*6881a400Schristos    Copyright (C) 2014-2023 Free Software Foundation, Inc.
37f2ac410Schristos 
47f2ac410Schristos    This program is free software; you can redistribute it and/or modify
57f2ac410Schristos    it under the terms of the GNU General Public License as published by
67f2ac410Schristos    the Free Software Foundation; either version 3 of the License, or
77f2ac410Schristos    (at your option) any later version.
87f2ac410Schristos 
97f2ac410Schristos    This program is distributed in the hope that it will be useful,
107f2ac410Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
117f2ac410Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
127f2ac410Schristos    GNU General Public License for more details.
137f2ac410Schristos 
147f2ac410Schristos    You should have received a copy of the GNU General Public License
157f2ac410Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
167f2ac410Schristos 
177f2ac410Schristos #ifndef COMPILE_COMPILE_C_H
187f2ac410Schristos #define COMPILE_COMPILE_C_H
197f2ac410Schristos 
207d62b00eSchristos #include "gdbsupport/enum-flags.h"
217f2ac410Schristos #include "gcc-c-plugin.h"
227f2ac410Schristos 
237f2ac410Schristos /* enum-flags wrapper.  */
247f2ac410Schristos 
257f2ac410Schristos DEF_ENUM_FLAGS_TYPE (enum gcc_qualifiers, gcc_qualifiers_flags);
267f2ac410Schristos 
277f2ac410Schristos /* A callback suitable for use as the GCC C symbol oracle.  */
287f2ac410Schristos 
297f2ac410Schristos extern gcc_c_oracle_function gcc_convert_symbol;
307f2ac410Schristos 
317f2ac410Schristos /* A callback suitable for use as the GCC C address oracle.  */
327f2ac410Schristos 
337f2ac410Schristos extern gcc_c_symbol_address_function gcc_symbol_address;
347f2ac410Schristos 
357f2ac410Schristos /* A subclass of compile_instance that is specific to the C front
367f2ac410Schristos    end.  */
377f2ac410Schristos 
387f2ac410Schristos class compile_c_instance : public compile_instance
397f2ac410Schristos {
407f2ac410Schristos public:
417f2ac410Schristos   explicit compile_c_instance (struct gcc_c_context *gcc_c)
427f2ac410Schristos     : compile_instance (&gcc_c->base, m_default_cflags),
437f2ac410Schristos       m_plugin (gcc_c)
447f2ac410Schristos   {
457f2ac410Schristos     m_plugin.set_callbacks (gcc_convert_symbol, gcc_symbol_address, this);
467f2ac410Schristos   }
477f2ac410Schristos 
487f2ac410Schristos   /* Convert a gdb type, TYPE, to a GCC type.
497f2ac410Schristos 
507f2ac410Schristos      The new GCC type is returned.  */
517f2ac410Schristos   gcc_type convert_type (struct type *type);
527f2ac410Schristos 
537f2ac410Schristos   /* Return a handle for the GCC plug-in.  */
547f2ac410Schristos   gcc_c_plugin &plugin () { return m_plugin; }
557f2ac410Schristos 
567f2ac410Schristos private:
577f2ac410Schristos   /* Default compiler flags for C.  */
587f2ac410Schristos   static const char *m_default_cflags;
597f2ac410Schristos 
607f2ac410Schristos   /* The GCC plug-in.  */
617f2ac410Schristos   gcc_c_plugin m_plugin;
627f2ac410Schristos };
637f2ac410Schristos 
647f2ac410Schristos /* Emit code to compute the address for all the local variables in
657f2ac410Schristos    scope at PC in BLOCK.  Returns a malloc'd vector, indexed by gdb
667f2ac410Schristos    register number, where each element indicates if the corresponding
677f2ac410Schristos    register is needed to compute a local variable.  */
687f2ac410Schristos 
69*6881a400Schristos extern std::vector<bool>
707f2ac410Schristos   generate_c_for_variable_locations
717f2ac410Schristos      (compile_instance *compiler,
727f2ac410Schristos       string_file *stream,
737f2ac410Schristos       struct gdbarch *gdbarch,
747f2ac410Schristos       const struct block *block,
757f2ac410Schristos       CORE_ADDR pc);
767f2ac410Schristos 
777f2ac410Schristos /* Get the GCC mode attribute value for a given type size.  */
787f2ac410Schristos 
797f2ac410Schristos extern const char *c_get_mode_for_size (int size);
807f2ac410Schristos 
817f2ac410Schristos /* Given a dynamic property, return an xmallocd name that is used to
827f2ac410Schristos    represent its size.  The result must be freed by the caller.  The
837f2ac410Schristos    contents of the resulting string will be the same each time for
847f2ac410Schristos    each call with the same argument.  */
857f2ac410Schristos 
867f2ac410Schristos struct dynamic_prop;
877f2ac410Schristos extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
887f2ac410Schristos 
897f2ac410Schristos /* Compute the name of the pointer representing a local symbol's
907f2ac410Schristos    address.  */
917f2ac410Schristos 
927f2ac410Schristos extern gdb::unique_xmalloc_ptr<char>
937f2ac410Schristos   c_symbol_substitution_name (struct symbol *sym);
947f2ac410Schristos 
957f2ac410Schristos #endif /* COMPILE_COMPILE_C_H */
96