From patchwork Mon Dec 29 16:15:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 127203 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7AA534BA2E04 for ; Mon, 29 Dec 2025 16:18:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AA534BA2E04 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XPy9/uT1 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 45CD14BA2E2F for ; Mon, 29 Dec 2025 16:15:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45CD14BA2E2F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 45CD14BA2E2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767024942; cv=none; b=H8cJ5lY5XDuQWTr4CRe/ER1TRoAA+h6kFa2bfE8CnO9UZ6Sxb1/LUi0AIdd6PhXyjguMiIqi5JKlvHf2RnkZeTeGiSV18IrQdTv2MpmXMPeH1BZX8yVyf2GbYnw0c3E2xkeyeJy95dOSfCPrluz8sj0hfB14BbK+lfgtbtgz/qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767024942; c=relaxed/simple; bh=AmFLF7VrnLMYNsm2c26VgXI8iQJTxRkwTcT9ix38//M=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=AwOcCY7Z9g1obMAxaVIv1KVgWG6N/IZxrBL+bRY/IynouGfLenqxg7LJSsl5KqaRVyZbGSk10wRNAojCNImmwhB4bq9xu8SW98Z9+jwHWtzTwPP9FsClP94WwBxualdbl6eQ/5OfdcG/pZkROs1on4cqNGe2RPO/zmdLKeGESnw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45CD14BA2E2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767024937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m2XYBcPSTEq+uQxyEtZL14O8a+hcbI30chi9VPOuRVE=; b=XPy9/uT1Ltay7MbWHWuUAbU/SFonCZ98RjZbQX2RbHpEDz6xtAR6/Oy09gpMgSCAK306x2 YIXLzMjwQ58kBMCdVN3VtR03a3WzoPw/HxFcUvs8vSCa5qfltr7b0xdgvdsyN9kyMfQhZf wSOdrcwdDi8UlIMUejqpJZUhHgdunQE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-Zgky48v-NjCZTjYsMSmmHg-1; Mon, 29 Dec 2025 11:15:36 -0500 X-MC-Unique: Zgky48v-NjCZTjYsMSmmHg-1 X-Mimecast-MFC-AGG-ID: Zgky48v-NjCZTjYsMSmmHg_1767024935 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4775f51ce36so85347935e9.1 for ; Mon, 29 Dec 2025 08:15:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767024935; x=1767629735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=m2XYBcPSTEq+uQxyEtZL14O8a+hcbI30chi9VPOuRVE=; b=OUSMgA660Z0irUsfi05VPuKZPwGaiIS6aL8D2uIsKlE3+ysJCjmn74iPEw44HBcoMu wth5yp+D1BPMASuCr+0QZ2UgyB3AHGSy6KWpO3+YSxpU086EIgEt1A9iR9rUWy+0poVg rdfbl+nD0vmSX05OXwx+0V4yLqKb5gT8Xim8F83owog6MPpWh+9vpfqNZso0r4vvif7o rnUlPoKbc6lYZFwXV7iz2CkuRxEblmft6zyqbJZHkiVxzpuL8ZuxncXeqKDy7Zh7OkiN BOeHyG24g3XJpkIkeC1fydZXgQwzTBu01nd33u4TZ91XCnQEYlf71m0dtWJZ8iYsofYQ RN/g== X-Gm-Message-State: AOJu0Yys1mCYMLEVDObm6nImRqsl10Gs1K5YZ22wa2akcrHHeQGa2NJk QjbBeGBvG2H6gV9TyCi5kzqGsV+gxXTjJlZFqo4vNx+qAAibV0Y/1siZPBdFBJEUfGrlfouyKtS 22svDHTTyMJZmq8sFJsIUOJzB/czI44C2+7QXARwSER7IP67k3seYMXU3E/yEMabRrALsGweEbj lLAT/KhM6YuSOL5tW0HwcgnOVfQ5kPHwdjAUy6pD4pgcnIBJo= X-Gm-Gg: AY/fxX6Xct7Nrqm2C2jR4SRQtV/l9SQewTfFfkV6kFycoZNGVgB/ZTMygaj9MiKouAm gvESsQJC8n8QqeyVbac4uynVvOmdDpqCiiqCxRUPDx13D7OW9NNMgWkD9N2W0pvMmSGGlvIgHc1 nd0RYh65mnAS7fyeLchKBAl/+ey7NFScvVfbMPxh9bHZvQyZ7DNG4uqiHDJZgi7ETDEhdVkk9ql 57MntakKSrvCVnk5Ic7Zg1IRMvdiZdXOaXEGirkWCXiX1kdxaj1pdqe8XkxdYx5MoX1UKJaMdzv 0ZqXJ4SwlELTlYJN6z8tjR34waZB9oDTlO8TT2tGY2mKvw4VJZwUZaQvRFe2anFcMxEzQ9jONqB 2LSMP+N0BK6lOOimQOBAfu1+05NUSHCAyGA== X-Received: by 2002:a05:600c:3584:b0:46e:59bd:f7d3 with SMTP id 5b1f17b1804b1-47d195a724bmr400685745e9.20.1767024934798; Mon, 29 Dec 2025 08:15:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6YuD7RlqFjZmwWwyUK1SPju/6Gax66X47TxgqRz3gL/7OpCyeVLn7nlrYggd+ayEs+PUTFA== X-Received: by 2002:a05:600c:3584:b0:46e:59bd:f7d3 with SMTP id 5b1f17b1804b1-47d195a724bmr400685315e9.20.1767024934317; Mon, 29 Dec 2025 08:15:34 -0800 (PST) Received: from localhost (92.40.168.223.threembb.co.uk. [92.40.168.223]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3a49315sm251832375e9.2.2025.12.29.08.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Dec 2025 08:15:33 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv4 5/7] gdb/dwarf: rename dwarf2_start_subfile to dwarf2_cu::start_subfile Date: Mon, 29 Dec 2025 16:15:18 +0000 Message-Id: <66d978fa035c1b674dc895eaa63b8c5db6651672.1767024363.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: FAQXzgyk88-MWtKtkTHvYBf9i8H3W1igixd5MgPacCo_1767024935 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, POISEN_SPAM_PILL, POISEN_SPAM_PILL_1, POISEN_SPAM_PILL_3, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Rename dwarf2_start_subfile to dwarf2_cu::start_subfile. This refactor continues the work started in the previous commit. There should be no user visible changes after this commit. --- gdb/dwarf2/cu.c | 29 ++++++++++++++++++++++++++++- gdb/dwarf2/cu.h | 4 ++++ gdb/dwarf2/line-program.c | 4 ++-- gdb/dwarf2/read.c | 26 -------------------------- gdb/dwarf2/read.h | 23 ----------------------- 5 files changed, 34 insertions(+), 52 deletions(-) diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index b4da4dfe248..eb27dc2ff1b 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -250,7 +250,7 @@ dwarf2_cu::create_subfiles_and_symtabs () for (file_entry &fe : this->line_header->file_names ()) { - dwarf2_start_subfile (*this, fe); + this->start_subfile (fe); subfile *sf = builder->get_current_subfile (); if (sf->symtab == nullptr) @@ -260,3 +260,30 @@ dwarf2_cu::create_subfiles_and_symtabs () fe.symtab = sf->symtab; } } + +/* See dwarf2/cu.h. */ + +void +dwarf2_cu::start_subfile (const file_entry &fe) +{ + std::string filename_holder; + const char *filename = fe.name; + const char *dirname = this->line_header->include_dir_at (fe.d_index); + + /* In order not to lose the line information directory, + we concatenate it to the filename when it makes sense. + Note that the Dwarf3 standard says (speaking of filenames in line + information): ``The directory index is ignored for file names + that represent full path names''. Thus ignoring dirname in the + `else' branch below isn't an issue. */ + + if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) + { + filename_holder = path_join (dirname, filename); + filename = filename_holder.c_str (); + } + + std::string filename_for_id = this->line_header->file_file_name (fe); + this->get_builder ()->start_subfile (filename, filename_for_id.c_str ()); +} + diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index d4a5ae65f3c..0fd64425e32 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -26,6 +26,7 @@ #include "language.h" #include "gdbsupport/unordered_set.h" #include "dwarf2/die.h" +#include "line-header.h" /* Type used for delaying computation of method physnames. See comments for compute_delayed_physnames. */ @@ -75,6 +76,9 @@ struct dwarf2_cu /* Create a subfile and symtab for every entry in the line_header. */ void create_subfiles_and_symtabs (); + /* Start a subfile for FE within this CU. */ + void start_subfile (const file_entry &fe); + /* Reset the builder. */ void reset_builder () { m_builder.reset (); } diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c index 3e4e30fb227..2fc5c283c00 100644 --- a/gdb/dwarf2/line-program.c +++ b/gdb/dwarf2/line-program.c @@ -244,7 +244,7 @@ lnp_state_machine::handle_set_file (file_name_index file) else { m_line_has_non_zero_discriminator = m_discriminator != 0; - dwarf2_start_subfile (*m_cu, *fe); + m_cu->start_subfile (*fe); } } @@ -507,7 +507,7 @@ dwarf_decode_lines_1 (struct dwarf2_cu *cu, unrelocated_addr lowpc) const file_entry *fe = state_machine.current_file (); if (fe != NULL) - dwarf2_start_subfile (*cu, *fe); + cu->start_subfile (*fe); /* Decode the table. */ while (line_ptr < line_end && !end_sequence) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 09568c02715..2c15deb0454 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15976,32 +15976,6 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu, comp_dir); } -/* See dwarf2/read.h. */ - -void -dwarf2_start_subfile (dwarf2_cu &cu, const file_entry &fe) -{ - std::string filename_holder; - const char *filename = fe.name; - const char *dirname = cu.line_header->include_dir_at (fe.d_index); - - /* In order not to lose the line information directory, - we concatenate it to the filename when it makes sense. - Note that the Dwarf3 standard says (speaking of filenames in line - information): ``The directory index is ignored for file names - that represent full path names''. Thus ignoring dirname in the - `else' branch below isn't an issue. */ - - if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) - { - filename_holder = path_join (dirname, filename); - filename = filename_holder.c_str (); - } - - std::string filename_for_id = cu.line_header->file_file_name (fe); - cu.get_builder ()->start_subfile (filename, filename_for_id.c_str ()); -} - static void var_decode_location (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu) diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 4ae2236466f..e00383ce2e8 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -1410,29 +1410,6 @@ extern const dwarf2_section_info &get_section_for_ref extern struct dwarf2_section_info *get_debug_line_section (struct dwarf2_cu *cu); -/* Start a subfile for FE within CU. - - This routine tries to keep line numbers from identical absolute and - relative file names in a common subfile. - - Using the `list' example from the GDB testsuite, which resides in - /srcdir and compiling it with Irix6.2 cc in /compdir using a filename - of /srcdir/list0.c yields the following debugging information for list0.c: - - DW_AT_name: /srcdir/list0.c - DW_AT_comp_dir: /compdir - files.files[0].name: list0.h - files.files[0].dir: /srcdir - files.files[1].name: list0.c - files.files[1].dir: /srcdir - - The line number information for list0.c has to end up in a single - subfile, so that `break /srcdir/list0.c:1' works as expected. - start_subfile will ensure that this happens provided that we pass the - concatenation of files.files[1].dir and files.files[1].name as the - subfile's name. */ -extern void dwarf2_start_subfile (dwarf2_cu &cu, const file_entry &fe); - /* A helper function that decides if a given symbol is an Ada Pragma Import or Pragma Export. */