]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Update with 'origin/master'
authorKeith Seitz <keiths@redhat.com>
Wed, 11 Jan 2017 19:07:25 +0000 (11:07 -0800)
committerKeith Seitz <keiths@redhat.com>
Wed, 11 Jan 2017 19:07:25 +0000 (11:07 -0800)
Problems:
gdb/Makefile.in
gdb/c-exp.y
gdb/c-lang.h
gdb/compile/compile-c-support.c
gdb/compile/compile-internal.h
gdb/compile/compile.c
gdb/linespec.c
include/gcc-interface.h

61 files changed:
1  2 
gdb/Makefile.in
gdb/NEWS
gdb/ada-lang.c
gdb/buildsym.c
gdb/buildsym.h
gdb/c-exp.y
gdb/c-lang.c
gdb/c-lang.h
gdb/c-typeprint.c
gdb/coffread.c
gdb/compile/compile-c-support.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-c-types.c
gdb/compile/compile-internal.h
gdb/compile/compile-loc2c.c
gdb/compile/compile-object-load.c
gdb/compile/compile.c
gdb/cp-abi.h
gdb/cp-name-parser.y
gdb/cp-namespace.c
gdb/cp-support.c
gdb/cp-support.h
gdb/d-lang.c
gdb/dbxread.c
gdb/dictionary.c
gdb/dictionary.h
gdb/doc/gdb.texinfo
gdb/dwarf2read.c
gdb/f-lang.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/gnu-v3-abi.c
gdb/go-lang.c
gdb/jit.c
gdb/language.c
gdb/language.h
gdb/linespec.c
gdb/linespec.h
gdb/m2-lang.c
gdb/mdebugread.c
gdb/minsyms.h
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/stabsread.h
gdb/symtab.c
gdb/symtab.h
gdb/testsuite/gdb.compile/compile-ifunc.exp
gdb/testsuite/gdb.compile/compile-ops.exp
gdb/testsuite/gdb.compile/compile-print.exp
gdb/testsuite/gdb.compile/compile-setjmp.exp
gdb/testsuite/gdb.compile/compile-tls.exp
gdb/testsuite/gdb.compile/compile.exp
gdb/testsuite/gdb.cp/mb-templates.exp
gdb/typeprint.c
gdb/valops.c
gdb/xcoffread.c
include/gcc-c-fe.def
include/gcc-c-interface.h
include/gcc-interface.h

diff --cc gdb/Makefile.in
index 5e4d048d30d69c695913051b72ef926c619853fc,ae5a80e7c82d76e7bc839f3793772ff15bff3e69..4652e7dd7c6856183a3b1a4abe626248c2939060
@@@ -299,18 -350,20 +350,28 @@@ SUBDIR_TUI_CFLAGS = -DTUI=
  # GCC Compile support sub-directory definitions
  #
  SUBDIR_GCC_COMPILE_OBS = \
-       compile.o compile-c-symbols.o compile-cplus-symbols.o \
-       compile-c-types.o compile-cplus-types.o \
-       compile-object-load.o compile-object-run.o \
-       compile-loc2c.o compile-c-support.o \
-       compile-cplus-support.o compile-cplus-templates.o
+       compile.o \
+       compile-c-support.o \
+       compile-c-symbols.o \
+       compile-c-types.o \
++      compile-cplus-support.o \
++      compile-cplus-symbols.o \
++      compile-cplus-templates.o \
++      compile-cplus-types.o \
+       compile-loc2c.o \
+       compile-object-load.o \
+       compile-object-run.o
  
  SUBDIR_GCC_COMPILE_SRCS = \
        compile/compile.c \
+       compile/compile-c-support.c \
        compile/compile-c-symbols.c \
-       compile/compile-cplus-symbols.c \
        compile/compile-c-types.c \
++      compile/compile-cplus-support.c \
++      compile/compile-cplus-symbols.c \
++      compile/compile-cplus-templates.c \
 +      compile/compile-cplus-types.c \
+       compile/compile-loc2c.c \
        compile/compile-object-load.c \
        compile/compile-object-load.h \
        compile/compile-object-run.c \
diff --cc gdb/NEWS
Simple merge
diff --cc gdb/ada-lang.c
Simple merge
diff --cc gdb/buildsym.c
Simple merge
diff --cc gdb/buildsym.h
Simple merge
diff --cc gdb/c-exp.y
index 7fb999e812f6f08e4d5c2e8fb4f1e5fb9e9cb44d,8a92cce0ab3fa903e7a0466f35dfe2e177405deb..9d1eb782486e15639911c07744767d44bb8ddc5c
@@@ -1555,26 -1555,13 +1555,19 @@@ oper:        OPERATOR NE
        |       OPERATOR OBJC_LBRAC ']'
                        { $$ = operator_stoken ("[]"); }
        |       OPERATOR conversion_type_id
-                       { char *name;
-                         char *canon;
-                         long length;
-                         struct ui_file *buf = mem_fileopen ();
+                       { struct ui_file *buf = mem_fileopen ();
  
-                         /* This also needs canonicalization.  */
                          c_print_type ($2, NULL, buf, -1, 0,
                                        &type_print_raw_options);
-                         name = ui_file_xstrdup (buf, &length);
 -                        std::string name = ui_file_as_string (buf);
++                        std::string name = " " + ui_file_as_string (buf);
                          ui_file_delete (buf);
-                         canon = cp_canonicalize_string (name);
-                         if (canon != NULL)
-                           {
-                             free (name);
-                             name = canon;
-                           }
-                         canon = xstrprintf (" %s", name);
-                         $$ = operator_stoken (canon);
-                         free (name);
-                         free (canon);
++
++                        /* This also needs canonicalization.  */
++                        std::string canon
++                          = cp_canonicalize_string (name.c_str ());
++                        if (!canon.empty ())
++                          name = " " + canon;
+                         $$ = operator_stoken (name.c_str ());
                        }
        ;
  
diff --cc gdb/c-lang.c
Simple merge
diff --cc gdb/c-lang.h
index 1afbbbe80c8cf6bc150cbdf351b69a632dfdd567,c4b19ecfef610584a1c716fff0d802495c379be0..508a5461f2f41572e7da2b3eb01c0f79fc98c246
@@@ -152,36 -152,16 +152,35 @@@ extern int c_textual_element_type (stru
  
  extern struct compile_instance *c_get_compile_context (void);
  
- /* This takes the user-supplied text and returns a newly malloc'd bit
-    of code to compile.
 +/* Create a new instance of the C++ compiler and return it.  The new
 +   compiler is owned by the caller and must be freed using the destroy
 +   method.  This function never returns NULL, but rather throws an
 +   exception on failure.  This is suitable for use as the
 +   la_get_compile_instance language method.  */
 +
 +extern struct compile_instance *cplus_get_compile_context (void);
 +
+ /* This takes the user-supplied text and returns a new bit of code to
+    compile.
  
     This is used as the la_compute_program language method; see that
     for a description of the arguments.  */
  
- extern char *c_compute_program (struct compile_instance *inst,
-                               const char *input,
-                               struct gdbarch *gdbarch,
-                               const struct block *expr_block,
-                               CORE_ADDR expr_pc);
+ extern std::string c_compute_program (struct compile_instance *inst,
+                                     const char *input,
+                                     struct gdbarch *gdbarch,
+                                     const struct block *expr_block,
+                                     CORE_ADDR expr_pc);
  
- /* This takes the user-supplied text and returns a newly malloc'd bit
-    of code to compile.
++/* This takes the user-supplied text and returns a new bit of code to compile.
 +
 +   This is used as the la_compute_program language method; see that
 +   for a description of the arguments.  */
 +
- extern char *cplus_compute_program (struct compile_instance *inst,
-                                   const char *input,
-                                   struct gdbarch *gdbarch,
-                                   const struct block *expr_block,
-                                   CORE_ADDR expr_pc);
++extern std::string cplus_compute_program (struct compile_instance *inst,
++                                        const char *input,
++                                        struct gdbarch *gdbarch,
++                                        const struct block *expr_block,
++                                        CORE_ADDR expr_pc);
 +
  #endif /* !defined (C_LANG_H) */
Simple merge
diff --cc gdb/coffread.c
Simple merge
index 1ee90ef0f53e9d05b623b6dcdc1763b4469db010,877bfb726ebabc9ae68cf19168b25b65cf012f57..de2a67548afca0916d933e996c5969acad0bb1a1
@@@ -281,420 -318,124 +281,420 @@@ generate_register_struct (struct ui_fil
    fputs_unfiltered ("};\n\n", stream);
  }
  
 -/* Take the source code provided by the user with the 'compile'
 -   command, and compute the additional wrapping, macro, variable and
 -   register operations needed.  INPUT is the source code derived from
 -   the 'compile' command, GDBARCH is the architecture to use when
 -   computing above, EXPR_BLOCK denotes the block relevant contextually
 -   to the inferior when the expression was created, and EXPR_PC
 -   indicates the value of $PC.  */
 +/* C-language policy to emit a push user expression pragma into BUF.  */
  
 -std::string
 -c_compute_program (struct compile_instance *inst,
 -                 const char *input,
 -                 struct gdbarch *gdbarch,
 -                 const struct block *expr_block,
 -                 CORE_ADDR expr_pc)
 +struct c_push_user_expression
  {
 -  struct ui_file *buf, *var_stream = NULL;
 -  std::string code;
 -  struct cleanup *cleanup;
 -  struct compile_c_instance *context = (struct compile_c_instance *) inst;
 +  void push_user_expression (struct ui_file *buf)
 +  {
 +    fputs_unfiltered ("#pragma GCC user_expression\n", buf);
 +  }
 +};
  
 -  buf = mem_fileopen ();
 -  cleanup = make_cleanup_ui_file_delete (buf);
 +/* C-language policy to emit a pop user expression pragma into BUF.
 +   For C, this is a nop.  */
  
 -  write_macro_definitions (expr_block, expr_pc, buf);
 +struct pop_user_expression_nop
 +{
 +  void pop_user_expression (struct ui_file *buf)
 +  {
 +    /* Nothing to do.  */
 +  }
 +};
 +
 +/* C-language policy to construct a code header for a block of code.
 +   Takes a scope TYPE argument which selects the correct header to
 +   insert into BUF.  */
  
 -  /* Do not generate local variable information for "raw"
 -     compilations.  In this case we aren't emitting our own function
 -     and the user's code may only refer to globals.  */
 -  if (inst->scope != COMPILE_I_RAW_SCOPE)
 -    {
 -      unsigned char *registers_used;
 -      int i;
 +struct c_add_code_header
 +{
 +  void add_code_header (enum compile_i_scope_types type, struct ui_file *buf)
 +  {
 +    switch (type)
 +      {
 +      case COMPILE_I_SIMPLE_SCOPE:
 +      fputs_unfiltered ("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:
 +      /* <string.h> is needed for a memcpy call below.  */
 +      fputs_unfiltered ("#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
 +                        ") {\n",
 +                        buf);
 +      break;
 +
 +      case COMPILE_I_RAW_SCOPE:
 +      break;
 +
 +      default:
 +      gdb_assert_not_reached (_("Unknown compiler scope reached."));
 +      }
 +  }
 +};
  
 -      /* Generate the code to compute variable locations, but do it
 -       before generating the function header, so we can define the
 -       register struct before the function body.  This requires a
 -       temporary stream.  */
 -      var_stream = mem_fileopen ();
 -      make_cleanup_ui_file_delete (var_stream);
 -      registers_used = generate_c_for_variable_locations (context,
 -                                                        var_stream, gdbarch,
 -                                                        expr_block, expr_pc);
 -      make_cleanup (xfree, registers_used);
 -
 -      fputs_unfiltered ("typedef unsigned int"
 -                      " __attribute__ ((__mode__(__pointer__)))"
 -                      " __gdb_uintptr;\n",
 -                      buf);
 -      fputs_unfiltered ("typedef int"
 -                      " __attribute__ ((__mode__(__pointer__)))"
 -                      " __gdb_intptr;\n",
 -                      buf);
 +/* C-language policy to construct a code footer for a block of code.
 +   Takes a scope TYPE which selects the correct footer to insert into BUF.  */
  
 -      /* Iterate all log2 sizes in bytes supported by c_get_mode_for_size.  */
 -      for (i = 0; i < 4; ++i)
 -      {
 -        const char *mode = c_get_mode_for_size (1 << i);
 -
 -        gdb_assert (mode != NULL);
 -        fprintf_unfiltered (buf,
 -                            "typedef int"
 -                            " __attribute__ ((__mode__(__%s__)))"
 -                            " __gdb_int_%s;\n",
 -                            mode, mode);
 -      }
 +struct c_add_code_footer
 +{
 +  void add_code_footer (enum compile_i_scope_types type, struct ui_file *buf)
 +  {
 +    switch (type)
 +      {
 +      case COMPILE_I_SIMPLE_SCOPE:
 +      case COMPILE_I_PRINT_ADDRESS_SCOPE:
 +      case COMPILE_I_PRINT_VALUE_SCOPE:
 +      fputs_unfiltered ("}\n", buf);
 +      break;
  
 -      generate_register_struct (buf, gdbarch, registers_used);
 -    }
 +      case COMPILE_I_RAW_SCOPE:
 +      break;
  
 -  add_code_header (inst->scope, buf);
 +      default:
 +      gdb_assert_not_reached (_("Unknown compiler scope reached."));
 +      }
 +  }
 +};
  
 -  if (inst->scope == COMPILE_I_SIMPLE_SCOPE
 -      || inst->scope == COMPILE_I_PRINT_ADDRESS_SCOPE
 -      || inst->scope == COMPILE_I_PRINT_VALUE_SCOPE)
 -    {
 -      ui_file_put (var_stream, ui_file_write_for_put, buf);
 -      fputs_unfiltered ("#pragma GCC user_expression\n", buf);
 -    }
 +/* C-language policy to emit the user code snippet INPUT into BUF based on the
 +   scope TYPE.  */
 +
 +struct c_add_input
 +{
 +  void add_input (enum compile_i_scope_types type, const char *input,
 +                struct ui_file *buf)
 +  {
 +    switch (type)
 +      {
 +      case COMPILE_I_PRINT_ADDRESS_SCOPE:
 +      case COMPILE_I_PRINT_VALUE_SCOPE:
 +      fprintf_unfiltered (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
 +                           ? "&" : ""));
 +      break;
 +
 +      default:
 +      fputs_unfiltered (input, buf);
 +      break;
 +      }
 +    fputs_unfiltered ("\n", buf);
 +  }
 +};
 +
 +/* C++-language policy to emit a push user expression pragma into
 +   BUF.  */
 +
 +struct cplus_push_user_expression
 +{
 +  void push_user_expression (struct ui_file *buf)
 +  {
 +    fputs_unfiltered ("#pragma GCC push_user_expression\n", buf);
 +  }
 +};
  
 -  /* The user expression has to be in its own scope, so that "extern"
 -     works properly.  Otherwise gcc thinks that the "extern"
 -     declaration is in the same scope as the declaration provided by
 -     gdb.  */
 -  if (inst->scope != COMPILE_I_RAW_SCOPE)
 -    fputs_unfiltered ("{\n", buf);
 +/* C++-language policy to emit a pop user expression pragma into BUF.  */
  
 -  fputs_unfiltered ("#line 1 \"gdb command line\"\n", buf);
 +struct cplus_pop_user_expression
 +{
 +  void pop_user_expression (struct ui_file *buf)
 +  {
 +    fputs_unfiltered ("#pragma GCC pop_user_expression\n", buf);
 +  }
 +};
 +
 +/* C++-language policy to construct a code header for a block of code.
 +   Takes a scope TYPE argument which selects the correct header to
 +   insert into BUF.  */
  
 -  switch (inst->scope)
 +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:
 +      fputs_unfiltered ("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:
 -      fprintf_unfiltered (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,
 -                        (inst->scope == COMPILE_I_PRINT_ADDRESS_SCOPE
 -                         ? "&" : ""));
 +      fputs_unfiltered (
 +                      "#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;
 -    default:
 -      fputs_unfiltered (input, buf);
 +
 +    case COMPILE_I_RAW_SCOPE:
        break;
 +
 +    default:
 +      gdb_assert_not_reached (_("Unknown compiler scope reached."));
      }
-   void add_input (enum compile_i_scope_types type,
-                          const char *input, struct ui_file *buf)
 +  }
 +};
 +
 +/* C++-language policy to emit the user code snippet INPUT into BUF based on
 +   the scope TYPE.  */
 +
 +struct cplus_add_input
 +{
-   char *compute (const char *input, const struct block *expr_block,
-                CORE_ADDR expr_pc)
++  void add_input (enum compile_i_scope_types type, const char *input,
++                struct ui_file *buf)
 +  {
 +    switch (type)
 +      {
 +      case COMPILE_I_PRINT_ADDRESS_SCOPE:
 +      case COMPILE_I_PRINT_VALUE_SCOPE:
 +      fprintf_unfiltered
 +        (buf,
 +         "auto " COMPILE_I_EXPR_VAL " = %s;\n"
 +         "decltype (" COMPILE_I_EXPR_VAL ") *" COMPILE_I_EXPR_PTR_TYPE ";\n"
 +         "std::memcpy (" COMPILE_I_PRINT_OUT_ARG ", %s ("
 +         COMPILE_I_EXPR_VAL "),\n"
 +         "sizeof (" COMPILE_I_EXPR_VAL "));\n"
 +         ,input,
 +         (type == COMPILE_I_PRINT_ADDRESS_SCOPE
 +          ? "std::__addressof" : ""));
 +      break;
 +
 +      default:
 +      fputs_unfiltered (input, buf);
 +      break;
 +      }
 +    fputs_unfiltered ("\n", buf);
 +  }
 +};
 +
 +/* A host class representing a compile program.
 +
 +   CompileInstanceType is the type of the compile_instance for the
 +   langauge.
 +
 +   PushUserExpressionPolicy and PopUserExpressionPolicy are used to
 +   push and pop user expression pragmas to the compile plug-in.
 +
 +   AddCodeHeaderPolicy and AddCodeFooterPolicy are used to add the appropriate
 +   code header and footer, respectively.
 +
 +   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
 +{
 +  using PushUserExpressionPolicy::push_user_expression;
 +  using PopUserExpressionPolicy::pop_user_expression;
 +  using AddCodeHeaderPolicy::add_code_header;
 +  using AddCodeFooterPolicy::add_code_footer;
 +  using AddInputPolicy::add_input;
 +
 +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)
 +  {
 +  }
 +
 +  /* Take the source code provided by the user with the 'compile'
 +     command and compute the additional wrapping, macro, variable and
 +     register operations needed.  INPUT is the source code derived from
 +     the 'compile' command, EXPR_BLOCK denotes the block relevant contextually
 +     to the inferior when the expression was created, and EXPR_PC
 +     indicates the value of $PC.
 +
 +     Returns the text of the program to compile.  This must be free'd by
 +     the caller.  */
 +
++  std::string compute (const char *input, const struct block *expr_block,
++                     CORE_ADDR expr_pc)
 +  {
 +    struct ui_file *var_stream = NULL;
 +    struct ui_file *buf = mem_fileopen ();
 +    struct cleanup *cleanup = make_cleanup_ui_file_delete (buf);
 +
 +    /* Do not generate local variable information for "raw"
 +       compilations.  In this case we aren't emitting our own function
 +       and the user's code may only refer to globals.  */
 +    if (m_instance->scope () != COMPILE_I_RAW_SCOPE)
 +      {
 +      /* Generate the code to compute variable locations, but do it
 +         before generating the function header, so we can define the
 +         register struct before the function body.  This requires a
 +         temporary stream.  */
 +      var_stream = mem_fileopen ();
 +      make_cleanup_ui_file_delete (var_stream);
 +      unsigned char *registers_used
 +        = generate_c_for_variable_locations (m_instance, var_stream, m_arch,
 +                                             expr_block, expr_pc);
 +      make_cleanup (xfree, registers_used);
 +
 +      fputs_unfiltered ("typedef unsigned int"
 +                        " __attribute__ ((__mode__(__pointer__)))"
 +                        " __gdb_uintptr;\n",
 +                        buf);
 +      fputs_unfiltered ("typedef int"
 +                        " __attribute__ ((__mode__(__pointer__)))"
 +                        " __gdb_intptr;\n",
 +                        buf);
 +
 +      /* Iterate all log2 sizes in bytes supported by c_get_mode_for_size.  */
 +      for (int i = 0; i < 4; ++i)
 +        {
 +          const char *mode = c_get_mode_for_size (1 << i);
 +
 +          gdb_assert (mode != NULL);
 +          fprintf_unfiltered (buf,
 +                              "typedef int"
 +                              " __attribute__ ((__mode__(__%s__)))"
 +                              " __gdb_int_%s;\n",
 +                              mode, mode);
 +        }
 +
 +      generate_register_struct (buf, m_arch, registers_used);
 +      }
 +
 +    add_code_header (m_instance->scope (), buf);
 +
 +    if (m_instance->scope () == COMPILE_I_SIMPLE_SCOPE
 +      || m_instance->scope () == COMPILE_I_PRINT_ADDRESS_SCOPE
 +      || m_instance->scope () == COMPILE_I_PRINT_VALUE_SCOPE)
 +      {
 +      ui_file_put (var_stream, ui_file_write_for_put, buf);
 +      push_user_expression (buf);
 +      }
 +
 +    write_macro_definitions (expr_block, expr_pc, buf);
 +
 +    /* The user expression has to be in its own scope, so that "extern"
 +       works properly.  Otherwise gcc thinks that the "extern"
 +       declaration is in the same scope as the declaration provided by
 +       gdb.  */
 +    if (m_instance->scope () != COMPILE_I_RAW_SCOPE)
 +      fputs_unfiltered ("{\n", buf);
 +
 +    fputs_unfiltered ("#line 1 \"gdb command line\"\n", buf);
 +
 +    add_input (m_instance->scope (), input, buf);
 +
 +    /* For larger user expressions the automatic semicolons may be
 +       confusing.  */
 +    if (strchr (input, '\n') == NULL)
 +      fputs_unfiltered (";\n", buf);
  
 -  fputs_unfiltered ("\n", buf);
 +    if (m_instance->scope () != COMPILE_I_RAW_SCOPE)
 +      fputs_unfiltered ("}\n", buf);
 +
 +    if (m_instance->scope () == COMPILE_I_SIMPLE_SCOPE
 +      || m_instance->scope () == COMPILE_I_PRINT_ADDRESS_SCOPE
 +      || m_instance->scope () == COMPILE_I_PRINT_VALUE_SCOPE)
 +      pop_user_expression (buf);
 +
 +    add_code_footer (m_instance->scope (), buf);
-     char *code = ui_file_xstrdup (buf, NULL);
++    std::string code = ui_file_as_string (buf);
 +    do_cleanups (cleanup);
 +    return code;
 +  }
 +
 +private:
 +
 +  /* The compile instance to be used for compilation and
 +     type-conversion.  */
 +  CompileInstanceType *m_instance;
 +
 +  /* The architecture to be used.  */
 +  struct gdbarch *m_arch;
 +};
  
 -  /* For larger user expressions the automatic semicolons may be
 -     confusing.  */
 -  if (strchr (input, '\n') == NULL)
 -    fputs_unfiltered (";\n", buf);
 +/* 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::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 la_compute_program method for C.  */
 +
- char *
++std::string
 +c_compute_program (struct 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);
 +  c_compile_program program (c_inst, gdbarch);
 +
 +  return program.compute (input, expr_block, expr_pc);
 +}
 +
 +/* The la_compute_program method for C++.  */
 +
- char *
++std::string
 +cplus_compute_program (struct compile_instance *inst,
 +                     const char *input,
 +                     struct gdbarch *gdbarch,
 +                     const struct block *expr_block,
 +                     CORE_ADDR expr_pc)
 +{
 +  using namespace compile;
  
 -  if (inst->scope != COMPILE_I_RAW_SCOPE)
 -    fputs_unfiltered ("}\n", buf);
 +  compile_cplus_instance *cplus_inst
 +    = static_cast<compile_cplus_instance *> (inst);
 +  cplus_compile_program program (cplus_inst, gdbarch);
  
 -  add_code_footer (inst->scope, buf);
 -  code = ui_file_as_string (buf);
 -  do_cleanups (cleanup);
 -  return code;
 +  return program.compute (input, expr_block, expr_pc);
  }
Simple merge
Simple merge
index 79775decf35d7ebaab2b12ad98b846525bc08670,4bf5bf926f8f90ea244a6dafd6b426639bf0ddf8..d883a46f944703db8eb024bd952ac4922047ba9b
@@@ -209,4 -108,73 +209,29 @@@ extern char *compile_register_name_mang
  extern int compile_register_name_demangle (struct gdbarch *gdbarch,
                                           const char *reg_name);
  
 -/* Convert a gdb type, TYPE, to a GCC type.  CONTEXT is used to do the
 -   actual conversion.  The new GCC type is returned.  */
 -
 -struct type;
 -extern gcc_type convert_type (struct compile_c_instance *context,
 -                            struct type *type);
 -
 -/* A callback suitable for use as the GCC C symbol oracle.  */
 -
 -extern gcc_c_oracle_function gcc_convert_symbol;
 -
 -/* A callback suitable for use as the GCC C address oracle.  */
 -
 -extern gcc_c_symbol_address_function gcc_symbol_address;
 -
 -/* Instantiate a GDB object holding state for the GCC context FE.  The
 -   new object is returned.  */
 -
 -extern struct compile_instance *new_compile_instance (struct gcc_c_context *fe);
 -
 -/* Emit code to compute the address for all the local variables in
 -   scope at PC in BLOCK.  Returns a malloc'd vector, indexed by gdb
 -   register number, where each element indicates if the corresponding
 -   register is needed to compute a local variable.  */
 -
 -extern unsigned char *generate_c_for_variable_locations
 -     (struct compile_c_instance *compiler,
 -      struct ui_file *stream,
 -      struct gdbarch *gdbarch,
 -      const struct block *block,
 -      CORE_ADDR pc);
 -
 -/* Get the GCC mode attribute value for a given type size.  */
 -
 -extern const char *c_get_mode_for_size (int size);
 -
 -/* Given a dynamic property, return an xmallocd name that is used to
 -   represent its size.  The result must be freed by the caller.  The
 -   contents of the resulting string will be the same each time for
 -   each call with the same argument.  */
 -
 -struct dynamic_prop;
 -extern char *c_get_range_decl_name (const struct dynamic_prop *prop);
 -
+ /* Type used to hold and pass around the source and object file names
+    to use for compilation.  */
+ 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)
+   {}
+   /* 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 *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;
+ };
  #endif /* GDB_COMPILE_INTERNAL_H */
Simple merge
Simple merge
index 154046f9e41dc0a01ebc3ffe794e859a896b3935,0ae212501fe9b7f5c022dbdf1506992a7f4eb9bb..63f54d3ddb0b463791ced83c1cf7c52bfb6abd7c
@@@ -544,35 -517,18 +543,35 @@@ compile_to_object (struct command_line 
    else
      error (_("Neither a simple expression, or a multi-line specified."));
  
-   code = current_language->la_compute_program (compiler, input, gdbarch,
-                                              expr_block, expr_pc);
-   make_cleanup (xfree, code);
+   std::string code
+     = current_language->la_compute_program (compiler, input, gdbarch,
+                                           expr_block, expr_pc);
    if (compile_debug)
-     fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code);
+     fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code.c_str ());
  
 -  os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
 -  arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
 +  if (compiler->version () >= GCC_FE_VERSION_1)
 +    compiler->set_verbose (compile_debug);
  
 -  /* Allow triplets with or without vendor set.  */
 -  triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
 -  make_cleanup (xfree, triplet_rx);
 +  if (compile_gcc[0] != 0)
 +    {
 +      if (compiler->version () < GCC_FE_VERSION_1)
 +      error (_("Command 'set compile-gcc' requires GCC version 6 or higher "
 +               "(libcc1 interface version 1 or higher)"));
 +
 +      compiler->set_driver_filename (compile_gcc);
 +    }
 +  else
 +    {
 +      const char *os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
 +      const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
 +
 +      /* Allow triplets with or without vendor set.  */
 +      triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
 +      make_cleanup (xfree, triplet_rx);
 +
 +      if (compiler->version () >= GCC_FE_VERSION_1)
 +      compiler->set_triplet_regexp (triplet_rx);
 +    }
  
    /* Set compiler command-line arguments.  */
    get_args (compiler, gdbarch, &argc, &argv);
  
    if (compile_debug)
      fprintf_unfiltered (gdb_stdlog, "source file produced: %s\n\n",
-                       source_file);
+                       fnames.source_file ());
  
    /* Call the compiler and start the compilation process.  */
-   compiler->set_source_file (source_file);
 -  compiler->fe->ops->set_source_file (compiler->fe, fnames.source_file ());
++  compiler->set_source_file (fnames.source_file ());
  
 -  if (!compiler->fe->ops->compile (compiler->fe, fnames.object_file (),
 -                                 compile_debug))
 +  if (compiler->version () >= GCC_FE_VERSION_1)
-     ok = compiler->compile (object_file);
++    ok = compiler->compile (fnames.object_file ());
 +  else
-     ok = compiler->compile (object_file, compile_debug);
++    ok = compiler->compile (fnames.object_file (), compile_debug);
 +  if (!ok)
      error (_("Compilation failed."));
  
    if (compile_debug)
diff --cc gdb/cp-abi.h
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc gdb/d-lang.c
Simple merge
diff --cc gdb/dbxread.c
index a84efa615b69d504688e70639663f8ba938a0ce0,e95d2287ff5e30bcde4c875f552cd28c0adc918b..712f0cdc06a357954bcc729f1b254fe44c7854fb
@@@ -2902,11 -2712,10 +2716,10 @@@ process_one_symbol (int type, int desc
        if (*name == '\000')
        break;
  
-       if (block_address_function_relative)
-       function_start_offset = 0;
+       function_start_offset = 0;
  
        start_stabs ();
 -      start_symtab (objfile, name, NULL, valu);
 +      start_symtab (objfile, name, NULL, valu, language);
        record_debugformat ("stabs");
        break;
  
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc gdb/f-lang.c
Simple merge
diff --cc gdb/gdbtypes.c
Simple merge
diff --cc gdb/gdbtypes.h
Simple merge
Simple merge
diff --cc gdb/go-lang.c
Simple merge
diff --cc gdb/jit.c
Simple merge
diff --cc gdb/language.c
Simple merge
diff --cc gdb/language.h
Simple merge
diff --cc gdb/linespec.c
index aa79f7339059f0259bcedafb83aa37e0adbe5c68,a538de7ab8c7e6b7614cf583a091e6a8ee1b4128..ac19636f0f8c3a9ffde70fe42e6b639e9b9f7414
@@@ -3475,15 -3265,13 +3475,13 @@@ static voi
  find_linespec_symbols (struct linespec_state *state,
                       VEC (symtab_ptr) *file_symtabs,
                       const char *name,
 -                     VEC (symbolp) **symbols,
 +                     VEC (block_symbol_d) **symbols,
                       VEC (bound_minimal_symbol_d) **minsyms)
  {
-   struct cleanup *cleanup;
-   char *canon;
+   demangle_result_storage demangle_storage;
+   std::string ada_lookup_storage;
    const char *lookup_name;
  
-   cleanup = demangle_for_lookup (name, state->language->la_language,
-                                &lookup_name);
    if (state->language->la_language == language_ada)
      {
        /* In Ada, the symbol lookups are performed using the encoded
    /* If we were unable to locate a symbol of the same name, try dividing
       the name into class and method names and searching the class and its
       baseclasses.  */
 -  if (VEC_empty (symbolp, *symbols)
 +  if (VEC_empty (block_symbol_d, *symbols)
        && VEC_empty (bound_minimal_symbol_d, *minsyms))
      {
-       char *klass, *method;
+       std::string klass, method;
        const char *last, *p, *scope_op;
 -      VEC (symbolp) *classes;
 +      VEC (block_symbol_d) *classes;
  
        /* See if we can find a scope operator and break this symbol
         name into namespaces${SCOPE_OPERATOR}class_name and method_name.  */
  
        /* Skip past the scope operator.  */
        last += strlen (scope_op);
-       method = XNEWVEC (char, strlen (last) + 1);
-       make_cleanup (xfree, method);
-       strcpy (method, last);
+       method = last;
  
        /* Find a list of classes named KLASS.  */
-       classes = lookup_prefix_sym (state, file_symtabs, klass);
-       make_cleanup (VEC_cleanup (block_symbol_d), &classes);
+       classes = lookup_prefix_sym (state, file_symtabs, klass.c_str ());
+       struct cleanup *old_chain
 -      = make_cleanup (VEC_cleanup (symbolp), &classes);
++      = make_cleanup (VEC_cleanup (block_symbol_d), &classes);
  
 -      if (!VEC_empty (symbolp, classes))
 +      if (!VEC_empty (block_symbol_d, classes))
        {
          /* Now locate a list of suitable methods named METHOD.  */
          TRY
diff --cc gdb/linespec.h
Simple merge
diff --cc gdb/m2-lang.c
Simple merge
Simple merge
diff --cc gdb/minsyms.h
Simple merge
diff --cc gdb/objc-lang.c
Simple merge
Simple merge
diff --cc gdb/p-lang.c
Simple merge
diff --cc gdb/rust-lang.c
Simple merge
diff --cc gdb/stabsread.h
Simple merge
diff --cc gdb/symtab.c
Simple merge
diff --cc gdb/symtab.h
Simple merge
index 10d0178a8a103ad43a56abfbfa0dfa32e09d471f,42213944405b686f726ae8c884f1aef794f8b6b7..3870e10a752a716da9a4dd7f7390e9dc94ee44d2
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 +load_lib compiler-support.exp
 +
  standard_testfile
  
- if { [prepare_for_testing ${testfile}.exp "$testfile"] } {
+ if { [prepare_for_testing "failed to prepare" "$testfile"] } {
      return -1
  }
  
index a6259246b72f3f30abe8c99a0943654e0fd48b3a,3692d6815c4086a972185f42741611edeee65b04..031551e73359be889b368b42eda6b6563addffaa
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 +load_lib compiler-support.exp
 +
  standard_testfile .c compile-setjmp-mod.c
  
- if { [prepare_for_testing ${testfile}.exp $testfile] } {
+ if { [prepare_for_testing "failed to prepare" $testfile] } {
      return -1
  }
  
Simple merge
Simple merge
diff --cc gdb/typeprint.c
Simple merge
diff --cc gdb/valops.c
Simple merge
diff --cc gdb/xcoffread.c
Simple merge
Simple merge
Simple merge
Simple merge