From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4bU4J/XgtGqL3zsAWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 04:36:05 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=iXMA2eFC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9CFF01E06B; Thu, 24 Sep 2026 04:36:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DFD361E033 for ; Thu, 24 Sep 2026 04:36:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A106A4BB3BD6 for ; Thu, 24 Sep 2026 08:36:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A106A4BB3BD6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=iXMA2eFC Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 12A664BB5881 for ; Thu, 24 Sep 2026 08:34:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12A664BB5881 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 12A664BB5881 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790238858; cv=none; b=nb+60O2FBVL/S745/xRF6230KZtzdAeHXXPl84mVIDxp33eoLO6twOo7w1j6oXA95hSaxKzTjPXdwhAITdxZ+NIYUdddt5szfg2CrHx6YWbH1Ypz9pQphkwbJvn6lu1hV2QbTkVKNywVXMWvuzZKjcxBLu7W4Rm7Y0oQrwi/Ulg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790238858; c=relaxed/simple; bh=zuAaCDKZyyd6jxCdK8NmodLuIymhqD/WAwmKZYdw3DI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VRuFDM6haxAc3AbElCuIiV6evwIZBupvx/oMnxKW3Akc50qAT+CUerrJM7zQu4VQ4NiXEmzi2Cmid/DIMVqp4wcpiNXhd/14M2YGQ7PEfQCTUlRhihdu4c5zYu/AC0dugYNXmZLQ5itohR04+QDpvJH6Vk1ITZbxjVrEvtn1vf4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=iXMA2eFC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12A664BB5881 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790238858; x=1821774858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zuAaCDKZyyd6jxCdK8NmodLuIymhqD/WAwmKZYdw3DI=; b=iXMA2eFCVb98AnlhNH6XiBUccYih859ssD0oeTVBBlWfCbZvviGuZRaz BoTtF0VTAiOqBGrOeBte6DZDW8SYOWyOnbLmcinfFREu5NSXYAp4aXBC4 5nMD43unUyktaomu4dadA+961+auD6MU2R4OMdICLXvGWMdaQs8VMMY3Q T9wIvKzJzLBAgRSrJ8K7Lk3Yi6GSQFZzxGkcfD7YdfEHHU04CqwxFium1 nhVKGKGB9lif8Tj5yg4Qg/ddLtooEZQMbQORtFLWnqRwLzJ6NNwwwlI42 HxRx+6AHoOWoz0ZNwnwhgygbVDMwMnNwgudjhjSSrFXXjqhKT9tMaMkKY A==; X-CSE-ConnectionGUID: 3pW1PYGKSC2YiaT0riXPXg== X-CSE-MsgGUID: WE0RT679SN2axB5282d5Ow== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="90123836" X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="90123836" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 01:34:18 -0700 X-CSE-ConnectionGUID: FuE+Km/tS5agIuFOU2HqIg== X-CSE-MsgGUID: ksqPGu1NRJ6VGN+VUxzLAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,120,1787036400"; d="scan'208";a="277709270" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 01:34:16 -0700 From: Christina Joos To: gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org, tom@tromey.com, luis.machado.foss@gmail.com Subject: [PATCH v5 03/13] gdb: Add get_main_func_start_pc to refactor frame.c:inside_main_func. Date: Thu, 24 Sep 2026 10:33:00 +0200 Message-ID: <20260924083311.1961530-4-christina.joos@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924083311.1961530-1-christina.joos@intel.com> References: <20260924083311.1961530-1-christina.joos@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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~public-inbox=simark.ca@sourceware.org Refactor frame.c:inside_main_func to use the new function get_main_func_start_pc, which will be called in a following commmit. Reviewed-by: Thiago Jung Bauermann --- gdb/frame.c | 37 +++++++++++++++++++++++++------------ gdb/frame.h | 6 ++++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 6b02c5f559a..6bf72b6908e 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2650,27 +2650,26 @@ frame_debug_got_null_frame (const frame_info_ptr &this_frame, } } -/* Is this (non-sentinel) frame in the "main"() function? */ +/* See frame.h. */ -static bool -inside_main_func (const frame_info_ptr &this_frame) +std::optional +get_main_func_start_pc (gdbarch *gdbarch, const language lang) { if (current_program_space->symfile_object_file == nullptr) - return false; + return {}; - CORE_ADDR sym_addr = 0; const char *name = main_name (); bound_minimal_symbol msymbol = lookup_minimal_symbol (current_program_space, name, current_program_space->symfile_object_file); + CORE_ADDR sym_addr = 0; if (msymbol.minsym != nullptr) sym_addr = msymbol.value_address (); /* Favor a full symbol in Fortran, for the case where the Fortran main is also called "main". */ - if (msymbol.minsym == nullptr - || get_frame_language (this_frame) == language_fortran) + if (msymbol.minsym == nullptr || lang == language_fortran) { /* In some language (for example Fortran) there will be no minimal symbol with the name of the main function. In this case we should @@ -2686,16 +2685,30 @@ inside_main_func (const frame_info_ptr &this_frame) sym_addr = block->start (); } else if (msymbol.minsym == nullptr) - return false; + return {}; } /* Convert any function descriptor addresses into the actual function code address. */ - sym_addr = (gdbarch_convert_from_func_ptr_addr - (get_frame_arch (this_frame), sym_addr, - current_inferior ()->top_target ())); + return {gdbarch_convert_from_func_ptr_addr + (gdbarch, + sym_addr, + current_inferior ()->top_target ())}; +} + +/* Is this (non-sentinel) frame in the "main"() function? */ + +static bool +inside_main_func (const frame_info_ptr &this_frame) +{ + std::optional sym_addr + = get_main_func_start_pc (get_frame_arch (this_frame), + get_frame_language (this_frame)); + + if (!sym_addr.has_value ()) + return false; - return sym_addr == get_frame_func (this_frame); + return get_frame_func (this_frame) == *sym_addr; } /* Test whether THIS_FRAME is inside the process entry point function. */ diff --git a/gdb/frame.h b/gdb/frame.h index b64650f3215..6f6259cf722 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -888,6 +888,12 @@ extern struct symbol *get_frame_function (const frame_info_ptr &); extern CORE_ADDR get_pc_function_start (CORE_ADDR); +/* If possible, get the start pc of the main function of the current program + space for the language LANG. */ + +extern std::optional get_main_func_start_pc (gdbarch *gdbarch, + const language lang); + extern frame_info_ptr find_relative_frame (frame_info_ptr, int *); /* Wrapper over print_stack_frame modifying current_uiout with UIOUT for -- 2.53.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.