daily update
[deliverable/binutils-gdb.git] / gdb / p-valprint.c
index 0a32a22b6072c2ede724f80f5cff6ecdcac48b31..9f4461723d986de86694a9e3badfeba7f2dbbecd 100644 (file)
@@ -72,8 +72,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
   unsigned eltlen;
   int length_pos, length_size, string_pos;
   struct type *char_type;
-  LONGEST val;
   CORE_ADDR addr;
+  int want_space = 0;
 
   CHECK_TYPEDEF (type);
   switch (TYPE_CODE (type))
@@ -176,6 +176,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       if (options->addressprint && options->format != 's')
        {
          fputs_filtered (paddress (gdbarch, addr), stream);
+         want_space = 1;
        }
 
       /* For a pointer to char or unsigned char, also print the string
@@ -188,6 +189,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
          && (options->format == 0 || options->format == 's')
          && addr != 0)
        {
+         if (want_space)
+           fputs_filtered (" ", stream);
          /* No wide string yet.  */
          i = val_print_string (elttype, NULL, addr, -1, stream, options);
        }
@@ -203,6 +206,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
          ULONGEST string_length;
          void *buffer;
 
+         if (want_space)
+           fputs_filtered (" ", stream);
          buffer = xmalloc (length_size);
          read_memory (addr + length_pos, buffer, length_size);
          string_length = extract_unsigned_integer (buffer, length_size,
@@ -220,12 +225,17 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
          struct minimal_symbol *msymbol =
            lookup_minimal_symbol_by_pc (vt_address);
 
-         if ((msymbol != NULL)
+         /* If 'symbol_print' is set, we did the work above.  */
+         if (!options->symbol_print
+             && (msymbol != NULL)
              && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
            {
-             fputs_filtered (" <", stream);
+             if (want_space)
+               fputs_filtered (" ", stream);
+             fputs_filtered ("<", stream);
              fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
              fputs_filtered (">", stream);
+             want_space = 1;
            }
          if (vt_address && options->vtblprint)
            {
@@ -235,6 +245,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
              struct block *block = (struct block *) NULL;
              int is_this_fld;
 
+             if (want_space)
+               fputs_filtered (" ", stream);
+
              if (msymbol != NULL)
                wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol), block,
                                      VAR_DOMAIN, &is_this_fld);
@@ -784,8 +797,11 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
          if (boffset < 0 || boffset >= TYPE_LENGTH (type))
            {
-             /* FIXME (alloc): not safe is baseclass is really really big. */
-             gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
+             gdb_byte *buf;
+             struct cleanup *back_to;
+
+             buf = xmalloc (TYPE_LENGTH (baseclass));
+             back_to = make_cleanup (xfree, buf);
 
              base_valaddr = buf;
              if (target_read_memory (address + boffset, buf,
@@ -794,6 +810,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
              address = address + boffset;
              thisoffset = 0;
              boffset = 0;
+             do_cleanups (back_to);
            }
          else
            base_valaddr = valaddr;
This page took 0.02567 seconds and 4 git commands to generate.