From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18224 invoked by alias); 4 Apr 2017 18:57:05 -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 18117 invoked by uid 89); 4 Apr 2017 18:57:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Apr 2017 18:57:02 +0000 Received: by mail-wr0-f172.google.com with SMTP id w11so219857959wrc.3 for ; Tue, 04 Apr 2017 11:57:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=bulxSjYbNHFbvQ6CBXNfCwkzJPY5XwC7RTCElqeUs4k=; b=nSAQqiQGETENpVSLYvEvCdcLk/80SZafq+E3c0q12Ww6vin8JcrPP6P+eZJ1v1Nq+S ygBsdL/3vEK9kqI7RvmR956NIfXRXg7KOQbcbeBk7oh+42tdJQt+OyQTQGYPsV28Cxjp fRaC5qRftA53PweBrRoD8VRgJnIt8uGPuMQgv/ararBRXagaS2v8X6PZNE74gVp2wRDD 1s9vm637N6nhUYSJzsfVClPSYQExVS521J7xKW9MRvyeisTh7S/8qax0OYw2fJI7ONzy 7XmLmi5MNwS0Bgs0mvX18bln0zxhgBTTazBOvPQp5h8dVTEHkQdGgeFvateE2IyMxUKK Mx1Q== X-Gm-Message-State: AFeK/H0c8eegb2fLJ4yUkSVcC4+T2BVVz3VlpksCxHJFf06AM34MJiF6QCJLrJ7uGkMkTo2F X-Received: by 10.223.153.233 with SMTP id y96mr3735282wrb.96.1491332221724; Tue, 04 Apr 2017 11:57:01 -0700 (PDT) Received: from [192.168.43.236] ([95.69.91.145]) by smtp.gmail.com with ESMTPSA id j32sm23238458wre.7.2017.04.04.11.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 11:57:00 -0700 (PDT) Subject: Re: [PATCH 1/5] dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr To: Simon Marchi References: <1490754298-9455-1-git-send-email-palves@redhat.com> <1490754298-9455-2-git-send-email-palves@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <43dc3793-10e5-4a4b-8983-f5f18b2c6388@redhat.com> Date: Tue, 04 Apr 2017 18:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00062.txt.bz2 On 03/29/2017 04:06 PM, Simon Marchi wrote: >> -/* Add an entry to LH's include directory table. */ >> - >> -static void >> -add_include_dir (struct line_header *lh, const char *include_dir) >> +void >> +line_header::add_include_dir (const char *include_dir) >> { >> if (dwarf_line_debug >= 2) >> fprintf_unfiltered (gdb_stdlog, "Adding dir %u: %s\n", >> - lh->num_include_dirs + 1, include_dir); >> + (unsigned) include_dirs.size () + 1, include_dir); > > Can you use %zu for these? Hmm, we didn't use to because that would require a C99 runtime. C++11 is rebased on top of C99, but that doesn't mean that in practice you're using a C++11 compiler with a fully conforming C library. E.g., mingw+msvrt doesn't support it. However, I think that gnulib enables __USE_MINGW_ANSI_STDIO, so it should work there. I don't know about other systems, but it's likely to be safe to use it nowadays. In any case, we can always throw more gnulib at the problem. There's a printf module that AFAICS supports '%z'. I'll push with that change. > >> @@ -17952,11 +17890,22 @@ dwarf_decode_line_header (unsigned int >> offset, struct dwarf2_cu *cu) >> if (lh->version >= 5) >> { >> /* Read directory table. */ >> - read_formatted_entries (abfd, &line_ptr, lh, &cu->header, >> - add_include_dir_stub); >> + read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header, >> + [] (struct line_header *lh, const char *name, >> + unsigned int dir_index, unsigned int mod_time, >> + unsigned int length) >> + { >> + lh->add_include_dir (name); >> + }); >> >> /* Read file name table. */ >> - read_formatted_entries (abfd, &line_ptr, lh, &cu->header, >> add_file_name); >> + read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header, >> + [] (struct line_header *lh, const char *name, >> + unsigned int dir_index, unsigned int mod_time, >> + unsigned int length) >> + { >> + lh->add_file_name (name, dir_index, mod_time, length); >> + }); > > We can do it afterwards to avoid adding noise to this patch, but I > noticed that if we captured lh in the lambda, we could avoid passing the > line_header in read_formatted_entries and the callback. Yeah, that'd require switching to use gdb::function_view though, because otherwise you can't pass a lambda with a capture. > I took a quick look, it looks good to me. Thanks!