Fix regresssion(internal-error) printing subprogram argument (PR gdb/22670)
[deliverable/binutils-gdb.git] / gdb / p-valprint.c
index 1cd69cc2b111ec83cbd5c2e774d55c06f0c173c2..933dbfb6c4d0b8a39c1d208183a82acc7c28a8a0 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing Pascal values for GDB, the GNU debugger.
 
-   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   Copyright (C) 2000-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,6 +38,7 @@
 #include "cp-abi.h"
 #include "cp-support.h"
 #include "objfiles.h"
+#include "common/byte-vector.h"
 \f
 
 /* Decorations for Pascal.  */
@@ -245,15 +246,17 @@ pascal_val_print (struct type *type,
              struct symbol *wsym = NULL;
              struct type *wtype;
              struct block *block = NULL;
-             struct field_of_this_result is_this_fld;
 
              if (want_space)
                fputs_filtered (" ", stream);
 
              if (msymbol.minsym != NULL)
-               wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME (msymbol.minsym),
-                                     block,
-                                     VAR_DOMAIN, &is_this_fld).symbol;
+               {
+                 const char *search_name
+                   = MSYMBOL_SEARCH_NAME (msymbol.minsym);
+                 wsym = lookup_symbol_search_name (search_name, block,
+                                                   VAR_DOMAIN).symbol;
+               }
 
              if (wsym)
                {
@@ -730,6 +733,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
       const gdb_byte *base_valaddr = NULL;
       LONGEST thisoffset;
       int skip = 0;
+      gdb::byte_vector buf;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
        {
@@ -769,20 +773,15 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
          if (boffset < 0 || boffset >= TYPE_LENGTH (type))
            {
-             gdb_byte *buf;
-             struct cleanup *back_to;
-
-             buf = (gdb_byte *) xmalloc (TYPE_LENGTH (baseclass));
-             back_to = make_cleanup (xfree, buf);
+             buf.resize (TYPE_LENGTH (baseclass));
 
-             base_valaddr = buf;
-             if (target_read_memory (address + boffset, buf,
+             base_valaddr = buf.data ();
+             if (target_read_memory (address + boffset, buf.data (),
                                      TYPE_LENGTH (baseclass)) != 0)
                skip = 1;
              address = address + boffset;
              thisoffset = 0;
              boffset = 0;
-             do_cleanups (back_to);
            }
          else
            base_valaddr = valaddr;
This page took 0.036325 seconds and 4 git commands to generate.