diff options
author | Keith Seitz <keiths@redhat.com> | 2012-11-10 20:19:01 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2012-11-10 20:19:01 +0000 |
commit | 0d63ecdad04d410698c905283d095505680ba907 (patch) | |
tree | 3f894b47be2cfef2d36d71ffb1cb4d33717bd9b7 /gdb/c-valprint.c | |
parent | 9b8d6827200e1b04d3ca860ce52472655e84248c (diff) | |
download | gdb-0d63ecdad04d410698c905283d095505680ba907.zip gdb-0d63ecdad04d410698c905283d095505680ba907.tar.gz gdb-0d63ecdad04d410698c905283d095505680ba907.tar.bz2 |
PR gdb/14288
* c-valprint.c (c_val_print): For character arrays
with "print null" option on, print ellipses if
the output is truncated and the next character is not \000.
* valprint.c (MAX_WCHARS): Define.
(WCHAR_BUFLEN): Likewise.
(WCHAR_BUFLEN_MAX): Likewise.
(struct converted_character): New structure.
(count_next_character): New function.
(print_converted_chars_to_obstack): New function.
(generic_printstr): Rewrite using count_next_character
and print_converted_chars_to_obstack.
* gdb.base/printcmds.c: Add invalid_XXX globals
for repeated byte tests.
* gdb.base/printcmds.exp (test_repeat_bytes): New procedure.
* gdb.base/wchar.c (main): Add and construct a wchar_t
array with repeated characters.
* gdb.base/wchar.exp: Add repeated character tests.
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r-- | gdb/c-valprint.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 7a1bb02..dada9e2 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -177,6 +177,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) { + int force_ellipses = 0; + /* If requested, look for the first null char and only print elements up to it. */ if (options->stop_print_at_null) @@ -191,12 +193,26 @@ c_val_print (struct type *type, const gdb_byte *valaddr, eltlen, byte_order) != 0); ++temp_len) ; + + /* Force LA_PRINT_STRING to print ellipses if + we've printed the maximum characters and + the next character is not \000. */ + if (temp_len == options->print_max && temp_len < len) + { + ULONGEST val + = extract_unsigned_integer (valaddr + embedded_offset + + temp_len * eltlen, + eltlen, byte_order); + if (val != 0) + force_ellipses = 1; + } + len = temp_len; } LA_PRINT_STRING (stream, unresolved_elttype, valaddr + embedded_offset, len, - NULL, 0, options); + NULL, force_ellipses, options); i = len; } else |