diff options
Diffstat (limited to 'gdb/compile')
-rw-r--r-- | gdb/compile/compile-c-support.c | 240 | ||||
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 137 | ||||
-rw-r--r-- | gdb/compile/compile-c-types.c | 107 | ||||
-rw-r--r-- | gdb/compile/compile-c.h | 14 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-symbols.c | 98 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-types.c | 467 | ||||
-rw-r--r-- | gdb/compile/compile-cplus.h | 18 | ||||
-rw-r--r-- | gdb/compile/compile-internal.h | 14 | ||||
-rw-r--r-- | gdb/compile/compile-loc2c.c | 219 | ||||
-rw-r--r-- | gdb/compile/compile-object-load.c | 288 | ||||
-rw-r--r-- | gdb/compile/compile-object-load.h | 6 | ||||
-rw-r--r-- | gdb/compile/compile-object-run.c | 22 | ||||
-rw-r--r-- | gdb/compile/compile.c | 182 | ||||
-rw-r--r-- | gdb/compile/compile.h | 59 | ||||
-rw-r--r-- | gdb/compile/gcc-c-plugin.h | 5 |
15 files changed, 869 insertions, 1007 deletions
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index f9b3220..9cd0428 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -53,7 +53,7 @@ c_get_mode_for_size (int size) mode = "DI"; break; default: - internal_error (_("Invalid GCC mode size %d."), size); + internal_error (_ ("Invalid GCC mode size %d."), size); } return mode; @@ -67,12 +67,10 @@ c_get_range_decl_name (const struct dynamic_prop *prop) return string_printf ("__gdb_prop_%s", host_address_to_string (prop)); } - - /* Load the plug-in library FE_LIBCC and return the initialization function FE_CONTEXT. */ -template <typename FUNCTYPE> +template<typename FUNCTYPE> FUNCTYPE * load_libcompile (const char *fe_libcc, const char *fe_context) { @@ -84,7 +82,7 @@ load_libcompile (const char *fe_libcc, const char *fe_context) func = (FUNCTYPE *) gdb_dlsym (handle, fe_context); if (func == NULL) - error (_("could not find symbol %s in library %s"), fe_context, fe_libcc); + error (_ ("could not find symbol %s in library %s"), fe_context, fe_libcc); /* Leave the library open. */ handle.release (); @@ -97,8 +95,8 @@ load_libcompile (const char *fe_libcc, const char *fe_context) base compile plug-in version we support. API_VERSION is the API version supported. */ -template <typename INSTTYPE, typename FUNCTYPE, typename CTXTYPE, - typename BASE_VERSION_TYPE, typename API_VERSION_TYPE> +template<typename INSTTYPE, typename FUNCTYPE, typename CTXTYPE, + typename BASE_VERSION_TYPE, typename API_VERSION_TYPE> std::unique_ptr<compile_instance> get_compile_context (const char *fe_libcc, const char *fe_context, BASE_VERSION_TYPE base_version, @@ -115,8 +113,9 @@ get_compile_context (const char *fe_libcc, const char *fe_context, context = (*func) (base_version, api_version); if (context == NULL) - error (_("The loaded version of GCC does not support the required version " - "of the API.")); + error ( + _ ("The loaded version of GCC does not support the required version " + "of the API.")); return std::unique_ptr<compile_instance> (new INSTTYPE (context)); } @@ -126,11 +125,12 @@ get_compile_context (const char *fe_libcc, const char *fe_context, std::unique_ptr<compile_instance> c_get_compile_context () { - return get_compile_context - <compile_c_instance, gcc_c_fe_context_function, gcc_c_context, - gcc_base_api_version, gcc_c_api_version> - (STRINGIFY (GCC_C_FE_LIBCC), STRINGIFY (GCC_C_FE_CONTEXT), - GCC_FE_VERSION_0, GCC_C_FE_VERSION_0); + return get_compile_context<compile_c_instance, gcc_c_fe_context_function, + gcc_c_context, gcc_base_api_version, + gcc_c_api_version> (STRINGIFY (GCC_C_FE_LIBCC), + STRINGIFY (GCC_C_FE_CONTEXT), + GCC_FE_VERSION_0, + GCC_C_FE_VERSION_0); } /* A C++-language implementation of get_compile_context. */ @@ -138,21 +138,18 @@ c_get_compile_context () std::unique_ptr<compile_instance> cplus_get_compile_context () { - return get_compile_context - <compile_cplus_instance, gcc_cp_fe_context_function, gcc_cp_context, - gcc_base_api_version, gcc_cp_api_version> - (STRINGIFY (GCC_CP_FE_LIBCC), STRINGIFY (GCC_CP_FE_CONTEXT), - GCC_FE_VERSION_0, GCC_CP_FE_VERSION_0); + return get_compile_context<compile_cplus_instance, + gcc_cp_fe_context_function, gcc_cp_context, + gcc_base_api_version, gcc_cp_api_version> ( + STRINGIFY (GCC_CP_FE_LIBCC), STRINGIFY (GCC_CP_FE_CONTEXT), + GCC_FE_VERSION_0, GCC_CP_FE_VERSION_0); } - - /* Write one macro definition. */ static void print_one_macro (const char *name, const struct macro_definition *macro, - struct macro_source_file *source, int line, - ui_file *file) + struct macro_source_file *source, int line, ui_file *file) { /* Don't print command-line defines. They will be supplied another way. */ @@ -200,11 +197,9 @@ write_macro_definitions (const struct block *block, CORE_ADDR pc, macro_for_each_in_scope (scope->file, scope->line, [&] (const char *name, const macro_definition *macro, - macro_source_file *source, - int line) - { - print_one_macro (name, macro, source, line, file); - }); + macro_source_file *source, int line) { + print_one_macro (name, macro, source, line, file); + }); } } @@ -218,8 +213,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, int i; int seen = 0; - gdb_puts ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n", - stream); + gdb_puts ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n", stream); if (!registers_used.empty ()) for (i = 0; i < gdbarch_num_regs (gdbarch); ++i) @@ -245,14 +239,12 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, switch (regtype->code ()) { case TYPE_CODE_PTR: - gdb_printf (stream, "__gdb_uintptr %s", - regname.c_str ()); + gdb_printf (stream, "__gdb_uintptr %s", regname.c_str ()); break; case TYPE_CODE_INT: { - const char *mode - = c_get_mode_for_size (regtype->length ()); + const char *mode = c_get_mode_for_size (regtype->length ()); if (mode != NULL) { @@ -261,8 +253,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, gdb_printf (stream, "int %s" " __attribute__ ((__mode__(__%s__)))", - regname.c_str (), - mode); + regname.c_str (), mode); break; } } @@ -274,16 +265,14 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, " unsigned char %s[%s]" " __attribute__((__aligned__(" "__BIGGEST_ALIGNMENT__)))", - regname.c_str (), - pulongest (regtype->length ())); + regname.c_str (), pulongest (regtype->length ())); } gdb_puts (";\n", stream); } } if (!seen) - gdb_puts (" char " COMPILE_I_SIMPLE_REGISTER_DUMMY ";\n", - stream); + gdb_puts (" char " COMPILE_I_SIMPLE_REGISTER_DUMMY ";\n", stream); gdb_puts ("};\n\n", stream); } @@ -304,8 +293,7 @@ struct c_push_user_expression struct pop_user_expression_nop { void pop_user_expression (struct ui_file *buf) - { - /* Nothing to do. */ + { /* Nothing to do. */ } }; @@ -320,13 +308,9 @@ struct c_add_code_header switch (type) { case COMPILE_I_SIMPLE_SCOPE: - gdb_puts ("void " - GCC_FE_WRAPPER_FUNCTION - " (struct " - COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG - " *" - COMPILE_I_SIMPLE_REGISTER_ARG_NAME - ") {\n", + gdb_puts ("void " GCC_FE_WRAPPER_FUNCTION + " (struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG + " *" COMPILE_I_SIMPLE_REGISTER_ARG_NAME ") {\n", buf); break; @@ -334,16 +318,10 @@ struct c_add_code_header case COMPILE_I_PRINT_VALUE_SCOPE: /* <string.h> is needed for a memcpy call below. */ gdb_puts ("#include <string.h>\n" - "void " - GCC_FE_WRAPPER_FUNCTION - " (struct " - COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG - " *" - COMPILE_I_SIMPLE_REGISTER_ARG_NAME - ", " - COMPILE_I_PRINT_OUT_ARG_TYPE - " " - COMPILE_I_PRINT_OUT_ARG + "void " GCC_FE_WRAPPER_FUNCTION + " (struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG + " *" COMPILE_I_SIMPLE_REGISTER_ARG_NAME + ", " COMPILE_I_PRINT_OUT_ARG_TYPE " " COMPILE_I_PRINT_OUT_ARG ") {\n", buf); break; @@ -396,12 +374,11 @@ struct c_add_input gdb_printf (buf, "__auto_type " COMPILE_I_EXPR_VAL " = %s;\n" "typeof (%s) *" COMPILE_I_EXPR_PTR_TYPE ";\n" - "memcpy (" COMPILE_I_PRINT_OUT_ARG ", %s" - COMPILE_I_EXPR_VAL ",\n" - "sizeof (*" COMPILE_I_EXPR_PTR_TYPE "));\n" - , input, input, - (type == COMPILE_I_PRINT_ADDRESS_SCOPE - ? "&" : "")); + "memcpy (" COMPILE_I_PRINT_OUT_ARG + ", %s" COMPILE_I_EXPR_VAL ",\n" + "sizeof (*" COMPILE_I_EXPR_PTR_TYPE "));\n", + input, input, + (type == COMPILE_I_PRINT_ADDRESS_SCOPE ? "&" : "")); break; default: @@ -441,44 +418,33 @@ struct cplus_add_code_header { void add_code_header (enum compile_i_scope_types type, struct ui_file *buf) { - switch (type) - { - case COMPILE_I_SIMPLE_SCOPE: - gdb_puts ("void " - GCC_FE_WRAPPER_FUNCTION - " (struct " - COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG - " *" - COMPILE_I_SIMPLE_REGISTER_ARG_NAME - ") {\n", - buf); - break; + switch (type) + { + case COMPILE_I_SIMPLE_SCOPE: + gdb_puts ("void " GCC_FE_WRAPPER_FUNCTION + " (struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG + " *" COMPILE_I_SIMPLE_REGISTER_ARG_NAME ") {\n", + buf); + break; - case COMPILE_I_PRINT_ADDRESS_SCOPE: - case COMPILE_I_PRINT_VALUE_SCOPE: - gdb_puts ( - "#include <cstring>\n" - "#include <bits/move.h>\n" - "void " - GCC_FE_WRAPPER_FUNCTION - " (struct " - COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG - " *" - COMPILE_I_SIMPLE_REGISTER_ARG_NAME - ", " - COMPILE_I_PRINT_OUT_ARG_TYPE - " " - COMPILE_I_PRINT_OUT_ARG - ") {\n", - buf); - break; + case COMPILE_I_PRINT_ADDRESS_SCOPE: + case COMPILE_I_PRINT_VALUE_SCOPE: + gdb_puts ("#include <cstring>\n" + "#include <bits/move.h>\n" + "void " GCC_FE_WRAPPER_FUNCTION + " (struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG + " *" COMPILE_I_SIMPLE_REGISTER_ARG_NAME + ", " COMPILE_I_PRINT_OUT_ARG_TYPE " " COMPILE_I_PRINT_OUT_ARG + ") {\n", + buf); + break; - case COMPILE_I_RAW_SCOPE: - break; + case COMPILE_I_RAW_SCOPE: + break; - default: - gdb_assert_not_reached ("Unknown compiler scope reached."); - } + default: + gdb_assert_not_reached ("Unknown compiler scope reached."); + } } }; @@ -494,21 +460,21 @@ struct cplus_add_input { case COMPILE_I_PRINT_VALUE_SCOPE: case COMPILE_I_PRINT_ADDRESS_SCOPE: - gdb_printf - (buf, - /* "auto" strips ref- and cv- qualifiers, so we need to also strip + gdb_printf ( + buf, + /* "auto" strips ref- and cv- qualifiers, so we need to also strip those from COMPILE_I_EXPR_PTR_TYPE. */ - "auto " COMPILE_I_EXPR_VAL " = %s;\n" - "typedef " - "std::add_pointer<std::remove_cv<decltype (%s)>::type>::type " - " __gdb_expr_ptr;\n" - "__gdb_expr_ptr " COMPILE_I_EXPR_PTR_TYPE ";\n" - "std::memcpy (" COMPILE_I_PRINT_OUT_ARG ", %s (" - COMPILE_I_EXPR_VAL "),\n" - "\tsizeof (*" COMPILE_I_EXPR_PTR_TYPE "));\n" - ,input, input, - (type == COMPILE_I_PRINT_ADDRESS_SCOPE - ? "__builtin_addressof" : "")); + "auto " COMPILE_I_EXPR_VAL " = %s;\n" + "typedef " + "std::add_pointer<std::remove_cv<decltype (%s)>::type>::type " + " __gdb_expr_ptr;\n" + "__gdb_expr_ptr " COMPILE_I_EXPR_PTR_TYPE ";\n" + "std::memcpy (" COMPILE_I_PRINT_OUT_ARG ", %s (" COMPILE_I_EXPR_VAL + "),\n" + "\tsizeof (*" COMPILE_I_EXPR_PTR_TYPE "));\n", + input, input, + (type == COMPILE_I_PRINT_ADDRESS_SCOPE ? "__builtin_addressof" + : "")); break; default: @@ -532,20 +498,22 @@ struct cplus_add_input AddInputPolicy adds the actual user code. */ -template <class CompileInstanceType, class PushUserExpressionPolicy, - class PopUserExpressionPolicy, class AddCodeHeaderPolicy, - class AddCodeFooterPolicy, class AddInputPolicy> -class compile_program - : private PushUserExpressionPolicy, private PopUserExpressionPolicy, - private AddCodeHeaderPolicy, private AddCodeFooterPolicy, - private AddInputPolicy +template<class CompileInstanceType, class PushUserExpressionPolicy, + class PopUserExpressionPolicy, class AddCodeHeaderPolicy, + class AddCodeFooterPolicy, class AddInputPolicy> +class compile_program : private PushUserExpressionPolicy, + private PopUserExpressionPolicy, + private AddCodeHeaderPolicy, + private AddCodeFooterPolicy, + private AddInputPolicy { public: /* Construct a compile_program using the compiler instance INST using the architecture given by GDBARCH. */ compile_program (CompileInstanceType *inst, struct gdbarch *gdbarch) - : m_instance (inst), m_arch (gdbarch) + : m_instance (inst), + m_arch (gdbarch) { } @@ -650,23 +618,21 @@ private: /* The types used for C and C++ program computations. */ -typedef compile_program<compile_c_instance, - c_push_user_expression, pop_user_expression_nop, - c_add_code_header, c_add_code_footer, - c_add_input> c_compile_program; +typedef compile_program<compile_c_instance, c_push_user_expression, + pop_user_expression_nop, c_add_code_header, + c_add_code_footer, c_add_input> + c_compile_program; -typedef compile_program<compile_cplus_instance, - cplus_push_user_expression, cplus_pop_user_expression, - cplus_add_code_header, c_add_code_footer, - cplus_add_input> cplus_compile_program; +typedef compile_program<compile_cplus_instance, cplus_push_user_expression, + cplus_pop_user_expression, cplus_add_code_header, + c_add_code_footer, cplus_add_input> + cplus_compile_program; /* The compute_program method for C. */ std::string -c_compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, +c_compute_program (compile_instance *inst, const char *input, + struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc) { compile_c_instance *c_inst = static_cast<compile_c_instance *> (inst); @@ -678,10 +644,8 @@ c_compute_program (compile_instance *inst, /* The compute_program method for C++. */ std::string -cplus_compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, +cplus_compute_program (compile_instance *inst, const char *input, + struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc) { compile_cplus_instance *cplus_inst diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 00ac452..cbf06b9 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "defs.h" #include "compile-internal.h" #include "compile-c.h" @@ -31,16 +30,14 @@ #include "gdbtypes.h" #include "dwarf2/loc.h" - - /* Compute the name of the pointer representing a local symbol's address. */ gdb::unique_xmalloc_ptr<char> c_symbol_substitution_name (struct symbol *sym) { - return gdb::unique_xmalloc_ptr<char> - (concat ("__", sym->natural_name (), "_ptr", (char *) NULL)); + return gdb::unique_xmalloc_ptr<char> (concat ("__", sym->natural_name (), + "_ptr", (char *) NULL)); } /* Convert a given symbol, SYM, to the compiler's representation. @@ -51,10 +48,8 @@ c_symbol_substitution_name (struct symbol *sym) scope.) */ static void -convert_one_symbol (compile_c_instance *context, - struct block_symbol sym, - int is_global, - int is_local) +convert_one_symbol (compile_c_instance *context, struct block_symbol sym, + int is_global, int is_local) { gcc_type sym_type; const char *filename = sym.symbol->symtab ()->filename; @@ -70,8 +65,8 @@ convert_one_symbol (compile_c_instance *context, if (sym.symbol->domain () == STRUCT_DOMAIN) { /* Binding a tag, so we don't need to build a decl. */ - context->plugin ().tagbind (sym.symbol->natural_name (), - sym_type, filename, line); + context->plugin ().tagbind (sym.symbol->natural_name (), sym_type, + filename, line); } else { @@ -104,37 +99,37 @@ convert_one_symbol (compile_c_instance *context, /* Already handled by convert_enum. */ return; } - context->plugin ().build_constant - (sym_type, sym.symbol->natural_name (), - sym.symbol->value_longest (), - filename, line); + context->plugin ().build_constant (sym_type, + sym.symbol->natural_name (), + sym.symbol->value_longest (), + filename, line); return; case LOC_CONST_BYTES: - error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."), + error (_ ("Unsupported LOC_CONST_BYTES for symbol \"%s\"."), sym.symbol->print_name ()); case LOC_UNDEF: - internal_error (_("LOC_UNDEF found for \"%s\"."), + internal_error (_ ("LOC_UNDEF found for \"%s\"."), sym.symbol->print_name ()); case LOC_COMMON_BLOCK: - error (_("Fortran common block is unsupported for compilation " - "evaluaton of symbol \"%s\"."), + error (_ ("Fortran common block is unsupported for compilation " + "evaluaton of symbol \"%s\"."), sym.symbol->print_name ()); case LOC_OPTIMIZED_OUT: - error (_("Symbol \"%s\" cannot be used for compilation evaluation " - "as it is optimized out."), + error (_ ("Symbol \"%s\" cannot be used for compilation evaluation " + "as it is optimized out."), sym.symbol->print_name ()); case LOC_COMPUTED: if (is_local) goto substitution; /* Probably TLS here. */ - warning (_("Symbol \"%s\" is thread-local and currently can only " - "be referenced from the current thread in " - "compiled code."), + warning (_ ("Symbol \"%s\" is thread-local and currently can only " + "be referenced from the current thread in " + "compiled code."), sym.symbol->print_name ()); /* FALLTHROUGH */ case LOC_UNRESOLVED: @@ -150,15 +145,15 @@ convert_one_symbol (compile_c_instance *context, { frame = get_selected_frame (NULL); if (frame == NULL) - error (_("Symbol \"%s\" cannot be used because " - "there is no selected frame"), + error (_ ("Symbol \"%s\" cannot be used because " + "there is no selected frame"), sym.symbol->print_name ()); } val = read_var_value (sym.symbol, sym.block, frame); if (VALUE_LVAL (val) != lval_memory) - error (_("Symbol \"%s\" cannot be used for compilation " - "evaluation as its address has not been found."), + error (_ ("Symbol \"%s\" cannot be used for compilation " + "evaluation as its address has not been found."), sym.symbol->print_name ()); kind = GCC_C_SYMBOL_VARIABLE; @@ -166,7 +161,6 @@ convert_one_symbol (compile_c_instance *context, } break; - case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: @@ -185,19 +179,15 @@ convert_one_symbol (compile_c_instance *context, case LOC_FINAL_VALUE: default: gdb_assert_not_reached ("Unreachable case in convert_one_symbol."); - } /* Don't emit local variable decls for a raw expression. */ - if (context->scope () != COMPILE_I_RAW_SCOPE - || symbol_name == NULL) + if (context->scope () != COMPILE_I_RAW_SCOPE || symbol_name == NULL) { - decl = context->plugin ().build_decl - (sym.symbol->natural_name (), - kind, - sym_type, - symbol_name.get (), addr, - filename, line); + decl + = context->plugin ().build_decl (sym.symbol->natural_name (), kind, + sym_type, symbol_name.get (), + addr, filename, line); context->plugin ().bind (decl, is_global); } @@ -249,8 +239,7 @@ convert_symbol_sym (compile_c_instance *context, const char *identifier, } if (compile_debug) - gdb_printf (gdb_stdlog, - "gcc_convert_symbol \"%s\": local symbol\n", + gdb_printf (gdb_stdlog, "gcc_convert_symbol \"%s\": local symbol\n", identifier); convert_one_symbol (context, sym, 0, is_local_symbol); } @@ -308,22 +297,18 @@ convert_symbol_bmsym (compile_c_instance *context, } sym_type = context->convert_type (type); - decl = context->plugin ().build_decl (msym->natural_name (), - kind, sym_type, NULL, addr, - NULL, 0); + decl = context->plugin ().build_decl (msym->natural_name (), kind, sym_type, + NULL, addr, NULL, 0); context->plugin ().bind (decl, 1 /* is_global */); } /* See compile-internal.h. */ void -gcc_convert_symbol (void *datum, - struct gcc_c_context *gcc_context, - enum gcc_c_oracle_request request, - const char *identifier) +gcc_convert_symbol (void *datum, struct gcc_c_context *gcc_context, + enum gcc_c_oracle_request request, const char *identifier) { - compile_c_instance *context - = static_cast<compile_c_instance *> (datum); + compile_c_instance *context = static_cast<compile_c_instance *> (datum); domain_enum domain; int found = 0; @@ -385,8 +370,7 @@ gcc_address gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, const char *identifier) { - compile_c_instance *context - = static_cast<compile_c_instance *> (datum); + compile_c_instance *context = static_cast<compile_c_instance *> (datum); gcc_address result = 0; int found = 0; @@ -401,8 +385,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, if (sym != NULL && sym->aclass () == LOC_BLOCK) { if (compile_debug) - gdb_printf (gdb_stdlog, - "gcc_symbol_address \"%s\": full symbol\n", + gdb_printf (gdb_stdlog, "gcc_symbol_address \"%s\": full symbol\n", identifier); result = sym->value_block ()->entry_pc (); if (sym->type ()->is_gnu_ifunc ()) @@ -435,14 +418,10 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, } if (compile_debug && !found) - gdb_printf (gdb_stdlog, - "gcc_symbol_address \"%s\": failed\n", - identifier); + gdb_printf (gdb_stdlog, "gcc_symbol_address \"%s\": failed\n", identifier); return result; } - - /* A hash function for symbol names. */ static hashval_t @@ -484,13 +463,9 @@ symbol_seen (htab_t hashtab, struct symbol *sym) /* Generate C code to compute the length of a VLA. */ static void -generate_vla_size (compile_instance *compiler, - string_file *stream, - struct gdbarch *gdbarch, - std::vector<bool> ®isters_used, - CORE_ADDR pc, - struct type *type, - struct symbol *sym) +generate_vla_size (compile_instance *compiler, string_file *stream, + struct gdbarch *gdbarch, std::vector<bool> ®isters_used, + CORE_ADDR pc, struct type *type, struct symbol *sym) { type = check_typedef (type); @@ -507,9 +482,8 @@ generate_vla_size (compile_instance *compiler, const struct dynamic_prop *prop = &type->bounds ()->high; std::string name = c_get_range_decl_name (prop); - dwarf2_compile_property_to_c (stream, name.c_str (), - gdbarch, registers_used, - prop, pc, sym); + dwarf2_compile_property_to_c (stream, name.c_str (), gdbarch, + registers_used, prop, pc, sym); } } break; @@ -539,13 +513,10 @@ generate_vla_size (compile_instance *compiler, static void generate_c_for_for_one_variable (compile_instance *compiler, - string_file *stream, - struct gdbarch *gdbarch, + string_file *stream, struct gdbarch *gdbarch, std::vector<bool> ®isters_used, - CORE_ADDR pc, - struct symbol *sym) + CORE_ADDR pc, struct symbol *sym) { - try { if (is_dynamic_type (sym->type ())) @@ -554,8 +525,8 @@ generate_c_for_for_one_variable (compile_instance *compiler, occurs in the middle. */ string_file local_file; - generate_vla_size (compiler, &local_file, gdbarch, registers_used, pc, - sym->type (), sym); + generate_vla_size (compiler, &local_file, gdbarch, registers_used, + pc, sym->type (), sym); stream->write (local_file.c_str (), local_file.size ()); } @@ -568,11 +539,9 @@ generate_c_for_for_one_variable (compile_instance *compiler, occurs in the middle. */ string_file local_file; - SYMBOL_COMPUTED_OPS (sym)->generate_c_location (sym, &local_file, - gdbarch, - registers_used, - pc, - generated_name.get ()); + SYMBOL_COMPUTED_OPS (sym)->generate_c_location ( + sym, &local_file, gdbarch, registers_used, pc, + generated_name.get ()); stream->write (local_file.c_str (), local_file.size ()); } else @@ -584,7 +553,7 @@ generate_c_for_for_one_variable (compile_instance *compiler, case LOC_REF_ARG: case LOC_REGPARM_ADDR: case LOC_LOCAL: - error (_("Local symbol unhandled when generating C code.")); + error (_ ("Local symbol unhandled when generating C code.")); case LOC_COMPUTED: gdb_assert_not_reached ("LOC_COMPUTED variable " @@ -610,8 +579,7 @@ std::vector<bool> generate_c_for_variable_locations (compile_instance *compiler, string_file *stream, struct gdbarch *gdbarch, - const struct block *block, - CORE_ADDR pc) + const struct block *block, CORE_ADDR pc) { const struct block *static_block = block_static_block (block); @@ -634,8 +602,7 @@ generate_c_for_variable_locations (compile_instance *compiler, /* Iterate over symbols in this block, generating code to compute the location of each local variable. */ - for (sym = block_iterator_first (block, &iter); - sym != NULL; + for (sym = block_iterator_first (block, &iter); sym != NULL; sym = block_iterator_next (&iter)) { if (!symbol_seen (symhash.get (), sym)) diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 68903c2..b6bf0ef 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "defs.h" #include "gdbtypes.h" #include "compile-internal.h" @@ -45,11 +44,11 @@ convert_array (compile_c_instance *context, struct type *type) element_type = context->convert_type (type->target_type ()); if (range->bounds ()->low.kind () != PROP_CONST) - return context->plugin ().error (_("array type with non-constant" - " lower bound is not supported")); + return context->plugin ().error (_ ("array type with non-constant" + " lower bound is not supported")); if (range->bounds ()->low.const_val () != 0) - return context->plugin ().error (_("cannot convert array type with " - "non-zero lower bound to C")); + return context->plugin ().error (_ ("cannot convert array type with " + "non-zero lower bound to C")); if (range->bounds ()->high.kind () == PROP_LOCEXPR || range->bounds ()->high.kind () == PROP_LOCLIST) @@ -57,8 +56,8 @@ convert_array (compile_c_instance *context, struct type *type) gcc_type result; if (type->is_vector ()) - return context->plugin ().error (_("variably-sized vector type" - " is not supported")); + return context->plugin ().error (_ ("variably-sized vector type" + " is not supported")); std::string upper_bound = c_get_range_decl_name (&range->bounds ()->high); @@ -111,10 +110,8 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) field_type = context->convert_type (type->field (i).type ()); if (bitsize == 0) bitsize = 8 * type->field (i).type ()->length (); - context->plugin ().build_add_field (result, - type->field (i).name (), - field_type, - bitsize, + context->plugin ().build_add_field (result, type->field (i).name (), + field_type, bitsize, type->field (i).loc_bitpos ()); } @@ -130,14 +127,14 @@ convert_enum (compile_c_instance *context, struct type *type) gcc_type int_type, result; int i; - int_type = context->plugin ().int_type_v0 (type->is_unsigned (), - type->length ()); + int_type + = context->plugin ().int_type_v0 (type->is_unsigned (), type->length ()); result = context->plugin ().build_enum_type (int_type); for (i = 0; i < type->num_fields (); ++i) { - context->plugin ().build_add_enum_constant - (result, type->field (i).name (), type->field (i).loc_enumval ()); + context->plugin ().build_add_enum_constant ( + result, type->field (i).name (), type->field (i).loc_enumval ()); } context->plugin ().finish_enum_type (result); @@ -168,7 +165,7 @@ convert_func (compile_c_instance *context, struct type *type) target_type = objfile_type (type->objfile_owner ())->builtin_int; else target_type = builtin_type (type->arch_owner ())->builtin_int; - warning (_("function has unknown return type; assuming int")); + warning (_ ("function has unknown return type; assuming int")); } /* This approach means we can't make self-referential function @@ -181,8 +178,8 @@ convert_func (compile_c_instance *context, struct type *type) for (i = 0; i < type->num_fields (); ++i) array.elements[i] = context->convert_type (type->field (i).type ()); - result = context->plugin ().build_function_type (return_type, - &array, is_varargs); + result + = context->plugin ().build_function_type (return_type, &array, is_varargs); return result; } @@ -200,8 +197,7 @@ convert_int (compile_c_instance *context, struct type *type) return context->plugin ().char_type (); } return context->plugin ().int_type (type->is_unsigned (), - type->length (), - type->name ()); + type->length (), type->name ()); } else return context->plugin ().int_type_v0 (type->is_unsigned (), @@ -214,8 +210,7 @@ static gcc_type convert_float (compile_c_instance *context, struct type *type) { if (context->plugin ().version () >= GCC_C_FE_VERSION_1) - return context->plugin ().float_type (type->length (), - type->name ()); + return context->plugin ().float_type (type->length (), type->name ()); else return context->plugin ().float_type_v0 (type->length ()); } @@ -278,9 +273,10 @@ convert_type_basic (compile_c_instance *context, struct type *type) { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if ((type->instance_flags () & (TYPE_INSTANCE_FLAG_CONST - | TYPE_INSTANCE_FLAG_VOLATILE - | TYPE_INSTANCE_FLAG_RESTRICT)) != 0) + if ((type->instance_flags () + & (TYPE_INSTANCE_FLAG_CONST | TYPE_INSTANCE_FLAG_VOLATILE + | TYPE_INSTANCE_FLAG_RESTRICT)) + != 0) return convert_qualified (context, type); switch (type->code ()) @@ -327,22 +323,23 @@ convert_type_basic (compile_c_instance *context, struct type *type) fallback = objfile_type (type->objfile_owner ())->builtin_int; else fallback = builtin_type (type->arch_owner ())->builtin_int; - warning (_("variable has unknown type; assuming int")); + warning (_ ("variable has unknown type; assuming int")); return convert_int (context, fallback); } } - return context->plugin ().error (_("cannot convert gdb type to gcc type")); + return context->plugin ().error (_ ("cannot convert gdb type to gcc type")); } /* Default compile flags for C. */ -const char *compile_c_instance::m_default_cflags = "-std=gnu11" - /* Otherwise the .o file may need +const char *compile_c_instance::m_default_cflags + = "-std=gnu11" + /* Otherwise the .o file may need "_Unwind_Resume" and "__gcc_personality_v0". */ - " -fno-exceptions" - " -Wno-implicit-function-declaration"; + " -fno-exceptions" + " -Wno-implicit-function-declaration"; /* See compile-c.h. */ @@ -362,32 +359,44 @@ compile_c_instance::convert_type (struct type *type) return result; } - - /* C plug-in wrapper. */ -#define FORWARD(OP,...) m_context->c_ops->OP(m_context, ##__VA_ARGS__) -#define GCC_METHOD0(R, N) \ +#define FORWARD(OP, ...) m_context->c_ops->OP (m_context, ##__VA_ARGS__) +#define GCC_METHOD0(R, N) \ R gcc_c_plugin::N () const \ - { return FORWARD (N); } -#define GCC_METHOD1(R, N, A) \ + { \ + return FORWARD (N); \ + } +#define GCC_METHOD1(R, N, A) \ R gcc_c_plugin::N (A a) const \ - { return FORWARD (N, a); } -#define GCC_METHOD2(R, N, A, B) \ + { \ + return FORWARD (N, a); \ + } +#define GCC_METHOD2(R, N, A, B) \ R gcc_c_plugin::N (A a, B b) const \ - { return FORWARD (N, a, b); } -#define GCC_METHOD3(R, N, A, B, C) \ - R gcc_c_plugin::N (A a, B b, C c) const \ - { return FORWARD (N, a, b, c); } -#define GCC_METHOD4(R, N, A, B, C, D) \ + { \ + return FORWARD (N, a, b); \ + } +#define GCC_METHOD3(R, N, A, B, C) \ + R gcc_c_plugin::N (A a, B b, C c) const \ + { \ + return FORWARD (N, a, b, c); \ + } +#define GCC_METHOD4(R, N, A, B, C, D) \ R gcc_c_plugin::N (A a, B b, C c, D d) const \ - { return FORWARD (N, a, b, c, d); } -#define GCC_METHOD5(R, N, A, B, C, D, E) \ + { \ + return FORWARD (N, a, b, c, d); \ + } +#define GCC_METHOD5(R, N, A, B, C, D, E) \ R gcc_c_plugin::N (A a, B b, C c, D d, E e) const \ - { return FORWARD (N, a, b, c, d, e); } -#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ + { \ + return FORWARD (N, a, b, c, d, e); \ + } +#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ R gcc_c_plugin::N (A a, B b, C c, D d, E e, F f, G g) const \ - { return FORWARD (N, a, b, c, d, e, f, g); } + { \ + return FORWARD (N, a, b, c, d, e, f, g); \ + } #include "gcc-c-fe.def" diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h index f047774..8ad80f9 100644 --- a/gdb/compile/compile-c.h +++ b/gdb/compile/compile-c.h @@ -39,6 +39,7 @@ extern gcc_c_symbol_address_function gcc_symbol_address; class compile_c_instance : public compile_instance { public: + explicit compile_c_instance (struct gcc_c_context *gcc_c) : compile_instance (&gcc_c->base, m_default_cflags), m_plugin (gcc_c) @@ -55,6 +56,7 @@ public: gcc_c_plugin &plugin () { return m_plugin; } private: + /* Default compiler flags for C. */ static const char *m_default_cflags; @@ -67,13 +69,9 @@ private: register number, where each element indicates if the corresponding register is needed to compute a local variable. */ -extern std::vector<bool> - generate_c_for_variable_locations - (compile_instance *compiler, - string_file *stream, - struct gdbarch *gdbarch, - const struct block *block, - CORE_ADDR pc); +extern std::vector<bool> generate_c_for_variable_locations ( + compile_instance *compiler, string_file *stream, struct gdbarch *gdbarch, + const struct block *block, CORE_ADDR pc); /* Get the GCC mode attribute value for a given type size. */ @@ -91,6 +89,6 @@ extern std::string c_get_range_decl_name (const struct dynamic_prop *prop); address. */ extern gdb::unique_xmalloc_ptr<char> - c_symbol_substitution_name (struct symbol *sym); +c_symbol_substitution_name (struct symbol *sym); #endif /* COMPILE_COMPILE_C_H */ diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 2df68b7..b440ada 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "defs.h" #include "compile-internal.h" #include "compile-cplus.h" @@ -43,8 +42,8 @@ scope.) */ static void -convert_one_symbol (compile_cplus_instance *instance, - struct block_symbol sym, bool is_global, bool is_local) +convert_one_symbol (compile_cplus_instance *instance, struct block_symbol sym, + bool is_global, bool is_local) { /* Squash compiler warning. */ gcc_type sym_type = 0; @@ -75,7 +74,7 @@ convert_one_symbol (compile_cplus_instance *instance, case LOC_TYPEDEF: if (sym.symbol->type ()->code () == TYPE_CODE_TYPEDEF) kind = GCC_CP_SYMBOL_TYPEDEF; - else if (sym.symbol->type ()->code () == TYPE_CODE_NAMESPACE) + else if (sym.symbol->type ()->code () == TYPE_CODE_NAMESPACE) return; break; @@ -87,7 +86,7 @@ convert_one_symbol (compile_cplus_instance *instance, case LOC_BLOCK: { kind = GCC_CP_SYMBOL_FUNCTION; - addr = sym.symbol->value_block()->start (); + addr = sym.symbol->value_block ()->start (); if (is_global && sym.symbol->type ()->is_gnu_ifunc ()) addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr); } @@ -99,36 +98,37 @@ convert_one_symbol (compile_cplus_instance *instance, /* Already handled by convert_enum. */ return; } - instance->plugin ().build_constant - (sym_type, sym.symbol->natural_name (), - sym.symbol->value_longest (), filename, line); + instance->plugin ().build_constant (sym_type, + sym.symbol->natural_name (), + sym.symbol->value_longest (), + filename, line); return; case LOC_CONST_BYTES: - error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."), + error (_ ("Unsupported LOC_CONST_BYTES for symbol \"%s\"."), sym.symbol->print_name ()); case LOC_UNDEF: - internal_error (_("LOC_UNDEF found for \"%s\"."), + internal_error (_ ("LOC_UNDEF found for \"%s\"."), sym.symbol->print_name ()); case LOC_COMMON_BLOCK: - error (_("Fortran common block is unsupported for compilation " - "evaluaton of symbol \"%s\"."), + error (_ ("Fortran common block is unsupported for compilation " + "evaluaton of symbol \"%s\"."), sym.symbol->print_name ()); case LOC_OPTIMIZED_OUT: - error (_("Symbol \"%s\" cannot be used for compilation evaluation " - "as it is optimized out."), + error (_ ("Symbol \"%s\" cannot be used for compilation evaluation " + "as it is optimized out."), sym.symbol->print_name ()); case LOC_COMPUTED: if (is_local) goto substitution; /* Probably TLS here. */ - warning (_("Symbol \"%s\" is thread-local and currently can only " - "be referenced from the current thread in " - "compiled code."), + warning (_ ("Symbol \"%s\" is thread-local and currently can only " + "be referenced from the current thread in " + "compiled code."), sym.symbol->print_name ()); /* FALLTHROUGH */ case LOC_UNRESOLVED: @@ -144,15 +144,15 @@ convert_one_symbol (compile_cplus_instance *instance, { frame = get_selected_frame (nullptr); if (frame == nullptr) - error (_("Symbol \"%s\" cannot be used because " - "there is no selected frame"), + error (_ ("Symbol \"%s\" cannot be used because " + "there is no selected frame"), sym.symbol->print_name ()); } val = read_var_value (sym.symbol, sym.block, frame); if (VALUE_LVAL (val) != lval_memory) - error (_("Symbol \"%s\" cannot be used for compilation " - "evaluation as its address has not been found."), + error (_ ("Symbol \"%s\" cannot be used for compilation " + "evaluation as its address has not been found."), sym.symbol->print_name ()); kind = GCC_CP_SYMBOL_VARIABLE; @@ -160,7 +160,6 @@ convert_one_symbol (compile_cplus_instance *instance, } break; - case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: @@ -203,13 +202,15 @@ convert_one_symbol (compile_cplus_instance *instance, /* Get the `raw' name of the symbol. */ if (name.empty () && sym.symbol->natural_name () != nullptr) - name = compile_cplus_instance::decl_name - (sym.symbol->natural_name ()).get (); + name + = compile_cplus_instance::decl_name (sym.symbol->natural_name ()) + .get (); /* Define the decl. */ - instance->plugin ().build_decl - ("variable", name.c_str (), kind.raw (), sym_type, - symbol_name.get (), addr, filename, line); + instance->plugin ().build_decl ("variable", name.c_str (), + kind.raw (), sym_type, + symbol_name.get (), addr, filename, + line); /* Pop scope for non-local symbols. */ if (!is_local) @@ -223,9 +224,8 @@ convert_one_symbol (compile_cplus_instance *instance, itself, and DOMAIN is the domain which was searched. */ static void -convert_symbol_sym (compile_cplus_instance *instance, - const char *identifier, struct block_symbol sym, - domain_enum domain) +convert_symbol_sym (compile_cplus_instance *instance, const char *identifier, + struct block_symbol sym, domain_enum domain) { /* If we found a symbol and it is not in the static or global scope, then we should first convert any static or global scope @@ -241,7 +241,8 @@ convert_symbol_sym (compile_cplus_instance *instance, const struct block *static_block = block_static_block (sym.block); /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */ - bool is_local_symbol = (sym.block != static_block && static_block != nullptr); + bool is_local_symbol + = (sym.block != static_block && static_block != nullptr); if (is_local_symbol) { struct block_symbol global_sym; @@ -261,8 +262,7 @@ convert_symbol_sym (compile_cplus_instance *instance, } if (compile_debug) - gdb_printf (gdb_stdlog, - "gcc_convert_symbol \"%s\": local symbol\n", + gdb_printf (gdb_stdlog, "gcc_convert_symbol \"%s\": local symbol\n", identifier); convert_one_symbol (instance, sym, false, is_local_symbol); } @@ -322,23 +322,20 @@ convert_symbol_bmsym (compile_cplus_instance *instance, sym_type = instance->convert_type (type); instance->plugin ().push_namespace (""); - instance->plugin ().build_decl - ("minsym", msym->natural_name (), kind.raw (), sym_type, nullptr, addr, - nullptr, 0); + instance->plugin ().build_decl ("minsym", msym->natural_name (), kind.raw (), + sym_type, nullptr, addr, nullptr, 0); instance->plugin ().pop_binding_level (""); } /* See compile-cplus.h. */ void -gcc_cplus_convert_symbol (void *datum, - struct gcc_cp_context *gcc_context, +gcc_cplus_convert_symbol (void *datum, struct gcc_cp_context *gcc_context, enum gcc_cp_oracle_request request, const char *identifier) { if (compile_debug) - gdb_printf (gdb_stdlog, - "got oracle request for \"%s\"\n", identifier); + gdb_printf (gdb_stdlog, "got oracle request for \"%s\"\n", identifier); bool found = false; compile_cplus_instance *instance = (compile_cplus_instance *) datum; @@ -363,8 +360,8 @@ gcc_cplus_convert_symbol (void *datum, all non-variable symbols for which we have debug info. */ symbol_searcher searcher; - searcher.find_all_symbols (identifier, current_language, - ALL_DOMAIN, nullptr, nullptr); + searcher.find_all_symbols (identifier, current_language, ALL_DOMAIN, + nullptr, nullptr); /* Convert any found symbols. */ for (const auto &it : searcher.matching_symbols ()) @@ -406,8 +403,7 @@ gcc_cplus_convert_symbol (void *datum, gdb_printf (gdb_stdlog, "found type for %s\n", identifier); else { - gdb_printf (gdb_stdlog, "did not find type for %s\n", - identifier); + gdb_printf (gdb_stdlog, "did not find type for %s\n", identifier); } } @@ -425,8 +421,8 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, int found = 0; if (compile_debug) - gdb_printf (gdb_stdlog, - "got oracle request for address of %s\n", identifier); + gdb_printf (gdb_stdlog, "got oracle request for address of %s\n", + identifier); /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ @@ -438,8 +434,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, if (sym != nullptr && sym->aclass () == LOC_BLOCK) { if (compile_debug) - gdb_printf (gdb_stdlog, - "gcc_symbol_address \"%s\": full symbol\n", + gdb_printf (gdb_stdlog, "gcc_symbol_address \"%s\": full symbol\n", identifier); result = sym->value_block ()->start (); if (sym->type ()->is_gnu_ifunc ()) @@ -472,17 +467,14 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, } if (compile_debug && !found) - gdb_printf (gdb_stdlog, - "gcc_symbol_address \"%s\": failed\n", - identifier); + gdb_printf (gdb_stdlog, "gcc_symbol_address \"%s\": failed\n", identifier); if (compile_debug) { if (found) gdb_printf (gdb_stdlog, "found address for %s!\n", identifier); else - gdb_printf (gdb_stdlog, - "did not find address for %s\n", identifier); + gdb_printf (gdb_stdlog, "did not find address for %s\n", identifier); } return result; diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 5566115..670e182 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "defs.h" #include "gdbsupport/preprocessor.h" #include "gdbtypes.h" @@ -109,11 +108,11 @@ get_method_access_flag (const struct type *type, int fni, int num) static void __attribute__ ((used)) debug_print_scope (const compile_scope &scope) { - for (const auto &comp: scope) + for (const auto &comp : scope) { const char *symbol = (comp.bsymbol.symbol != nullptr - ? comp.bsymbol.symbol->natural_name () - : "<none>"); + ? comp.bsymbol.symbol->natural_name () + : "<none>"); printf_unfiltered ("\tname = %s, symbol = %s\n", comp.name.c_str (), symbol); @@ -157,7 +156,7 @@ type_name_to_scope (const char *type_name, const struct block *block) if (bsymbol.symbol != nullptr) { - scope_component comp = {s, bsymbol}; + scope_component comp = { s, bsymbol }; scope.push_back (comp); @@ -178,7 +177,7 @@ type_name_to_scope (const char *type_name, const struct block *block) /* This shouldn't happen since we are not attempting to loop over user input. This name is generated by GDB from debug info. */ - internal_error (_("malformed TYPE_NAME during parsing")); + internal_error (_ ("malformed TYPE_NAME during parsing")); } } } @@ -266,25 +265,24 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope) /* Push all other namespaces. Note that we do not push the last scope_component -- that's the actual type we are converting. */ - std::for_each - (m_scopes.back ().begin (), m_scopes.back ().end () - 1, - [this] (const scope_component &comp) - { - gdb_assert (comp.bsymbol.symbol->type ()->code () - == TYPE_CODE_NAMESPACE); - - const char *ns = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr - : comp.name.c_str ()); - - this->plugin ().push_namespace (ns); - }); + std::for_each (m_scopes.back ().begin (), m_scopes.back ().end () - 1, + [this] (const scope_component &comp) { + gdb_assert (comp.bsymbol.symbol->type ()->code () + == TYPE_CODE_NAMESPACE); + + const char *ns + = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr + : comp.name.c_str ()); + + this->plugin ().push_namespace (ns); + }); } else { if (debug_compile_cplus_scopes) { gdb_printf (gdb_stdlog, "staying in current scope -- " - "scopes are identical\n"); + "scopes are identical\n"); } } } @@ -309,13 +307,12 @@ compile_cplus_instance::leave_scope () } /* Pop namespaces. */ - std::for_each - (current.begin (),current.end () - 1, - [this] (const scope_component &comp) { - gdb_assert (comp.bsymbol.symbol->type ()->code () - == TYPE_CODE_NAMESPACE); - this->plugin ().pop_binding_level (comp.name.c_str ()); - }); + std::for_each (current.begin (), current.end () - 1, + [this] (const scope_component &comp) { + gdb_assert (comp.bsymbol.symbol->type ()->code () + == TYPE_CODE_NAMESPACE); + this->plugin ().pop_binding_level (comp.name.c_str ()); + }); /* Pop global namespace. */ plugin ().pop_binding_level (""); @@ -323,8 +320,7 @@ compile_cplus_instance::leave_scope () else { if (debug_compile_cplus_scopes) - gdb_printf (gdb_stdlog, - "identical scopes -- not leaving scope\n"); + gdb_printf (gdb_stdlog, "identical scopes -- not leaving scope\n"); } } @@ -381,10 +377,8 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type) else { scope_component comp - = { - decl_name (type->name ()).get (), - lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr) - }; + = { decl_name (type->name ()).get (), + lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr) }; scope.push_back (comp); } } @@ -397,8 +391,8 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type) /* See description in compile-cplus.h. */ gcc_type -compile_cplus_instance::convert_reference_base - (gcc_type base, enum gcc_cp_ref_qualifiers rquals) +compile_cplus_instance::convert_reference_base ( + gcc_type base, enum gcc_cp_ref_qualifiers rquals) { return this->plugin ().build_reference_type (base, rquals); } @@ -430,7 +424,7 @@ compile_cplus_convert_reference (compile_cplus_instance *instance, /* See description in compile-cplus.h. */ gcc_type -compile_cplus_instance::convert_pointer_base(gcc_type target) +compile_cplus_instance::convert_pointer_base (gcc_type target) { return plugin ().build_pointer_type (target); } @@ -457,16 +451,16 @@ compile_cplus_convert_array (compile_cplus_instance *instance, if (range->bounds ()->low.kind () != PROP_CONST) { - const char *s = _("array type with non-constant" - " lower bound is not supported"); + const char *s = _ ("array type with non-constant" + " lower bound is not supported"); return instance->plugin ().error (s); } if (range->bounds ()->low.const_val () != 0) { - const char *s = _("cannot convert array type with " - "non-zero lower bound to C"); + const char *s = _ ("cannot convert array type with " + "non-zero lower bound to C"); return instance->plugin ().error (s); } @@ -476,7 +470,7 @@ compile_cplus_convert_array (compile_cplus_instance *instance, { if (type->is_vector ()) { - const char *s = _("variably-sized vector type is not supported"); + const char *s = _ ("variably-sized vector type is not supported"); return instance->plugin ().error (s); } @@ -484,7 +478,7 @@ compile_cplus_convert_array (compile_cplus_instance *instance, std::string upper_bound = c_get_range_decl_name (&range->bounds ()->high); return instance->plugin ().build_vla_array_type (element_type, - upper_bound.c_str ()); + upper_bound.c_str ()); } else { @@ -530,7 +524,7 @@ compile_cplus_convert_typedef (compile_cplus_instance *instance, instance->plugin ().build_decl ("typedef", name.get (), GCC_CP_SYMBOL_TYPEDEF | nested_access, - typedef_type, 0, 0, nullptr, 0); + typedef_type, 0, 0, nullptr, 0); /* Completed this scope. */ instance->leave_scope (); @@ -555,7 +549,8 @@ compile_cplus_convert_type_defns (compile_cplus_instance *instance, accessibility = GCC_CP_ACCESS_PRIVATE; else accessibility = GCC_CP_ACCESS_PUBLIC; - instance->convert_type (TYPE_TYPEDEF_FIELD_TYPE (type, i), accessibility); + instance->convert_type (TYPE_TYPEDEF_FIELD_TYPE (type, i), + accessibility); } /* Convert nested types. */ @@ -576,23 +571,21 @@ compile_cplus_convert_type_defns (compile_cplus_instance *instance, with gcc_type COMP_TYPE. */ static void -compile_cplus_convert_struct_or_union_members - (compile_cplus_instance *instance, struct type *type, gcc_type comp_type) +compile_cplus_convert_struct_or_union_members ( + compile_cplus_instance *instance, struct type *type, gcc_type comp_type) { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i) { const char *field_name = type->field (i).name (); - if (TYPE_FIELD_IGNORE (type, i) - || TYPE_FIELD_ARTIFICIAL (type, i)) + if (TYPE_FIELD_IGNORE (type, i) || TYPE_FIELD_ARTIFICIAL (type, i)) continue; /* GDB records unnamed/anonymous fields with empty string names. */ if (*field_name == '\0') field_name = nullptr; - gcc_type field_type - = instance->convert_type (type->field (i).type ()); + gcc_type field_type = instance->convert_type (type->field (i).type ()); if (field_is_static (&type->field (i))) { @@ -604,10 +597,10 @@ compile_cplus_convert_struct_or_union_members { physaddr = type->field (i).loc_physaddr (); - instance->plugin ().build_decl - ("field physaddr", field_name, - (GCC_CP_SYMBOL_VARIABLE | get_field_access_flag (type, i)), - field_type, nullptr, physaddr, nullptr, 0); + instance->plugin ().build_decl ( + "field physaddr", field_name, + (GCC_CP_SYMBOL_VARIABLE | get_field_access_flag (type, i)), + field_type, nullptr, physaddr, nullptr, 0); } break; @@ -615,8 +608,8 @@ compile_cplus_convert_struct_or_union_members { const char *physname = type->field (i).loc_physname (); struct block_symbol sym - = lookup_symbol (physname, instance->block (), - VAR_DOMAIN, nullptr); + = lookup_symbol (physname, instance->block (), VAR_DOMAIN, + nullptr); if (sym.symbol == nullptr) { @@ -628,30 +621,29 @@ compile_cplus_convert_struct_or_union_members unsigned int line = sym.symbol->line (); physaddr = sym.symbol->value_address (); - instance->plugin ().build_decl - ("field physname", field_name, - (GCC_CP_SYMBOL_VARIABLE| get_field_access_flag (type, i)), - field_type, nullptr, physaddr, filename, line); + instance->plugin ().build_decl ( + "field physname", field_name, + (GCC_CP_SYMBOL_VARIABLE | get_field_access_flag (type, i)), + field_type, nullptr, physaddr, filename, line); } break; default: - gdb_assert_not_reached - ("unexpected static field location kind"); + gdb_assert_not_reached ("unexpected static field location kind"); } } else { unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i); - enum gcc_cp_symbol_kind field_flags = GCC_CP_SYMBOL_FIELD - | get_field_access_flag (type, i); + enum gcc_cp_symbol_kind field_flags + = GCC_CP_SYMBOL_FIELD | get_field_access_flag (type, i); if (bitsize == 0) bitsize = 8 * type->field (i).type ()->length (); - instance->plugin ().build_field - (field_name, field_type, field_flags, bitsize, - type->field (i).loc_bitpos ()); + instance->plugin ().build_field (field_name, field_type, field_flags, + bitsize, + type->field (i).loc_bitpos ()); } } } @@ -665,7 +657,8 @@ compile_cplus_convert_method (compile_cplus_instance *instance, { /* Get the actual function type of the method, the corresponding class's type and corresponding qualifier flags. */ - gcc_type func_type = compile_cplus_convert_func (instance, method_type, true); + gcc_type func_type + = compile_cplus_convert_func (instance, method_type, true); gcc_type class_type = instance->convert_type (parent_type); gcc_cp_qualifiers_flags quals = 0; @@ -679,8 +672,8 @@ compile_cplus_convert_method (compile_cplus_instance *instance, /* Not yet implemented. */ gcc_cp_ref_qualifiers_flags rquals = GCC_CP_REF_QUAL_NONE; - return instance->plugin ().build_method_type - (class_type, func_type, quals.raw (), rquals.raw ()); + return instance->plugin ().build_method_type (class_type, func_type, + quals.raw (), rquals.raw ()); } /* Convert a member or method pointer represented by TYPE. */ @@ -695,20 +688,18 @@ compile_cplus_convert_memberptr (compile_cplus_instance *instance, return GCC_TYPE_NONE; gcc_type class_type = instance->convert_type (containing_class); - gcc_type member_type - = instance->convert_type (type->target_type ()); + gcc_type member_type = instance->convert_type (type->target_type ()); - return instance->plugin ().build_pointer_to_member_type - (class_type, member_type); + return instance->plugin ().build_pointer_to_member_type (class_type, + member_type); } /* Convert all methods defined in TYPE, which should be a class/struct/union with gcc_type CLASS_TYPE. */ static void -compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance, - struct type *type, - gcc_type class_type) +compile_cplus_convert_struct_or_union_methods ( + compile_cplus_instance *instance, struct type *type, gcc_type class_type) { for (int i = 0; i < TYPE_NFN_FIELDS (type); ++i) { @@ -736,16 +727,16 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance, { /* This is beyond hacky, and is really only a workaround for detecting pure virtual methods. */ - method_type = compile_cplus_convert_method - (instance, type, TYPE_FN_FIELD_TYPE (methods, j)); - - instance->plugin ().build_decl - ("pure virtual method", overloaded_name.get (), - (sym_kind - | get_method_access_flag (type, i, j) - | GCC_CP_FLAG_VIRTUAL_FUNCTION - | GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION).raw (), - method_type, nullptr, 0, nullptr, 0); + method_type = compile_cplus_convert_method ( + instance, type, TYPE_FN_FIELD_TYPE (methods, j)); + + instance->plugin ().build_decl ( + "pure virtual method", overloaded_name.get (), + (sym_kind | get_method_access_flag (type, i, j) + | GCC_CP_FLAG_VIRTUAL_FUNCTION + | GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION) + .raw (), + method_type, nullptr, 0, nullptr, 0); continue; } @@ -757,37 +748,39 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance, In this case, all we can hope to do is issue a warning to the user letting him know. If the user has not actually requested using this method, things should still work. */ - warning (_("Method %s appears to be optimized out.\n" - "All references to this method will be undefined."), - TYPE_FN_FIELD_PHYSNAME (methods, j)); + warning (_ ("Method %s appears to be optimized out.\n" + "All references to this method will be undefined."), + TYPE_FN_FIELD_PHYSNAME (methods, j)); continue; } const char *filename = sym.symbol->symtab ()->filename; unsigned int line = sym.symbol->line (); - CORE_ADDR address = sym.symbol->value_block()->start (); + CORE_ADDR address = sym.symbol->value_block ()->start (); const char *kind; if (TYPE_FN_FIELD_STATIC_P (methods, j)) { kind = "static method"; - method_type = compile_cplus_convert_func - (instance, TYPE_FN_FIELD_TYPE (methods, j), true); + method_type + = compile_cplus_convert_func (instance, + TYPE_FN_FIELD_TYPE (methods, j), + true); } else { kind = "method"; - method_type = (compile_cplus_convert_method - (instance, type, TYPE_FN_FIELD_TYPE (methods, j))); + method_type = (compile_cplus_convert_method ( + instance, type, TYPE_FN_FIELD_TYPE (methods, j))); } if (TYPE_FN_FIELD_VIRTUAL_P (methods, j)) sym_kind |= GCC_CP_FLAG_VIRTUAL_FUNCTION; - instance->plugin ().build_decl - (kind, overloaded_name.get (), - (sym_kind | get_method_access_flag (type, i, j)).raw (), - method_type, nullptr, address, filename, line); + instance->plugin ().build_decl ( + kind, overloaded_name.get (), + (sym_kind | get_method_access_flag (type, i, j)).raw (), + method_type, nullptr, address, filename, line); } } } @@ -829,19 +822,20 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, { const char *what = type->is_declared_class () ? "class" : "struct"; - resuld = instance->plugin ().build_decl - (what, name.get (), (GCC_CP_SYMBOL_CLASS | nested_access - | (type->is_declared_class () - ? GCC_CP_FLAG_CLASS_NOFLAG - : GCC_CP_FLAG_CLASS_IS_STRUCT)), - 0, nullptr, 0, filename, line); + resuld = instance->plugin ().build_decl ( + what, name.get (), + (GCC_CP_SYMBOL_CLASS | nested_access + | (type->is_declared_class () ? GCC_CP_FLAG_CLASS_NOFLAG + : GCC_CP_FLAG_CLASS_IS_STRUCT)), + 0, nullptr, 0, filename, line); } else { gdb_assert (type->code () == TYPE_CODE_UNION); - resuld = instance->plugin ().build_decl - ("union", name.get (), GCC_CP_SYMBOL_UNION | nested_access, - 0, nullptr, 0, filename, line); + resuld + = instance->plugin ().build_decl ("union", name.get (), + GCC_CP_SYMBOL_UNION | nested_access, + 0, nullptr, 0, filename, line); } gcc_type result; @@ -851,7 +845,10 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, std::vector<gcc_type> elements (num_baseclasses); std::vector<enum gcc_cp_symbol_kind> flags (num_baseclasses); - struct gcc_vbase_array bases {}; + struct gcc_vbase_array bases + { + }; + bases.elements = elements.data (); bases.flags = flags.data (); bases.n_elements = num_baseclasses; @@ -860,22 +857,22 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, { struct type *base_type = TYPE_BASECLASS (type, i); - bases.flags[i] = (GCC_CP_SYMBOL_BASECLASS - | get_field_access_flag (type, i) - | (BASETYPE_VIA_VIRTUAL (type, i) - ? GCC_CP_FLAG_BASECLASS_VIRTUAL - : GCC_CP_FLAG_BASECLASS_NOFLAG)); + bases.flags[i] + = (GCC_CP_SYMBOL_BASECLASS | get_field_access_flag (type, i) + | (BASETYPE_VIA_VIRTUAL (type, i) + ? GCC_CP_FLAG_BASECLASS_VIRTUAL + : GCC_CP_FLAG_BASECLASS_NOFLAG)); bases.elements[i] = instance->convert_type (base_type); } - result = instance->plugin ().start_class_type - (name.get (), resuld, &bases, filename, line); + result = instance->plugin ().start_class_type (name.get (), resuld, + &bases, filename, line); } else { gdb_assert (type->code () == TYPE_CODE_UNION); - result = instance->plugin ().start_class_type - (name.get (), resuld, nullptr, filename, line); + result = instance->plugin ().start_class_type (name.get (), resuld, + nullptr, filename, line); } instance->insert_type (type, result); @@ -902,7 +899,8 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, accessibility of this type.*/ static gcc_type -compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type, +compile_cplus_convert_enum (compile_cplus_instance *instance, + struct type *type, enum gcc_cp_symbol_kind nested_access) { bool scoped_enum_p = false; @@ -924,15 +922,13 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type, instance->enter_scope (std::move (scope)); gcc_type int_type - = instance->plugin ().get_int_type (type->is_unsigned (), - type->length (), nullptr); - gcc_type result - = instance->plugin ().start_enum_type (name.get (), int_type, - GCC_CP_SYMBOL_ENUM | nested_access - | (scoped_enum_p - ? GCC_CP_FLAG_ENUM_SCOPED - : GCC_CP_FLAG_ENUM_NOFLAG), - nullptr, 0); + = instance->plugin ().get_int_type (type->is_unsigned (), type->length (), + nullptr); + gcc_type result = instance->plugin ().start_enum_type ( + name.get (), int_type, + GCC_CP_SYMBOL_ENUM | nested_access + | (scoped_enum_p ? GCC_CP_FLAG_ENUM_SCOPED : GCC_CP_FLAG_ENUM_NOFLAG), + nullptr, 0); for (int i = 0; i < type->num_fields (); ++i) { gdb::unique_xmalloc_ptr<char> fname @@ -973,7 +969,7 @@ compile_cplus_convert_func (compile_cplus_instance *instance, target_type = objfile_type (type->objfile_owner ())->builtin_int; else target_type = builtin_type (type->arch_owner ())->builtin_int; - warning (_("function has unknown return type; assuming int")); + warning (_ ("function has unknown return type; assuming int")); } /* This approach means we can't make self-referential function @@ -999,8 +995,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance, /* We omit setting the argument types to `void' to be a little flexible with some minsyms like printf (compile-cplus.exp has examples). */ - gcc_type result = instance->plugin ().build_function_type - (return_type, &array, is_varargs); + gcc_type result + = instance->plugin ().build_function_type (return_type, &array, + is_varargs); return result; } @@ -1015,8 +1012,8 @@ compile_cplus_convert_int (compile_cplus_instance *instance, struct type *type) return instance->plugin ().get_char_type (); } - return instance->plugin ().get_int_type - (type->is_unsigned (), type->length (), type->name ()); + return instance->plugin ().get_int_type (type->is_unsigned (), + type->length (), type->name ()); } /* Convert a floating-point type to its gcc representation. */ @@ -1025,14 +1022,14 @@ static gcc_type compile_cplus_convert_float (compile_cplus_instance *instance, struct type *type) { - return instance->plugin ().get_float_type - (type->length (), type->name ()); + return instance->plugin ().get_float_type (type->length (), type->name ()); } /* Convert the 'void' type to its gcc representation. */ static gcc_type -compile_cplus_convert_void (compile_cplus_instance *instance, struct type *type) +compile_cplus_convert_void (compile_cplus_instance *instance, + struct type *type) { return instance->plugin ().get_void_type (); } @@ -1040,7 +1037,8 @@ compile_cplus_convert_void (compile_cplus_instance *instance, struct type *type) /* Convert a boolean type to its gcc representation. */ static gcc_type -compile_cplus_convert_bool (compile_cplus_instance *instance, struct type *type) +compile_cplus_convert_bool (compile_cplus_instance *instance, + struct type *type) { return instance->plugin ().get_bool_type (); } @@ -1123,15 +1121,15 @@ compile_cplus_convert_namespace (compile_cplus_instance *instance, accessibility of this type. */ static gcc_type -convert_type_cplus_basic (compile_cplus_instance *instance, - struct type *type, +convert_type_cplus_basic (compile_cplus_instance *instance, struct type *type, enum gcc_cp_symbol_kind nested_access) { /* If we are converting a qualified type, first convert the unqualified type and then apply the qualifiers. */ - if ((type->instance_flags () & (TYPE_INSTANCE_FLAG_CONST - | TYPE_INSTANCE_FLAG_VOLATILE - | TYPE_INSTANCE_FLAG_RESTRICT)) != 0) + if ((type->instance_flags () + & (TYPE_INSTANCE_FLAG_CONST | TYPE_INSTANCE_FLAG_VOLATILE + | TYPE_INSTANCE_FLAG_RESTRICT)) + != 0) return compile_cplus_convert_qualified (instance, type); switch (type->code ()) @@ -1148,8 +1146,8 @@ convert_type_cplus_basic (compile_cplus_instance *instance, case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: - return - compile_cplus_convert_struct_or_union (instance, type, nested_access); + return compile_cplus_convert_struct_or_union (instance, type, + nested_access); case TYPE_CODE_ENUM: return compile_cplus_convert_enum (instance, type, nested_access); @@ -1158,8 +1156,8 @@ convert_type_cplus_basic (compile_cplus_instance *instance, return compile_cplus_convert_func (instance, type, false); case TYPE_CODE_METHOD: - return - compile_cplus_convert_method (instance, TYPE_SELF_TYPE (type), type); + return compile_cplus_convert_method (instance, TYPE_SELF_TYPE (type), + type); case TYPE_CODE_MEMBERPTR: case TYPE_CODE_METHODPTR: @@ -1191,8 +1189,7 @@ convert_type_cplus_basic (compile_cplus_instance *instance, break; } - std::string s = string_printf (_("unhandled TYPE_CODE %d"), - type->code ()); + std::string s = string_printf (_ ("unhandled TYPE_CODE %d"), type->code ()); return instance->plugin ().error (s.c_str ()); } @@ -1215,19 +1212,17 @@ compile_cplus_instance::convert_type (struct type *type, } void -compile_cplus_instance::gcc_cplus_enter_scope - (void *datum, struct gcc_cp_context *gcc_context) +compile_cplus_instance::gcc_cplus_enter_scope ( + void *datum, struct gcc_cp_context *gcc_context) { } void -compile_cplus_instance::gcc_cplus_leave_scope - (void *datum, struct gcc_cp_context *gcc_context) +compile_cplus_instance::gcc_cplus_leave_scope ( + void *datum, struct gcc_cp_context *gcc_context) { } - - /* Plug-in forwards. */ /* C++ plug-in wrapper. */ @@ -1255,13 +1250,13 @@ compile_cplus_debug_output () { } -template <typename T> +template<typename T> static void compile_cplus_debug_output_1 (const T *arg) { } -template <typename T, typename... Targs> +template<typename T, typename... Targs> static void compile_cplus_debug_output (T arg, Targs... Args) { @@ -1270,77 +1265,77 @@ compile_cplus_debug_output (T arg, Targs... Args) compile_cplus_debug_output (Args...); } -#define FORWARD(OP,...) m_context->cp_ops->OP(m_context, ##__VA_ARGS__) -#define OUTPUT_DEBUG_RESULT(R) \ - if (debug_compile_cplus_types) \ - { \ - gdb_puts (": ", gdb_stdlog); \ - compile_cplus_debug_output (R); \ - gdb_putc ('\n', gdb_stdlog); \ - } \ - -#define GCC_METHOD0(R, N) \ - R gcc_cp_plugin::N () const \ - { \ - if (debug_compile_cplus_types) \ +#define FORWARD(OP, ...) m_context->cp_ops->OP (m_context, ##__VA_ARGS__) +#define OUTPUT_DEBUG_RESULT(R) \ + if (debug_compile_cplus_types) \ + { \ + gdb_puts (": ", gdb_stdlog); \ + compile_cplus_debug_output (R); \ + gdb_putc ('\n', gdb_stdlog); \ + } + +#define GCC_METHOD0(R, N) \ + R gcc_cp_plugin::N () const \ + { \ + if (debug_compile_cplus_types) \ compile_cplus_debug_output (STRINGIFY (N)); \ - auto result = FORWARD (N); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ + auto result = FORWARD (N); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD1(R, N, A) \ - R gcc_cp_plugin::N (A a) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a); \ - auto result = FORWARD (N, a); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD1(R, N, A) \ + R gcc_cp_plugin::N (A a) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a); \ + auto result = FORWARD (N, a); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD2(R, N, A, B) \ - R gcc_cp_plugin::N (A a, B b) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a, b); \ - auto result = FORWARD (N, a, b); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD2(R, N, A, B) \ + R gcc_cp_plugin::N (A a, B b) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a, b); \ + auto result = FORWARD (N, a, b); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD3(R, N, A, B, C) \ - R gcc_cp_plugin::N (A a, B b, C c) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a, b, c); \ - auto result = FORWARD (N, a, b, c); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD3(R, N, A, B, C) \ + R gcc_cp_plugin::N (A a, B b, C c) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a, b, c); \ + auto result = FORWARD (N, a, b, c); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD4(R, N, A, B, C, D) \ - R gcc_cp_plugin::N (A a, B b, C c, D d) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a, b, c, d); \ - auto result = FORWARD (N, a, b, c, d); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD4(R, N, A, B, C, D) \ + R gcc_cp_plugin::N (A a, B b, C c, D d) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a, b, c, d); \ + auto result = FORWARD (N, a, b, c, d); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD5(R, N, A, B, C, D, E) \ - R gcc_cp_plugin::N (A a, B b, C c, D d, E e) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e); \ - auto result = FORWARD (N, a, b, c, d, e); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD5(R, N, A, B, C, D, E) \ + R gcc_cp_plugin::N (A a, B b, C c, D d, E e) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e); \ + auto result = FORWARD (N, a, b, c, d, e); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } -#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ - R gcc_cp_plugin::N (A a, B b, C c, D d, E e, F f, G g) const \ - { \ - if (debug_compile_cplus_types) \ - compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e, f, g); \ - auto result = FORWARD (N, a, b, c, d, e, f, g); \ - OUTPUT_DEBUG_RESULT (result); \ - return result; \ +#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ + R gcc_cp_plugin::N (A a, B b, C c, D d, E e, F f, G g) const \ + { \ + if (debug_compile_cplus_types) \ + compile_cplus_debug_output (STRINGIFY (N), a, b, c, d, e, f, g); \ + auto result = FORWARD (N, a, b, c, d, e, f, g); \ + OUTPUT_DEBUG_RESULT (result); \ + return result; \ } #include "gcc-cp-fe.def" @@ -1364,14 +1359,15 @@ gcc_cp_plugin::build_decl (const char *debug_decltype, const char *name, if (debug_compile_cplus_types) gdb_printf (gdb_stdlog, "<%s> ", debug_decltype); - return build_decl (name, sym_kind, sym_type, substitution_name, - address, filename, line_number); + return build_decl (name, sym_kind, sym_type, substitution_name, address, + filename, line_number); } gcc_type gcc_cp_plugin::start_class_type (const char *debug_name, gcc_decl typedecl, const struct gcc_vbase_array *base_classes, - const char *filename, unsigned int line_number) + const char *filename, + unsigned int line_number) { if (debug_compile_cplus_types) gdb_printf (gdb_stdlog, "<%s> ", debug_name); @@ -1399,28 +1395,27 @@ gcc_cp_plugin::pop_binding_level (const char *debug_name) } void _initialize_compile_cplus_types (); + void _initialize_compile_cplus_types () { add_setshow_boolean_cmd ("compile-cplus-types", no_class, - &debug_compile_cplus_types, _("\ -Set debugging of C++ compile type conversion."), _("\ -Show debugging of C++ compile type conversion."), _("\ + &debug_compile_cplus_types, _ ("\ +Set debugging of C++ compile type conversion."), + _ ("\ +Show debugging of C++ compile type conversion."), + _ ("\ When enabled debugging messages are printed during C++ type conversion for\n\ the compile commands."), - nullptr, - nullptr, - &setdebuglist, - &showdebuglist); + nullptr, nullptr, &setdebuglist, &showdebuglist); add_setshow_boolean_cmd ("compile-cplus-scopes", no_class, - &debug_compile_cplus_scopes, _("\ -Set debugging of C++ compile scopes."), _("\ -Show debugging of C++ compile scopes."), _("\ + &debug_compile_cplus_scopes, _ ("\ +Set debugging of C++ compile scopes."), + _ ("\ +Show debugging of C++ compile scopes."), + _ ("\ When enabled debugging messages are printed about definition scopes during\n\ C++ type conversion for the compile commands."), - nullptr, - nullptr, - &setdebuglist, - &showdebuglist); + nullptr, nullptr, &setdebuglist, &showdebuglist); } diff --git a/gdb/compile/compile-cplus.h b/gdb/compile/compile-cplus.h index 91f2e13..5e495a1 100644 --- a/gdb/compile/compile-cplus.h +++ b/gdb/compile/compile-cplus.h @@ -50,7 +50,6 @@ struct scope_component bool operator== (const scope_component &lhs, const scope_component &rhs); bool operator!= (const scope_component &lhs, const scope_component &rhs); - /* A single compiler scope used to define a type. A compile_scope is a list of scope_components, where all leading @@ -71,16 +70,14 @@ public: using std::vector<scope_component>::operator[]; compile_scope () - : m_nested_type (GCC_TYPE_NONE), m_pushed (false) + : m_nested_type (GCC_TYPE_NONE), + m_pushed (false) { } /* Return the gcc_type of the type if it is a nested definition. Returns GCC_TYPE_NONE if this type was not nested. */ - gcc_type nested_type () - { - return m_nested_type; - } + gcc_type nested_type () { return m_nested_type; } private: @@ -131,8 +128,7 @@ public: : compile_instance (&gcc_cp->base, m_default_cflags), m_plugin (gcc_cp) { - m_plugin.set_callbacks (gcc_cplus_convert_symbol, - gcc_cplus_symbol_address, + m_plugin.set_callbacks (gcc_cplus_convert_symbol, gcc_cplus_symbol_address, gcc_cplus_enter_scope, gcc_cplus_leave_scope, this); } @@ -144,9 +140,9 @@ public: type). GCC_CP_ACCESS_NONE is the default nested access. The new GCC type is returned. */ - gcc_type convert_type - (struct type *type, - enum gcc_cp_symbol_kind nested_access = GCC_CP_ACCESS_NONE); + gcc_type convert_type (struct type *type, + enum gcc_cp_symbol_kind nested_access + = GCC_CP_ACCESS_NONE); /* Return a handle for the GCC plug-in. */ gcc_cp_plugin &plugin () { return m_plugin; } diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h index ecf7c11..625f665 100644 --- a/gdb/compile/compile-internal.h +++ b/gdb/compile/compile-internal.h @@ -60,21 +60,23 @@ extern int compile_register_name_demangle (struct gdbarch *gdbarch, class compile_file_names { public: + compile_file_names (std::string source_file, std::string object_file) - : m_source_file (source_file), m_object_file (object_file) - {} + : m_source_file (source_file), + m_object_file (object_file) + { + } /* Provide read-only views only. Return 'const char *' instead of std::string to avoid having to use c_str() everywhere in client code. */ - const char *source_file () const - { return m_source_file.c_str (); } + const char *source_file () const { return m_source_file.c_str (); } - const char *object_file () const - { return m_object_file.c_str (); } + const char *object_file () const { return m_object_file.c_str (); } private: + /* Storage for the file names. */ std::string m_source_file; std::string m_object_file; diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 517cf89..81f708c 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -34,8 +34,6 @@ #include "value.h" #include "gdbarch.h" - - /* Information about a given instruction. */ struct insn_info @@ -80,7 +78,7 @@ compute_stack_depth_worker (int start, int *need_tempvar, enum bfd_endian byte_order, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end) { - const gdb_byte * const base = op_ptr; + const gdb_byte *const base = op_ptr; int stack_depth; op_ptr += start; @@ -89,23 +87,23 @@ compute_stack_depth_worker (int start, int *need_tempvar, while (op_ptr < op_end) { - enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; + enum dwarf_location_atom op = (enum dwarf_location_atom) * op_ptr; uint64_t reg; int64_t offset; int ndx = op_ptr - base; -#define SET_CHECK_DEPTH(WHERE) \ - if ((*info)[WHERE].visited) \ - { \ - if ((*info)[WHERE].depth != stack_depth) \ - error (_("inconsistent stack depths")); \ - } \ - else \ - { \ - /* Stack depth not set, so set it. */ \ - (*info)[WHERE].visited = 1; \ - (*info)[WHERE].depth = stack_depth; \ - } +#define SET_CHECK_DEPTH(WHERE) \ + if ((*info)[WHERE].visited) \ + { \ + if ((*info)[WHERE].depth != stack_depth) \ + error (_ ("inconsistent stack depths")); \ + } \ + else \ + { \ + /* Stack depth not set, so set it. */ \ + (*info)[WHERE].visited = 1; \ + (*info)[WHERE].depth = stack_depth; \ + } SET_CHECK_DEPTH (ndx); @@ -361,7 +359,7 @@ compute_stack_depth_worker (int start, int *need_tempvar, break; default: - error (_("unhandled DWARF op: %s"), get_DW_OP_name (op)); + error (_ ("unhandled DWARF op: %s"), get_DW_OP_name (op)); } } @@ -388,9 +386,8 @@ compute_stack_depth_worker (int start, int *need_tempvar, static int compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, - int *need_tempvar, int *is_tls, - const gdb_byte *op_ptr, const gdb_byte *op_end, - int initial_depth, + int *need_tempvar, int *is_tls, const gdb_byte *op_ptr, + const gdb_byte *op_end, int initial_depth, std::vector<struct insn_info> *info) { std::vector<int> to_do; @@ -407,9 +404,8 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, int ndx = to_do.back (); to_do.pop_back (); - compute_stack_depth_worker (ndx, need_tempvar, info, &to_do, - byte_order, addr_size, - op_ptr, op_end); + compute_stack_depth_worker (ndx, need_tempvar, info, &to_do, byte_order, + addr_size, op_ptr, op_end); } stack_depth = 0; @@ -425,8 +421,6 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, return stack_depth + 1; } - - #define GCC_UINTPTR "__gdb_uintptr" #define GCC_INTPTR "__gdb_intptr" @@ -435,8 +429,7 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, static void push (int indent, string_file *stream, ULONGEST l) { - gdb_printf (stream, - "%*s__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n", + gdb_printf (stream, "%*s__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n", indent, "", hex_string (l)); } @@ -516,7 +509,7 @@ note_register (int regnum, std::vector<bool> ®isters_used) compile it. We would need a gdbarch method to handle this situation. */ if (regnum >= registers_used.size ()) - error (_("Expression uses \"cooked\" register and cannot be compiled.")); + error (_ ("Expression uses \"cooked\" register and cannot be compiled.")); registers_used[regnum] = true; } @@ -544,8 +537,8 @@ pushf_register_address (int indent, string_file *stream, static void pushf_register (int indent, string_file *stream, - std::vector<bool> ®isters_used, - struct gdbarch *gdbarch, int regnum, uint64_t offset) + std::vector<bool> ®isters_used, struct gdbarch *gdbarch, + int regnum, uint64_t offset) { std::string regname = compile_register_name_mangled (gdbarch, regnum); @@ -590,14 +583,12 @@ pushf_register (int indent, string_file *stream, static void do_compile_dwarf_expr_to_c (int indent, string_file *stream, - const char *type_name, - const char *result_name, + const char *type_name, const char *result_name, struct symbol *sym, CORE_ADDR pc, struct gdbarch *arch, std::vector<bool> ®isters_used, - unsigned int addr_size, - const gdb_byte *op_ptr, const gdb_byte *op_end, - CORE_ADDR *initial, + unsigned int addr_size, const gdb_byte *op_ptr, + const gdb_byte *op_end, CORE_ADDR *initial, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { @@ -606,7 +597,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, static unsigned int scope; enum bfd_endian byte_order = gdbarch_byte_order (arch); - const gdb_byte * const base = op_ptr; + const gdb_byte *const base = op_ptr; int need_tempvar = 0; int is_tls = 0; std::vector<struct insn_info> info; @@ -614,15 +605,14 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, ++scope; - gdb_printf (stream, "%*s__attribute__ ((unused)) %s %s;\n", - indent, "", type_name, result_name); + gdb_printf (stream, "%*s__attribute__ ((unused)) %s %s;\n", indent, "", + type_name, result_name); gdb_printf (stream, "%*s{\n", indent, ""); indent += 2; - stack_depth = compute_stack_depth (byte_order, addr_size, - &need_tempvar, &is_tls, - op_ptr, op_end, initial != NULL, - &info); + stack_depth + = compute_stack_depth (byte_order, addr_size, &need_tempvar, &is_tls, + op_ptr, op_end, initial != NULL, &info); /* This is a hack until we can add a feature to glibc to let us properly generate code for TLS. You might think we could emit @@ -637,30 +627,29 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, struct value *val; if (frame == NULL) - error (_("Symbol \"%s\" cannot be used because " - "there is no selected frame"), + error (_ ("Symbol \"%s\" cannot be used because " + "there is no selected frame"), sym->print_name ()); val = read_var_value (sym, NULL, frame); if (VALUE_LVAL (val) != lval_memory) - error (_("Symbol \"%s\" cannot be used for compilation evaluation " - "as its address has not been found."), + error (_ ("Symbol \"%s\" cannot be used for compilation evaluation " + "as its address has not been found."), sym->print_name ()); - warning (_("Symbol \"%s\" is thread-local and currently can only " - "be referenced from the current thread in " - "compiled code."), + warning (_ ("Symbol \"%s\" is thread-local and currently can only " + "be referenced from the current thread in " + "compiled code."), sym->print_name ()); - gdb_printf (stream, "%*s%s = %s;\n", - indent, "", result_name, + gdb_printf (stream, "%*s%s = %s;\n", indent, "", result_name, core_addr_to_string (value_address (val))); gdb_printf (stream, "%*s}\n", indent - 2, ""); return; } - gdb_printf (stream, "%*s" GCC_UINTPTR " __gdb_stack[%d];\n", - indent, "", stack_depth); + gdb_printf (stream, "%*s" GCC_UINTPTR " __gdb_stack[%d];\n", indent, "", + stack_depth); if (need_tempvar) gdb_printf (stream, "%*s" GCC_UINTPTR " __gdb_tmp;\n", indent, ""); @@ -671,7 +660,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, while (op_ptr < op_end) { - enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; + enum dwarf_location_atom op = (enum dwarf_location_atom) * op_ptr; uint64_t uoffset, reg; int64_t offset; @@ -821,9 +810,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, case DW_OP_reg30: case DW_OP_reg31: dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx"); - pushf_register_address (indent, stream, registers_used, arch, - dwarf_reg_to_regnum_or_error - (arch, op - DW_OP_reg0)); + pushf_register_address ( + indent, stream, registers_used, arch, + dwarf_reg_to_regnum_or_error (arch, op - DW_OP_reg0)); break; case DW_OP_regx: @@ -890,15 +879,15 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, b = block_for_pc (pc); if (!b) - error (_("No block found for address")); + error (_ ("No block found for address")); framefunc = block_linkage_function (b); if (!framefunc) - error (_("No function found for block")); + error (_ ("No function found for block")); - func_get_frame_base_dwarf_block (framefunc, pc, - &datastart, &datalen); + func_get_frame_base_dwarf_block (framefunc, pc, &datastart, + &datalen); op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); @@ -907,12 +896,11 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, xsnprintf (fb_name, sizeof (fb_name), "__frame_base_%ld", (long) (op_ptr - base)); - do_compile_dwarf_expr_to_c (indent, stream, - GCC_UINTPTR, fb_name, - sym, pc, - arch, registers_used, addr_size, - datastart, datastart + datalen, - NULL, per_cu, per_objfile); + do_compile_dwarf_expr_to_c (indent, stream, GCC_UINTPTR, fb_name, + sym, pc, arch, registers_used, + addr_size, datastart, + datastart + datalen, NULL, per_cu, + per_objfile); pushf (indent, stream, "%s + %s", fb_name, hex_string (offset)); } @@ -933,15 +921,15 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_swap: - gdb_printf (stream, - "%*s__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n", + gdb_printf (stream, "%*s__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n", indent, ""); gdb_printf (stream, "%*s__gdb_stack[__gdb_tos - 1] = " "__gdb_stack[__gdb_tos];\n", indent, ""); - gdb_printf (stream, ("%*s__gdb_stack[__gdb_tos] = " - "__gdb_tmp;\n"), + gdb_printf (stream, + ("%*s__gdb_stack[__gdb_tos] = " + "__gdb_tmp;\n"), indent, ""); break; @@ -950,8 +938,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_rot: - gdb_printf (stream, ("%*s__gdb_tmp = " - "__gdb_stack[__gdb_tos];\n"), + gdb_printf (stream, + ("%*s__gdb_tmp = " + "__gdb_stack[__gdb_tos];\n"), indent, ""); gdb_printf (stream, "%*s__gdb_stack[__gdb_tos] = " @@ -961,7 +950,8 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, "%*s__gdb_stack[__gdb_tos - 1] = " "__gdb_stack[__gdb_tos -2];\n", indent, ""); - gdb_printf (stream, "%*s__gdb_stack[__gdb_tos - 2] = " + gdb_printf (stream, + "%*s__gdb_stack[__gdb_tos - 2] = " "__gdb_tmp;\n", indent, ""); break; @@ -979,8 +969,8 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, mode = c_get_mode_for_size (size); if (mode == NULL) - error (_("Unsupported size %d in %s"), - size, get_DW_OP_name (op)); + error (_ ("Unsupported size %d in %s"), size, + get_DW_OP_name (op)); /* Cast to a pointer of the desired type, then dereference. */ @@ -1013,9 +1003,10 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_div: - binary (indent, stream, ("((" GCC_INTPTR - ") __gdb_stack[__gdb_tos-1]) / ((" - GCC_INTPTR ") __gdb_stack[__gdb_tos])")); + binary (indent, stream, + ("((" GCC_INTPTR + ") __gdb_stack[__gdb_tos-1]) / ((" GCC_INTPTR + ") __gdb_stack[__gdb_tos])")); break; case DW_OP_shra: @@ -1024,10 +1015,10 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, "__gdb_stack[__gdb_tos]"); break; -#define BINARY(OP) \ - binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \ - " __gdb_stack[__gdb_tos]"); \ - break +#define BINARY(OP) \ + binary (indent, stream, "%s", \ + "__gdb_stack[__gdb_tos-1] " #OP " __gdb_stack[__gdb_tos]"); \ + break case DW_OP_and: BINARY (&); @@ -1049,12 +1040,11 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, BINARY (^); #undef BINARY -#define COMPARE(OP) \ - binary (indent, stream, \ - "(((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) " #OP \ - " ((" GCC_INTPTR \ - ") __gdb_stack[__gdb_tos]))"); \ - break +#define COMPARE(OP) \ + binary (indent, stream, \ + "(((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) " #OP \ + " ((" GCC_INTPTR ") __gdb_stack[__gdb_tos]))"); \ + break case DW_OP_le: COMPARE (<=); @@ -1077,8 +1067,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, LONGEST off; const gdb_byte *cfa_start, *cfa_end; - if (dwarf2_fetch_cfa_info (arch, pc, per_cu, - ®num, &off, + if (dwarf2_fetch_cfa_info (arch, pc, per_cu, ®num, &off, &text_offset, &cfa_start, &cfa_end)) { /* Register. */ @@ -1092,15 +1081,14 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, /* Generate a unique-enough name, in case the CFA is computed multiple times in this expression. */ - xsnprintf (cfa_name, sizeof (cfa_name), - "__cfa_%ld", (long) (op_ptr - base)); - - do_compile_dwarf_expr_to_c (indent, stream, - GCC_UINTPTR, cfa_name, - sym, pc, arch, registers_used, - addr_size, - cfa_start, cfa_end, - &text_offset, per_cu, per_objfile); + xsnprintf (cfa_name, sizeof (cfa_name), "__cfa_%ld", + (long) (op_ptr - base)); + + do_compile_dwarf_expr_to_c (indent, stream, GCC_UINTPTR, + cfa_name, sym, pc, arch, + registers_used, addr_size, + cfa_start, cfa_end, &text_offset, + per_cu, per_objfile); pushf (indent, stream, "%s", cfa_name); } } @@ -1130,12 +1118,12 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; default: - error (_("unhandled DWARF op: %s"), get_DW_OP_name (op)); + error (_ ("unhandled DWARF op: %s"), get_DW_OP_name (op)); } } - gdb_printf (stream, "%*s%s = __gdb_stack[__gdb_tos];\n", - indent, "", result_name); + gdb_printf (stream, "%*s%s = __gdb_stack[__gdb_tos];\n", indent, "", + result_name); gdb_printf (stream, "%*s}\n", indent - 2, ""); } @@ -1146,9 +1134,8 @@ compile_dwarf_expr_to_c (string_file *stream, const char *result_name, struct symbol *sym, CORE_ADDR pc, struct gdbarch *arch, std::vector<bool> ®isters_used, - unsigned int addr_size, - const gdb_byte *op_ptr, const gdb_byte *op_end, - dwarf2_per_cu_data *per_cu, + unsigned int addr_size, const gdb_byte *op_ptr, + const gdb_byte *op_end, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { do_compile_dwarf_expr_to_c (2, stream, GCC_UINTPTR, result_name, sym, pc, @@ -1159,19 +1146,15 @@ compile_dwarf_expr_to_c (string_file *stream, const char *result_name, /* See compile.h. */ void -compile_dwarf_bounds_to_c (string_file *stream, - const char *result_name, - const struct dynamic_prop *prop, - struct symbol *sym, CORE_ADDR pc, - struct gdbarch *arch, +compile_dwarf_bounds_to_c (string_file *stream, const char *result_name, + const struct dynamic_prop *prop, struct symbol *sym, + CORE_ADDR pc, struct gdbarch *arch, std::vector<bool> ®isters_used, - unsigned int addr_size, - const gdb_byte *op_ptr, const gdb_byte *op_end, - dwarf2_per_cu_data *per_cu, + unsigned int addr_size, const gdb_byte *op_ptr, + const gdb_byte *op_end, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { - do_compile_dwarf_expr_to_c (2, stream, "unsigned long ", result_name, - sym, pc, arch, registers_used, - addr_size, op_ptr, op_end, NULL, per_cu, - per_objfile); + do_compile_dwarf_expr_to_c (2, stream, "unsigned long ", result_name, sym, + pc, arch, registers_used, addr_size, op_ptr, + op_end, NULL, per_cu, per_objfile); } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 83b97f1..345cbe2 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -98,7 +98,6 @@ private: /* Maximum of alignments of all sections matching LAST_PROT. This value is always at least 1. This value is always a power of 2. */ CORE_ADDR m_last_max_alignment = -1; - }; /* See setup_sections_data. */ @@ -128,17 +127,14 @@ setup_sections_data::setup_one_section (asection *sect) if (compile_debug) gdb_printf (gdb_stdlog, "module \"%s\" section \"%s\" size %s prot %u\n", - bfd_get_filename (m_bfd), - bfd_section_name (sect), - paddress (target_gdbarch (), - bfd_section_size (sect)), + bfd_get_filename (m_bfd), bfd_section_name (sect), + paddress (target_gdbarch (), bfd_section_size (sect)), prot); } else prot = -1; - if (sect == NULL - || (m_last_prot != prot && bfd_section_size (sect) != 0)) + if (sect == NULL || (m_last_prot != prot && bfd_section_size (sect) != 0)) { CORE_ADDR addr; asection *sect_iter; @@ -149,18 +145,16 @@ setup_sections_data::setup_one_section (asection *sect) m_last_prot); munmap_list.add (addr, m_last_size); if (compile_debug) - gdb_printf (gdb_stdlog, - "allocated %s bytes at %s prot %u\n", + gdb_printf (gdb_stdlog, "allocated %s bytes at %s prot %u\n", paddress (target_gdbarch (), m_last_size), - paddress (target_gdbarch (), addr), - m_last_prot); + paddress (target_gdbarch (), addr), m_last_prot); } else addr = 0; if ((addr & (m_last_max_alignment - 1)) != 0) - error (_("Inferior compiled module address %s " - "is not aligned to BFD required %s."), + error (_ ("Inferior compiled module address %s " + "is not aligned to BFD required %s."), paddress (target_gdbarch (), addr), paddress (target_gdbarch (), m_last_max_alignment)); @@ -200,7 +194,7 @@ link_callbacks_multiple_definition (struct bfd_link_info *link_info, if (link_info->allow_multiple_definition) return; - warning (_("Compiled module \"%s\": multiple symbol definitions: %s"), + warning (_ ("Compiled module \"%s\": multiple symbol definitions: %s"), bfd_get_filename (abfd), h->root.string); } @@ -211,20 +205,20 @@ link_callbacks_warning (struct bfd_link_info *link_info, const char *xwarning, const char *symbol, bfd *abfd, asection *section, bfd_vma address) { - warning (_("Compiled module \"%s\" section \"%s\": warning: %s"), - bfd_get_filename (abfd), bfd_section_name (section), - xwarning); + warning (_ ("Compiled module \"%s\" section \"%s\": warning: %s"), + bfd_get_filename (abfd), bfd_section_name (section), xwarning); } /* Helper for link_callbacks callbacks vector. */ static void link_callbacks_undefined_symbol (struct bfd_link_info *link_info, - const char *name, bfd *abfd, asection *section, - bfd_vma address, bfd_boolean is_fatal) + const char *name, bfd *abfd, + asection *section, bfd_vma address, + bfd_boolean is_fatal) { - warning (_("Cannot resolve relocation to \"%s\" " - "from compiled module \"%s\" section \"%s\"."), + warning (_ ("Cannot resolve relocation to \"%s\" " + "from compiled module \"%s\" section \"%s\"."), name, bfd_get_filename (abfd), bfd_section_name (section)); } @@ -246,23 +240,21 @@ link_callbacks_reloc_dangerous (struct bfd_link_info *link_info, const char *message, bfd *abfd, asection *section, bfd_vma address) { - warning (_("Compiled module \"%s\" section \"%s\": dangerous " - "relocation: %s\n"), - bfd_get_filename (abfd), bfd_section_name (section), - message); + warning (_ ("Compiled module \"%s\" section \"%s\": dangerous " + "relocation: %s\n"), + bfd_get_filename (abfd), bfd_section_name (section), message); } /* Helper for link_callbacks callbacks vector. */ static void link_callbacks_unattached_reloc (struct bfd_link_info *link_info, - const char *name, bfd *abfd, asection *section, - bfd_vma address) + const char *name, bfd *abfd, + asection *section, bfd_vma address) { - warning (_("Compiled module \"%s\" section \"%s\": unattached " - "relocation: %s\n"), - bfd_get_filename (abfd), bfd_section_name (section), - name); + warning (_ ("Compiled module \"%s\" section \"%s\": unattached " + "relocation: %s\n"), + bfd_get_filename (abfd), bfd_section_name (section), name); } /* Helper for link_callbacks callbacks vector. */ @@ -279,30 +271,29 @@ link_callbacks_einfo (const char *fmt, ...) std::string str = string_vprintf (fmt, ap); va_end (ap); - warning (_("Compile module: warning: %s"), str.c_str ()); + warning (_ ("Compile module: warning: %s"), str.c_str ()); } /* Helper for bfd_get_relocated_section_contents. Only these symbols are set by bfd_simple_get_relocated_section_contents but bfd/ seems to use even the NULL ones without checking them first. */ -static const struct bfd_link_callbacks link_callbacks = -{ - NULL, /* add_archive_element */ +static const struct bfd_link_callbacks link_callbacks = { + NULL, /* add_archive_element */ link_callbacks_multiple_definition, /* multiple_definition */ - NULL, /* multiple_common */ - NULL, /* add_to_set */ - NULL, /* constructor */ - link_callbacks_warning, /* warning */ - link_callbacks_undefined_symbol, /* undefined_symbol */ - link_callbacks_reloc_overflow, /* reloc_overflow */ - link_callbacks_reloc_dangerous, /* reloc_dangerous */ - link_callbacks_unattached_reloc, /* unattached_reloc */ - NULL, /* notice */ - link_callbacks_einfo, /* einfo */ - NULL, /* info */ - NULL, /* minfo */ - NULL, /* override_segment_assignment */ + NULL, /* multiple_common */ + NULL, /* add_to_set */ + NULL, /* constructor */ + link_callbacks_warning, /* warning */ + link_callbacks_undefined_symbol, /* undefined_symbol */ + link_callbacks_reloc_overflow, /* reloc_overflow */ + link_callbacks_reloc_dangerous, /* reloc_dangerous */ + link_callbacks_unattached_reloc, /* unattached_reloc */ + NULL, /* notice */ + link_callbacks_einfo, /* einfo */ + NULL, /* info */ + NULL, /* minfo */ + NULL, /* override_segment_assignment */ }; struct link_hash_table_cleanup_data @@ -367,25 +358,26 @@ copy_sections (bfd *abfd, asection *sect, void *data) link_order.size = bfd_section_size (sect); link_order.u.indirect.section = sect; - gdb::unique_xmalloc_ptr<gdb_byte> sect_data - ((bfd_byte *) xmalloc (bfd_section_size (sect))); + gdb::unique_xmalloc_ptr<gdb_byte> sect_data ( + (bfd_byte *) xmalloc (bfd_section_size (sect))); - sect_data_got = bfd_get_relocated_section_contents (abfd, &link_info, - &link_order, - sect_data.get (), - FALSE, symbol_table); + sect_data_got + = bfd_get_relocated_section_contents (abfd, &link_info, &link_order, + sect_data.get (), FALSE, + symbol_table); if (sect_data_got == NULL) - error (_("Cannot map compiled module \"%s\" section \"%s\": %s"), + error (_ ("Cannot map compiled module \"%s\" section \"%s\": %s"), bfd_get_filename (abfd), bfd_section_name (sect), bfd_errmsg (bfd_get_error ())); gdb_assert (sect_data_got == sect_data.get ()); inferior_addr = bfd_section_vma (sect); - if (0 != target_write_memory (inferior_addr, sect_data.get (), - bfd_section_size (sect))) - error (_("Cannot write compiled module \"%s\" section \"%s\" " - "to inferior memory range %s-%s."), + if (0 + != target_write_memory (inferior_addr, sect_data.get (), + bfd_section_size (sect))) + error (_ ("Cannot write compiled module \"%s\" section \"%s\" " + "to inferior memory range %s-%s."), bfd_get_filename (abfd), bfd_section_name (sect), paddress (target_gdbarch (), inferior_addr), paddress (target_gdbarch (), @@ -433,8 +425,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, block = bv->block (block_loop); if (block->function () != NULL) continue; - gdb_val_sym = block_lookup_symbol (block, - COMPILE_I_EXPR_VAL, + gdb_val_sym = block_lookup_symbol (block, COMPILE_I_EXPR_VAL, symbol_name_match_type::SEARCH_NAME, VAR_DOMAIN); if (gdb_val_sym == NULL) @@ -455,36 +446,36 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, break; } if (block_loop == nblocks) - error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_VAL); + error (_ ("No \"%s\" symbol found"), COMPILE_I_EXPR_VAL); gdb_type = gdb_val_sym->type (); gdb_type = check_typedef (gdb_type); - gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, - symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + gdb_ptr_type_sym + = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, + symbol_name_match_type::SEARCH_NAME, VAR_DOMAIN); if (gdb_ptr_type_sym == NULL) - error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); + error (_ ("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); gdb_ptr_type = gdb_ptr_type_sym->type (); gdb_ptr_type = check_typedef (gdb_ptr_type); if (gdb_ptr_type->code () != TYPE_CODE_PTR) - error (_("Type of \"%s\" is not a pointer"), COMPILE_I_EXPR_PTR_TYPE); + error (_ ("Type of \"%s\" is not a pointer"), COMPILE_I_EXPR_PTR_TYPE); gdb_type_from_ptr = check_typedef (gdb_ptr_type->target_type ()); if (types_deeply_equal (gdb_type, gdb_type_from_ptr)) { if (scope != COMPILE_I_PRINT_ADDRESS_SCOPE) - error (_("Expected address scope in compiled module \"%s\"."), + error (_ ("Expected address scope in compiled module \"%s\"."), objfile_name (objfile)); return gdb_type; } if (gdb_type->code () != TYPE_CODE_PTR) - error (_("Invalid type code %d of symbol \"%s\" " - "in compiled module \"%s\"."), + error (_ ("Invalid type code %d of symbol \"%s\" " + "in compiled module \"%s\"."), gdb_type_from_ptr->code (), COMPILE_I_EXPR_VAL, objfile_name (objfile)); - + retval = gdb_type_from_ptr; switch (gdb_type_from_ptr->code ()) { @@ -494,15 +485,14 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, case TYPE_CODE_FUNC: break; default: - error (_("Invalid type code %d of symbol \"%s\" " - "in compiled module \"%s\"."), + error (_ ("Invalid type code %d of symbol \"%s\" " + "in compiled module \"%s\"."), gdb_type_from_ptr->code (), COMPILE_I_EXPR_PTR_TYPE, objfile_name (objfile)); } - if (!types_deeply_equal (gdb_type_from_ptr, - gdb_type->target_type ())) - error (_("Referenced types do not match for symbols \"%s\" and \"%s\" " - "in compiled module \"%s\"."), + if (!types_deeply_equal (gdb_type_from_ptr, gdb_type->target_type ())) + error (_ ("Referenced types do not match for symbols \"%s\" and \"%s\" " + "in compiled module \"%s\"."), COMPILE_I_EXPR_PTR_TYPE, COMPILE_I_EXPR_VAL, objfile_name (objfile)); if (scope == COMPILE_I_PRINT_ADDRESS_SCOPE) @@ -525,15 +515,15 @@ get_regs_type (struct symbol *func_sym, struct objfile *objfile) regsp_type = check_typedef (func_type->field (0).type ()); if (regsp_type->code () != TYPE_CODE_PTR) - error (_("Invalid type code %d of first parameter of function \"%s\" " - "in compiled module \"%s\"."), + error (_ ("Invalid type code %d of first parameter of function \"%s\" " + "in compiled module \"%s\"."), regsp_type->code (), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); regs_type = check_typedef (regsp_type->target_type ()); if (regs_type->code () != TYPE_CODE_STRUCT) - error (_("Invalid type code %d of dereferenced first parameter " - "of function \"%s\" in compiled module \"%s\"."), + error (_ ("Invalid type code %d of dereferenced first parameter " + "of function \"%s\" in compiled module \"%s\"."), regs_type->code (), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); @@ -566,28 +556,28 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) continue; if ((reg_bitpos % 8) != 0 || reg_bitsize != 0) - error (_("Invalid register \"%s\" position %s bits or size %s bits"), + error (_ ("Invalid register \"%s\" position %s bits or size %s bits"), reg_name, pulongest (reg_bitpos), pulongest (reg_bitsize)); reg_offset = reg_bitpos / 8; if (reg_type->code () != TYPE_CODE_INT && reg_type->code () != TYPE_CODE_PTR) - error (_("Invalid register \"%s\" type code %d"), reg_name, + error (_ ("Invalid register \"%s\" type code %d"), reg_name, reg_type->code ()); regnum = compile_register_name_demangle (gdbarch, reg_name); regval = value_from_register (reg_type, regnum, get_current_frame ()); if (value_optimized_out (regval)) - error (_("Register \"%s\" is optimized out."), reg_name); + error (_ ("Register \"%s\" is optimized out."), reg_name); if (!value_entirely_available (regval)) - error (_("Register \"%s\" is not available."), reg_name); + error (_ ("Register \"%s\" is not available."), reg_name); inferior_addr = regs_base + reg_offset; - if (0 != target_write_memory (inferior_addr, - value_contents (regval).data (), - reg_size)) - error (_("Cannot write register \"%s\" to inferior memory at %s."), + if (0 + != target_write_memory (inferior_addr, + value_contents (regval).data (), reg_size)) + error (_ ("Cannot write register \"%s\" to inferior memory at %s."), reg_name, paddress (gdbarch, inferior_addr)); } } @@ -615,21 +605,20 @@ compile_object_load (const compile_file_names &file_names, int expect_parameters; struct type *expect_return_type; - gdb::unique_xmalloc_ptr<char> filename - (tilde_expand (file_names.object_file ())); + gdb::unique_xmalloc_ptr<char> filename ( + tilde_expand (file_names.object_file ())); gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename.get (), gnutarget)); if (abfd == NULL) - error (_("\"%s\": could not open as compiled module: %s"), - filename.get (), bfd_errmsg (bfd_get_error ())); + error (_ ("\"%s\": could not open as compiled module: %s"), + filename.get (), bfd_errmsg (bfd_get_error ())); if (!bfd_check_format_matches (abfd.get (), bfd_object, &matching)) - error (_("\"%s\": not in loadable format: %s"), - filename.get (), + error (_ ("\"%s\": not in loadable format: %s"), filename.get (), gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); if ((bfd_get_file_flags (abfd.get ()) & (EXEC_P | DYNAMIC)) != 0) - error (_("\"%s\": not in object format."), filename.get ()); + error (_ ("\"%s\": not in object format."), filename.get ()); struct setup_sections_data setup_sections_data (abfd.get ()); for (asection *sect = abfd->sections; sect != nullptr; sect = sect->next) @@ -638,27 +627,26 @@ compile_object_load (const compile_file_names &file_names, storage_needed = bfd_get_symtab_upper_bound (abfd.get ()); if (storage_needed < 0) - error (_("Cannot read symbols of compiled module \"%s\": %s"), + error (_ ("Cannot read symbols of compiled module \"%s\": %s"), filename.get (), bfd_errmsg (bfd_get_error ())); /* SYMFILE_VERBOSE is not passed even if FROM_TTY, user is not interested in "Reading symbols from ..." message for automatically generated file. */ - objfile_up objfile_holder (symbol_file_add_from_bfd (abfd, - filename.get (), + objfile_up objfile_holder (symbol_file_add_from_bfd (abfd, filename.get (), 0, NULL, 0, NULL)); objfile = objfile_holder.get (); - func_sym = lookup_global_symbol_from_objfile (objfile, - GLOBAL_BLOCK, - GCC_FE_WRAPPER_FUNCTION, - VAR_DOMAIN).symbol; + func_sym + = lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, + GCC_FE_WRAPPER_FUNCTION, VAR_DOMAIN) + .symbol; if (func_sym == NULL) - error (_("Cannot find function \"%s\" in compiled module \"%s\"."), + error (_ ("Cannot find function \"%s\" in compiled module \"%s\"."), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); func_type = func_sym->type (); if (func_type->code () != TYPE_CODE_FUNC) - error (_("Invalid type code %d of function \"%s\" in compiled " - "module \"%s\"."), + error (_ ("Invalid type code %d of function \"%s\" in compiled " + "module \"%s\"."), func_type->code (), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); @@ -678,26 +666,26 @@ compile_object_load (const compile_file_names &file_names, expect_return_type = builtin_type (target_gdbarch ())->builtin_void; break; default: - internal_error (_("invalid scope %d"), scope); + internal_error (_ ("invalid scope %d"), scope); } if (func_type->num_fields () != expect_parameters) - error (_("Invalid %d parameters of function \"%s\" in compiled " - "module \"%s\"."), + error (_ ("Invalid %d parameters of function \"%s\" in compiled " + "module \"%s\"."), func_type->num_fields (), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); if (!types_deeply_equal (expect_return_type, func_type->target_type ())) - error (_("Invalid return type of function \"%s\" in compiled " - "module \"%s\"."), + error (_ ("Invalid return type of function \"%s\" in compiled " + "module \"%s\"."), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); /* The memory may be later needed by bfd_generic_get_relocated_section_contents called from default_symfile_relocate. */ - symbol_table = (asymbol **) obstack_alloc (&objfile->objfile_obstack, - storage_needed); + symbol_table + = (asymbol **) obstack_alloc (&objfile->objfile_obstack, storage_needed); number_of_symbols = bfd_canonicalize_symtab (abfd.get (), symbol_table); if (number_of_symbols < 0) - error (_("Cannot parse symbols of compiled module \"%s\": %s"), + error (_ ("Cannot parse symbols of compiled module \"%s\": %s"), filename.get (), bfd_errmsg (bfd_get_error ())); missing_symbols = 0; @@ -712,8 +700,7 @@ compile_object_load (const compile_file_names &file_names, if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0) { if (compile_debug) - gdb_printf (gdb_stdlog, - "ELF symbol \"%s\" relocated to zero\n", + gdb_printf (gdb_stdlog, "ELF symbol \"%s\" relocated to zero\n", sym->name); /* It seems to be a GCC bug, with -mcmodel=large there should be no @@ -732,40 +719,40 @@ compile_object_load (const compile_file_names &file_names, with the SEC_ALLOC flag set. In the unlikely case that we still do not have a section identified, fall back to using the "*ABS*" section. */ - asection *toc_fallback = bfd_get_section_by_name(abfd.get(), ".toc"); + asection *toc_fallback + = bfd_get_section_by_name (abfd.get (), ".toc"); if (toc_fallback == NULL) { for (asection *tsect = abfd->sections; tsect != nullptr; tsect = tsect->next) - { - if (bfd_section_flags (tsect) & SEC_ALLOC) - { - toc_fallback = tsect; - break; - } - } + { + if (bfd_section_flags (tsect) & SEC_ALLOC) + { + toc_fallback = tsect; + break; + } + } } if (toc_fallback == NULL) /* If we've gotten here, we have not found a section usable as a backup for the .toc section. In this case, use the absolute (*ABS*) section. */ - toc_fallback = bfd_abs_section_ptr; + toc_fallback = bfd_abs_section_ptr; sym->section = toc_fallback; sym->value = 0x8000; - bfd_set_gp_value(abfd.get(), toc_fallback->vma); + bfd_set_gp_value (abfd.get (), toc_fallback->vma); if (compile_debug) - gdb_printf (gdb_stdlog, - "Connectiong ELF symbol \"%s\" to the .toc section (%s)\n", - sym->name, - paddress (target_gdbarch (), sym->value)); + gdb_printf ( + gdb_stdlog, + "Connectiong ELF symbol \"%s\" to the .toc section (%s)\n", + sym->name, paddress (target_gdbarch (), sym->value)); continue; } bmsym = lookup_minimal_symbol (sym->name, NULL, NULL); - switch (bmsym.minsym == NULL - ? mst_unknown : bmsym.minsym->type ()) + switch (bmsym.minsym == NULL ? mst_unknown : bmsym.minsym->type ()) { case mst_text: case mst_bss: @@ -774,8 +761,7 @@ compile_object_load (const compile_file_names &file_names, if (compile_debug) gdb_printf (gdb_stdlog, "ELF mst_text symbol \"%s\" relocated to %s\n", - sym->name, - paddress (target_gdbarch (), sym->value)); + sym->name, paddress (target_gdbarch (), sym->value)); break; case mst_text_gnu_ifunc: sym->value = gnu_ifunc_resolve_addr (target_gdbarch (), @@ -784,18 +770,17 @@ compile_object_load (const compile_file_names &file_names, gdb_printf (gdb_stdlog, "ELF mst_text_gnu_ifunc symbol \"%s\" " "relocated to %s\n", - sym->name, - paddress (target_gdbarch (), sym->value)); + sym->name, paddress (target_gdbarch (), sym->value)); break; default: - warning (_("Could not find symbol \"%s\" " - "for compiled module \"%s\"."), + warning (_ ("Could not find symbol \"%s\" " + "for compiled module \"%s\"."), sym->name, filename.get ()); missing_symbols++; } } if (missing_symbols) - error (_("%ld symbols were missing, cannot continue."), missing_symbols); + error (_ ("%ld symbols were missing, cannot continue."), missing_symbols); bfd_map_over_sections (abfd.get (), copy_sections, symbol_table); @@ -805,16 +790,14 @@ compile_object_load (const compile_file_names &file_names, else { /* Use read-only non-executable memory protection. */ - regs_addr = gdbarch_infcall_mmap (target_gdbarch (), - regs_type->length (), - GDB_MMAP_PROT_READ); + regs_addr + = gdbarch_infcall_mmap (target_gdbarch (), regs_type->length (), + GDB_MMAP_PROT_READ); gdb_assert (regs_addr != 0); setup_sections_data.munmap_list.add (regs_addr, regs_type->length ()); if (compile_debug) - gdb_printf (gdb_stdlog, - "allocated %s bytes at %s for registers\n", - paddress (target_gdbarch (), - regs_type->length ()), + gdb_printf (gdb_stdlog, "allocated %s bytes at %s for registers\n", + paddress (target_gdbarch (), regs_type->length ()), paddress (target_gdbarch (), regs_addr)); store_regs (regs_type, regs_addr); } @@ -826,18 +809,15 @@ compile_object_load (const compile_file_names &file_names, if (out_value_type == NULL) return NULL; check_typedef (out_value_type); - out_value_addr = gdbarch_infcall_mmap (target_gdbarch (), - out_value_type->length (), - (GDB_MMAP_PROT_READ - | GDB_MMAP_PROT_WRITE)); + out_value_addr + = gdbarch_infcall_mmap (target_gdbarch (), out_value_type->length (), + (GDB_MMAP_PROT_READ | GDB_MMAP_PROT_WRITE)); gdb_assert (out_value_addr != 0); setup_sections_data.munmap_list.add (out_value_addr, out_value_type->length ()); if (compile_debug) - gdb_printf (gdb_stdlog, - "allocated %s bytes at %s for printed value\n", - paddress (target_gdbarch (), - out_value_type->length ()), + gdb_printf (gdb_stdlog, "allocated %s bytes at %s for printed value\n", + paddress (target_gdbarch (), out_value_type->length ()), paddress (target_gdbarch (), out_value_addr)); } diff --git a/gdb/compile/compile-object-load.h b/gdb/compile/compile-object-load.h index a959f83..f4df6d8 100644 --- a/gdb/compile/compile-object-load.h +++ b/gdb/compile/compile-object-load.h @@ -90,8 +90,8 @@ struct compile_module /* A unique pointer for a compile_module. */ typedef std::unique_ptr<compile_module> compile_module_up; -extern compile_module_up compile_object_load - (const compile_file_names &fnames, - enum compile_i_scope_types scope, void *scope_data); +extern compile_module_up compile_object_load (const compile_file_names &fnames, + enum compile_i_scope_types scope, + void *scope_data); #endif /* COMPILE_COMPILE_OBJECT_LOAD_H */ diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index abdea4d..c0164c9 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -52,6 +52,7 @@ struct do_module_cleanup discarded. */ static dummy_frame_dtor_ftype do_module_cleanup; + static void do_module_cleanup (void *arg, int registers_valid) { @@ -70,8 +71,8 @@ do_module_cleanup (void *arg, int registers_valid) struct type *ptr_type = lookup_pointer_type (data->module->out_value_type); - addr_value = value_from_pointer (ptr_type, - data->module->out_value_addr); + addr_value + = value_from_pointer (ptr_type, data->module->out_value_addr); /* SCOPE_DATA would be stale unless EXECUTEDP != NULL. */ compile_print_value (value_ind (addr_value), @@ -142,28 +143,29 @@ compile_object_run (compile_module_up &&module) gdb_assert (func_type->code () == TYPE_CODE_FUNC); func_val = value_from_pointer (lookup_pointer_type (func_type), - func_sym->value_block ()->entry_pc ()); + func_sym->value_block ()->entry_pc ()); vargs = XALLOCAVEC (struct value *, func_type->num_fields ()); if (func_type->num_fields () >= 1) { gdb_assert (regs_addr != 0); - vargs[current_arg] = value_from_pointer - (func_type->field (current_arg).type (), regs_addr); + vargs[current_arg] + = value_from_pointer (func_type->field (current_arg).type (), + regs_addr); ++current_arg; } if (func_type->num_fields () >= 2) { gdb_assert (data->module->out_value_addr != 0); - vargs[current_arg] = value_from_pointer - (func_type->field (current_arg).type (), - data->module->out_value_addr); + vargs[current_arg] + = value_from_pointer (func_type->field (current_arg).type (), + data->module->out_value_addr); ++current_arg; } gdb_assert (current_arg == func_type->num_fields ()); auto args = gdb::make_array_view (vargs, func_type->num_fields ()); - call_function_by_hand_dummy (func_val, NULL, args, - do_module_cleanup, data); + call_function_by_hand_dummy (func_val, NULL, args, do_module_cleanup, + data); } catch (const gdb_exception_error &ex) { diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index c07686c..5a0f6d7 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -46,8 +46,6 @@ #include "gdbsupport/scoped_ignore_signal.h" #include "gdbsupport/buildargv.h" - - /* Initial filename for temporary files. */ #define TMP_PREFIX "/tmp/gdbobj-" @@ -144,10 +142,11 @@ del_symbol_error (void *a) compile_instance::compile_instance (struct gcc_base_context *gcc_fe, const char *options) - : m_gcc_fe (gcc_fe), m_gcc_target_options (options), + : m_gcc_fe (gcc_fe), + m_gcc_target_options (options), m_type_map (htab_create_alloc (10, hash_type_map_instance, - eq_type_map_instance, - xfree, xcalloc, xfree)), + eq_type_map_instance, xfree, xcalloc, + xfree)), m_symbol_err_map (htab_create_alloc (10, hash_symbol_error, eq_symbol_error, del_symbol_error, xcalloc, xfree)) @@ -188,7 +187,8 @@ compile_instance::insert_type (struct type *type, gcc_type gcc_type) /* The type might have already been inserted in order to handle recursive types. */ if (add != NULL && add->gcc_type_handle != gcc_type) - error (_("Unexpected type id from GCC, check you use recent enough GCC.")); + error ( + _ ("Unexpected type id from GCC, check you use recent enough GCC.")); if (add == NULL) { @@ -237,7 +237,7 @@ compile_instance::error_symbol_once (const struct symbol *sym) gdb::unique_xmalloc_ptr<char> message (err->message); err->message = NULL; - error (_("%s"), message.get ()); + error (_ ("%s"), message.get ()); } /* Implement "show debug compile". */ @@ -246,11 +246,9 @@ static void show_compile_debug (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("Compile debugging is %s.\n"), value); + gdb_printf (file, _ ("Compile debugging is %s.\n"), value); } - - /* Options for the compile command. */ struct compile_options @@ -259,15 +257,14 @@ struct compile_options bool raw = false; }; -using compile_flag_option_def - = gdb::option::flag_option_def<compile_options>; +using compile_flag_option_def = gdb::option::flag_option_def<compile_options>; static const gdb::option::option_def compile_command_option_defs[] = { compile_flag_option_def { "raw", [] (compile_options *opts) { return &opts->raw; }, - N_("Suppress automatic 'void _gdb_expr () { CODE }' wrapping."), + N_ ("Suppress automatic 'void _gdb_expr () { CODE }' wrapping."), }, }; @@ -278,7 +275,7 @@ static const gdb::option::option_def compile_command_option_defs[] = { static gdb::option::option_def_group make_compile_options_def_group (compile_options *opts) { - return {{compile_command_option_defs}, opts}; + return { { compile_command_option_defs }, opts }; } /* Handle the input from the 'compile file' command. The "compile @@ -296,9 +293,9 @@ compile_file_command (const char *args, int from_tty) const gdb::option::option_def_group group = make_compile_options_def_group (&options); - gdb::option::process_options - (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, - group); + gdb::option::process_options (&args, + gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, + group); enum compile_i_scope_types scope = options.raw ? COMPILE_I_RAW_SCOPE : COMPILE_I_SIMPLE_SCOPE; @@ -307,7 +304,7 @@ compile_file_command (const char *args, int from_tty) /* After processing options, check whether we have a filename. */ if (args == nullptr || args[0] == '\0') - error (_("You must provide a filename for this command.")); + error (_ ("You must provide a filename for this command.")); args = skip_spaces (args); std::string abspath = gdb_abspath (args); @@ -319,13 +316,13 @@ compile_file_command (const char *args, int from_tty) static void compile_file_command_completer (struct cmd_list_element *ignore, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { const gdb::option::option_def_group group = make_compile_options_def_group (nullptr); - if (gdb::option::complete_options - (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group)) + if (gdb::option::complete_options ( + tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group)) return; word = advance_to_filename_complete_word_point (tracker, text); @@ -346,8 +343,9 @@ compile_code_command (const char *args, int from_tty) const gdb::option::option_def_group group = make_compile_options_def_group (&options); - gdb::option::process_options - (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group); + gdb::option::process_options (&args, + gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, + group); enum compile_i_scope_types scope = options.raw ? COMPILE_I_RAW_SCOPE : COMPILE_I_SIMPLE_SCOPE; @@ -367,13 +365,13 @@ compile_code_command (const char *args, int from_tty) static void compile_code_command_completer (struct cmd_list_element *ignore, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { const gdb::option::option_def_group group = make_compile_options_def_group (nullptr); - if (gdb::option::complete_options - (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group)) + if (gdb::option::complete_options ( + tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, group)) return; word = advance_to_expression_complete_word_point (tracker, text); @@ -406,8 +404,9 @@ compile_print_command (const char *arg, int from_tty) get_user_print_options (&print_opts); /* Override global settings with explicit options, if any. */ auto group = make_value_print_options_def_group (&print_opts); - gdb::option::process_options - (&arg, gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER, group); + gdb::option::process_options (&arg, + gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER, + group); print_command_parse_format (&arg, "compile print", &print_opts); @@ -440,7 +439,7 @@ do_rmdir (void *arg) zap = concat ("rm -rf ", dir, (char *) NULL); wstat = system (zap); if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0) - warning (_("Could not remove temporary directory %s"), dir); + warning (_ ("Could not remove temporary directory %s"), dir); XDELETEVEC (zap); } @@ -462,7 +461,7 @@ get_compile_file_tempdir (void) #undef TEMPLATE tempdir_name = mkdtemp (tname); if (tempdir_name == NULL) - perror_with_name (_("Could not make temporary directory")); + perror_with_name (_ ("Could not make temporary directory")); tempdir_name = xstrdup (tempdir_name); make_final_cleanup (do_rmdir, tempdir_name); @@ -479,10 +478,10 @@ get_new_file_names () ++seq; - return compile_file_names (string_printf ("%s%sout%d.c", - dir, SLASH_STRING, seq), - string_printf ("%s%sout%d.o", - dir, SLASH_STRING, seq)); + return compile_file_names (string_printf ("%s%sout%d.c", dir, SLASH_STRING, + seq), + string_printf ("%s%sout%d.o", dir, SLASH_STRING, + seq)); } /* Get the block and PC at which to evaluate an expression. */ @@ -543,8 +542,9 @@ static void show_compile_args (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("Compile command command-line arguments " - "are \"%s\".\n"), + gdb_printf (file, + _ ("Compile command command-line arguments " + "are \"%s\".\n"), value); } @@ -557,7 +557,7 @@ static void show_compile_gcc (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("Compile command GCC driver filename is \"%s\".\n"), + gdb_printf (file, _ ("Compile command GCC driver filename is \"%s\".\n"), value); } @@ -678,8 +678,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, std::string triplet_rx; if (!target_has_execution ()) - error (_("The program must be running for the compile command to "\ - "work.")); + error (_ ("The program must be running for the compile command to " + "work.")); expr_block = get_expr_block_and_pc (&trash_pc); expr_pc = get_frame_address_in_block (get_selected_frame (NULL)); @@ -688,7 +688,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, std::unique_ptr<compile_instance> compiler = current_language->get_compile_instance (); if (compiler == nullptr) - error (_("No compiler support for language %s."), + error (_ ("No compiler support for language %s."), current_language->name ()); compiler->set_print_callback (print_callback, NULL); compiler->set_scope (scope); @@ -715,7 +715,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, else if (cmd_string != NULL) input = cmd_string; else - error (_("Neither a simple expression, or a multi-line specified.")); + error (_ ("Neither a simple expression, or a multi-line specified.")); std::string code = current_language->compute_program (compiler.get (), input, gdbarch, @@ -728,8 +728,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, if (!compile_gcc.empty ()) { if (compiler->version () < GCC_FE_VERSION_1) - error (_("Command 'set compile-gcc' requires GCC version 6 or higher " - "(libcc1 interface version 1 or higher)")); + error (_ ("Command 'set compile-gcc' requires GCC version 6 or higher " + "(libcc1 interface version 1 or higher)")); compiler->set_driver_filename (compile_gcc.c_str ()); } @@ -762,8 +762,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, gdb_printf (gdb_stdlog, "Passing %d compiler options:\n", argc); for (argi = 0; argi < argc; argi++) - gdb_printf (gdb_stdlog, "Compiler option %d: <%s>\n", - argi, argv[argi]); + gdb_printf (gdb_stdlog, "Compiler option %d: <%s>\n", argi, + argv[argi]); } compile_file_names fnames = get_new_file_names (); @@ -773,12 +773,12 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, { gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w"); if (src == NULL) - perror_with_name (_("Could not open source file for writing")); + perror_with_name (_ ("Could not open source file for writing")); source_remover.emplace (fnames.source_file ()); if (fputs (code.c_str (), src.get ()) == EOF) - perror_with_name (_("Could not write to source file")); + perror_with_name (_ ("Could not write to source file")); } if (compile_debug) @@ -793,7 +793,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, compiler->set_source_file (fnames.source_file ()); ok = compiler->compile (fnames.object_file (), compile_debug); if (!ok) - error (_("Compilation failed.")); + error (_ ("Compilation failed.")); if (compile_debug) gdb_printf (gdb_stdlog, "object file produced: %s\n\n", @@ -825,13 +825,13 @@ eval_compile_command (struct command_line *cmd, const char *cmd_string, gdb::unlinker object_remover (fnames.object_file ()); gdb::unlinker source_remover (fnames.source_file ()); - compile_module_up compile_module = compile_object_load (fnames, scope, - scope_data); + compile_module_up compile_module + = compile_object_load (fnames, scope, scope_data); if (compile_module == NULL) { gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE); - eval_compile_command (cmd, cmd_string, - COMPILE_I_PRINT_VALUE_SCOPE, scope_data); + eval_compile_command (cmd, cmd_string, COMPILE_I_PRINT_VALUE_SCOPE, + scope_data); return; } @@ -855,31 +855,31 @@ compile_register_name_mangled (struct gdbarch *gdbarch, int regnum) /* See compile/compile-internal.h. */ int -compile_register_name_demangle (struct gdbarch *gdbarch, - const char *regname) +compile_register_name_demangle (struct gdbarch *gdbarch, const char *regname) { int regnum; if (regname[0] != '_' || regname[1] != '_') - error (_("Invalid register name \"%s\"."), regname); + error (_ ("Invalid register name \"%s\"."), regname); regname += 2; for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++) if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0) return regnum; - error (_("Cannot find gdbarch register \"%s\"."), regname); + error (_ ("Cannot find gdbarch register \"%s\"."), regname); } /* Forwards to the plug-in. */ -#define FORWARD(OP,...) (m_gcc_fe->ops->OP (m_gcc_fe, ##__VA_ARGS__)) +#define FORWARD(OP, ...) (m_gcc_fe->ops->OP (m_gcc_fe, ##__VA_ARGS__)) /* See compile-internal.h. */ void -compile_instance::set_print_callback - (void (*print_function) (void *, const char *), void *datum) +compile_instance::set_print_callback (void (*print_function) (void *, + const char *), + void *datum) { FORWARD (set_print_callback, print_function, datum); } @@ -956,21 +956,22 @@ compile_instance::compile (const char *filename, int verbose_level) cmd_list_element *compile_cmd_element = nullptr; void _initialize_compile (); + void _initialize_compile () { struct cmd_list_element *c = NULL; - compile_cmd_element = add_prefix_cmd ("compile", class_obscure, - compile_command, _("\ + compile_cmd_element + = add_prefix_cmd ("compile", class_obscure, compile_command, _ ("\ Command to compile source code and inject it into the inferior."), - &compile_command_list, 1, &cmdlist); + &compile_command_list, 1, &cmdlist); add_com_alias ("expression", compile_cmd_element, class_obscure, 0); const auto compile_opts = make_compile_options_def_group (nullptr); static const std::string compile_code_help - = gdb::option::build_help (_("\ + = gdb::option::build_help (_ ("\ Compile, inject, and execute code.\n\ \n\ Usage: compile code [OPTION]... [CODE]\n\ @@ -989,12 +990,11 @@ indicate the end of the expression."), compile_opts); c = add_cmd ("code", class_obscure, compile_code_command, - compile_code_help.c_str (), - &compile_command_list); + compile_code_help.c_str (), &compile_command_list); set_cmd_completer_handle_brkchars (c, compile_code_command_completer); -static const std::string compile_file_help - = gdb::option::build_help (_("\ + static const std::string compile_file_help + = gdb::option::build_help (_ ("\ Evaluate a file containing source code.\n\ \n\ Usage: compile file [OPTION].. [FILENAME]\n\ @@ -1004,14 +1004,13 @@ Options:\n\ compile_opts); c = add_cmd ("file", class_obscure, compile_file_command, - compile_file_help.c_str (), - &compile_command_list); + compile_file_help.c_str (), &compile_command_list); set_cmd_completer_handle_brkchars (c, compile_file_command_completer); const auto compile_print_opts = make_value_print_options_def_group (nullptr); static const std::string compile_print_help - = gdb::option::build_help (_("\ + = gdb::option::build_help (_ ("\ Evaluate EXPR by using the compiler and print result.\n\ \n\ Usage: compile print [[OPTION]... --] [/FMT] [EXPR]\n\ @@ -1037,38 +1036,37 @@ but no count or size letter (see \"x\" command)."), compile_print_opts); c = add_cmd ("print", class_obscure, compile_print_command, - compile_print_help.c_str (), - &compile_command_list); + compile_print_help.c_str (), &compile_command_list); set_cmd_completer_handle_brkchars (c, print_command_completer); - add_setshow_boolean_cmd ("compile", class_maintenance, &compile_debug, _("\ -Set compile command debugging."), _("\ -Show compile command debugging."), _("\ + add_setshow_boolean_cmd ("compile", class_maintenance, &compile_debug, _ ("\ +Set compile command debugging."), + _ ("\ +Show compile command debugging."), + _ ("\ When on, compile command debugging is enabled."), - NULL, show_compile_debug, - &setdebuglist, &showdebuglist); - - add_setshow_string_cmd ("compile-args", class_support, - &compile_args, - _("Set compile command GCC command-line arguments."), - _("Show compile command GCC command-line arguments."), - _("\ + NULL, show_compile_debug, &setdebuglist, + &showdebuglist); + + add_setshow_string_cmd ( + "compile-args", class_support, &compile_args, + _ ("Set compile command GCC command-line arguments."), + _ ("Show compile command GCC command-line arguments."), _ ("\ Use options like -I (include file directory) or ABI settings.\n\ String quoting is parsed like in shell, for example:\n\ -mno-align-double \"-I/dir with a space/include\""), - set_compile_args, show_compile_args, &setlist, &showlist); - + set_compile_args, show_compile_args, &setlist, &showlist); /* Initialize compile_args_argv. */ set_compile_args (compile_args.c_str (), 0, NULL); add_setshow_optional_filename_cmd ("compile-gcc", class_support, &compile_gcc, - _("Set compile command " - "GCC driver filename."), - _("Show compile command " - "GCC driver filename."), - _("\ + _ ("Set compile command " + "GCC driver filename."), + _ ("Show compile command " + "GCC driver filename."), + _ ("\ It should be absolute filename of the gcc executable.\n\ If empty the default target triplet will be searched in $PATH."), NULL, show_compile_gcc, &setlist, diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h index a3b6a18f..54dc769 100644 --- a/gdb/compile/compile.h +++ b/gdb/compile/compile.h @@ -33,12 +33,10 @@ struct dynamic_prop; class compile_instance { public: + compile_instance (struct gcc_base_context *gcc_fe, const char *options); - virtual ~compile_instance () - { - m_gcc_fe->ops->destroy (m_gcc_fe); - } + virtual ~compile_instance () { m_gcc_fe->ops->destroy (m_gcc_fe); } /* Returns the GCC options to be passed during compilation. */ const std::string &gcc_target_options () const @@ -96,28 +94,16 @@ public: bool compile (const char *filename, int verbose_level = -1); /* Set the scope type for this compile. */ - void set_scope (enum compile_i_scope_types scope) - { - m_scope = scope; - } + void set_scope (enum compile_i_scope_types scope) { m_scope = scope; } /* Return the scope type. */ - enum compile_i_scope_types scope () const - { - return m_scope; - } + enum compile_i_scope_types scope () const { return m_scope; } /* Set the block to be used for symbol searches. */ - void set_block (const struct block *block) - { - m_block = block; - } + void set_block (const struct block *block) { m_block = block; } /* Return the search block. */ - const struct block *block () const - { - return m_block; - } + const struct block *block () const { return m_block; } protected: @@ -175,17 +161,11 @@ extern void eval_compile_command (struct command_line *cmd, PER_OBJFILE is the per-objfile object also used for looking up various other things. */ -extern void compile_dwarf_expr_to_c (string_file *stream, - const char *result_name, - struct symbol *sym, - CORE_ADDR pc, - struct gdbarch *arch, - std::vector<bool> ®isters_used, - unsigned int addr_size, - const gdb_byte *op_ptr, - const gdb_byte *op_end, - dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile); +extern void compile_dwarf_expr_to_c ( + string_file *stream, const char *result_name, struct symbol *sym, + CORE_ADDR pc, struct gdbarch *arch, std::vector<bool> ®isters_used, + unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end, + dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile); /* Compile a DWARF bounds expression to C, suitable for use by the compiler. @@ -214,17 +194,12 @@ extern void compile_dwarf_expr_to_c (string_file *stream, PER_OBJFILE is the per-objfile object also used for looking up various other things. */ -extern void compile_dwarf_bounds_to_c (string_file *stream, - const char *result_name, - const struct dynamic_prop *prop, - struct symbol *sym, CORE_ADDR pc, - struct gdbarch *arch, - std::vector<bool> ®isters_used, - unsigned int addr_size, - const gdb_byte *op_ptr, - const gdb_byte *op_end, - dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile); +extern void compile_dwarf_bounds_to_c ( + string_file *stream, const char *result_name, + const struct dynamic_prop *prop, struct symbol *sym, CORE_ADDR pc, + struct gdbarch *arch, std::vector<bool> ®isters_used, + unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end, + dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile); extern void compile_print_value (struct value *val, void *data_voidp); diff --git a/gdb/compile/gcc-c-plugin.h b/gdb/compile/gcc-c-plugin.h index 7595197..f151d4c 100644 --- a/gdb/compile/gcc-c-plugin.h +++ b/gdb/compile/gcc-c-plugin.h @@ -38,8 +38,8 @@ public: gcc_c_symbol_address_function *address_oracle, void *datum) { - m_context->c_ops->set_callbacks (m_context, binding_oracle, - address_oracle, datum); + m_context->c_ops->set_callbacks (m_context, binding_oracle, address_oracle, + datum); } /* Returns the interface version of the compiler plug-in. */ @@ -64,6 +64,7 @@ public: #undef GCC_METHOD7 private: + /* The GCC C context. */ struct gcc_c_context *m_context; }; |