From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15694 invoked by alias); 27 Jan 2020 13:31:34 -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 15411 invoked by uid 89); 27 Jan 2020 13:31:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-29.3 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy=HX-Received:ed08, observing, H*c:alternative, HX-Spam-Relays-External:209.85.167.194 X-HELO: mail-oi1-f194.google.com Received: from mail-oi1-f194.google.com (HELO mail-oi1-f194.google.com) (209.85.167.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Jan 2020 13:31:28 +0000 Received: by mail-oi1-f194.google.com with SMTP id a142so5027075oii.7 for ; Mon, 27 Jan 2020 05:31:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gSK5fKXm38rOrWZ7joM8835QU0mYPll8QWui7W03ITE=; b=WVhSEEiX+PUYhTuELqX5OnOwS7z7KykRiBZ4VmvC/9HF/tOv9AiauFIT8eT1J0mD7s hv6WiqSEiTkV3rYUbj+I5Fm6Khi7DHswkSRu0o1ZiYrsGx4xYQFjKG1euwnspSgHx07Y OzFz5RT4SYToE9CnIYRCESZ0ydx8G4S40u3isxosARdLLCgi1f7mREoxFMy+b4KWC79r wusrUbroobfpu1UbQQL2EO1uWUcgf8s+3geLiqOZ17QXDtNryWtprim9ovjzDmqVh1oS G6QHs72E2TSLv7qlP1V0cPYcJ6vBAnis1T9CGVf+HTHFNl2GBmPxjFH37A6YxH/D4bCG YOmQ== MIME-Version: 1.0 References: <20200123005710.7978-1-tom@tromey.com> <20200123005710.7978-26-tom@tromey.com> In-Reply-To: <20200123005710.7978-26-tom@tromey.com> From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Mon, 27 Jan 2020 13:31:00 -0000 Message-ID: Subject: Re: [PATCH 25/38] Change file_full_name and file_file_name methods To: Tom Tromey Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00880.txt.bz2 On Thu, Jan 23, 2020, 01:59 Tom Tromey wrote: > This changes file_full_name and file_file_name methods to be methods > on line_header. This seems more clear to me. > > 2020-01-22 Tom Tromey > > * dwarf2/read.c (struct line_header) file_file_name>: Declare methods. > (dw2_get_file_names_reader): Update. > (file_file_name): Now a method. > (file_full_name): Likewise. > (macro_start_file): Update. > > Change-Id: I50d3e91665a9637c732e1e8d8e4263764c766d9c > --- > gdb/ChangeLog | 9 +++++++++ > gdb/dwarf2/read.c | 47 ++++++++++++++++++++++++----------------------- > 2 files changed, 33 insertions(+), 23 deletions(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index c230778980e..153faac8238 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -1074,6 +1074,18 @@ struct line_header > header. These point into dwarf2_per_objfile->line_buffer. */ > const gdb_byte *statement_program_start {}, *statement_program_end {}; > > + /* Return the full name of file number I in this object's file name > I -> FILE, I think. + table. Use COMP_DIR as the name of the current directory of the > + compilation. The result is allocated using xmalloc; the caller > + is responsible for freeing it. */ > + char *file_full_name (int file, const char *comp_dir); > + > + /* Return file name relative to the compilation directory of file > + number I in this object's file name table. The result is > Same + allocated using xmalloc; the caller is responsible for freeing > + it. */ > + char *file_file_name (int file); > + > private: > /* The include_directories table. Note these are observing > pointers. The memory is owned by debug_line_buffer. */ > @@ -1860,9 +1872,6 @@ struct file_and_directory > static file_and_directory find_file_and_directory (struct die_info *die, > struct dwarf2_cu *cu); > > -static char *file_full_name (int file, struct line_header *lh, > - const char *comp_dir); > - > /* Expected enum dwarf_unit_type for read_comp_unit_head. */ > enum class rcuh_kind { COMPILE, TYPE }; > > @@ -3401,7 +3410,7 @@ dw2_get_file_names_reader (const struct > die_reader_specs *reader, > if (offset != 0) > qfn->file_names[0] = xstrdup (fnd.name); > for (int i = 0; i < lh->file_names_size (); ++i) > - qfn->file_names[i + offset] = file_full_name (i + 1, lh.get (), > fnd.comp_dir); > + qfn->file_names[i + offset] = lh->file_full_name (i + 1, > fnd.comp_dir); > qfn->real_names = NULL; > > lh_cu->v.quick->file_names = qfn; > @@ -23788,22 +23797,18 @@ dwarf_alloc_die (struct dwarf2_cu *cu, int > num_attrs) > > /* Macro support. */ > > -/* Return file name relative to the compilation directory of file number > I in > - *LH's file name table. The result is allocated using xmalloc; the > caller is > - responsible for freeing it. */ > - > -static char * > -file_file_name (int file, struct line_header *lh) > +char * > +line_header::file_file_name (int file) > { > /* Is the file number a valid index into the line header's file name > table? Remember that file numbers start with one, not zero. */ > - if (lh->is_valid_file_index (file)) > + if (is_valid_file_index (file)) > { > - const file_entry *fe = lh->file_name_at (file); > + const file_entry *fe = file_name_at (file); > > if (!IS_ABSOLUTE_PATH (fe->name)) > { > - const char *dir = fe->include_dir (lh); > + const char *dir = fe->include_dir (this); > if (dir != NULL) > return concat (dir, SLASH_STRING, fe->name, (char *) NULL); > } > @@ -23826,18 +23831,14 @@ file_file_name (int file, struct line_header *lh) > } > } > > -/* Return the full name of file number I in *LH's file name table. > - Use COMP_DIR as the name of the current directory of the > - compilation. The result is allocated using xmalloc; the caller is > - responsible for freeing it. */ > -static char * > -file_full_name (int file, struct line_header *lh, const char *comp_dir) > +char * > +line_header::file_full_name (int file, const char *comp_dir) > { > /* Is the file number a valid index into the line header's file name > table? Remember that file numbers start with one, not zero. */ > - if (lh->is_valid_file_index (file)) > + if (is_valid_file_index (file)) > { > - char *relative = file_file_name (file, lh); > + char *relative = file_file_name (file); > > if (IS_ABSOLUTE_PATH (relative) || comp_dir == NULL) > return relative; > @@ -23845,7 +23846,7 @@ file_full_name (int file, struct line_header *lh, > const char *comp_dir) > relative, (char *) NULL); > } > else > - return file_file_name (file, lh); > + return file_file_name (file); > } > > > @@ -23856,7 +23857,7 @@ macro_start_file (struct dwarf2_cu *cu, > struct line_header *lh) > { > /* File name relative to the compilation directory of this source > file. */ > - char *file_name = file_file_name (file, lh); > + char *file_name = lh->file_file_name (file); > > if (! current_file) > { > -- > 2.17.2 > >