From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 14/31] Use read_var_value in gdb/compile
Date: Sun, 05 Nov 2023 11:11:52 -0700 [thread overview]
Message-ID: <20231105-split-objfile-2023-bound-sym-october-v2-14-dbd2d158bbc3@tromey.com> (raw)
In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com>
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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®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<bool> ®isters_used,
CORE_ADDR pc, const char *result_name);
--
2.41.0
next prev parent reply other threads:[~2023-11-05 18:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 18:11 [PATCH v2 00/31] Baby step for objfile splitting Tom Tromey
2023-11-05 18:11 ` [PATCH v2 01/31] Introduce block-symbol.h Tom Tromey
2023-11-05 18:11 ` [PATCH v2 02/31] Add block_symbol::address Tom Tromey
2023-11-05 18:11 ` [PATCH v2 03/31] Add bound_symbol Tom Tromey
2023-11-05 18:11 ` [PATCH v2 04/31] Easy conversions to use block_symbol::address Tom Tromey
2023-11-05 18:11 ` [PATCH v2 05/31] Use block_symbol::address in ada-tasks.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 06/31] Use block_symbol::address in printcmd.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 07/31] Use bound_symbol::address in tracepoint.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 08/31] Use block_symbol::address " Tom Tromey
2023-11-05 18:11 ` [PATCH v2 09/31] Use block_symbol::address in ax-gdb.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 10/31] Use block_symbol::address in linespec.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 11/31] Use block_symbol::address in ada-lang.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 12/31] Use bound_symbol::address in symmisc.c Tom Tromey
2023-11-05 18:11 ` [PATCH v2 13/31] Introduce read_var_value overload Tom Tromey
2023-11-05 18:11 ` Tom Tromey [this message]
2023-11-05 18:11 ` [PATCH v2 15/31] Return a block_symbol from find_pc_sect_function Tom Tromey
2023-11-05 18:11 ` [PATCH v2 16/31] Use read_var_value overload in finish_command_fsm Tom Tromey
2023-11-05 18:11 ` [PATCH v2 17/31] Use block_symbol in overload-handling code Tom Tromey
2023-11-05 18:11 ` [PATCH v2 18/31] Change evaluate_var_value to accept a block_symbol Tom Tromey
2023-11-05 18:11 ` [PATCH v2 19/31] Change value_of_variable to take " Tom Tromey
2023-11-05 18:11 ` [PATCH v2 20/31] Return a block_symbol from get_frame_function Tom Tromey
2023-11-05 18:11 ` [PATCH v2 21/31] Use read_var_value overload in return_command Tom Tromey
2023-11-05 18:12 ` [PATCH v2 22/31] Use read_var_value overload in py-finishbreakpoint.c Tom Tromey
2023-11-05 18:12 ` [PATCH v2 23/31] Use read_var_value overload in py-framefilter.c Tom Tromey
2023-11-05 18:12 ` [PATCH v2 24/31] Use read_var_value overload in Guile Tom Tromey
2023-11-05 18:12 ` [PATCH v2 25/31] Use read_var_value in read_frame_arg and read_frame_local Tom Tromey
2023-11-05 18:12 ` [PATCH v2 26/31] Change print_variable_and_value to take a block_symbol Tom Tromey
2023-11-05 18:12 ` [PATCH v2 27/31] Change find_frame_funname to return " Tom Tromey
2023-11-05 18:12 ` [PATCH v2 28/31] Change btrace_function::sym to " Tom Tromey
2023-11-05 18:12 ` [PATCH v2 29/31] Use read_var_value overload in Python Tom Tromey
2023-11-05 18:12 ` [PATCH v2 30/31] Remove the old read_var_value Tom Tromey
2023-11-05 18:12 ` [PATCH v2 31/31] Change language_defn::read_var_value to accept block_symbol Tom Tromey
2023-11-06 15:16 ` [PATCH v2 00/31] Baby step for objfile splitting Andrew Burgess
2023-11-07 3:36 ` Tom Tromey
2023-11-07 11:06 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231105-split-objfile-2023-bound-sym-october-v2-14-dbd2d158bbc3@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).