diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 0e0de2e..39f6d1d 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -218,7 +218,10 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string, /* If the string was not truncated due to `set print elements', and the last byte of it is a null, we don't print that, in traditional C style. */ - if ((!force_ellipses) && length > 0 && string[length - 1] == '\0') + if (!force_ellipses + && length > 0 + && (extract_unsigned_integer (string + (length - 1) * width, width) + == '\0')) length--; if (length == 0) @@ -234,6 +237,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string, unsigned int rep1; /* Number of repetitions we have detected so far. */ unsigned int reps; + unsigned long current_char; QUIT; @@ -243,9 +247,13 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string, need_comma = 0; } + current_char = extract_unsigned_integer (string + i * width, width); + rep1 = i + 1; reps = 1; - while (rep1 < length && string[rep1] == string[i]) + while (rep1 < length + && extract_unsigned_integer (string + rep1 * width, width) + == current_char) { ++rep1; ++reps; @@ -262,15 +270,14 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string, in_quotes = 0; } pascal_printchar (string[i], stream); - fprintf_filtered (stream, " ", reps); + fprintf_filtered (stream, _(" "), reps); i = rep1 - 1; things_printed += options->repeat_count_threshold; need_comma = 1; } else { - int c = string[i]; - if ((!in_quotes) && (PRINT_LITERAL_FORM (c))) + if ((!in_quotes) && (PRINT_LITERAL_FORM (current_char))) { if (options->inspect_it) fputs_filtered ("\\'", stream); @@ -278,7 +285,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string, fputs_filtered ("'", stream); in_quotes = 1; } - pascal_one_char (c, stream, &in_quotes); + pascal_one_char (current_char, stream, &in_quotes); ++things_printed; } } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 9b1b7ff..3e3b688 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -79,10 +79,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, print_spaces_filtered (2 + 2 * recurse, stream); } /* For an array of chars, print with string syntax. */ - if (eltlen == 1 - && ((TYPE_CODE (elttype) == TYPE_CODE_INT) - || ((current_language->la_language == language_pascal) - && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) + if (TYPE_CODE (elttype) == TYPE_CODE_CHAR && (options->format == 0 || options->format == 's')) { /* If requested, look for the first null char and only print @@ -99,7 +96,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, len = temp_len; } - LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0, + LA_PRINT_STRING (stream, valaddr + embedded_offset, len, TYPE_LENGTH (elttype), 0, options); i = len; } @@ -165,14 +162,11 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ - if (TYPE_LENGTH (elttype) == 1 - && (TYPE_CODE (elttype) == TYPE_CODE_INT - || TYPE_CODE(elttype) == TYPE_CODE_CHAR) + if (TYPE_CODE(elttype) == TYPE_CODE_CHAR && (options->format == 0 || options->format == 's') && addr != 0) { - /* no wide string yet */ - i = val_print_string (addr, -1, 1, stream, options); + i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options); } /* also for pointers to pascal strings */ /* Note: this is Free Pascal specific: