From patchwork Sun Oct 29 23:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78708 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 A3B1A387689B for ; Sun, 29 Oct 2023 23:24:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 0090F38618EF for ; Sun, 29 Oct 2023 23:23:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0090F38618EF Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0090F38618EF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621793; cv=none; b=OAi6cWB8JHGqeU4iD6eoOuPYT48c0ao4h3/gEcBMFs9NdSTyodks+Qmgt8VHLG8Vcq5UiAxaWhoLXGfg8z00dXaQ+DgP+L05rP0mvoyG1EYhxa8FdmCCMO619wtKI5p0Kqn14wkJUKY1VOPMJuDWL+1dQUXjN2tmOTrBxima/BI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621793; c=relaxed/simple; bh=7VHzn+HlpIHrXaJkL58g/G6e1Ju2E3O1uNuxbhw2dXk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=wZWjH+dgbOWgsBSnKpAfoCqo3qxXm3gcHZ7epEwPkPh4Nvjm7tRK6qxyG/X2h1QwvjpBKIP1OlCI4FNXR2ARQCjoy16xVeYc31lAeusk8Aof81aVDwkPJJZyuIfU53O7iIHBkEat+OM7At08OSXxJa+F9VnUqb1v361S6STzzzk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id xB11qAo1G6nOZxF7cqwrf5; Sun, 29 Oct 2023 23:23:08 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xF7cqlJoWF1O4xF7cq7arA; Sun, 29 Oct 2023 23:23:08 +0000 X-Authority-Analysis: v=2.4 cv=CcwbWZnl c=1 sm=1 tr=0 ts=653ee95c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=Qbun_eYptAEA:10 a=ePMSK9q8hqG6NbDvU7cA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ySQIrp9rlZphOikU+DCUOQpyU821vhNhhAu5FwcHc+w=; b=LwVThGXWcKEvNECH2uTI2hFBBC TeUfXH3xPCu21DfwgXPCq9gS9Hlr9g5eDcYWEWk/agxM8357AuVQ2p7HpT0hrBCe3WHGRoGNfxuBE dqByWCMs1MhGyRrcoT+SrOb9q; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:56344 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qxF7b-0042zY-2i for gdb-patches@sourceware.org; Sun, 29 Oct 2023 17:23:07 -0600 From: Tom Tromey Date: Sun, 29 Oct 2023 17:23:35 -0600 Subject: [PATCH 14/30] Return a block_symbol from find_pc_sect_function MIME-Version: 1.0 Message-Id: <20231029-split-objfile-2023-bound-sym-october-v1-14-612531df2734@tromey.com> References: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@tromey.com> In-Reply-To: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.77.73 X-Source-L: No X-Exim-ID: 1qxF7b-0042zY-2i X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:56344 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMQuEsrXbYuVNrDw46J8/oqlCCr6DYQ0QghrZr/OUkCACDbYwv4e9U0mTSB90KRgfAbT5wOMJqQN2hC7PxfO4PS0q4O08RaF957/MGj0PbXyeD0ZrY9J Z/InAlkr7x8/E1sNgfdP74188ZnQCHjtxy2a1R7Y9chfaUayxIs08jL7qRHExTYaxfbR7PMslRQL40c6cdh4ZeRxC7GxW8klaAE= X-Spam-Status: No, score=-3024.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.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 This changes find_pc_sect_function to return a block_symbol and updates all the callers in a minimal way. A less intrusive approach might be possible -- but in the long run we'll want to add an objfile into this result, so it makes sense to go ahead with the conversion now. --- gdb/blockframe.c | 12 ++++++------ gdb/breakpoint.c | 2 +- gdb/btrace.c | 2 +- gdb/cli/cli-cmds.c | 4 ++-- gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 2 +- gdb/guile/scm-frame.c | 2 +- gdb/infcall.c | 2 +- gdb/infcmd.c | 6 +++--- gdb/infrun.c | 4 ++-- gdb/printcmd.c | 2 +- gdb/python/py-finishbreakpoint.c | 2 +- gdb/solib-frv.c | 2 +- gdb/sparc-tdep.c | 4 ++-- gdb/symtab.c | 4 ++-- gdb/symtab.h | 4 ++-- gdb/tracepoint.c | 4 ++-- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 633a9674d97..981094803ed 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -132,21 +132,21 @@ get_frame_function (frame_info_ptr frame) /* Return the function containing pc value PC in section SECTION. Returns 0 if function is not known. */ -struct symbol * +block_symbol find_pc_sect_function (CORE_ADDR pc, struct obj_section *section) { const struct block *b = block_for_pc_sect (pc, section); if (b == 0) - return 0; - return b->linkage_function (); + return {}; + return { b->linkage_function (), b }; } /* Return the function containing pc value PC. Returns 0 if function is not known. Backward compatibility, no section */ -struct symbol * +block_symbol find_pc_function (CORE_ADDR pc) { return find_pc_sect_function (pc, find_pc_mapped_section (pc)); @@ -251,7 +251,7 @@ find_pc_partial_function_sym (CORE_ADDR pc, address of the function. This will happen when the function has more than one range and the entry pc is not within the lowest range of addresses. */ - f = find_pc_sect_function (mapped_pc, section); + f = find_pc_sect_function (mapped_pc, section).symbol; if (f != NULL && (msymbol.minsym == NULL || (f->value_block ()->entry_pc () @@ -421,7 +421,7 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name, struct type * find_function_type (CORE_ADDR pc) { - struct symbol *sym = find_pc_function (pc); + struct symbol *sym = find_pc_function (pc).symbol; if (sym != NULL && sym->value_block ()->entry_pc () == pc) return sym->type (); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 828c99cabc0..60ba22c3257 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -12865,7 +12865,7 @@ update_static_tracepoint (tracepoint *tp, struct symtab_and_line sal) tp->number, tp->static_trace_marker_id.c_str ()); symtab_and_line sal2 = find_pc_line (tpmarker->address, 0); - sym = find_pc_sect_function (tpmarker->address, NULL); + sym = find_pc_sect_function (tpmarker->address, NULL).symbol; uiout->text ("Now in "); if (sym) { diff --git a/gdb/btrace.c b/gdb/btrace.c index 3f72b9c91e5..ea18daa23e0 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -556,7 +556,7 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc) /* Try to determine the function we're in. We use both types of symbols to avoid surprises when we sometimes get a full symbol and sometimes only a minimal symbol. */ - fun = find_pc_function (pc); + fun = find_pc_function (pc).symbol; bmfun = lookup_minimal_symbol_by_pc (pc); mfun = bmfun.minsym; diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 8cadd637151..cfd0ff15acb 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1040,7 +1040,7 @@ edit_command (const char *arg, int from_tty) paddress (get_current_arch (), sal.pc)); gdbarch = sal.symtab->compunit ()->objfile ()->arch (); - sym = find_pc_function (sal.pc); + sym = find_pc_function (sal.pc).symbol; if (sym) gdb_printf ("%s is in %s (%s:%d).\n", paddress (gdbarch, sal.pc), @@ -1424,7 +1424,7 @@ list_command (const char *arg, int from_tty) paddress (get_current_arch (), sal.pc)); gdbarch = sal.symtab->compunit ()->objfile ()->arch (); - sym = find_pc_function (sal.pc); + sym = find_pc_function (sal.pc).symbol; if (sym) gdb_printf ("%s is in %s (%s:%d).\n", paddress (gdbarch, sal.pc), diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 53031aa809a..17509f81464 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -762,7 +762,7 @@ call_site_target::iterate_over_addresses static struct symbol * func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr) { - struct symbol *sym = find_pc_function (addr); + struct symbol *sym = find_pc_function (addr).symbol; struct type *type; if (sym == NULL || sym->value_block ()->entry_pc () != addr) diff --git a/gdb/eval.c b/gdb/eval.c index b859e825925..9b76d3d5376 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2037,7 +2037,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, (exp->gdbarch, addr, current_inferior ()->top_target ()); /* Is it a high_level symbol? */ - sym = find_pc_function (addr); + sym = find_pc_function (addr).symbol; if (sym != NULL) method = value_of_variable (sym, 0); } diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 45863c587c1..74012ffea4f 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -666,7 +666,7 @@ gdbscm_frame_function (SCM self) if (frame != NULL) { found = true; - sym = find_pc_function (get_frame_address_in_block (frame)); + sym = find_pc_function (get_frame_address_in_block (frame)).symbol; } } catch (const gdb_exception &except) diff --git a/gdb/infcall.c b/gdb/infcall.c index 0f9ad34bbb4..a36a5e81b3a 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -413,7 +413,7 @@ static const char * get_function_name (CORE_ADDR funaddr, char *buf, int buf_size) { { - struct symbol *symbol = find_pc_function (funaddr); + struct symbol *symbol = find_pc_function (funaddr).symbol; if (symbol) return symbol->print_name (); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index cf8cd527955..c50d9bcd47d 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -750,7 +750,7 @@ set_step_frame (thread_info *tp) set_step_info (tp, frame, sal); CORE_ADDR pc = get_frame_pc (frame); - tp->control.step_start_function = find_pc_function (pc); + tp->control.step_start_function = find_pc_function (pc).symbol; } /* Step until outside of current statement. */ @@ -1343,7 +1343,7 @@ until_next_command (int from_tty) not). */ pc = get_frame_pc (frame); - func = find_pc_function (pc); + func = find_pc_function (pc).symbol; if (!func) { @@ -1883,7 +1883,7 @@ finish_command (const char *arg, int from_tty) /* Find the function we will return from. */ frame_info_ptr callee_frame = get_selected_frame (nullptr); - sm->function = find_pc_function (get_frame_pc (callee_frame)); + sm->function = find_pc_function (get_frame_pc (callee_frame)).symbol; sm->return_buf = 0; /* Initialize buffer address is not available. */ /* Determine the return convention. If it is RETURN_VALUE_STRUCT_CONVENTION, diff --git a/gdb/infrun.c b/gdb/infrun.c index a7cb02c958e..2a004690e67 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7343,7 +7343,7 @@ process_event_stop_test (struct execution_control_state *ecs) && ((ecs->event_thread->control.step_stack_frame_id != outer_frame_id) || (ecs->event_thread->control.step_start_function - != find_pc_function (ecs->event_thread->stop_pc ()))))) + != find_pc_function (ecs->event_thread->stop_pc ()).symbol)))) { CORE_ADDR stop_pc = ecs->event_thread->stop_pc (); CORE_ADDR real_stop_pc; @@ -8752,7 +8752,7 @@ print_stop_location (const target_waitstatus &ws) && (tp->control.step_frame_id == get_frame_id (get_current_frame ())) && (tp->control.step_start_function - == find_pc_function (tp->stop_pc ()))) + == find_pc_function (tp->stop_pc ()).symbol)) { /* Finished step, just print source line. */ source_flag = SRC_LINE; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 94ce5113e06..cb7023b1880 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -637,7 +637,7 @@ build_address_symbolic (struct gdbarch *gdbarch, anything/stabs--it would be inconvenient to eliminate those minimal symbols anyway). */ msymbol = lookup_minimal_symbol_by_pc_section (addr, section); - symbol = find_pc_sect_function (addr, section); + symbol = find_pc_sect_function (addr, section).symbol; if (symbol) { diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 627eb297542..04fc8c9e8a7 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -252,7 +252,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) { if (get_frame_pc_if_available (frame, &pc)) { - struct symbol *function = find_pc_function (pc); + struct symbol *function = find_pc_function (pc).symbol; if (function != nullptr) { struct type *ret_type = diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 0897bce2325..aeaf0044ba7 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -893,7 +893,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point) /* Attempt to find the name of the function. If the name is available, it'll be used as an aid in finding matching functions in the dynamic symbol table. */ - sym = find_pc_function (entry_point); + sym = find_pc_function (entry_point).symbol; if (sym == 0) name = 0; else diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 78f240db04e..48a1adb7553 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1249,7 +1249,7 @@ sparc32_frame_cache (frame_info_ptr this_frame, void **this_cache) cache = sparc_frame_cache (this_frame, this_cache); - sym = find_pc_function (cache->pc); + sym = find_pc_function (cache->pc).symbol; if (sym) { cache->struct_return_p = sparc32_struct_return_from_sym (sym); @@ -1552,7 +1552,7 @@ static int sparc32_dwarf2_struct_return_p (frame_info_ptr this_frame) { CORE_ADDR pc = get_frame_address_in_block (this_frame); - struct symbol *sym = find_pc_function (pc); + struct symbol *sym = find_pc_function (pc).symbol; if (sym) return sparc32_struct_return_from_sym (sym); diff --git a/gdb/symtab.c b/gdb/symtab.c index 5ec56f4f2af..c1d78e1e2a6 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3790,7 +3790,7 @@ skip_prologue_sal (struct symtab_and_line *sal) switch_to_program_space_and_thread (sal->pspace); - sym = find_pc_sect_function (sal->pc, sal->section); + sym = find_pc_sect_function (sal->pc, sal->section).symbol; if (sym != NULL) { objfile = sym->objfile (); @@ -4069,7 +4069,7 @@ find_function_alias_target (bound_minimal_symbol msymbol) if (!msymbol_is_function (msymbol.objfile, msymbol.minsym, &func_addr)) return NULL; - symbol *sym = find_pc_function (func_addr); + symbol *sym = find_pc_function (func_addr).symbol; if (sym != NULL && sym->aclass () == LOC_BLOCK && sym->value_block ()->entry_pc () == func_addr) diff --git a/gdb/symtab.h b/gdb/symtab.h index 5292fadbbab..9f7257f3002 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2149,13 +2149,13 @@ extern struct type *lookup_enum (const char *, const struct block *); return value will not be an inlined function; the containing function will be returned instead. */ -extern struct symbol *find_pc_function (CORE_ADDR); +extern block_symbol find_pc_function (CORE_ADDR); /* lookup the function corresponding to the address and section. The return value will not be an inlined function; the containing function will be returned instead. */ -extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); +extern block_symbol find_pc_sect_function (CORE_ADDR, struct obj_section *); /* lookup the function symbol corresponding to the address and section. The return value will be the closest enclosing function, diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 80239200984..9492274c5f4 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -217,7 +217,7 @@ set_traceframe_context (frame_info_ptr trace_frame) && get_frame_pc_if_available (trace_frame, &trace_pc)) { traceframe_sal = find_pc_line (trace_pc, 0); - traceframe_fun = find_pc_function (trace_pc); + traceframe_fun = find_pc_function (trace_pc).symbol; /* Save linenumber as "$trace_line", a debugger variable visible to users. */ @@ -3621,7 +3621,7 @@ print_one_static_tracepoint_marker (int count, uiout->field_core_addr ("addr", marker.gdbarch, marker.address); sal = find_pc_line (marker.address, 0); - sym = find_pc_sect_function (marker.address, NULL); + sym = find_pc_sect_function (marker.address, NULL).symbol; if (sym) { uiout->text ("in ");