From patchwork Fri Apr 28 12:49:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 68491 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 172343858426 for ; Fri, 28 Apr 2023 12:50:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 172343858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682686229; bh=pTEm2xHofdPq1ThrxFsYSu1tbgESWKrKY4drIYNQib4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fiov+0bQu/aXrfPgLypc9R80d8CxMyaVeXqja5KVn4Gdsd5ULvb0+IuTiBaZ0A6o6 c4a3W9HI19KfIuLsX1ai3oearV1P/lQsVem2pImun+opbr2NuIKAiZRsmPknigI1N8 rKDSL+Wxm5Gf+UxWq+P02mXlA2GY2dHWsX8Cz9LY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 9496A3858D37 for ; Fri, 28 Apr 2023 12:50:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9496A3858D37 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-32951864ad9so23882315ab.0 for ; Fri, 28 Apr 2023 05:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682686203; x=1685278203; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pTEm2xHofdPq1ThrxFsYSu1tbgESWKrKY4drIYNQib4=; b=KwH/xtOgXlFhDkT0DetCcXQ4Ogsk02T+MNa6HCtr5S05aFlBjdhKv5EBk4lNg9AWGt ztuSJ94SHmSrkyfqZuNjsSTM5ldMT0NM9FQWAObePBj/scKPcBMPojtNWgNMpWBeM5n0 4PdKTkhbsWLU9x3tWh5ZXNOCMZIPK1th0U/NK0oa/7a6HV6REBJKhhBSJXDA+OM0tpiE xndLlyR78Lin01ic0dguiTX4kZD6PpTLyzSvWs1jKwwpZ1Uwny0tywsMXV5k3S+5jxz1 xCdBjjDyLKx+EHLegg1o3TPyVWEGECv5J8fojWorVP6pAhFSgVzy4ff25Q9rOI9VGeEM vk0g== X-Gm-Message-State: AC+VfDznpJGzx4xWd08Q0aY4560yBCsC6G1QluxMwkFm1xiqClwBeuV9 peAuVY3NrmUJ/IfW0PDUxj4h0uUoojCq7IETdfbdhQ== X-Google-Smtp-Source: ACHHUZ521OR1ZST7tquHfPiCdbT7+IduNiwSSt9tFp46IAXKlhW9d/0HLGS24m8yxjVB3IYMfPnkxw== X-Received: by 2002:a05:6e02:4d2:b0:329:4331:1586 with SMTP id f18-20020a056e0204d200b0032943311586mr3326626ils.28.1682686202713; Fri, 28 Apr 2023 05:50:02 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id 1-20020a020a01000000b0040f95d1fc9fsm6094610jaw.153.2023.04.28.05.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 05:50:02 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Move find_minimal_symbol_address to minsyms.c Date: Fri, 28 Apr 2023 06:49:56 -0600 Message-Id: <20230428124956.1093451-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 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, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I found find_minimal_symbol_address in parse.c, but it seems to me that it belongs in minsyms.c. Reviewed-By: Andrew Burgess --- gdb/minsyms.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ gdb/parse.c | 80 --------------------------------------------------- 2 files changed, 78 insertions(+), 80 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index a2c139db24d..5fcc7242626 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1611,3 +1611,81 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym) return result; } + +/* See minsyms.h. */ + +type * +find_minsym_type_and_address (minimal_symbol *msymbol, + struct objfile *objfile, + CORE_ADDR *address_p) +{ + bound_minimal_symbol bound_msym = {msymbol, objfile}; + struct obj_section *section = msymbol->obj_section (objfile); + enum minimal_symbol_type type = msymbol->type (); + + bool is_tls = (section != NULL + && section->the_bfd_section->flags & SEC_THREAD_LOCAL); + + /* The minimal symbol might point to a function descriptor; + resolve it to the actual code address instead. */ + CORE_ADDR addr; + if (is_tls) + { + /* Addresses of TLS symbols are really offsets into a + per-objfile/per-thread storage block. */ + addr = CORE_ADDR (bound_msym.minsym->unrelocated_address ()); + } + else if (msymbol_is_function (objfile, msymbol, &addr)) + { + if (addr != bound_msym.value_address ()) + { + /* This means we resolved a function descriptor, and we now + have an address for a code/text symbol instead of a data + symbol. */ + if (msymbol->type () == mst_data_gnu_ifunc) + type = mst_text_gnu_ifunc; + else + type = mst_text; + section = NULL; + } + } + else + addr = bound_msym.value_address (); + + if (overlay_debugging) + addr = symbol_overlayed_address (addr, section); + + if (is_tls) + { + /* Skip translation if caller does not need the address. */ + if (address_p != NULL) + *address_p = target_translate_tls_address (objfile, addr); + return builtin_type (objfile)->nodebug_tls_symbol; + } + + if (address_p != NULL) + *address_p = addr; + + switch (type) + { + case mst_text: + case mst_file_text: + case mst_solib_trampoline: + return builtin_type (objfile)->nodebug_text_symbol; + + case mst_text_gnu_ifunc: + return builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol; + + case mst_data: + case mst_file_data: + case mst_bss: + case mst_file_bss: + return builtin_type (objfile)->nodebug_data_symbol; + + case mst_slot_got_plt: + return builtin_type (objfile)->nodebug_got_plt_symbol; + + default: + return builtin_type (objfile)->nodebug_unknown_symbol; + } +} diff --git a/gdb/parse.c b/gdb/parse.c index 85a6caf14ba..a84b4b64fdb 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -92,86 +92,6 @@ innermost_block_tracker::update (const struct block *b, -/* Return the type of MSYMBOL, a minimal symbol of OBJFILE. If - ADDRESS_P is not NULL, set it to the MSYMBOL's resolved - address. */ - -type * -find_minsym_type_and_address (minimal_symbol *msymbol, - struct objfile *objfile, - CORE_ADDR *address_p) -{ - bound_minimal_symbol bound_msym = {msymbol, objfile}; - struct obj_section *section = msymbol->obj_section (objfile); - enum minimal_symbol_type type = msymbol->type (); - - bool is_tls = (section != NULL - && section->the_bfd_section->flags & SEC_THREAD_LOCAL); - - /* The minimal symbol might point to a function descriptor; - resolve it to the actual code address instead. */ - CORE_ADDR addr; - if (is_tls) - { - /* Addresses of TLS symbols are really offsets into a - per-objfile/per-thread storage block. */ - addr = CORE_ADDR (bound_msym.minsym->unrelocated_address ()); - } - else if (msymbol_is_function (objfile, msymbol, &addr)) - { - if (addr != bound_msym.value_address ()) - { - /* This means we resolved a function descriptor, and we now - have an address for a code/text symbol instead of a data - symbol. */ - if (msymbol->type () == mst_data_gnu_ifunc) - type = mst_text_gnu_ifunc; - else - type = mst_text; - section = NULL; - } - } - else - addr = bound_msym.value_address (); - - if (overlay_debugging) - addr = symbol_overlayed_address (addr, section); - - if (is_tls) - { - /* Skip translation if caller does not need the address. */ - if (address_p != NULL) - *address_p = target_translate_tls_address (objfile, addr); - return builtin_type (objfile)->nodebug_tls_symbol; - } - - if (address_p != NULL) - *address_p = addr; - - switch (type) - { - case mst_text: - case mst_file_text: - case mst_solib_trampoline: - return builtin_type (objfile)->nodebug_text_symbol; - - case mst_text_gnu_ifunc: - return builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol; - - case mst_data: - case mst_file_data: - case mst_bss: - case mst_file_bss: - return builtin_type (objfile)->nodebug_data_symbol; - - case mst_slot_got_plt: - return builtin_type (objfile)->nodebug_got_plt_symbol; - - default: - return builtin_type (objfile)->nodebug_unknown_symbol; - } -} - bool expr_complete_tag::complete (struct expression *exp, completion_tracker &tracker)