From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.46.107]) by sourceware.org (Postfix) with ESMTPS id BF3DC385E021 for ; Sun, 22 Mar 2020 18:45:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF3DC385E021 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway20.websitewelcome.com (Postfix) with ESMTP id CE114400C554D for ; Sun, 22 Mar 2020 12:29:49 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id G5bDjE0gCSl8qG5bDjm0xn; Sun, 22 Mar 2020 13:45:27 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kYQrW+hV/PF8syAycaX5lIZFeBHUaD/PGApqTWI6A78=; b=vW+lzcGhbXCI9O/gqY5ThUHQBy rFBh3Jp7Z2ROSqdk+QeUUIQko3d6fTlj1ze7EsBaTJzn/NFyay2P1bYI0zrAfLSsKtgdJZAihyUfy +nbWl04h/iMEx7di7QFKAfa1s; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:48304 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jG5bD-000LNS-8k; Sun, 22 Mar 2020 12:45:27 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/22] Make some line_header methods const Date: Sun, 22 Mar 2020 12:45:10 -0600 Message-Id: <20200322184523.28959-10-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200322184523.28959-1-tom@tromey.com> References: <20200322184523.28959-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.117.21 X-Source-L: No X-Exim-ID: 1jG5bD-000LNS-8k X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:48304 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-23.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2020 18:45:29 -0000 This changes a few line_header methods to be const. In some cases, a const overload is added. gdb/ChangeLog 2020-03-22 Tom Tromey * dwarf2/line-header.h (struct line_header) : Use const. : Add const overload. * dwarf2/line-header.c (line_header::file_file_name) (line_header::file_full_name): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/line-header.c | 4 ++-- gdb/dwarf2/line-header.h | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index 56dfb5c2dd2..f417f2d0fae 100644 --- a/gdb/dwarf2/line-header.c +++ b/gdb/dwarf2/line-header.c @@ -59,7 +59,7 @@ line_header::add_file_name (const char *name, } gdb::unique_xmalloc_ptr -line_header::file_file_name (int file) +line_header::file_file_name (int file) const { /* Is the file number a valid index into the line header's file name table? Remember that file numbers start with one, not zero. */ @@ -95,7 +95,7 @@ line_header::file_file_name (int file) } gdb::unique_xmalloc_ptr -line_header::file_full_name (int file, const char *comp_dir) +line_header::file_full_name (int file, const char *comp_dir) const { /* Is the file number a valid index into the line header's file name table? Remember that file numbers start with one, not zero. */ diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h index 08cf7b0810f..30bc37fb85a 100644 --- a/gdb/dwarf2/line-header.h +++ b/gdb/dwarf2/line-header.h @@ -96,7 +96,7 @@ struct line_header return m_include_dirs[vec_index]; } - bool is_valid_file_index (int file_index) + bool is_valid_file_index (int file_index) const { if (version >= 5) return 0 <= file_index && file_index < file_names_size (); @@ -117,11 +117,21 @@ struct line_header return &m_file_names[vec_index]; } + /* A const overload of the same. */ + const file_entry *file_name_at (file_name_index index) const + { + line_header *lh = const_cast (this); + return lh->file_name_at (index); + } + /* The indexes are 0-based in DWARF 5 and 1-based in DWARF 4. Therefore, this method should only be used to iterate through all file entries in an index-agnostic manner. */ std::vector &file_names () { return m_file_names; } + /* A const overload of the same. */ + const std::vector &file_names () const + { return m_file_names; } /* Offset of line number information in .debug_line section. */ sect_offset sect_off {}; @@ -145,7 +155,7 @@ struct line_header element is standard_opcode_lengths[opcode_base - 1]. */ std::unique_ptr standard_opcode_lengths; - int file_names_size () + int file_names_size () const { return m_file_names.size(); } /* The start and end of the statement program following this @@ -157,13 +167,13 @@ struct line_header compilation. The result is allocated using xmalloc; the caller is responsible for freeing it. */ gdb::unique_xmalloc_ptr file_full_name (int file, - const char *comp_dir); + const char *comp_dir) const; /* Return file name relative to the compilation directory of file number I in this object's file name table. The result is allocated using xmalloc; the caller is responsible for freeing it. */ - gdb::unique_xmalloc_ptr file_file_name (int file); + gdb::unique_xmalloc_ptr file_file_name (int file) const; private: /* The include_directories table. Note these are observing -- 2.17.2