From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 838 invoked by alias); 15 Sep 2009 13:29:44 -0000 Received: (qmail 800 invoked by uid 48); 15 Sep 2009 13:29:44 -0000 Date: Tue, 15 Sep 2009 13:29:00 -0000 Message-ID: <20090915132944.794.qmail@sourceware.org> From: "pmuldoon at redhat dot com" To: gdb-prs@sourceware.org In-Reply-To: <20090912003708.10633.ppluzhnikov@google.com> References: <20090912003708.10633.ppluzhnikov@google.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug python/10633] std::string pretty printer should respect 'print elements' limit X-Bugzilla-Reason: CC Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00251.txt.bz2 ------- Additional Comments From pmuldoon at redhat dot com 2009-09-15 13:29 ------- After looking at this again this afternoon, looks like this is a bug in c-lang.c:c_printstr after all. Attempt 3 .. ;) I'm not sure why val_print pre-sized the string to conform with print_max before passing it to LA_PRINT_STRING, but it just happened to do so. Anyway, not so important. But from reading the code LA_PRINT_STRING should respect print_max in all cases. So cases like print_string_repr which do not do any form of pre-size check with print_max can happily rely on LA_PRINT_STRING to enforce it. In the current code's case, the code has two loops. One outer which does gate on print_max, and one inner which doesn't. So the inner loop races past the check, as far as I can tell. I added a check to the inner loop, and this prints string to the print_max size, and does the right thing with ellipses too. It passes all tests in the testsuite. git diff c-lang.c diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 83a7382..515685a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -459,7 +459,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string, single character in isolation. This makes the code simpler and probably does the sensible thing in the majority of cases. */ - while (num_chars == 1) + while (num_chars == 1 && things_printed < options->print_max) { /* Count the number of repetitions. */ unsigned int reps = 0; -- http://sourceware.org/bugzilla/show_bug.cgi?id=10633 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.