From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D020C3858C2D for ; Fri, 28 Apr 2023 14:42:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D020C3858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682692971; 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: in-reply-to:in-reply-to:references:references; bh=GqvbwUsNW9S1RpnexXgvAkZQdCDavBG3yv6oKhjYnkw=; b=IbfLtq011XpdaGwwB6wtxMtk5noYntD4HKfApkClX4CM8fJiMismRF9u7zbAloeFjmQD7v PGUSqUvedr6ufva3O8eYB3AazZy2v9sBH9JjrP5ZiihRaveJuUf08h/NxpvLm1mxITiVkJ wtqNQrOPLXUXaw6BapaTcTqXrIOwabU= 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-274-l5usOLCbOmuqfMsuJPpPKw-1; Fri, 28 Apr 2023 10:42:50 -0400 X-MC-Unique: l5usOLCbOmuqfMsuJPpPKw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f170a1fbe7so62022805e9.2 for ; Fri, 28 Apr 2023 07:42:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682692969; x=1685284969; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kjRoApFMSzA4D1re32juDg20xq1q2WyCpg63BIOHw68=; b=hLzi1mx+5yjsc0Xm9Ut3LyK/HG0ybJz8qt3LugMPM6Cn+pZtpLNcILjUk66nm7lcqH oTVNN1r+iHkuQiVydQ7aFXYCbuzLFGW8v9WEM++C5rXM+5gWYeLHzCkX2cK2Z1Jve0+C 6/LvQcEx/1nPXvOnFL8XkNMouM/iHEVRwhxTKjxW6FHi7qZ0cilbio3gsg2Dbg2BsbX0 WcoGz/hK9gui8HIiUILXiP8c5eqcRA1QWmpq2QtPJ9k8cYlmt+ZXVjGvLwaxwOMHQ5za mqpxnA7oahMVHA1wQiBiyIPEfXucMSFNqUHi2EIp7QD0Vbg5+Y9sp311B8Gnu2z77/Yv 9sng== X-Gm-Message-State: AC+VfDzQmAIwGCafLzjyjtTlXikLk05r9Jt7sz0Uf8vpEr2v+tfVQxJo 4HFsj8N1YMXyltmwhHJ6OgVsMUDUJmTuVjlDuqtyek0XvqDwiVPcvd62Vwiy7EPT0ZF6Wry3pMW UHD9TbqQXpsgkSBjLDtklvmMKMjM3dXlIUPIH+yXWW/Am9IEmpXPytByFKIRstmTN7WxcRBEsiF 5xecbc+A== X-Received: by 2002:a7b:cc94:0:b0:3f1:69cc:475b with SMTP id p20-20020a7bcc94000000b003f169cc475bmr4449799wma.36.1682692968938; Fri, 28 Apr 2023 07:42:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6AQGICBeE13HMTOFbJJSLLhA5UE2rJbwKPHqgwFlGvN+sMdftKBhtO1ImRg6byzEjyLgET/g== X-Received: by 2002:a7b:cc94:0:b0:3f1:69cc:475b with SMTP id p20-20020a7bcc94000000b003f169cc475bmr4449778wma.36.1682692968523; Fri, 28 Apr 2023 07:42:48 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id r3-20020a05600c35c300b003f1836c98b7sm25952194wmq.48.2023.04.28.07.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 07:42:48 -0700 (PDT) From: Andrew Burgess To: Tom Tromey via Gdb-patches , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Move find_minimal_symbol_address to minsyms.c In-Reply-To: <20230428124956.1093451-1-tromey@adacore.com> References: <20230428124956.1093451-1-tromey@adacore.com> Date: Fri, 28 Apr 2023 15:42:47 +0100 Message-ID: <87wn1w9ifs.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: Tom Tromey via Gdb-patches writes: > I found find_minimal_symbol_address in parse.c, but it seems to me > that it belongs in minsyms.c. No objections from me. Seems sensible. Reviewed-By: Andrew Burgess Thanks, Andrew > --- > 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) > -- > 2.39.1