From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DEDA03857727 for ; Sat, 13 May 2023 17:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEDA03857727 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683999024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KA/k32+CPxpo65YOZAn5+gv0gXye0UfbiyV4X+8LggI=; b=CaZfDEi/1Q/u9IOXUNuLuXbb1DCGMtBF+q5TSIeUOgPo0eLLkezeDa338359pEoH2dYDuh crYolXxF3sy2fD6jACcv7O3qulQcOxQsgTQv1215lCCywHXf+BL4O17vhLja1pmiq1YpmJ iyN2xVpOLdCzPIVkDWAJG1WTmHUfxAA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-iV6Jl-9gNJyQSdBF8v_g-w-1; Sat, 13 May 2023 13:30:23 -0400 X-MC-Unique: iV6Jl-9gNJyQSdBF8v_g-w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA722185A790; Sat, 13 May 2023 17:30:22 +0000 (UTC) Received: from [10.22.9.236] (unknown [10.22.9.236]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD29448FB13; Sat, 13 May 2023 17:30:22 +0000 (UTC) Message-ID: <8f642a5b-7144-5cca-5566-a1dadc9e93fc@redhat.com> Date: Sat, 13 May 2023 10:30:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] Fix bad interaction between element limit and repeated values (BZ#24331). To: Paul Pluzhnikov , gdb-patches@sourceware.org References: <20230508012211.3770553-1-ppluzhnikov@google.com> From: Keith Seitz In-Reply-To: <20230508012211.3770553-1-ppluzhnikov@google.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On 5/7/23 18:22, Paul Pluzhnikov via Gdb-patches wrote: > Currently > > print -elements=3 -- "AAAAAA" > > prints complete string, which is not what the user asked for. > > Fix two buggy tests exposed by the fix, and add a new test. Thank you for the patch. I just have one small ask. > diff --git a/gdb/valprint.c b/gdb/valprint.c > index b05d90dd26b..b770c93d805 100644 > --- a/gdb/valprint.c > +++ b/gdb/valprint.c > @@ -2363,16 +2363,19 @@ print_converted_chars_to_obstack (struct obstack *obstack, > const std::vector &chars, > int quote_char, int width, > enum bfd_endian byte_order, > - const struct value_print_options *options) > + const struct value_print_options *options, > + int *finished) The comment preceding this function explains the meaning of all of its arguments. Please add `finished', too. > { > - unsigned int idx; > + unsigned int idx, num_elements; > const converted_character *elem; > enum {START, SINGLE, REPEAT, INCOMPLETE, FINISH} state, last; > gdb_wchar_t wide_quote_char = gdb_btowc (quote_char); > bool need_escape = false; > + const int print_max = options->print_max_chars > 0 > + ? options->print_max_chars : options->print_max; > > /* Set the start state. */ > - idx = 0; > + idx = num_elements = 0; > last = state = START; > elem = NULL; > Otherwise LGTM. Reviewed-by: Keith Seitz Keith