Skip to content

Commit

Permalink
gdb/dwarf: rename dwarf2_per_cu_data -> dwarf2_per_cu
Browse files Browse the repository at this point in the history
This scratches an itch I had for a while.  I don't know why this struct
type has "data" in its name.  Others like "dwarf2_per_objfile" and
"dwarf2_per_bfd" don't.  The primary job of a structure is to hold data,
there's no need to specify it.  It also makes the name a bit shorter,
which is always nice.

Rename related types too.

Change-Id: Ifb63195ff105809fc15b502f639c0bb4d18a675e
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
  • Loading branch information
simark committed Mar 3, 2025
1 parent 58539c5 commit b55c841
Show file tree
Hide file tree
Showing 21 changed files with 260 additions and 298 deletions.
6 changes: 3 additions & 3 deletions gdb/compile/compile-loc2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
CORE_ADDR *initial,
dwarf2_per_cu_data *per_cu,
dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile)
{
/* We keep a counter so that labels and other objects we create have
Expand Down Expand Up @@ -1147,7 +1147,7 @@ compile_dwarf_expr_to_c (string_file *stream, const char *result_name,
std::vector<bool> &registers_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile)
{
do_compile_dwarf_expr_to_c (2, stream, GCC_UINTPTR, result_name, sym, pc,
Expand All @@ -1166,7 +1166,7 @@ compile_dwarf_bounds_to_c (string_file *stream,
std::vector<bool> &registers_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile)
{
do_compile_dwarf_expr_to_c (2, stream, "unsigned long ", result_name,
Expand Down
6 changes: 3 additions & 3 deletions gdb/compile/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

struct ui_file;
struct gdbarch;
struct dwarf2_per_cu_data;
struct dwarf2_per_cu;
struct dwarf2_per_objfile;
struct symbol;
struct dynamic_prop;
Expand Down Expand Up @@ -215,7 +215,7 @@ extern void compile_dwarf_expr_to_c (string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile);

/* Compile a DWARF bounds expression to C, suitable for use by the
Expand Down Expand Up @@ -254,7 +254,7 @@ extern void compile_dwarf_bounds_to_c (string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile);

extern void compile_print_value (struct value *val, void *data_voidp);
Expand Down
5 changes: 2 additions & 3 deletions gdb/dwarf2/aranges.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
struct gdbarch *gdbarch = objfile->arch ();
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;

gdb::unordered_map<sect_offset, dwarf2_per_cu_data *>
debug_info_offset_to_per_cu;
gdb::unordered_map<sect_offset, dwarf2_per_cu *> debug_info_offset_to_per_cu;
for (const auto &per_cu : per_bfd->all_units)
{
/* A TU will not need aranges, and skipping them here is an easy
Expand Down Expand Up @@ -123,7 +122,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
sect_offset_str (sect_offset (debug_info_offset)));
return false;
}
dwarf2_per_cu_data *const per_cu = per_cu_it->second;
dwarf2_per_cu *const per_cu = per_cu_it->second;

const uint8_t address_size = *addr++;
if (address_size < 1 || address_size > 8)
Expand Down
6 changes: 3 additions & 3 deletions gdb/dwarf2/call-site.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "gdbsupport/unordered_set.h"

struct dwarf2_locexpr_baton;
struct dwarf2_per_cu_data;
struct dwarf2_per_cu;
struct dwarf2_per_objfile;

/* struct call_site_parameter can be referenced in callees by several ways. */
Expand Down Expand Up @@ -164,7 +164,7 @@ struct call_site_parameter

struct call_site
{
call_site (unrelocated_addr pc, dwarf2_per_cu_data *per_cu,
call_site (unrelocated_addr pc, dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile)
: per_cu (per_cu), per_objfile (per_objfile), m_unrelocated_pc (pc)
{}
Expand Down Expand Up @@ -209,7 +209,7 @@ struct call_site
/* * CU of the function where the call is located. It gets used
for DWARF blocks execution in the parameter array below. */

dwarf2_per_cu_data *const per_cu = nullptr;
dwarf2_per_cu *const per_cu = nullptr;

/* objfile of the function where the call is located. */

Expand Down
18 changes: 8 additions & 10 deletions gdb/dwarf2/cooked-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,8 @@ cooked_index_entry::write_scope (struct obstack *storage,
cooked_index_entry *
cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag,
cooked_index_flag flags, enum language lang,
const char *name,
cooked_index_entry_ref parent_entry,
dwarf2_per_cu_data *per_cu)
const char *name, cooked_index_entry_ref parent_entry,
dwarf2_per_cu *per_cu)
{
cooked_index_entry *result = create (die_offset, tag, flags, lang, name,
parent_entry, per_cu);
Expand Down Expand Up @@ -691,14 +690,14 @@ cooked_index::~cooked_index ()

/* See cooked-index.h. */

dwarf2_per_cu_data *
dwarf2_per_cu *
cooked_index::lookup (unrelocated_addr addr)
{
/* Ensure that the address maps are ready. */
wait (cooked_state::MAIN_AVAILABLE, true);
for (const auto &shard : m_shards)
{
dwarf2_per_cu_data *result = shard->lookup (addr);
dwarf2_per_cu *result = shard->lookup (addr);
if (result != nullptr)
return result;
}
Expand Down Expand Up @@ -857,14 +856,13 @@ cooked_index::dump (gdbarch *arch)

if (obj != nullptr)
{
const dwarf2_per_cu_data *per_cu
= static_cast<const dwarf2_per_cu_data *> (obj);
gdb_printf (" [%s] ((dwarf2_per_cu_data *) %p)\n",
const dwarf2_per_cu *per_cu
= static_cast<const dwarf2_per_cu *> (obj);
gdb_printf (" [%s] ((dwarf2_per_cu *) %p)\n",
start_addr_str, per_cu);
}
else
gdb_printf (" [%s] ((dwarf2_per_cu_data *) 0)\n",
start_addr_str);
gdb_printf (" [%s] ((dwarf2_per_cu *) 0)\n", start_addr_str);

return 0;
});
Expand Down
24 changes: 11 additions & 13 deletions gdb/dwarf2/cooked-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <condition_variable>
#endif /* CXX_STD_THREAD */

struct dwarf2_per_cu_data;
struct dwarf2_per_cu;
struct dwarf2_per_bfd;
struct index_cache_store_context;
struct cooked_index_entry;
Expand Down Expand Up @@ -105,7 +105,7 @@ struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
cooked_index_flag flags_,
enum language lang_, const char *name_,
cooked_index_entry_ref parent_entry_,
dwarf2_per_cu_data *per_cu_)
dwarf2_per_cu *per_cu_)
: name (name_),
tag (tag_),
flags (flags_),
Expand Down Expand Up @@ -241,7 +241,7 @@ struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
/* The offset of this DIE. */
sect_offset die_offset;
/* The CU from which this entry originates. */
dwarf2_per_cu_data *per_cu;
dwarf2_per_cu *per_cu;

private:

Expand Down Expand Up @@ -279,7 +279,7 @@ class cooked_index_shard
cooked_index_flag flags, enum language lang,
const char *name,
cooked_index_entry_ref parent_entry,
dwarf2_per_cu_data *per_cu);
dwarf2_per_cu *per_cu);

/* Install a new fixed addrmap from the given mutable addrmap. */
void install_addrmap (addrmap_mutable *map)
Expand Down Expand Up @@ -317,13 +317,12 @@ class cooked_index_shard
/* Look up ADDR in the address map, and return either the
corresponding CU, or nullptr if the address could not be
found. */
dwarf2_per_cu_data *lookup (unrelocated_addr addr)
dwarf2_per_cu *lookup (unrelocated_addr addr)
{
if (m_addrmap == nullptr)
return nullptr;

return (static_cast<dwarf2_per_cu_data *>
(m_addrmap->find ((CORE_ADDR) addr)));
return (static_cast<dwarf2_per_cu *> (m_addrmap->find ((CORE_ADDR) addr)));
}

/* Create a new cooked_index_entry and register it with this object.
Expand All @@ -334,7 +333,7 @@ class cooked_index_shard
enum language lang,
const char *name,
cooked_index_entry_ref parent_entry,
dwarf2_per_cu_data *per_cu)
dwarf2_per_cu *per_cu)
{
return new (&m_storage) cooked_index_entry (die_offset, tag, flags,
lang, name, parent_entry,
Expand All @@ -360,8 +359,7 @@ class cooked_index_shard
std::vector<cooked_index_entry *> m_entries;
/* If we found an entry with 'is_main' set, store it here. */
cooked_index_entry *m_main = nullptr;
/* The addrmap. This maps address ranges to dwarf2_per_cu_data
objects. */
/* The addrmap. This maps address ranges to dwarf2_per_cu objects. */
addrmap_fixed *m_addrmap = nullptr;
/* Storage for canonical names. */
std::vector<gdb::unique_xmalloc_ptr<char>> m_names;
Expand Down Expand Up @@ -389,7 +387,7 @@ class cooked_index_storage

/* Return the DIE reader corresponding to PER_CU. If no such reader
has been registered, return NULL. */
cutu_reader *get_reader (dwarf2_per_cu_data *per_cu);
cutu_reader *get_reader (dwarf2_per_cu *per_cu);

/* Preserve READER by storing it in the local hash table. */
cutu_reader *preserve (cutu_reader_up reader);
Expand All @@ -400,7 +398,7 @@ class cooked_index_storage
cooked_index_flag flags,
const char *name,
cooked_index_entry_ref parent_entry,
dwarf2_per_cu_data *per_cu)
dwarf2_per_cu *per_cu)
{
return m_shard->add (die_offset, tag, flags, per_cu->lang (),
name, parent_entry, per_cu);
Expand Down Expand Up @@ -671,7 +669,7 @@ class cooked_index : public dwarf_scanner_base
/* Look up ADDR in the address map, and return either the
corresponding CU, or nullptr if the address could not be
found. */
dwarf2_per_cu_data *lookup (unrelocated_addr addr) override;
dwarf2_per_cu *lookup (unrelocated_addr addr) override;

/* Return a new vector of all the addrmaps used by all the indexes
held by this object.
Expand Down
5 changes: 2 additions & 3 deletions gdb/dwarf2/cu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

/* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */

dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
dwarf2_cu::dwarf2_cu (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile)
: per_cu (per_cu),
per_objfile (per_objfile),
m_mark (false),
Expand Down Expand Up @@ -141,7 +140,7 @@ dwarf2_cu::mark ()

m_mark = true;

for (dwarf2_per_cu_data *per_cu : m_dependencies)
for (dwarf2_per_cu *per_cu : m_dependencies)
{
/* cu->m_dependencies references may not yet have been ever
read if QUIT aborts reading of the chain. As such
Expand Down
15 changes: 7 additions & 8 deletions gdb/dwarf2/cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ struct delayed_method_info
/* Internal state when decoding a particular compilation unit. */
struct dwarf2_cu
{
explicit dwarf2_cu (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
explicit dwarf2_cu (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile);

DISABLE_COPY_AND_ASSIGN (dwarf2_cu);

Expand Down Expand Up @@ -97,7 +96,7 @@ struct dwarf2_cu
}

/* Add a dependence relationship from this cu to REF_PER_CU. */
void add_dependence (struct dwarf2_per_cu_data *ref_per_cu)
void add_dependence (dwarf2_per_cu *ref_per_cu)
{ m_dependencies.emplace (ref_per_cu); }

/* The header of the compilation unit. */
Expand Down Expand Up @@ -268,10 +267,10 @@ struct dwarf2_cu
symbols are being read. */
buildsym_compunit_up m_builder;

/* A set of pointers to dwarf2_per_cu_data objects for compilation
units referenced by this one. Only used during full symbol processing;
partial symbol tables do not have dependencies. */
gdb::unordered_set<dwarf2_per_cu_data *> m_dependencies;
/* A set of pointers to dwarf2_per_cu objects for compilation units referenced
by this one. Only used during full symbol processing; partial symbol
tables do not have dependencies. */
gdb::unordered_set<dwarf2_per_cu *> m_dependencies;

public:
/* The generic symbol table building routines have separate lists for
Expand All @@ -290,7 +289,7 @@ struct dwarf2_cu
auto_obstack comp_unit_obstack;

/* Backlink to our per_cu entry. */
struct dwarf2_per_cu_data *per_cu;
dwarf2_per_cu *per_cu;

/* The dwarf2_per_objfile that owns this. */
dwarf2_per_objfile *per_objfile;
Expand Down
15 changes: 7 additions & 8 deletions gdb/dwarf2/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ensure_have_frame (const frame_info_ptr &frame, const char *op_name)
/* Ensure that a PER_CU is defined and throw an exception otherwise. */

static void
ensure_have_per_cu (dwarf2_per_cu_data *per_cu, const char* op_name)
ensure_have_per_cu (dwarf2_per_cu *per_cu, const char *op_name)
{
if (per_cu == nullptr)
throw_error (GENERIC_ERROR,
Expand Down Expand Up @@ -96,7 +96,7 @@ struct piece_closure
dwarf2_per_objfile *per_objfile = nullptr;

/* The CU from which this closure's expression came. */
dwarf2_per_cu_data *per_cu = nullptr;
dwarf2_per_cu *per_cu = nullptr;

/* The pieces describing this variable. */
std::vector<dwarf_expr_piece> pieces;
Expand All @@ -110,8 +110,7 @@ struct piece_closure
PIECES. */

static piece_closure *
allocate_piece_closure (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
allocate_piece_closure (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile,
std::vector<dwarf_expr_piece> &&pieces,
const frame_info_ptr &frame)
{
Expand Down Expand Up @@ -670,8 +669,7 @@ static const struct lval_funcs pieced_value_funcs = {
found at SECT_OFF. */

static value *
sect_variable_value (sect_offset sect_off,
dwarf2_per_cu_data *per_cu,
sect_variable_value (sect_offset sect_off, dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile)
{
const char *var_name = nullptr;
Expand Down Expand Up @@ -890,7 +888,7 @@ dwarf_expr_context::push_dwarf_reg_entry_value (call_site_parameter_kind kind,
ensure_have_per_cu (this->m_per_cu, "DW_OP_entry_value");
ensure_have_frame (this->m_frame, "DW_OP_entry_value");

dwarf2_per_cu_data *caller_per_cu;
dwarf2_per_cu *caller_per_cu;
dwarf2_per_objfile *caller_per_objfile;
frame_info_ptr caller_frame = get_prev_frame (this->m_frame);
call_site_parameter *parameter
Expand Down Expand Up @@ -1096,7 +1094,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,

value *
dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len, bool as_lval,
dwarf2_per_cu_data *per_cu, const frame_info_ptr &frame,
dwarf2_per_cu *per_cu,
const frame_info_ptr &frame,
const struct property_addr_info *addr_info,
struct type *type, struct type *subobj_type,
LONGEST subobj_offset)
Expand Down
4 changes: 2 additions & 2 deletions gdb/dwarf2/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct dwarf_expr_context
The ADDR_INFO property can be specified to override the range of
memory addresses with the passed in buffer. */
value *evaluate (const gdb_byte *addr, size_t len, bool as_lval,
dwarf2_per_cu_data *per_cu, const frame_info_ptr &frame,
dwarf2_per_cu *per_cu, const frame_info_ptr &frame,
const struct property_addr_info *addr_info = nullptr,
struct type *type = nullptr,
struct type *subobj_type = nullptr,
Expand Down Expand Up @@ -203,7 +203,7 @@ struct dwarf_expr_context
frame_info_ptr m_frame = nullptr;

/* Compilation unit used for the evaluation. */
dwarf2_per_cu_data *m_per_cu = nullptr;
dwarf2_per_cu *m_per_cu = nullptr;

/* Property address info used for the evaluation. */
const struct property_addr_info *m_addr_info = nullptr;
Expand Down
5 changes: 2 additions & 3 deletions gdb/dwarf2/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,8 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs,

int
dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
struct dwarf2_per_cu_data *data,
int *regnum_out, LONGEST *offset_out,
CORE_ADDR *text_offset_out,
dwarf2_per_cu *data, int *regnum_out,
LONGEST *offset_out, CORE_ADDR *text_offset_out,
const gdb_byte **cfa_start_out,
const gdb_byte **cfa_end_out)
{
Expand Down
Loading

0 comments on commit b55c841

Please sign in to comment.