From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by sourceware.org (Postfix) with ESMTPS id 6DE44385C40E for ; Fri, 28 Jan 2022 14:32:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DE44385C40E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DyThzCXBuDBA1rKUvbIBHoxnVsQypHmz+Gmz1uxisQ+8Gz7YFkJh/2lfPnGS2CEPC7VFig1Z92K07LtRCDd5+AVnm2MrSsXbgpMJ+1FJ79Y7kNC/lZiYmLtEePzAoMIB4Ve2e+SNZWPhUvjJ24REcXlNlM/cK/IJR6Q8jEozbqiOcAi9QbiU0wZ62WSL9r+vtdR54Tqom1aV/Z18MTA3DIbvu3uUEcHcdYnjaVnZMbHjqyJ30nt/C9n6RxO6AJkAh4DtASUSUzJLWSVdwVN26lbqXj+vnQUjxa8gyrP3GhSLvXfe5KkuZnzY160faXbW+1795yxWbsSfkBnxGQJrUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zGE904/eSm1cT8+TXuNiaYMnrMfc7PxqKETuA8GzcuE=; b=BknrAjD3tSlLsdDAy3xakTP+cQZDvqGpi+9KdnfpCRNwqaMS3gEnVF/urzK0dz9SSrQEdFUK75AwnF6luquD/335GmkcopHbSkFWGsD5fjuR5MS9zR60upkznbWBHc7eujCU80mlRDTaoftWhCn7lU0XjIEijwg6xLxE6/5+AkSJaPYcXnXWKhdY7j9CLsejadII4eoMoPxGIiGo6CqzWlVB3kIPziku701BLr6wTyXB8gEi6LgZ868e7DT+UFb3vmWmjy8ehp2CM6K8Nt/7P8z3kwMD0QYiXMV5RjxVdLTZ44uMg6s6q6eN12wf+ab1J2zSpmFd8b3aWlpS7KdVwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from DM6PR01CA0019.prod.exchangelabs.com (2603:10b6:5:296::24) by BN9PR12MB5307.namprd12.prod.outlook.com (2603:10b6:408:104::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Fri, 28 Jan 2022 14:32:25 +0000 Received: from DM6NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::39) by DM6PR01CA0019.outlook.office365.com (2603:10b6:5:296::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Fri, 28 Jan 2022 14:32:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT065.mail.protection.outlook.com (10.13.172.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Fri, 28 Jan 2022 14:32:25 +0000 Received: from node-bp126-r03c.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 28 Jan 2022 08:32:17 -0600 From: Lancelot SIX To: CC: , Lancelot SIX Subject: [PATCH v2 1/2] gdb: Move most of get_function_name (COREADDR) in symtab.h Date: Fri, 28 Jan 2022 08:29:30 -0600 Message-ID: <20220128142931.39750-2-lancelot.six@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220128142931.39750-1-lancelot.six@amd.com> References: <20220128142931.39750-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f33b62ab-738c-4391-224b-08d9e26b00e1 X-MS-TrafficTypeDiagnostic: BN9PR12MB5307:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:277; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fd4X+4E0PPkrbQmc0T6xxMTybsl5UmBj+D2bwkZ252rPSmoDsty6rDLB8ezmekh6fhSzz1Ba+frdgoYst6eeKEcPTE2IpPEpJ2s9ueLWppHjuEatv82EP43douKtPbkEZP8+VLUf3X3dFCtuP80LME4DBtHW8/akpHaOaWpCQwLcjMft/s4tsboKhf8Uu6t09bg4384qoisp/tp1QTCGjUAa275kCgAR4Yw/SFwXlODZbp/5dZlmwB0+syLDx38NlvwyicBrQ560uw2tfuHuVALDiGIZymPWGW7HLWHFvmJD8HTH/9W9yTNFN1wyWIj4pZgJOlchiJoNL2vHV20/YNlK3FFGIMUIQbZOM05tDzoBuVlvZ3kTz7ha28PQENCbGIUgYgUmlp+iuHLbfyeLZfDEb5KFJc7bUQHleaMwREfh68rzbaSS7/xf/AOs+kzVfSYwzXg8nga9D/80kq8J6hecFpUJjIPeCAQnr3jPwTRuG/qLpofLs25gwOOsV58z2OiS9seCM083pTp/4INmz8/L3b4NHTgCh9kgiBdhy3p4KlYhnKHiqp79D1q5CrOn7O27MR4q8Bdd7Sx5TYq9IOjgsMywb4J9iSMQqwIaFbO/ouI6fVP69UeM8okHzUdfgTEm0uX2vUcpxrRTEGb+idWMIEAzGJLadUCx8coL3S3bZ2xXJvrT3zc1HQ2NgJLMJKKnKi3FEQttgNiHQ43dDYOEz4bPKeD8Ceq66bDp2eGTgkoxLqQyyW5veViAubfnh4Df50MP5kWENWpND3cI+mWZ33WVdYEyhuTepc1QZHM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700004)(36840700001)(46966006)(47076005)(316002)(4326008)(70206006)(6666004)(6916009)(8936002)(36756003)(82310400004)(356005)(83380400001)(2906002)(16526019)(81166007)(1076003)(70586007)(26005)(2616005)(54906003)(86362001)(336012)(40460700003)(186003)(36860700001)(508600001)(5660300002)(426003)(7696005)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 14:32:25.2830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f33b62ab-738c-4391-224b-08d9e26b00e1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5307 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 28 Jan 2022 14:32:32 -0000 A later commit will need to be able to print the name of a function given its address. This functionality is currently implemented in a static function in gdb/infcall.c. In order to make this functionality available to other parts of GDB, this commit moves it to gdb/symtab.h and gdb/blockframe.c. No user visible change after this commit. Tested on x86_64. Change-Id: I3d32d64f298bdb49acc9e224fdeff33dcc7aa6cb --- gdb/blockframe.c | 29 +++++++++++++++++++++++++++++ gdb/infcall.c | 38 -------------------------------------- gdb/symtab.h | 15 +++++++++++++++ 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 88595d4fcb0..bf557690f61 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -479,3 +479,32 @@ block_innermost_frame (const struct block *block) return NULL; } + +/* See symtab.h. */ + +const char * +get_function_name (CORE_ADDR funaddr, char *buf, int buf_size) +{ + { + struct symbol *symbol = find_pc_function (funaddr); + + if (symbol) + return symbol->print_name (); + } + + { + /* Try the minimal symbols. */ + struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (funaddr); + + if (msymbol.minsym) + return msymbol.minsym->print_name (); + } + + { + std::string tmp = string_printf (_(RAW_FUNCTION_ADDRESS_FORMAT), + hex_string (funaddr)); + + gdb_assert (tmp.length () + 1 <= buf_size); + return strcpy (buf, tmp.c_str ()); + } +} diff --git a/gdb/infcall.c b/gdb/infcall.c index 05cf18f0a7f..571e790fbee 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -44,11 +44,6 @@ #include "gdbsupport/scope-exit.h" #include -/* If we can't find a function's name from its address, - we print this instead. */ -#define RAW_FUNCTION_ADDRESS_FORMAT "at 0x%s" -#define RAW_FUNCTION_ADDRESS_SIZE (sizeof (RAW_FUNCTION_ADDRESS_FORMAT) \ - + 2 * sizeof (CORE_ADDR)) /* NOTE: cagney/2003-04-16: What's the future of this code? @@ -374,39 +369,6 @@ error_call_unknown_return_type (const char *func_name) "cast the call to its declared return type")); } -/* Fetch the name of the function at FUNADDR. - This is used in printing an error message for call_function_by_hand. - BUF is used to print FUNADDR in hex if the function name cannot be - determined. It must be large enough to hold formatted result of - RAW_FUNCTION_ADDRESS_FORMAT. */ - -static const char * -get_function_name (CORE_ADDR funaddr, char *buf, int buf_size) -{ - { - struct symbol *symbol = find_pc_function (funaddr); - - if (symbol) - return symbol->print_name (); - } - - { - /* Try the minimal symbols. */ - struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (funaddr); - - if (msymbol.minsym) - return msymbol.minsym->print_name (); - } - - { - std::string tmp = string_printf (_(RAW_FUNCTION_ADDRESS_FORMAT), - hex_string (funaddr)); - - gdb_assert (tmp.length () + 1 <= buf_size); - return strcpy (buf, tmp.c_str ()); - } -} - /* All the meta data necessary to extract the call's return value. */ struct call_return_meta_info diff --git a/gdb/symtab.h b/gdb/symtab.h index 55d1b772c45..aa951706c16 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1821,6 +1821,21 @@ extern bool find_function_entry_range_from_pc (CORE_ADDR pc, extern struct type *find_function_type (CORE_ADDR pc); +/* If we can't find a function's name from its address, + we print this instead. */ +#define RAW_FUNCTION_ADDRESS_FORMAT "at 0x%s" +#define RAW_FUNCTION_ADDRESS_SIZE (sizeof (RAW_FUNCTION_ADDRESS_FORMAT) \ + + 2 * sizeof (CORE_ADDR)) + +/* Fetch the name of the function at FUNADDR. + + BUF is used to print FUNADDR in hex if the function name cannot be + determined. It must be large enough to hold formatted result of + RAW_FUNCTION_ADDRESS_FORMAT. */ + +extern const char *get_function_name (CORE_ADDR funaddr, char *buf, + int buf_size); + /* See if we can figure out the function's actual type from the type that the resolver returns. RESOLVER_FUNADDR is the address of the ifunc resolver. */ -- 2.25.1