/* Header file for GDB compile C-language support.
- Copyright (C) 2014-2018 Free Software Foundation, Inc.
+ Copyright (C) 2014-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define GDB_COMPILE_C_H
#include "common/enum-flags.h"
-#include "hashtab.h"
+#include "gcc-c-plugin.h"
/* enum-flags wrapper. */
/* A subclass of compile_instance that is specific to the C front
end. */
-struct compile_c_instance
+class compile_c_instance : public compile_instance
{
- /* Base class. Note that the base class vtable actually points to a
- gcc_c_fe_vtable. */
- struct compile_instance base;
+public:
+ explicit compile_c_instance (struct gcc_c_context *gcc_c)
+ : compile_instance (&gcc_c->base, m_default_cflags),
+ m_plugin (gcc_c)
+ {
+ m_plugin.set_callbacks (gcc_convert_symbol, gcc_symbol_address, this);
+ }
- /* Map from gdb types to gcc types. */
- htab_t type_map;
+ /* Convert a gdb type, TYPE, to a GCC type.
- /* Map from gdb symbols to gcc error messages to emit. */
- htab_t symbol_err_map;
-};
+ The new GCC type is returned. */
+ gcc_type convert_type (struct type *type);
+
+ /* Return a handle for the GCC plug-in. */
+ gcc_c_plugin &plugin () { return m_plugin; }
-/* A helper macro that takes a compile_c_instance and returns its
- corresponding gcc_c_context. */
+private:
+ /* Default compiler flags for C. */
+ static const char *m_default_cflags;
-#define C_CTX(I) ((struct gcc_c_context *) ((I)->base.fe))
+ /* The GCC plug-in. */
+ gcc_c_plugin m_plugin;
+};
/* Emit code to compute the address for all the local variables in
scope at PC in BLOCK. Returns a malloc'd vector, indexed by gdb
extern gdb::unique_xmalloc_ptr<unsigned char>
generate_c_for_variable_locations
- (struct compile_c_instance *compiler,
- string_file &stream,
+ (compile_instance *compiler,
+ string_file *stream,
struct gdbarch *gdbarch,
const struct block *block,
CORE_ADDR pc);
struct dynamic_prop;
extern std::string c_get_range_decl_name (const struct dynamic_prop *prop);
+/* Compute the name of the pointer representing a local symbol's
+ address. */
+
+extern gdb::unique_xmalloc_ptr<char>
+ c_symbol_substitution_name (struct symbol *sym);
+
#endif /* GDB_COMPILE_C_H */