diff options
author | Keith Seitz <keiths@redhat.com> | 2012-11-10 20:18:58 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2012-11-10 20:18:58 +0000 |
commit | 6cad06895668ad73b91161fc2c95f0b113bdb898 (patch) | |
tree | 0af4ae7e2b701d9a760f26f600ef5b5eb77b96d5 /gdb/c-valprint.c | |
parent | e3fa7da3f6f27b5da85c1f906f5f88cd73d3f1d9 (diff) | |
download | gdb-6cad06895668ad73b91161fc2c95f0b113bdb898.tar.gz |
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 7a1bb02be63..dada9e2ac2c 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 |