From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122223 invoked by alias); 12 Jun 2017 19:40:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 120092 invoked by uid 89); 12 Jun 2017 19:40:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 19:40:14 +0000 Received: by simark.ca (Postfix, from userid 33) id E38351E5A3; Mon, 12 Jun 2017 15:40:16 -0400 (EDT) To: Andreas Arnez Subject: Re: [PATCH v2 14/19] read/write_pieced_value: Improve logic for buffer allocation X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 12 Jun 2017 19:40:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org In-Reply-To: <1494352015-10465-15-git-send-email-arnez@linux.vnet.ibm.com> References: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> <1494352015-10465-15-git-send-email-arnez@linux.vnet.ibm.com> Message-ID: <6078d216d5112c69d697f7e7a1c53012@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00354.txt.bz2 On 2017-05-09 19:46, Andreas Arnez wrote: > @@ -2045,21 +2022,44 @@ write_pieced_value (struct value *to, struct > value *from) > } > break; > case DWARF_VALUE_MEMORY: > - if (need_bitwise) > - { > - /* Only the first and last bytes can possibly have any > - bits reused. */ > - read_memory (p->v.mem.addr + dest_offset, buffer.data (), 1); > - read_memory (p->v.mem.addr + dest_offset + this_size - 1, > - &buffer[this_size - 1], 1); > - copy_bitwise (buffer.data (), dest_offset_bits % 8, > - contents, source_offset_bits, > - this_size_bits, > - bits_big_endian); > - } > + { > + CORE_ADDR start_addr = p->v.mem.addr + dest_offset_bits / 8; > > - write_memory (p->v.mem.addr + dest_offset, > - source_buffer, this_size); > + if (dest_offset_bits % 8 == 0 && this_size_bits % 8 == 0 > + && source_offset_bits % 8 == 0) > + { > + /* Everything is byte-aligned; no buffer needed. */ > + write_memory (start_addr, > + contents + source_offset_bits / 8, > + this_size_bits / 8); > + break; > + } > + > + this_size = bits_to_bytes (dest_offset_bits, this_size_bits); > + buffer.reserve (this_size); Reading Pedro's patch about byte_vector: https://sourceware.org/ml/gdb-patches/2017-06/msg00339.html reminded me of this, when I read the patch I didn't think it was a problem. I think this should use resize instead of reserve. Simon