From patchwork Sun Oct 29 23:23:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78715 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 91A8138323FA for ; Sun, 29 Oct 2023 23:24:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 0FA56386480A for ; Sun, 29 Oct 2023 23:23:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FA56386480A 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 0FA56386480A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621798; cv=none; b=IrQ17njEIU82G6Y+esyz+T74GuOjbKdNGG1YG4aCn4A2lCdXqb6HiBPGBY5g64k1sC07QLGIspaPKcR0639Znrbhzsk7161walY2NVIc4YgAelDyzBWvmrrKXsVQmlPM/Lizj4oZr5LTcvMY/6xXkuE6fFhfU88N/vqGudCrtyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621798; c=relaxed/simple; bh=av5rDW10IPfao6/E6YQbAOrNQH8asWRPMKY278vLCdY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QNg6F3sgqEKnoCzCgkpEClVX1Gr1iPYCUQ8Sm1fbucKOQBeJf+SjwMaL/GQP8EbRZdacCoEp3Q0h46gTk2C5dckz6CV1ZBGJd5oWtD+OukdFX0v96y0ZPPRhjp32wmFRrNnh3nBJA4Wn1txhhUI6GRJ8Zp4LCF1fQsjYTFV6xrc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id wpTXq4E3iWcCIxF7eqWTgk; Sun, 29 Oct 2023 23:23:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xF7dqb5lbOk5SxF7eqGq5f; Sun, 29 Oct 2023 23:23:10 +0000 X-Authority-Analysis: v=2.4 cv=E+DeGIRl c=1 sm=1 tr=0 ts=653ee95e 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=P3_9uBmkC6M_FAiY1AAA: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=bQqGfMYJD5NzEVbVD7Xjj+sJZS66/VcDBw2wr/pQb4k=; b=tz8Ga4CjtozACblTUkoAMkwqah E0QnFkRXHiUUvPhh+aWrd4/JEphAXHHEe7eq2pbnZagr/p2weNAY2Xu08TtXOTHlaLsyXQz8uhuGh YWRQpXahebJEwOUj51oS+Y6WS; 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 1qxF7d-0042zY-21 for gdb-patches@sourceware.org; Sun, 29 Oct 2023 17:23:09 -0600 From: Tom Tromey Date: Sun, 29 Oct 2023 17:23:48 -0600 Subject: [PATCH 27/30] Change btrace_function::sym to a block_symbol MIME-Version: 1.0 Message-Id: <20231029-split-objfile-2023-bound-sym-october-v1-27-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: 1qxF7d-0042zY-21 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: 28 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDujMSEPN0uz7uMhLM2mJLm5fjaysFvHl9MPoevt1F78IWhBPcqJAlVhNDM2RL61fi1gtEwNHNG7sZBJlSrcLL4BmpveFDi09XjFccTHkwsPrkT8sct9 xkp/ktytqoPbs53TMzLYCAvEylu01qvCONBfOGB0kYTtS6UKIJgSI17kiUh/jy0azS3rdzoTRo3oAzOGVM2itzmXTDWGnsWH7Rk= X-Spam-Status: No, score=-3024.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 btrace_function::sym to be a block_symbol, enabling a later patch. --- gdb/btrace.c | 38 +++++++++++++++++++------------------- gdb/btrace.h | 5 +++-- gdb/python/py-record-btrace.c | 2 +- gdb/record-btrace.c | 8 ++++---- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index ea18daa23e0..66b08dabb64 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -78,7 +78,7 @@ ftrace_print_function_name (const struct btrace_function *bfun) struct symbol *sym; msym = bfun->msym; - sym = bfun->sym; + sym = bfun->sym.symbol; if (sym != NULL) return sym->print_name (); @@ -98,7 +98,7 @@ ftrace_print_filename (const struct btrace_function *bfun) struct symbol *sym; const char *filename; - sym = bfun->sym; + sym = bfun->sym.symbol; if (sym != NULL) filename = symtab_to_filename_for_display (sym->symtab ()); @@ -192,7 +192,7 @@ ftrace_function_switched (const struct btrace_function *bfun, struct symbol *sym; msym = bfun->msym; - sym = bfun->sym; + sym = bfun->sym.symbol; /* If the minimal symbol changed, we certainly switched functions. */ if (mfun != NULL && msym != NULL @@ -235,7 +235,7 @@ ftrace_function_switched (const struct btrace_function *bfun, static struct btrace_function * ftrace_new_function (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, - struct symbol *fun) + block_symbol fun) { int level; unsigned int number, insn_offset; @@ -311,7 +311,7 @@ ftrace_fixup_caller (struct btrace_thread_info *btinfo, static struct btrace_function * ftrace_new_call (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, - struct symbol *fun) + block_symbol fun) { const unsigned int length = btinfo->functions.size (); struct btrace_function *bfun = ftrace_new_function (btinfo, mfun, fun); @@ -331,7 +331,7 @@ ftrace_new_call (struct btrace_thread_info *btinfo, static struct btrace_function * ftrace_new_tailcall (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, - struct symbol *fun) + block_symbol fun) { const unsigned int length = btinfo->functions.size (); struct btrace_function *bfun = ftrace_new_function (btinfo, mfun, fun); @@ -414,7 +414,7 @@ ftrace_find_call (struct btrace_thread_info *btinfo, static struct btrace_function * ftrace_new_return (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, - struct symbol *fun) + block_symbol fun) { struct btrace_function *prev, *bfun, *caller; @@ -424,7 +424,7 @@ ftrace_new_return (struct btrace_thread_info *btinfo, /* It is important to start at PREV's caller. Otherwise, we might find PREV itself, if PREV is a recursive function. */ caller = ftrace_find_call_by_number (btinfo, prev->up); - caller = ftrace_find_caller (btinfo, caller, mfun, fun); + caller = ftrace_find_caller (btinfo, caller, mfun, fun.symbol); if (caller != NULL) { /* The caller of PREV is the preceding btrace function segment in this @@ -496,7 +496,7 @@ ftrace_new_return (struct btrace_thread_info *btinfo, static struct btrace_function * ftrace_new_switch (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, - struct symbol *fun) + block_symbol fun) { struct btrace_function *prev, *bfun; @@ -524,13 +524,13 @@ ftrace_new_gap (struct btrace_thread_info *btinfo, int errcode, struct btrace_function *bfun; if (btinfo->functions.empty ()) - bfun = ftrace_new_function (btinfo, NULL, NULL); + bfun = ftrace_new_function (btinfo, NULL, {}); else { /* We hijack the previous function segment if it was empty. */ bfun = &btinfo->functions.back (); if (bfun->errcode != 0 || !bfun->insn.empty ()) - bfun = ftrace_new_function (btinfo, NULL, NULL); + bfun = ftrace_new_function (btinfo, NULL, {}); } bfun->errcode = errcode; @@ -550,17 +550,16 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc) { struct bound_minimal_symbol bmfun; struct minimal_symbol *mfun; - struct symbol *fun; struct btrace_function *bfun; /* 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).symbol; + block_symbol fun = find_pc_function (pc); bmfun = lookup_minimal_symbol_by_pc (pc); mfun = bmfun.minsym; - if (fun == NULL && mfun == NULL) + if (fun.symbol == NULL && mfun == NULL) DEBUG_FTRACE ("no symbol at %s", core_addr_to_string_nz (pc)); /* If we didn't have a function, we create one. */ @@ -629,7 +628,7 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc) { struct btrace_function *caller = ftrace_find_call_by_number (btinfo, bfun->up); - caller = ftrace_find_caller (btinfo, caller, mfun, fun); + caller = ftrace_find_caller (btinfo, caller, mfun, fun.symbol); if (caller != NULL) return ftrace_new_return (btinfo, mfun, fun); } @@ -637,7 +636,8 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc) /* If we can't determine the function for PC, we treat a jump at the end of the block as tail call if we're switching functions and as an intra-function branch if we don't. */ - if (start == 0 && ftrace_function_switched (bfun, mfun, fun)) + if (start == 0 && ftrace_function_switched (bfun, mfun, + fun.symbol)) return ftrace_new_tailcall (btinfo, mfun, fun); break; @@ -646,7 +646,7 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc) } /* Check if we're switching functions for some other reason. */ - if (ftrace_function_switched (bfun, mfun, fun)) + if (ftrace_function_switched (bfun, mfun, fun.symbol)) { DEBUG_FTRACE ("switching from %s in %s at %s", ftrace_print_insn_addr (last), @@ -707,7 +707,7 @@ ftrace_match_backtrace (struct btrace_thread_info *btinfo, for (matches = 0; lhs != NULL && rhs != NULL; ++matches) { - if (ftrace_function_switched (lhs, rhs->msym, rhs->sym)) + if (ftrace_function_switched (lhs, rhs->msym, rhs->sym.symbol)) return 0; lhs = ftrace_get_caller (btinfo, lhs); @@ -890,7 +890,7 @@ ftrace_connect_backtrace (struct btrace_thread_info *btinfo, { struct btrace_function *prev, *next; - gdb_assert (!ftrace_function_switched (lhs, rhs->msym, rhs->sym)); + gdb_assert (!ftrace_function_switched (lhs, rhs->msym, rhs->sym.symbol)); /* Connecting LHS and RHS may change the up link. */ prev = lhs; diff --git a/gdb/btrace.h b/gdb/btrace.h index 994af4c459b..9e32ce4da17 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -29,6 +29,7 @@ #include "gdbsupport/btrace-common.h" #include "target/waitstatus.h" #include "gdbsupport/enum-flags.h" +#include "block-symbol.h" #if defined (HAVE_LIBIPT) # include @@ -131,7 +132,7 @@ enum btrace_pt_error We do not allow function segments without instructions otherwise. */ struct btrace_function { - btrace_function (struct minimal_symbol *msym_, struct symbol *sym_, + btrace_function (struct minimal_symbol *msym_, block_symbol sym_, unsigned int number_, unsigned int insn_offset_, int level_) : msym (msym_), sym (sym_), insn_offset (insn_offset_), number (number_), level (level_) @@ -140,7 +141,7 @@ struct btrace_function /* The full and minimal symbol for the function. Both may be NULL. */ struct minimal_symbol *msym; - struct symbol *sym; + block_symbol sym; /* The function segment numbers of the previous and next segment belonging to the same function. If a function calls another function, the former will diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 822ae18e25e..7a51b1f0786 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -341,7 +341,7 @@ recpy_bt_func_symbol (PyObject *self, void *closure) if (func == NULL) return NULL; - if (func->sym == NULL) + if (func->sym.symbol == nullptr) Py_RETURN_NONE; return symbol_to_symbol_object (func->sym); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index abab79f3132..58017822923 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1069,7 +1069,7 @@ btrace_compute_src_line_range (const struct btrace_function *bfun, begin = INT_MAX; end = INT_MIN; - sym = bfun->sym; + sym = bfun->sym.symbol; if (sym == NULL) goto out; @@ -1101,7 +1101,7 @@ btrace_call_history_src_line (struct ui_out *uiout, struct symbol *sym; int begin, end; - sym = bfun->sym; + sym = bfun->sym.symbol; if (sym == NULL) return; @@ -1135,7 +1135,7 @@ btrace_get_bfun_name (const struct btrace_function *bfun) return "??"; msym = bfun->msym; - sym = bfun->sym; + sym = bfun->sym.symbol; if (sym != NULL) return sym->print_name (); @@ -1167,7 +1167,7 @@ btrace_call_history (struct ui_out *uiout, struct symbol *sym; bfun = btrace_call_get (&it); - sym = bfun->sym; + sym = bfun->sym.symbol; msym = bfun->msym; /* Print the function index. */