From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 42FBF3856DD0 for ; Sun, 5 Nov 2023 18:11:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42FBF3856DD0 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 42FBF3856DD0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207898; cv=none; b=qOkltMjkTrJEQvRYU7xNKsImP7Fj27haH1Cwjf79w2R0rLQuw47uBKgdez8IHzynwKST1UaDamVshr4DJ9YDN3nusDT7Vp1mOg5v+vQo9/sqVZOFCDAtRYtPBwrJYMISNX8OduIhHeFImjNPCqub9qoBI73kGUsayvVeZQSuKGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207898; c=relaxed/simple; bh=lgQGEoz7NvxqFxhuDrEKagNUa8EjuWeyg9g3+mN4MsA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=nYoypwczOjeHQf0f8lDv5AfmrKTxm0kihvKn9s1x1F0mB8MwkL3pnx3yKbnNklG/3Kj09oeakOEdqXEicZUoU6iJenlPPFUl1vA7nEB2pBp/1kOys6YwxBsMBJ6ndFs5YvFn74ep6D2jdztEy92Z22wmTb1REeFS9vE/yVh9eTM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id zFJrqJR5cL9AgzhavqXSuM; Sun, 05 Nov 2023 18:11:33 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id zhauqGXzgI9guzhauqa274; Sun, 05 Nov 2023 18:11:32 +0000 X-Authority-Analysis: v=2.4 cv=Ds1FRUz+ c=1 sm=1 tr=0 ts=6547dad4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=xk1Hb6maDT9vQznErTcA: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=saZ4Kv/4jx7yuz4+zdVKJS7Gl38iHYM66aU1JAY6GRk=; b=IbmHGXoZAiFTkEoY8b89u3hqmL mDeVJk3CxDsoszH8p7IwyGPu2gn+97ePohBP6yBDaoBe5ooxj3zT8BcNL6Xgq53z9t4LWyn0yn7sx gUT72BUqK3x46Sov4CFZfsPjh; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:51014 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 1qzhat-003Y66-34 for gdb-patches@sourceware.org; Sun, 05 Nov 2023 11:11:31 -0700 From: Tom Tromey Date: Sun, 05 Nov 2023 11:11:52 -0700 Subject: [PATCH v2 14/31] Use read_var_value in gdb/compile MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231105-split-objfile-2023-bound-sym-october-v2-14-dbd2d158bbc3@tromey.com> References: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@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: 1qzhat-003Y66-34 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]:51014 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: MS4xfLRHwrpiWyRaRxJipxcMoV5vCcAePUKu+5ZRYRuDISnFjrAMFWwqxA70XC0xQM3nUzVp4JpqFrwR9P4mKnwbTj7tQ+5ensQbn3oEHBJ0KJOiCtxlP/QH xTNbrWlD+GOMMhaFqCtsLVBLw81gpi0hDPJHU7PADnDPp6JzjCG1KMwUeJ4qJ+ub5zstXuMCslG7aOd7c+UjSfGANeXzD4AXp1s= X-Spam-Status: No, score=-3023.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_STOCKGEN,RCVD_IN_MSPIKE_H2,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 List-Id: This changes the code in gdb/compile to use the new read_var_value overload. --- gdb/compile/compile-c-symbols.c | 12 +++++++----- gdb/compile/compile-loc2c.c | 14 ++++++++------ gdb/compile/compile.h | 6 +++--- gdb/dwarf2/ada-imported.c | 2 +- gdb/dwarf2/loc.c | 12 +++++++----- gdb/dwarf2/loc.h | 3 ++- gdb/symtab.h | 2 +- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 40578bf36f4..b8632013909 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -493,7 +493,7 @@ generate_vla_size (compile_instance *compiler, std::vector ®isters_used, CORE_ADDR pc, struct type *type, - struct symbol *sym) + block_symbol sym) { type = check_typedef (type); @@ -546,8 +546,9 @@ generate_c_for_for_one_variable (compile_instance *compiler, struct gdbarch *gdbarch, std::vector ®isters_used, CORE_ADDR pc, - struct symbol *sym) + block_symbol bsym) { + struct symbol *sym = bsym.symbol; try { @@ -558,7 +559,7 @@ generate_c_for_for_one_variable (compile_instance *compiler, string_file local_file; generate_vla_size (compiler, &local_file, gdbarch, registers_used, pc, - sym->type (), sym); + sym->type (), bsym); stream->write (local_file.c_str (), local_file.size ()); } @@ -571,7 +572,7 @@ generate_c_for_for_one_variable (compile_instance *compiler, occurs in the middle. */ string_file local_file; - SYMBOL_COMPUTED_OPS (sym)->generate_c_location (sym, &local_file, + SYMBOL_COMPUTED_OPS (sym)->generate_c_location (bsym, &local_file, gdbarch, registers_used, pc, @@ -639,9 +640,10 @@ generate_c_for_variable_locations (compile_instance *compiler, compute the location of each local variable. */ for (struct symbol *sym : block_iterator_range (block)) { + block_symbol bsym { sym, block }; if (!symbol_seen (symhash.get (), sym)) generate_c_for_for_one_variable (compiler, stream, gdbarch, - registers_used, pc, sym); + registers_used, pc, bsym); } /* If we just finished the outermost block of a function, we're diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 8a5a0f5abc5..ef150e7c27e 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -592,7 +592,7 @@ static void do_compile_dwarf_expr_to_c (int indent, string_file *stream, const char *type_name, const char *result_name, - struct symbol *sym, CORE_ADDR pc, + block_symbol bsym, CORE_ADDR pc, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, @@ -605,6 +605,8 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, unique names. */ static unsigned int scope; + struct symbol *sym = bsym.symbol; + enum bfd_endian byte_order = gdbarch_byte_order (arch); const gdb_byte * const base = op_ptr; int need_tempvar = 0; @@ -641,7 +643,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, "there is no selected frame"), sym->print_name ()); - val = read_var_value (sym, NULL, frame); + val = read_var_value (bsym, frame); if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation evaluation " "as its address has not been found."), @@ -909,7 +911,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, do_compile_dwarf_expr_to_c (indent, stream, GCC_UINTPTR, fb_name, - sym, pc, + bsym, pc, arch, registers_used, addr_size, datastart, datastart + datalen, NULL, per_cu, per_objfile); @@ -1097,7 +1099,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, do_compile_dwarf_expr_to_c (indent, stream, GCC_UINTPTR, cfa_name, - sym, pc, arch, registers_used, + bsym, pc, arch, registers_used, addr_size, cfa_start, cfa_end, &text_offset, per_cu, per_objfile); @@ -1143,7 +1145,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, void compile_dwarf_expr_to_c (string_file *stream, const char *result_name, - struct symbol *sym, CORE_ADDR pc, + block_symbol sym, CORE_ADDR pc, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, @@ -1162,7 +1164,7 @@ void compile_dwarf_bounds_to_c (string_file *stream, const char *result_name, const struct dynamic_prop *prop, - struct symbol *sym, CORE_ADDR pc, + block_symbol sym, CORE_ADDR pc, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h index a3b6a18fe20..7cb38cb006c 100644 --- a/gdb/compile/compile.h +++ b/gdb/compile/compile.h @@ -19,12 +19,12 @@ #define COMPILE_COMPILE_H #include "gcc-c-interface.h" +#include "block-symbol.h" struct ui_file; struct gdbarch; struct dwarf2_per_cu_data; struct dwarf2_per_objfile; -struct symbol; struct dynamic_prop; /* An object of this type holds state associated with a given @@ -177,7 +177,7 @@ extern void eval_compile_command (struct command_line *cmd, extern void compile_dwarf_expr_to_c (string_file *stream, const char *result_name, - struct symbol *sym, + block_symbol sym, CORE_ADDR pc, struct gdbarch *arch, std::vector ®isters_used, @@ -217,7 +217,7 @@ extern void compile_dwarf_expr_to_c (string_file *stream, extern void compile_dwarf_bounds_to_c (string_file *stream, const char *result_name, const struct dynamic_prop *prop, - struct symbol *sym, CORE_ADDR pc, + block_symbol sym, CORE_ADDR pc, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index d1d99be6923..9947d8e04b7 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -75,7 +75,7 @@ ada_imported_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax, symbol_computed_ops. */ static void -ada_imported_generate_c_location (struct symbol *symbol, string_file *stream, +ada_imported_generate_c_location (block_symbol symbol, string_file *stream, struct gdbarch *gdbarch, std::vector ®isters_used, CORE_ADDR pc, const char *result_name) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 5b2d58ab44e..53031aa809a 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1786,7 +1786,7 @@ dwarf2_compile_property_to_c (string_file *stream, std::vector ®isters_used, const struct dynamic_prop *prop, CORE_ADDR pc, - struct symbol *sym) + block_symbol sym) { const dwarf2_property_baton *baton = prop->baton (); const gdb_byte *data; @@ -3847,11 +3847,12 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax, /* symbol_computed_ops 'generate_c_location' method. */ static void -locexpr_generate_c_location (struct symbol *sym, string_file *stream, +locexpr_generate_c_location (block_symbol bsym, string_file *stream, struct gdbarch *gdbarch, std::vector ®isters_used, CORE_ADDR pc, const char *result_name) { + symbol *sym = bsym.symbol; struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym); unsigned int addr_size = dlbaton->per_cu->addr_size (); @@ -3860,7 +3861,7 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream, error (_("symbol \"%s\" is optimized out"), sym->natural_name ()); compile_dwarf_expr_to_c (stream, result_name, - sym, pc, gdbarch, registers_used, addr_size, + bsym, pc, gdbarch, registers_used, addr_size, dlbaton->data, dlbaton->data + dlbaton->size, dlbaton->per_cu, dlbaton->per_objfile); } @@ -4083,11 +4084,12 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax, /* symbol_computed_ops 'generate_c_location' method. */ static void -loclist_generate_c_location (struct symbol *sym, string_file *stream, +loclist_generate_c_location (block_symbol bsym, string_file *stream, struct gdbarch *gdbarch, std::vector ®isters_used, CORE_ADDR pc, const char *result_name) { + symbol *sym = bsym.symbol; struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym); unsigned int addr_size = dlbaton->per_cu->addr_size (); @@ -4099,7 +4101,7 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream, error (_("symbol \"%s\" is optimized out"), sym->natural_name ()); compile_dwarf_expr_to_c (stream, result_name, - sym, pc, gdbarch, registers_used, addr_size, + bsym, pc, gdbarch, registers_used, addr_size, data, data + size, dlbaton->per_cu, dlbaton->per_objfile); diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 5cf824d3ae2..9722083cbeb 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -21,6 +21,7 @@ #define DWARF2LOC_H #include "dwarf2/expr.h" +#include "block-symbol.h" struct symbol_computed_ops; struct dwarf2_per_objfile; @@ -144,7 +145,7 @@ void dwarf2_compile_property_to_c (string_file *stream, std::vector ®isters_used, const struct dynamic_prop *prop, CORE_ADDR address, - struct symbol *sym); + block_symbol sym); /* The symbol location baton types used by the DWARF-2 reader (i.e. SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct diff --git a/gdb/symtab.h b/gdb/symtab.h index a518ed83622..34ce10f5011 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1130,7 +1130,7 @@ struct symbol_computed_ops The generated C code must assign the location to a local variable; this variable's name is RESULT_NAME. */ - void (*generate_c_location) (struct symbol *symbol, string_file *stream, + void (*generate_c_location) (block_symbol symbol, string_file *stream, struct gdbarch *gdbarch, std::vector ®isters_used, CORE_ADDR pc, const char *result_name); -- 2.41.0