--- gdb-6.4.old/gdb/p-valprint.c 2005-05-09 17:20:34.000000000 -0400 +++ gdb-6.4/gdb/p-valprint.c 2006-04-03 13:32:41.000000000 -0400 @@ -63,10 +63,10 @@ int recurse, enum val_prettyprint pretty) { unsigned int i = 0; /* Number of characters printed */ - unsigned len; + unsigned len, capacity; struct type *elttype; unsigned eltlen; - int length_pos, length_size, string_pos; + int length_pos, length_size, capacity_pos, capacity_size, string_pos; int char_size; LONGEST val; CORE_ADDR addr; @@ -193,7 +193,7 @@ as GDB does not recognize stabs pascal strings Pascal strings are mapped to records with lowercase names PM */ - if (is_pascal_string_type (elttype, &length_pos, &length_size, + if (is_pascal_string_type (elttype, &length_pos, &length_size, &capacity_pos, &capacity_size, &string_pos, &char_size, NULL) && addr != 0) { @@ -320,10 +320,16 @@ } else { - if (is_pascal_string_type (type, &length_pos, &length_size, + if (is_pascal_string_type (type, &length_pos, &length_size, &capacity_pos, &capacity_size, &string_pos, &char_size, NULL)) { len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size); + capacity = extract_unsigned_integer (valaddr + embedded_offset, length_size); + if ((len < 0) || (len > capacity)) + { + len = capacity; + } + LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0); } else