* [PATCH 01/14] gdb: remove BLOCK_{START,END} macros
@ 2022-04-21 14:58 Simon Marchi
2022-04-21 14:58 ` [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro Simon Marchi
` (9 more replies)
0 siblings, 10 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods.
Change-Id: I10a6c8a2a86462d9d4a6a6409a3f07a6bea66310
---
gdb/alpha-mdebug-tdep.c | 2 +-
gdb/block.c | 6 +--
gdb/block.h | 27 +++++++++++---
gdb/blockframe.c | 4 +-
gdb/buildsym.c | 48 ++++++++++++------------
gdb/compile/compile-cplus-symbols.c | 4 +-
gdb/compile/compile-cplus-types.c | 2 +-
gdb/csky-tdep.c | 2 +-
gdb/frame.c | 2 +-
gdb/guile/scm-block.c | 6 +--
gdb/infcmd.c | 4 +-
gdb/jit.c | 16 ++++----
gdb/mdebugread.c | 57 +++++++++++++++--------------
gdb/mips-tdep.c | 4 +-
gdb/objfiles.c | 4 +-
gdb/psymtab.c | 8 ++--
gdb/python/py-block.c | 4 +-
gdb/symmisc.c | 8 ++--
gdb/symtab.c | 8 ++--
gdb/varobj.c | 4 +-
20 files changed, 121 insertions(+), 99 deletions(-)
diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
index a8b4bcbea4aa..10169c76c378 100644
--- a/gdb/alpha-mdebug-tdep.c
+++ b/gdb/alpha-mdebug-tdep.c
@@ -102,7 +102,7 @@ find_proc_desc (CORE_ADDR pc)
CORE_ADDR startaddr;
find_pc_partial_function (pc, &sh_name, &startaddr, NULL);
- if (startaddr > BLOCK_START (b))
+ if (startaddr > b->start ())
/* This is the "pathological" case referred to in a comment in
print_frame_info. It might be better to move this check into
symbol reading. */
diff --git a/gdb/block.c b/gdb/block.c
index bab6868bbbb4..a4678ca6a84b 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -155,7 +155,7 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
{
half = (top - bot + 1) >> 1;
b = BLOCKVECTOR_BLOCK (bl, bot + half);
- if (BLOCK_START (b) <= pc)
+ if (b->start () <= pc)
bot += half;
else
top = bot + half;
@@ -166,9 +166,9 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
while (bot >= STATIC_BLOCK)
{
b = BLOCKVECTOR_BLOCK (bl, bot);
- if (!(BLOCK_START (b) <= pc))
+ if (!(b->start () <= pc))
return NULL;
- if (BLOCK_END (b) > pc)
+ if (b->end () > pc)
return b;
bot--;
}
diff --git a/gdb/block.h b/gdb/block.h
index eedba91ac896..82d20e4d25d6 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -90,11 +90,30 @@ struct blockranges
struct block
{
+ CORE_ADDR start () const
+ {
+ return m_start;
+ }
+
+ void set_start (CORE_ADDR start)
+ {
+ m_start = start;
+ }
+
+ CORE_ADDR end () const
+ {
+ return m_end;
+ }
+
+ void set_end (CORE_ADDR end)
+ {
+ m_end = end;
+ }
/* Addresses in the executable code that are in this block. */
- CORE_ADDR startaddr;
- CORE_ADDR endaddr;
+ CORE_ADDR m_start;
+ CORE_ADDR m_end;
/* The symbol that names this block, if the block is the body of a
function (real or inlined); otherwise, zero. */
@@ -139,8 +158,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-#define BLOCK_START(bl) (bl)->startaddr
-#define BLOCK_END(bl) (bl)->endaddr
#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_MULTIDICT(bl) (bl)->multidict
@@ -186,7 +203,7 @@ struct global_block
too). BLOCK_ENTRY_PC can then be redefined to be less DWARF-centric. */
#define BLOCK_ENTRY_PC(bl) (BLOCK_CONTIGUOUS_P (bl) \
- ? BLOCK_START (bl) \
+ ? bl->start () \
: BLOCK_RANGE_START (bl,0))
struct blockvector
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index df03901b6e79..fec7f0530579 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -278,8 +278,8 @@ find_pc_partial_function_sym (CORE_ADDR pc,
if (BLOCK_CONTIGUOUS_P (b))
{
- cache_pc_function_low = BLOCK_START (b);
- cache_pc_function_high = BLOCK_END (b);
+ cache_pc_function_low = b->start ();
+ cache_pc_function_high = b->end ();
}
else
{
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 927074b76691..3dba963d502f 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -233,8 +233,8 @@ buildsym_compunit::finish_block_internal
}
}
- BLOCK_START (block) = start;
- BLOCK_END (block) = end;
+ block->set_start (start);
+ block->set_end (end);
/* Put the block in as the value of the symbol that names it. */
@@ -305,7 +305,7 @@ buildsym_compunit::finish_block_internal
/* Check to be sure that the blocks have an end address that is
greater than starting address. */
- if (BLOCK_END (block) < BLOCK_START (block))
+ if (block->end () < block->start ())
{
if (symbol)
{
@@ -317,11 +317,11 @@ buildsym_compunit::finish_block_internal
{
complaint (_("block end address %s less than block "
"start address %s (patched it)"),
- paddress (gdbarch, BLOCK_END (block)),
- paddress (gdbarch, BLOCK_START (block)));
+ paddress (gdbarch, block->end ()),
+ paddress (gdbarch, block->start ()));
}
/* Better than nothing. */
- BLOCK_END (block) = BLOCK_START (block);
+ block->set_end (block->start ());
}
/* Install this block as the superblock of all blocks made since the
@@ -342,8 +342,8 @@ buildsym_compunit::finish_block_internal
physically nested inside this other blocks, only
lexically nested. */
if (BLOCK_FUNCTION (pblock->block) == NULL
- && (BLOCK_START (pblock->block) < BLOCK_START (block)
- || BLOCK_END (pblock->block) > BLOCK_END (block)))
+ && (pblock->block->start () < block->start ()
+ || pblock->block->end () > block->end ()))
{
if (symbol)
{
@@ -354,15 +354,17 @@ buildsym_compunit::finish_block_internal
{
complaint (_("inner block (%s-%s) not "
"inside outer block (%s-%s)"),
- paddress (gdbarch, BLOCK_START (pblock->block)),
- paddress (gdbarch, BLOCK_END (pblock->block)),
- paddress (gdbarch, BLOCK_START (block)),
- paddress (gdbarch, BLOCK_END (block)));
+ paddress (gdbarch, pblock->block->start ()),
+ paddress (gdbarch, pblock->block->end ()),
+ paddress (gdbarch, block->start ()),
+ paddress (gdbarch, block->end ()));
}
- if (BLOCK_START (pblock->block) < BLOCK_START (block))
- BLOCK_START (pblock->block) = BLOCK_START (block);
- if (BLOCK_END (pblock->block) > BLOCK_END (block))
- BLOCK_END (pblock->block) = BLOCK_END (block);
+
+ if (pblock->block->start () < block->start ())
+ pblock->block->set_start (block->start ());
+
+ if (pblock->block->end () > block->end ())
+ pblock->block->set_end (block->end ());
}
BLOCK_SUPERBLOCK (pblock->block) = block;
}
@@ -412,8 +414,8 @@ buildsym_compunit::record_block_range (struct block *block,
become interesting. Note that even if this block doesn't have
any "interesting" ranges, some later block might, so we still
need to record this block in the addrmap. */
- if (start != BLOCK_START (block)
- || end_inclusive + 1 != BLOCK_END (block))
+ if (start != block->start ()
+ || end_inclusive + 1 != block->end ())
m_pending_addrmap_interesting = true;
if (m_pending_addrmap == nullptr)
@@ -472,11 +474,11 @@ buildsym_compunit::make_blockvector ()
{
for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++)
{
- if (BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i - 1))
- > BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i)))
+ if (BLOCKVECTOR_BLOCK(blockvector, i - 1)->start ()
+ > BLOCKVECTOR_BLOCK(blockvector, i)->start ())
{
CORE_ADDR start
- = BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i));
+ = BLOCKVECTOR_BLOCK(blockvector, i)->start ();
complaint (_("block at %s out of order"),
hex_string ((LONGEST) start));
@@ -819,7 +821,7 @@ buildsym_compunit::end_compunit_symtab_get_static_block (CORE_ADDR end_addr,
std::stable_sort (barray.begin (), barray.end (),
[] (const block *a, const block *b)
{
- return BLOCK_START (a) > BLOCK_START (b);
+ return a->start () > b->start ();
});
int i = 0;
@@ -877,7 +879,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
gdb_assert (static_block != NULL);
gdb_assert (m_subfiles != NULL);
- end_addr = BLOCK_END (static_block);
+ end_addr = static_block->end ();
/* Create the GLOBAL_BLOCK and build the blockvector. */
finish_block_internal (NULL, get_global_symbols (), NULL, NULL,
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 95d43507c30e..ef2a1f57603b 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -87,7 +87,7 @@ convert_one_symbol (compile_cplus_instance *instance,
case LOC_BLOCK:
{
kind = GCC_CP_SYMBOL_FUNCTION;
- addr = BLOCK_START (sym.symbol->value_block ());
+ addr = sym.symbol->value_block()->start ();
if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
}
@@ -441,7 +441,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
gdb_printf (gdb_stdlog,
"gcc_symbol_address \"%s\": full symbol\n",
identifier);
- result = BLOCK_START (sym->value_block ());
+ result = sym->value_block ()->start ();
if (sym->type ()->is_gnu_ifunc ())
result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
found = 1;
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index ab65e47f49d6..e7c940b1355a 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -766,7 +766,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
const char *filename = sym.symbol->symtab ()->filename;
unsigned int line = sym.symbol->line ();
- CORE_ADDR address = BLOCK_START (sym.symbol->value_block ());
+ CORE_ADDR address = sym.symbol->value_block()->start ();
const char *kind;
if (TYPE_FN_FIELD_STATIC_P (methods, j))
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 105f5fccd129..a9b539165610 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -1839,7 +1839,7 @@ csky_frame_unwind_cache (struct frame_info *this_frame)
/* Get the (function) symbol matching prologue_start. */
bl = block_for_pc (prologue_start);
if (bl != NULL)
- func_size = bl->endaddr - bl->startaddr;
+ func_size = bl->end () - bl->start ();
else
{
struct bound_minimal_symbol msymbol
diff --git a/gdb/frame.c b/gdb/frame.c
index 5e3c02e2029b..ae45e22d613d 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2432,7 +2432,7 @@ inside_main_func (frame_info *this_frame)
const struct block *block = bs.symbol->value_block ();
gdb_assert (block != nullptr);
- sym_addr = BLOCK_START (block);
+ sym_addr = block->start ();
}
else
sym_addr = msymbol.value_address ();
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index df0ef7f0b1f0..921225dcf474 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -160,7 +160,7 @@ bkscm_print_block_smob (SCM self, SCM port, scm_print_state *pstate)
gdbscm_printf (port, " %s", BLOCK_FUNCTION (b)->print_name ());
gdbscm_printf (port, " %s-%s",
- hex_string (BLOCK_START (b)), hex_string (BLOCK_END (b)));
+ hex_string (b->start ()), hex_string (b->end ()));
scm_puts (">", port);
@@ -379,7 +379,7 @@ gdbscm_block_start (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
- return gdbscm_scm_from_ulongest (BLOCK_START (block));
+ return gdbscm_scm_from_ulongest (block->start ());
}
/* (block-end <gdb:block>) -> address */
@@ -391,7 +391,7 @@ gdbscm_block_end (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
- return gdbscm_scm_from_ulongest (BLOCK_END (block));
+ return gdbscm_scm_from_ulongest (block->end ());
}
/* (block-function <gdb:block>) -> <gdb:symbol> */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index c7f339a7a945..5368fcd71570 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -980,8 +980,8 @@ prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
if (sym->aclass () == LOC_BLOCK)
{
const block *block = sym->value_block ();
- if (BLOCK_END (block) < tp->control.step_range_end)
- tp->control.step_range_end = BLOCK_END (block);
+ if (block->end () < tp->control.step_range_end)
+ tp->control.step_range_end = block->end ();
}
}
diff --git a/gdb/jit.c b/gdb/jit.c
index f7e25e494d44..49db391f80c0 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -583,8 +583,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
BLOCK_MULTIDICT (new_block)
= mdict_create_linear (&objfile->objfile_obstack, NULL);
/* The address range. */
- BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter.begin;
- BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter.end;
+ new_block->set_start (gdb_block_iter.begin);
+ new_block->set_end (gdb_block_iter.end);
/* The name. */
block_name->set_domain (VAR_DOMAIN);
@@ -599,10 +599,10 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
BLOCK_FUNCTION (new_block) = block_name;
BLOCKVECTOR_BLOCK (bv, block_idx) = new_block;
- if (begin > BLOCK_START (new_block))
- begin = BLOCK_START (new_block);
- if (end < BLOCK_END (new_block))
- end = BLOCK_END (new_block);
+ if (begin > new_block->start ())
+ begin = new_block->start ();
+ if (end < new_block->end ())
+ end = new_block->end ();
gdb_block_iter.real_block = new_block;
@@ -623,8 +623,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
BLOCK_SUPERBLOCK (new_block) = block_iter;
block_iter = new_block;
- BLOCK_START (new_block) = (CORE_ADDR) begin;
- BLOCK_END (new_block) = (CORE_ADDR) end;
+ new_block->set_start (begin);
+ new_block->set_end (end);
BLOCKVECTOR_BLOCK (bv, i) = new_block;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 7083beb01ed3..1565a86bad01 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -798,7 +798,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
b = new_block (FUNCTION_BLOCK, s->language ());
s->set_value_block (b);
BLOCK_FUNCTION (b) = s;
- BLOCK_START (b) = BLOCK_END (b) = sh->value;
+ b->set_start (sh->value);
+ b->set_end (sh->value);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
add_block (b, top_stack->cur_st);
@@ -1126,7 +1127,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
top_stack->blocktype = stBlock;
b = new_block (NON_FUNCTION_BLOCK, psymtab_language);
- BLOCK_START (b) = sh->value + top_stack->procadr;
+ b->set_start (sh->value + top_stack->procadr);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
top_stack->cur_block = b;
add_block (b, top_stack->cur_st);
@@ -1150,7 +1151,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct type *ftype = top_stack->cur_type;
int i;
- BLOCK_END (top_stack->cur_block) += sh->value; /* size */
+ top_stack->cur_block->set_end
+ (top_stack->cur_block->end () + sh->value); /* size */
/* Make up special symbol to contain procedure specific info. */
s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
@@ -1171,11 +1173,11 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
if (BLOCK_SUPERBLOCK (b_bad) == cblock
- && BLOCK_START (b_bad) == top_stack->procadr
- && BLOCK_END (b_bad) == top_stack->procadr)
+ && b_bad->start () == top_stack->procadr
+ && b_bad->end () == top_stack->procadr)
{
- BLOCK_START (b_bad) = BLOCK_START (cblock);
- BLOCK_END (b_bad) = BLOCK_END (cblock);
+ b_bad->set_start (cblock->start ());
+ b_bad->set_end (cblock->end ());
}
}
@@ -1217,7 +1219,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* End of (code) block. The value of the symbol is the
displacement from the procedure`s start address of the
end of this block. */
- BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
+ top_stack->cur_block->set_end (sh->value + top_stack->procadr);
}
else if (sh->sc == scText && top_stack->blocktype == stNil)
{
@@ -2024,7 +2026,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
e->pdr.adr is sometimes offset by a bogus value.
To work around these problems, we replace e->pdr.adr with
the start address of the function. */
- e->pdr.adr = BLOCK_START (b);
+ e->pdr.adr = b->start ();
}
/* It would be reasonable that functions that have been compiled
@@ -4099,8 +4101,8 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
top_stack->cur_st = cust->primary_filetab ();
top_stack->cur_block
= BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
- BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
- BLOCK_END (top_stack->cur_block) = 0;
+ top_stack->cur_block->set_start (pst->text_low (objfile));
+ top_stack->cur_block->set_end (0);
top_stack->blocktype = stFile;
top_stack->cur_type = 0;
top_stack->procadr = 0;
@@ -4550,13 +4552,13 @@ add_line (struct linetable *lt, int lineno, CORE_ADDR adr, int last)
static bool
block_is_less_than (const struct block *b1, const struct block *b2)
{
- CORE_ADDR start1 = BLOCK_START (b1);
- CORE_ADDR start2 = BLOCK_START (b2);
+ CORE_ADDR start1 = b1->start ();
+ CORE_ADDR start2 = b2->start ();
if (start1 != start2)
return start1 < start2;
- return (BLOCK_END (b2)) < (BLOCK_END (b1));
+ return (b2->end ()) < (b1->end ());
}
/* Sort the blocks of a symtab S.
@@ -4574,10 +4576,10 @@ sort_blocks (struct symtab *s)
if (BLOCKVECTOR_NBLOCKS (bv) <= FIRST_LOCAL_BLOCK)
{
/* Cosmetic */
- if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0)
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0;
- if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0)
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0;
+ if (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->end () == 0)
+ BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_start (0);
+ if (BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->end () == 0)
+ BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_start (0);
return;
}
/*
@@ -4596,18 +4598,19 @@ sort_blocks (struct symtab *s)
int i, j = BLOCKVECTOR_NBLOCKS (bv);
for (i = FIRST_LOCAL_BLOCK; i < j; i++)
- if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)))
- high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i));
- BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high;
+ if (high < BLOCKVECTOR_BLOCK(bv, i)->end ())
+ high = BLOCKVECTOR_BLOCK(bv, i)->end ();
+ BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_end (high);
}
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) =
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK));
+ BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->set_start
+ (BLOCKVECTOR_BLOCK(bv, FIRST_LOCAL_BLOCK)->start ());
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
- BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
- BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
- BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
+ BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_start
+ (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->start ());
+
+ BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_end
+ (BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK)->end ());
}
\f
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 354c2b54e07c..ffed8723dce6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -490,11 +490,11 @@ mips_make_symbol_special (struct symbol *sym, struct objfile *objfile)
CORE_ADDR compact_block_start;
struct bound_minimal_symbol msym;
- compact_block_start = BLOCK_START (block) | 1;
+ compact_block_start = block->start () | 1;
msym = lookup_minimal_symbol_by_pc (compact_block_start);
if (msym.minsym && !msymbol_is_mips (msym.minsym))
{
- BLOCK_START (block) = compact_block_start;
+ block->set_start (compact_block_start);
}
}
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 849c6d73cab8..e664bcd2da97 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -677,8 +677,8 @@ objfile_relocate1 (struct objfile *objfile,
struct mdict_iterator miter;
b = BLOCKVECTOR_BLOCK (bv, i);
- BLOCK_START (b) += delta[block_line_section];
- BLOCK_END (b) += delta[block_line_section];
+ b->set_start (b->start () + delta[block_line_section]);
+ b->set_end (b->end () + delta[block_line_section]);
if (BLOCK_RANGES (b) != nullptr)
for (int j = 0; j < BLOCK_NRANGES (b); j++)
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 5d9949bca1d9..ce29e1922a15 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1835,8 +1835,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
}
}
if (ps->raw_text_high () != 0
- && (ps->text_low (objfile) < BLOCK_START (b)
- || ps->text_high (objfile) > BLOCK_END (b)))
+ && (ps->text_low (objfile) < b->start ()
+ || ps->text_high (objfile) > b->end ()))
{
gdb_printf ("Psymtab ");
gdb_puts (ps->filename);
@@ -1845,9 +1845,9 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
gdb_printf (" - ");
gdb_puts (paddress (gdbarch, ps->text_high (objfile)));
gdb_printf (" but symtab covers only ");
- gdb_puts (paddress (gdbarch, BLOCK_START (b)));
+ gdb_puts (paddress (gdbarch, b->start ()));
gdb_printf (" - ");
- gdb_puts (paddress (gdbarch, BLOCK_END (b)));
+ gdb_puts (paddress (gdbarch, b->end ()));
gdb_printf ("\n");
}
}
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index cf543c794842..aa8f3df7af93 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -109,7 +109,7 @@ blpy_get_start (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- return gdb_py_object_from_ulongest (BLOCK_START (block)).release ();
+ return gdb_py_object_from_ulongest (block->start ()).release ();
}
static PyObject *
@@ -119,7 +119,7 @@ blpy_get_end (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- return gdb_py_object_from_ulongest (BLOCK_END (block)).release ();
+ return gdb_py_object_from_ulongest (block->end ()).release ();
}
static PyObject *
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index dee11fdf57d9..097dc2dd3556 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -295,9 +295,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
wants it. */
gdb_printf (outfile, ", %d syms/buckets in ",
mdict_size (BLOCK_MULTIDICT (b)));
- gdb_puts (paddress (gdbarch, BLOCK_START (b)), outfile);
+ gdb_puts (paddress (gdbarch, b->start ()), outfile);
gdb_printf (outfile, "..");
- gdb_puts (paddress (gdbarch, BLOCK_END (b)), outfile);
+ gdb_puts (paddress (gdbarch, b->end ()), outfile);
if (BLOCK_FUNCTION (b))
{
gdb_printf (outfile, ", function %s",
@@ -631,8 +631,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
gdb_printf
(outfile, "block object %s, %s..%s",
host_address_to_string (symbol->value_block ()),
- paddress (gdbarch, BLOCK_START (symbol->value_block ())),
- paddress (gdbarch, BLOCK_END (symbol->value_block ())));
+ paddress (gdbarch, symbol->value_block()->start ()),
+ paddress (gdbarch, symbol->value_block()->end ()));
if (section)
gdb_printf (outfile, " section %s",
bfd_section_name (section->the_bfd_section));
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6926d1559b20..993b1962c8c3 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2982,8 +2982,8 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
const struct blockvector *bv = cust->blockvector ();
const struct block *global_block
= BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- CORE_ADDR start = BLOCK_START (global_block);
- CORE_ADDR end = BLOCK_END (global_block);
+ CORE_ADDR start = global_block->start ();
+ CORE_ADDR end = global_block->end ();
bool in_range_p = start <= pc && pc < end;
if (!in_range_p)
continue;
@@ -3406,7 +3406,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
else if (alt)
val.end = alt->pc;
else
- val.end = BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
+ val.end = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)->end ();
}
val.section = section;
return val;
@@ -3985,7 +3985,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
line is still part of the same function. */
if (skip && start_sal.pc != pc
&& (sym ? (BLOCK_ENTRY_PC (sym->value_block ()) <= start_sal.end
- && start_sal.end < BLOCK_END (sym->value_block ()))
+ && start_sal.end < sym->value_block()->end ())
: (lookup_minimal_symbol_by_pc_section (start_sal.end, section).minsym
== lookup_minimal_symbol_by_pc_section (pc, section).minsym)))
{
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 6693dacd7869..741fdb6a03b1 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1939,8 +1939,8 @@ check_scope (const struct varobj *var)
{
CORE_ADDR pc = get_frame_pc (fi);
- if (pc < BLOCK_START (var->root->valid_block) ||
- pc >= BLOCK_END (var->root->valid_block))
+ if (pc < var->root->valid_block->start () ||
+ pc >= var->root->valid_block->end ())
scope = false;
else
select_frame (fi);
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
@ 2022-04-21 14:58 ` Simon Marchi
2022-04-21 14:58 ` [PATCH 03/14] gdb: remove BLOCK_SUPERBLOCK macro Simon Marchi
` (8 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods.
Change-Id: I31ec00f5bf85335c8b23d306ca0fe0b84d489101
---
gdb/ada-lang.c | 4 ++--
gdb/block.c | 24 ++++++++++++------------
gdb/block.h | 13 +++++++++++--
gdb/blockframe.c | 4 ++--
gdb/buildsym.c | 14 ++++++--------
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-object-load.c | 4 ++--
gdb/cp-namespace.c | 2 +-
gdb/f-valprint.c | 2 +-
gdb/findvar.c | 8 ++++----
gdb/go-lang.c | 2 +-
gdb/guile/scm-block.c | 6 +++---
gdb/guile/scm-frame.c | 6 +++---
gdb/inline-frame.c | 6 +++---
gdb/jit.c | 2 +-
gdb/linespec.c | 4 ++--
gdb/mdebugread.c | 2 +-
gdb/mi/mi-cmd-stack.c | 2 +-
gdb/python/py-block.c | 2 +-
gdb/python/py-frame.c | 6 +++---
gdb/stack.c | 2 +-
gdb/symmisc.c | 8 ++++----
gdb/symtab.c | 18 +++++++++---------
gdb/tracepoint.c | 2 +-
24 files changed, 76 insertions(+), 69 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index bb9a16f8fe07..dfcaf12104aa 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5331,7 +5331,7 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
/* If we found a non-function match, assume that's the one. We
only check this when finding a function boundary, so that we
can accumulate all results from intervening blocks first. */
- if (BLOCK_FUNCTION (block) != nullptr && is_nonfunction (result))
+ if (block->function () != nullptr && is_nonfunction (result))
return;
block = BLOCK_SUPERBLOCK (block);
@@ -13038,7 +13038,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
}
}
}
- if (BLOCK_FUNCTION (block) != NULL)
+ if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
}
diff --git a/gdb/block.c b/gdb/block.c
index a4678ca6a84b..b70b8e22a91e 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -47,8 +47,8 @@ block_objfile (const struct block *block)
{
const struct global_block *global_block;
- if (BLOCK_FUNCTION (block) != NULL)
- return BLOCK_FUNCTION (block)->objfile ();
+ if (block->function () != nullptr)
+ return block->function ()->objfile ();
global_block = (struct global_block *) block_global_block (block);
return global_block->compunit_symtab->objfile ();
@@ -59,8 +59,8 @@ block_objfile (const struct block *block)
struct gdbarch *
block_gdbarch (const struct block *block)
{
- if (BLOCK_FUNCTION (block) != NULL)
- return BLOCK_FUNCTION (block)->arch ();
+ if (block->function () != nullptr)
+ return block->function ()->arch ();
return block_objfile (block)->arch ();
}
@@ -80,7 +80,7 @@ contained_in (const struct block *a, const struct block *b,
return true;
/* If A is a function block, then A cannot be contained in B,
except if A was inlined. */
- if (!allow_nested && BLOCK_FUNCTION (a) != NULL && !block_inlined_p (a))
+ if (!allow_nested && a->function () != NULL && !block_inlined_p (a))
return false;
a = BLOCK_SUPERBLOCK (a);
}
@@ -98,11 +98,11 @@ contained_in (const struct block *a, const struct block *b,
struct symbol *
block_linkage_function (const struct block *bl)
{
- while ((BLOCK_FUNCTION (bl) == NULL || block_inlined_p (bl))
+ while ((bl->function () == NULL || block_inlined_p (bl))
&& BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
- return BLOCK_FUNCTION (bl);
+ return bl->function ();
}
/* Return the symbol for the function which contains a specified
@@ -113,10 +113,10 @@ block_linkage_function (const struct block *bl)
struct symbol *
block_containing_function (const struct block *bl)
{
- while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
+ while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
- return BLOCK_FUNCTION (bl);
+ return bl->function ();
}
/* Return one if BL represents an inlined function. */
@@ -124,7 +124,7 @@ block_containing_function (const struct block *bl)
int
block_inlined_p (const struct block *bl)
{
- return BLOCK_FUNCTION (bl) != NULL && BLOCK_FUNCTION (bl)->is_inlined ();
+ return bl->function () != NULL && bl->function ()->is_inlined ();
}
/* A helper function that checks whether PC is in the blockvector BL.
@@ -433,7 +433,7 @@ block_static_link (const struct block *block)
/* Only objfile-owned blocks that materialize top function scopes can have
static links. */
- if (objfile == NULL || BLOCK_FUNCTION (block) == NULL)
+ if (objfile == NULL || block->function () == NULL)
return NULL;
return (struct dynamic_prop *) objfile_lookup_static_link (objfile, block);
@@ -714,7 +714,7 @@ block_lookup_symbol (const struct block *block, const char *name,
lookup_name_info lookup_name (name, match_type);
- if (!BLOCK_FUNCTION (block))
+ if (!block->function ())
{
struct symbol *other = NULL;
diff --git a/gdb/block.h b/gdb/block.h
index 82d20e4d25d6..5258b450ed25 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -110,6 +110,16 @@ struct block
m_end = end;
}
+ symbol *function () const
+ {
+ return m_function;
+ }
+
+ void set_function (symbol *function)
+ {
+ m_function = function;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -118,7 +128,7 @@ struct block
/* The symbol that names this block, if the block is the body of a
function (real or inlined); otherwise, zero. */
- struct symbol *function;
+ struct symbol *m_function;
/* The `struct block' for the containing block, or 0 if none.
@@ -158,7 +168,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index fec7f0530579..aaf76953648a 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -122,10 +122,10 @@ get_frame_function (struct frame_info *frame)
if (bl == NULL)
return NULL;
- while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
+ while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
bl = BLOCK_SUPERBLOCK (bl);
- return BLOCK_FUNCTION (bl);
+ return bl->function ();
}
\f
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 3dba963d502f..2b92e8c074be 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -243,7 +243,7 @@ buildsym_compunit::finish_block_internal
struct type *ftype = symbol->type ();
struct mdict_iterator miter;
symbol->set_value_block (block);
- BLOCK_FUNCTION (block) = symbol;
+ block->set_function (symbol);
if (ftype->num_fields () <= 0)
{
@@ -286,9 +286,7 @@ buildsym_compunit::finish_block_internal
}
}
else
- {
- BLOCK_FUNCTION (block) = NULL;
- }
+ block->set_function (nullptr);
if (static_link != NULL)
objfile_register_static_link (m_objfile, block, static_link);
@@ -341,7 +339,7 @@ buildsym_compunit::finish_block_internal
Skip blocks which correspond to a function; they're not
physically nested inside this other blocks, only
lexically nested. */
- if (BLOCK_FUNCTION (pblock->block) == NULL
+ if (pblock->block->function () == NULL
&& (pblock->block->start () < block->start ()
|| pblock->block->end () > block->end ()))
{
@@ -1007,9 +1005,9 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
/* Inlined functions may have symbols not in the global or
static symbol lists. */
- if (BLOCK_FUNCTION (block) != NULL)
- if (BLOCK_FUNCTION (block)->symtab () == NULL)
- BLOCK_FUNCTION (block)->set_symtab (symtab);
+ if (block->function () != nullptr
+ && block->function ()->symtab () == nullptr)
+ block->function ()->set_symtab (symtab);
/* Note that we only want to fix up symbols from the local
blocks, not blocks coming from included symtabs. That is why
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index d49ecdab92f3..9e13d7650ddb 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -645,7 +645,7 @@ generate_c_for_variable_locations (compile_instance *compiler,
/* If we just finished the outermost block of a function, we're
done. */
- if (BLOCK_FUNCTION (block) != NULL)
+ if (block->function () != NULL)
break;
block = BLOCK_SUPERBLOCK (block);
}
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 2303381b49af..89a47859c220 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -431,7 +431,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
const struct block *function_block;
block = BLOCKVECTOR_BLOCK (bv, block_loop);
- if (BLOCK_FUNCTION (block) != NULL)
+ if (block->function () != NULL)
continue;
gdb_val_sym = block_lookup_symbol (block,
COMPILE_I_EXPR_VAL,
@@ -445,7 +445,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
&& function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
{
function_block = BLOCK_SUPERBLOCK (function_block);
- function = BLOCK_FUNCTION (function_block);
+ function = function_block->function ();
if (function != NULL)
break;
}
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index b0fa33705ee1..d84486e8bf77 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -504,7 +504,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
const struct block *block,
const domain_enum domain)
{
- struct symbol *function = BLOCK_FUNCTION (block);
+ struct symbol *function = block->function ();
struct block_symbol result;
if (symbol_lookup_debug)
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 4f95b224d732..f977d8cad966 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -688,7 +688,7 @@ info_common_command (const char *comname, int from_tty)
info_common_command_for_block (block, comname, &values_printed);
/* After handling the function's top-level block, stop. Don't
continue to its superblock, the block of per-file symbols. */
- if (BLOCK_FUNCTION (block))
+ if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 067fb3f67570..2e2b10bb6254 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -534,7 +534,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
/* Assuming we have a block for this frame: if we are at the function
level, the immediate upper lexical block is in an outer function:
follow the static link. */
- else if (BLOCK_FUNCTION (frame_block))
+ else if (frame_block->function ())
{
const struct dynamic_prop *static_link
= block_static_link (frame_block);
@@ -571,11 +571,11 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
frame = block_innermost_frame (var_block);
if (frame == NULL)
{
- if (BLOCK_FUNCTION (var_block)
+ if (var_block->function ()
&& !block_inlined_p (var_block)
- && BLOCK_FUNCTION (var_block)->print_name ())
+ && var_block->function ()->print_name ())
error (_("No frame is currently executing in block %s."),
- BLOCK_FUNCTION (var_block)->print_name ());
+ var_block->function ()->print_name ());
else
error (_("No frame is currently executing in specified"
" block"));
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 74b8b214abbe..b4d85b06dd9d 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -418,7 +418,7 @@ go_block_package_name (const struct block *block)
{
while (block != NULL)
{
- struct symbol *function = BLOCK_FUNCTION (block);
+ struct symbol *function = block->function ();
if (function != NULL)
{
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 921225dcf474..1683ed1ac8ae 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -156,8 +156,8 @@ bkscm_print_block_smob (SCM self, SCM port, scm_print_state *pstate)
else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (b)) == NULL)
gdbscm_printf (port, " static");
- if (BLOCK_FUNCTION (b) != NULL)
- gdbscm_printf (port, " %s", BLOCK_FUNCTION (b)->print_name ());
+ if (b->function () != NULL)
+ gdbscm_printf (port, " %s", b->function ()->print_name ());
gdbscm_printf (port, " %s-%s",
hex_string (b->start ()), hex_string (b->end ()));
@@ -404,7 +404,7 @@ gdbscm_block_function (SCM self)
const struct block *block = b_smob->block;
struct symbol *sym;
- sym = BLOCK_FUNCTION (block);
+ sym = block->function ();
if (sym != NULL)
return syscm_scm_from_symbol (sym);
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index e53c8602322b..f0de7c368f91 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -611,11 +611,11 @@ gdbscm_frame_block (SCM self)
}
for (fn_block = block;
- fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
+ fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
continue;
- if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
+ if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
{
scm_misc_error (FUNC_NAME, _("cannot find block for frame"),
scm_list_1 (self));
@@ -624,7 +624,7 @@ gdbscm_frame_block (SCM self)
if (block != NULL)
{
return bkscm_scm_from_block
- (block, BLOCK_FUNCTION (fn_block)->objfile ());
+ (block, fn_block->function ()->objfile ());
}
return SCM_BOOL_F;
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index bcdf36cd067e..95cc80b7a1c1 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -230,7 +230,7 @@ inline_frame_sniffer (const struct frame_unwind *self,
{
if (block_inlined_p (cur_block))
depth++;
- else if (BLOCK_FUNCTION (cur_block) != NULL)
+ else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);
@@ -372,12 +372,12 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
break;
skip_count++;
- skipped_syms.push_back (BLOCK_FUNCTION (cur_block));
+ skipped_syms.push_back (cur_block->function ());
}
else
break;
}
- else if (BLOCK_FUNCTION (cur_block) != NULL)
+ else if (cur_block->function () != NULL)
break;
cur_block = BLOCK_SUPERBLOCK (cur_block);
diff --git a/gdb/jit.c b/gdb/jit.c
index 49db391f80c0..17dfdd9ef24f 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -596,7 +596,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
gdb_block_iter.name.get ());
- BLOCK_FUNCTION (new_block) = block_name;
+ new_block->set_function (block_name);
BLOCKVECTOR_BLOCK (bv, block_idx) = new_block;
if (begin > new_block->start ())
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 61ad69dd882d..90e4c813e4e0 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3967,14 +3967,14 @@ find_label_symbols (struct linespec_state *self,
block = get_current_search_block ();
for (;
- block && !BLOCK_FUNCTION (block);
+ block && !block->function ();
block = BLOCK_SUPERBLOCK (block))
;
if (!block)
return {};
- fn_sym = BLOCK_FUNCTION (block);
+ fn_sym = block->function ();
find_label_symbols_in_block (block, name, fn_sym, completion_mode,
&result, label_funcs_ret);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1565a86bad01..87d2fb1d4777 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -797,7 +797,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* Create and enter a new lexical context. */
b = new_block (FUNCTION_BLOCK, s->language ());
s->set_value_block (b);
- BLOCK_FUNCTION (b) = s;
+ b->set_function (s);
b->set_start (sh->value);
b->set_end (sh->value);
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index e894411765ad..9ae64f092a84 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -671,7 +671,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
}
}
- if (BLOCK_FUNCTION (block))
+ if (block->function ())
break;
else
block = BLOCK_SUPERBLOCK (block);
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index aa8f3df7af93..7ab98687387f 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -130,7 +130,7 @@ blpy_get_function (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- sym = BLOCK_FUNCTION (block);
+ sym = block->function ();
if (sym)
return symbol_to_symbol_object (sym);
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index d07158a5ec65..c4225c84affc 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -292,11 +292,11 @@ frapy_block (PyObject *self, PyObject *args)
}
for (fn_block = block;
- fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL;
+ fn_block != NULL && fn_block->function () == NULL;
fn_block = BLOCK_SUPERBLOCK (fn_block))
;
- if (block == NULL || fn_block == NULL || BLOCK_FUNCTION (fn_block) == NULL)
+ if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
_("Cannot locate block for frame."));
@@ -306,7 +306,7 @@ frapy_block (PyObject *self, PyObject *args)
if (block)
{
return block_to_block_object
- (block, BLOCK_FUNCTION (fn_block)->objfile ());
+ (block, fn_block->function ()->objfile ());
}
Py_RETURN_NONE;
diff --git a/gdb/stack.c b/gdb/stack.c
index 1229ee6b4921..35726b713982 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2273,7 +2273,7 @@ iterate_over_block_local_vars (const struct block *block,
/* After handling the function's top-level block, stop. Don't
continue to its superblock, the block of per-file
symbols. */
- if (BLOCK_FUNCTION (block))
+ if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 097dc2dd3556..1dd747d5386d 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -298,14 +298,14 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
gdb_puts (paddress (gdbarch, b->start ()), outfile);
gdb_printf (outfile, "..");
gdb_puts (paddress (gdbarch, b->end ()), outfile);
- if (BLOCK_FUNCTION (b))
+ if (b->function ())
{
gdb_printf (outfile, ", function %s",
- BLOCK_FUNCTION (b)->linkage_name ());
- if (BLOCK_FUNCTION (b)->demangled_name () != NULL)
+ b->function ()->linkage_name ());
+ if (b->function ()->demangled_name () != NULL)
{
gdb_printf (outfile, ", %s",
- BLOCK_FUNCTION (b)->demangled_name ());
+ b->function ()->demangled_name ());
}
}
gdb_printf (outfile, "\n");
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 993b1962c8c3..58a2033f1ff9 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2024,7 +2024,7 @@ lookup_language_this (const struct language_defn *lang,
}
return (struct block_symbol) {sym, block};
}
- if (BLOCK_FUNCTION (block))
+ if (block->function ())
break;
block = BLOCK_SUPERBLOCK (block);
}
@@ -2227,7 +2227,7 @@ lookup_local_symbol (const char *name,
return blocksym;
}
- if (BLOCK_FUNCTION (block) != NULL && block_inlined_p (block))
+ if (block->function () != NULL && block_inlined_p (block))
break;
block = BLOCK_SUPERBLOCK (block);
}
@@ -4042,17 +4042,17 @@ skip_prologue_sal (struct symtab_and_line *sal)
function_block = NULL;
while (b != NULL)
{
- if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b))
+ if (b->function () != NULL && block_inlined_p (b))
function_block = b;
- else if (BLOCK_FUNCTION (b) != NULL)
+ else if (b->function () != NULL)
break;
b = BLOCK_SUPERBLOCK (b);
}
if (function_block != NULL
- && BLOCK_FUNCTION (function_block)->line () != 0)
+ && function_block->function ()->line () != 0)
{
- sal->line = BLOCK_FUNCTION (function_block)->line ();
- sal->symtab = BLOCK_FUNCTION (function_block)->symtab ();
+ sal->line = function_block->function ()->line ();
+ sal->symtab = function_block->function ()->symtab ();
}
}
@@ -4140,7 +4140,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
{
if (block_inlined_p (bl))
break;
- if (BLOCK_FUNCTION (bl))
+ if (bl->function ())
{
bl = NULL;
break;
@@ -6011,7 +6011,7 @@ default_collect_symbol_completion_matches_break_on
/* Stop when we encounter an enclosing function. Do not stop for
non-inlined functions - the locals of the enclosing function
are in scope for a nested function. */
- if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b))
+ if (b->function () != NULL && block_inlined_p (b))
break;
b = BLOCK_SUPERBLOCK (b);
}
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 18c3803ac195..76da71df0380 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2615,7 +2615,7 @@ info_scope_command (const char *args_in, int from_tty)
gdb_printf (", length %s.\n", pulongest (TYPE_LENGTH (t)));
}
}
- if (BLOCK_FUNCTION (block))
+ if (block->function ())
break;
else
block = BLOCK_SUPERBLOCK (block);
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 03/14] gdb: remove BLOCK_SUPERBLOCK macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
2022-04-21 14:58 ` [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro Simon Marchi
@ 2022-04-21 14:58 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro Simon Marchi
` (7 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods.
Change-Id: I334a319909a50b5cc5570a45c38c70e10dc00630
---
gdb/ada-lang.c | 8 +++----
gdb/block.c | 40 +++++++++++++++----------------
gdb/block.h | 13 ++++++++--
gdb/blockframe.c | 6 ++---
gdb/buildsym.c | 4 ++--
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-object-load.c | 4 ++--
gdb/cp-namespace.c | 4 ++--
gdb/cp-support.c | 4 ++--
gdb/d-namespace.c | 2 +-
gdb/f-valprint.c | 2 +-
gdb/findvar.c | 2 +-
gdb/go-lang.c | 2 +-
gdb/guile/scm-block.c | 14 +++++------
gdb/guile/scm-frame.c | 2 +-
gdb/inline-frame.c | 8 +++----
gdb/jit.c | 11 +++++----
gdb/linespec.c | 4 ++--
gdb/mdebugread.c | 12 +++++-----
gdb/mi/mi-cmd-stack.c | 2 +-
gdb/python/py-block.c | 10 ++++----
gdb/python/py-frame.c | 2 +-
gdb/stack.c | 2 +-
gdb/symmisc.c | 6 ++---
gdb/symtab.c | 10 ++++----
gdb/tracepoint.c | 2 +-
26 files changed, 94 insertions(+), 84 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index dfcaf12104aa..c06dbc2f055e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5334,7 +5334,7 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
if (block->function () != nullptr && is_nonfunction (result))
return;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
}
@@ -13040,7 +13040,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
}
if (block->function () != NULL)
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
}
@@ -13662,9 +13662,9 @@ class ada_language : public language_defn
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
+ for (b = get_selected_block (0); b != NULL; b = b->superblock ())
{
- if (!BLOCK_SUPERBLOCK (b))
+ if (!b->superblock ())
surrounding_static_block = b; /* For elmin of dups */
ALL_BLOCK_SYMBOLS (b, iter, sym)
diff --git a/gdb/block.c b/gdb/block.c
index b70b8e22a91e..9c4ed260abb2 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -82,7 +82,7 @@ contained_in (const struct block *a, const struct block *b,
except if A was inlined. */
if (!allow_nested && a->function () != NULL && !block_inlined_p (a))
return false;
- a = BLOCK_SUPERBLOCK (a);
+ a = a->superblock ();
}
while (a != NULL);
@@ -99,8 +99,8 @@ struct symbol *
block_linkage_function (const struct block *bl)
{
while ((bl->function () == NULL || block_inlined_p (bl))
- && BLOCK_SUPERBLOCK (bl) != NULL)
- bl = BLOCK_SUPERBLOCK (bl);
+ && bl->superblock () != NULL)
+ bl = bl->superblock ();
return bl->function ();
}
@@ -113,8 +113,8 @@ block_linkage_function (const struct block *bl)
struct symbol *
block_containing_function (const struct block *bl)
{
- while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
- bl = BLOCK_SUPERBLOCK (bl);
+ while (bl->function () == NULL && bl->superblock () != NULL)
+ bl = bl->superblock ();
return bl->function ();
}
@@ -295,7 +295,7 @@ block_for_pc (CORE_ADDR pc)
const char *
block_scope (const struct block *block)
{
- for (; block != NULL; block = BLOCK_SUPERBLOCK (block))
+ for (; block != NULL; block = block->superblock ())
{
if (BLOCK_NAMESPACE (block) != NULL
&& BLOCK_NAMESPACE (block)->scope != NULL)
@@ -360,11 +360,11 @@ block_initialize_namespace (struct block *block, struct obstack *obstack)
const struct block *
block_static_block (const struct block *block)
{
- if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
+ if (block == NULL || block->superblock () == NULL)
return NULL;
- while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
- block = BLOCK_SUPERBLOCK (block);
+ while (block->superblock ()->superblock () != NULL)
+ block = block->superblock ();
return block;
}
@@ -378,8 +378,8 @@ block_global_block (const struct block *block)
if (block == NULL)
return NULL;
- while (BLOCK_SUPERBLOCK (block) != NULL)
- block = BLOCK_SUPERBLOCK (block);
+ while (block->superblock () != NULL)
+ block = block->superblock ();
return block;
}
@@ -418,7 +418,7 @@ set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu)
{
struct global_block *gb;
- gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
+ gdb_assert (block->superblock () == NULL);
gb = (struct global_block *) block;
gdb_assert (gb->compunit_symtab == NULL);
gb->compunit_symtab = cu;
@@ -446,7 +446,7 @@ get_block_compunit_symtab (const struct block *block)
{
struct global_block *gb;
- gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
+ gdb_assert (block->superblock () == NULL);
gb = (struct global_block *) block;
gdb_assert (gb->compunit_symtab != NULL);
return gb->compunit_symtab;
@@ -467,15 +467,15 @@ initialize_block_iterator (const struct block *block,
iter->idx = -1;
- if (BLOCK_SUPERBLOCK (block) == NULL)
+ if (block->superblock () == NULL)
{
which = GLOBAL_BLOCK;
cu = get_block_compunit_symtab (block);
}
- else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
+ else if (block->superblock ()->superblock () == NULL)
{
which = STATIC_BLOCK;
- cu = get_block_compunit_symtab (BLOCK_SUPERBLOCK (block));
+ cu = get_block_compunit_symtab (block->superblock ());
}
else
{
@@ -775,8 +775,8 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
- gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
- || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+ gdb_assert (block->superblock () == NULL
+ || block->superblock ()->superblock () == NULL);
other = NULL;
for (sym
@@ -838,8 +838,8 @@ block_find_symbol (const struct block *block, const char *name,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
- gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
- || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+ gdb_assert (block->superblock () == NULL
+ || block->superblock ()->superblock () == NULL);
ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
{
diff --git a/gdb/block.h b/gdb/block.h
index 5258b450ed25..00beab3423df 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -120,6 +120,16 @@ struct block
m_function = function;
}
+ const block *superblock () const
+ {
+ return m_superblock;
+ }
+
+ void set_superblock (const block *superblock)
+ {
+ m_superblock = superblock;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -136,7 +146,7 @@ struct block
case of C) is the STATIC_BLOCK. The superblock of the
STATIC_BLOCK is the GLOBAL_BLOCK. */
- const struct block *superblock;
+ const struct block *m_superblock;
/* This is used to store the symbols in the block. */
@@ -168,7 +178,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index aaf76953648a..cfc4fd2fd704 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -75,7 +75,7 @@ get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block)
if (block_inlined_p (bl))
inline_count--;
- bl = BLOCK_SUPERBLOCK (bl);
+ bl = bl->superblock ();
gdb_assert (bl != NULL);
}
@@ -122,8 +122,8 @@ get_frame_function (struct frame_info *frame)
if (bl == NULL)
return NULL;
- while (bl->function () == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
- bl = BLOCK_SUPERBLOCK (bl);
+ while (bl->function () == NULL && bl->superblock () != NULL)
+ bl = bl->superblock ();
return bl->function ();
}
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 2b92e8c074be..5ce40c554280 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -330,7 +330,7 @@ buildsym_compunit::finish_block_internal
pblock && pblock != old_blocks;
pblock = pblock->next)
{
- if (BLOCK_SUPERBLOCK (pblock->block) == NULL)
+ if (pblock->block->superblock () == NULL)
{
/* Check to be sure the blocks are nested as we receive
them. If the compiler/assembler/linker work, this just
@@ -364,7 +364,7 @@ buildsym_compunit::finish_block_internal
if (pblock->block->end () > block->end ())
pblock->block->set_end (block->end ());
}
- BLOCK_SUPERBLOCK (pblock->block) = block;
+ pblock->block->set_superblock (block);
}
opblock = pblock;
}
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 9e13d7650ddb..4c30ae98c1c2 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -647,7 +647,7 @@ generate_c_for_variable_locations (compile_instance *compiler,
done. */
if (block->function () != NULL)
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
return registers_used;
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 89a47859c220..2835f2d73d1f 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -444,13 +444,13 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
while (function_block != BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)
&& function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
{
- function_block = BLOCK_SUPERBLOCK (function_block);
+ function_block = function_block->superblock ();
function = function_block->function ();
if (function != NULL)
break;
}
if (function != NULL
- && (BLOCK_SUPERBLOCK (function_block)
+ && (function_block->superblock ()
== BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
&& symbol_matches_search_name (function, func_matcher))
break;
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index d84486e8bf77..e734effe7f0a 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -547,7 +547,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
struct type *context;
std::string name_copy (function->natural_name ());
const struct language_defn *lang = language_def (language_cplus);
- const struct block *parent = BLOCK_SUPERBLOCK (block);
+ const struct block *parent = block->superblock ();
struct symbol *sym;
while (1)
@@ -615,7 +615,7 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
if (sym.symbol)
return sym;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
return {};
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 78015d43fe8a..14fad2d453fe 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1400,7 +1400,7 @@ add_symbol_overload_list_using (const char *func_name,
for (block = get_selected_block (0);
block != NULL;
- block = BLOCK_SUPERBLOCK (block))
+ block = block->superblock ())
for (current = block_using (block);
current != NULL;
current = current->next)
@@ -1451,7 +1451,7 @@ add_symbol_overload_list_qualified (const char *func_name,
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
+ for (b = get_selected_block (0); b != NULL; b = b->superblock ())
add_symbol_overload_list_block (func_name, b, overload_list);
surrounding_static_block = block_static_block (get_selected_block (0));
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index 07c22e0eae54..5af042abb119 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -491,7 +491,7 @@ d_lookup_symbol_module (const char *scope, const char *name,
if (sym.symbol != NULL)
return sym;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
return {};
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index f977d8cad966..6a3f83c21941 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -690,7 +690,7 @@ info_common_command (const char *comname, int from_tty)
continue to its superblock, the block of per-file symbols. */
if (block->function ())
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
if (!values_printed)
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 2e2b10bb6254..bdc3d35c3458 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -559,7 +559,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
else
/* We must be in some function nested lexical block. Just get the
outer block: both must share the same frame. */
- frame_block = BLOCK_SUPERBLOCK (frame_block);
+ frame_block = frame_block->superblock ();
}
/* Old compilers may not provide a static link, or they may provide an
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index b4d85b06dd9d..844f743e83dc 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -433,7 +433,7 @@ go_block_package_name (const struct block *block)
return NULL;
}
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
return NULL;
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 1683ed1ac8ae..41954c705195 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -151,9 +151,9 @@ bkscm_print_block_smob (SCM self, SCM port, scm_print_state *pstate)
gdbscm_printf (port, "#<%s", block_smob_name);
- if (BLOCK_SUPERBLOCK (b) == NULL)
+ if (b->superblock () == NULL)
gdbscm_printf (port, " global");
- else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (b)) == NULL)
+ else if (b->superblock ()->superblock () == NULL)
gdbscm_printf (port, " static");
if (b->function () != NULL)
@@ -421,7 +421,7 @@ gdbscm_block_superblock (SCM self)
const struct block *block = b_smob->block;
const struct block *super_block;
- super_block = BLOCK_SUPERBLOCK (block);
+ super_block = block->superblock ();
if (super_block)
return bkscm_scm_from_block (super_block, b_smob->objfile);
@@ -456,7 +456,7 @@ gdbscm_block_static_block (SCM self)
const struct block *block = b_smob->block;
const struct block *static_block;
- if (BLOCK_SUPERBLOCK (block) == NULL)
+ if (block->superblock () == NULL)
return SCM_BOOL_F;
static_block = block_static_block (block);
@@ -474,7 +474,7 @@ gdbscm_block_global_p (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
- return scm_from_bool (BLOCK_SUPERBLOCK (block) == NULL);
+ return scm_from_bool (block->superblock () == NULL);
}
/* (block-static? <gdb:block>) -> boolean
@@ -487,8 +487,8 @@ gdbscm_block_static_p (SCM self)
= bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct block *block = b_smob->block;
- if (BLOCK_SUPERBLOCK (block) != NULL
- && BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
+ if (block->superblock () != NULL
+ && block->superblock ()->superblock () == NULL)
return SCM_BOOL_T;
return SCM_BOOL_F;
}
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index f0de7c368f91..6bbb6f81d685 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -612,7 +612,7 @@ gdbscm_frame_block (SCM self)
for (fn_block = block;
fn_block != NULL && fn_block->function () == NULL;
- fn_block = BLOCK_SUPERBLOCK (fn_block))
+ fn_block = fn_block->superblock ())
continue;
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index 95cc80b7a1c1..bd173a1d21b7 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -226,14 +226,14 @@ inline_frame_sniffer (const struct frame_unwind *self,
location. */
depth = 0;
cur_block = frame_block;
- while (BLOCK_SUPERBLOCK (cur_block))
+ while (cur_block->superblock ())
{
if (block_inlined_p (cur_block))
depth++;
else if (cur_block->function () != NULL)
break;
- cur_block = BLOCK_SUPERBLOCK (cur_block);
+ cur_block = cur_block->superblock ();
}
/* Check how many inlined functions already have frames. */
@@ -356,7 +356,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
if (frame_block != NULL)
{
cur_block = frame_block;
- while (BLOCK_SUPERBLOCK (cur_block))
+ while (cur_block->superblock ())
{
if (block_inlined_p (cur_block))
{
@@ -380,7 +380,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
else if (cur_block->function () != NULL)
break;
- cur_block = BLOCK_SUPERBLOCK (cur_block);
+ cur_block = cur_block->superblock ();
}
}
diff --git a/gdb/jit.c b/gdb/jit.c
index 17dfdd9ef24f..1283d2edc500 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -620,7 +620,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
: allocate_block (&objfile->objfile_obstack));
BLOCK_MULTIDICT (new_block)
= mdict_create_linear (&objfile->objfile_obstack, NULL);
- BLOCK_SUPERBLOCK (new_block) = block_iter;
+ new_block->set_superblock (block_iter);
block_iter = new_block;
new_block->set_start (begin);
@@ -640,14 +640,15 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
{
/* If the plugin specifically mentioned a parent block, we
use that. */
- BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
- gdb_block_iter.parent->real_block;
+ gdb_block_iter.real_block->set_superblock
+ (gdb_block_iter.parent->real_block);
+
}
else
{
/* And if not, we set a default parent block. */
- BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
- BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ gdb_block_iter.real_block->set_superblock
+ (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK));
}
}
}
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 90e4c813e4e0..fd3fba871c5c 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1234,7 +1234,7 @@ iterate_over_file_blocks
for (block = BLOCKVECTOR_BLOCK (symtab->compunit ()->blockvector (),
STATIC_BLOCK);
block != NULL;
- block = BLOCK_SUPERBLOCK (block))
+ block = block->superblock ())
current_language->iterate_over_symbols (block, name, domain, callback);
}
@@ -3968,7 +3968,7 @@ find_label_symbols (struct linespec_state *self,
for (;
block && !block->function ();
- block = BLOCK_SUPERBLOCK (block))
+ block = block->superblock ())
;
if (!block)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 87d2fb1d4777..ddf3cd582534 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -800,7 +800,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
b->set_function (s);
b->set_start (sh->value);
b->set_end (sh->value);
- BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
+ b->set_superblock (top_stack->cur_block);
add_block (b, top_stack->cur_st);
/* Not if we only have partial info. */
@@ -1128,7 +1128,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
top_stack->blocktype = stBlock;
b = new_block (NON_FUNCTION_BLOCK, psymtab_language);
b->set_start (sh->value + top_stack->procadr);
- BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
+ b->set_superblock (top_stack->cur_block);
top_stack->cur_block = b;
add_block (b, top_stack->cur_st);
break;
@@ -1172,7 +1172,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
{
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
- if (BLOCK_SUPERBLOCK (b_bad) == cblock
+ if (b_bad->superblock () == cblock
&& b_bad->start () == top_stack->procadr
&& b_bad->end () == top_stack->procadr)
{
@@ -4476,7 +4476,7 @@ mylookup_symbol (const char *name, const struct block *block,
return sym;
}
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
if (block)
return mylookup_symbol (name, block, domain, theclass);
return 0;
@@ -4637,8 +4637,8 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
bv = new_bvect (2);
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
- BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
- BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)->set_superblock
+ (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
cust->set_blockvector (bv);
cust->set_debugformat ("ECOFF");
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 9ae64f092a84..0fe204dbc666 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -674,7 +674,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
if (block->function ())
break;
else
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
}
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 7ab98687387f..872fb89ba834 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -146,7 +146,7 @@ blpy_get_superblock (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- super_block = BLOCK_SUPERBLOCK (block);
+ super_block = block->superblock ();
if (super_block)
return block_to_block_object (super_block, self_obj->objfile);
@@ -183,7 +183,7 @@ blpy_get_static_block (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- if (BLOCK_SUPERBLOCK (block) == NULL)
+ if (block->superblock () == NULL)
Py_RETURN_NONE;
static_block = block_static_block (block);
@@ -201,7 +201,7 @@ blpy_is_global (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- if (BLOCK_SUPERBLOCK (block))
+ if (block->superblock ())
Py_RETURN_FALSE;
Py_RETURN_TRUE;
@@ -217,8 +217,8 @@ blpy_is_static (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
- if (BLOCK_SUPERBLOCK (block) != NULL
- && BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
+ if (block->superblock () != NULL
+ && block->superblock ()->superblock () == NULL)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index c4225c84affc..769e28c1a2c3 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -293,7 +293,7 @@ frapy_block (PyObject *self, PyObject *args)
for (fn_block = block;
fn_block != NULL && fn_block->function () == NULL;
- fn_block = BLOCK_SUPERBLOCK (fn_block))
+ fn_block = fn_block->superblock ())
;
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
diff --git a/gdb/stack.c b/gdb/stack.c
index 35726b713982..71d85985d18c 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2275,7 +2275,7 @@ iterate_over_block_local_vars (const struct block *block,
symbols. */
if (block->function ())
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
}
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 1dd747d5386d..e49322c2a84a 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -287,9 +287,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
gdb_printf (outfile, "%*sblock #%03d, object at %s",
depth, "", i,
host_address_to_string (b));
- if (BLOCK_SUPERBLOCK (b))
+ if (b->superblock ())
gdb_printf (outfile, " under %s",
- host_address_to_string (BLOCK_SUPERBLOCK (b)));
+ host_address_to_string (b->superblock ()));
/* drow/2002-07-10: We could save the total symbols count
even if we're using a hashtable, but nothing else but this message
wants it. */
@@ -939,7 +939,7 @@ block_depth (const struct block *block)
{
int i = 0;
- while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
+ while ((block = block->superblock ()) != NULL)
{
i++;
}
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 58a2033f1ff9..63fa9ba3196e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2026,7 +2026,7 @@ lookup_language_this (const struct language_defn *lang,
}
if (block->function ())
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
if (symbol_lookup_debug > 1)
@@ -2229,7 +2229,7 @@ lookup_local_symbol (const char *name,
if (block->function () != NULL && block_inlined_p (block))
break;
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
/* We've reached the end of the function without finding a result. */
@@ -4046,7 +4046,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
function_block = b;
else if (b->function () != NULL)
break;
- b = BLOCK_SUPERBLOCK (b);
+ b = b->superblock ();
}
if (function_block != NULL
&& function_block->function ()->line () != 0)
@@ -4145,7 +4145,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
bl = NULL;
break;
}
- bl = BLOCK_SUPERBLOCK (bl);
+ bl = bl->superblock ();
}
if (bl != NULL)
break;
@@ -6013,7 +6013,7 @@ default_collect_symbol_completion_matches_break_on
are in scope for a nested function. */
if (b->function () != NULL && block_inlined_p (b))
break;
- b = BLOCK_SUPERBLOCK (b);
+ b = b->superblock ();
}
/* Add fields from the file's types; symbols will be added below. */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 76da71df0380..64419436fd74 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2618,7 +2618,7 @@ info_scope_command (const char *args_in, int from_tty)
if (block->function ())
break;
else
- block = BLOCK_SUPERBLOCK (block);
+ block = block->superblock ();
}
if (count <= 0)
gdb_printf ("Scope for %s contains no locals or arguments.\n",
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
2022-04-21 14:58 ` [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro Simon Marchi
2022-04-21 14:58 ` [PATCH 03/14] gdb: remove BLOCK_SUPERBLOCK macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 17:33 ` Lancelot SIX
2022-04-21 14:59 ` [PATCH 05/14] gdb: remove BLOCK_NAMESPACE macro Simon Marchi
` (6 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods.
Change-Id: If9a239c511a664f2a59fecb6d1cd579881b23dc2
---
gdb/block.c | 12 ++++++------
gdb/block.h | 13 +++++++++++--
gdb/buildsym.c | 25 +++++++++++++------------
gdb/jit.c | 8 ++++----
gdb/mdebugread.c | 6 +++---
gdb/objfiles.c | 2 +-
gdb/symmisc.c | 4 ++--
7 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/gdb/block.c b/gdb/block.c
index 9c4ed260abb2..5a6282bd1a97 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -545,7 +545,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
block = BLOCKVECTOR_BLOCK (cust->blockvector (),
iterator->which);
- sym = mdict_iterator_first (BLOCK_MULTIDICT (block),
+ sym = mdict_iterator_first (block->multidict (),
&iterator->mdict_iter);
}
else
@@ -571,7 +571,7 @@ block_iterator_first (const struct block *block,
initialize_block_iterator (block, iterator);
if (iterator->which == FIRST_LOCAL_BLOCK)
- return mdict_iterator_first (block->multidict, &iterator->mdict_iter);
+ return mdict_iterator_first (block->multidict (), &iterator->mdict_iter);
return block_iterator_step (iterator, 1);
}
@@ -614,7 +614,7 @@ block_iter_match_step (struct block_iterator *iterator,
block = BLOCKVECTOR_BLOCK (cust->blockvector (),
iterator->which);
- sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name,
+ sym = mdict_iter_match_first (block->multidict (), name,
&iterator->mdict_iter);
}
else
@@ -641,7 +641,7 @@ block_iter_match_first (const struct block *block,
initialize_block_iterator (block, iterator);
if (iterator->which == FIRST_LOCAL_BLOCK)
- return mdict_iter_match_first (block->multidict, name,
+ return mdict_iter_match_first (block->multidict (), name,
&iterator->mdict_iter);
return block_iter_match_step (iterator, name, 1);
@@ -779,8 +779,8 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
|| block->superblock ()->superblock () == NULL);
other = NULL;
- for (sym
- = mdict_iter_match_first (block->multidict, lookup_name, &mdict_iter);
+ for (sym = mdict_iter_match_first (block->multidict (), lookup_name,
+ &mdict_iter);
sym != NULL;
sym = mdict_iter_match_next (lookup_name, &mdict_iter))
{
diff --git a/gdb/block.h b/gdb/block.h
index 00beab3423df..9119963ddc64 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -130,6 +130,16 @@ struct block
m_superblock = superblock;
}
+ multidictionary *multidict () const
+ {
+ return m_multidict;
+ }
+
+ void set_multidict (multidictionary *multidict)
+ {
+ m_multidict = multidict;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -150,7 +160,7 @@ struct block
/* This is used to store the symbols in the block. */
- struct multidictionary *multidict;
+ struct multidictionary *m_multidict;
/* Contains information about namespace-related info relevant to this block:
using directives and the current namespace scope. */
@@ -178,7 +188,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info
/* Accessor for ranges field within block BL. */
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 5ce40c554280..f4e5eb39f527 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -216,20 +216,21 @@ buildsym_compunit::finish_block_internal
if (symbol)
{
- BLOCK_MULTIDICT (block)
- = mdict_create_linear (&m_objfile->objfile_obstack, *listhead);
+ block->set_multidict
+ (mdict_create_linear (&m_objfile->objfile_obstack, *listhead));
}
else
{
if (expandable)
{
- BLOCK_MULTIDICT (block) = mdict_create_hashed_expandable (m_language);
- mdict_add_pending (BLOCK_MULTIDICT (block), *listhead);
+ block->set_multidict
+ (mdict_create_hashed_expandable (m_language));
+ mdict_add_pending (block->multidict (), *listhead);
}
else
{
- BLOCK_MULTIDICT (block) =
- mdict_create_hashed (&m_objfile->objfile_obstack, *listhead);
+ block->set_multidict
+ (mdict_create_hashed (&m_objfile->objfile_obstack, *listhead));
}
}
@@ -255,7 +256,7 @@ buildsym_compunit::finish_block_internal
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
+ ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
{
if (sym->is_argument ())
nparams++;
@@ -270,7 +271,7 @@ buildsym_compunit::finish_block_internal
iparams = 0;
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
+ ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
{
if (iparams == nparams)
break;
@@ -1012,7 +1013,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
/* Note that we only want to fix up symbols from the local
blocks, not blocks coming from included symtabs. That is why
we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */
- ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
+ ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
if (sym->symtab () == NULL)
sym->set_symtab (symtab);
}
@@ -1147,7 +1148,7 @@ buildsym_compunit::augment_type_symtab ()
to the primary symtab. */
set_missing_symtab (m_file_symbols, cust);
- mdict_add_pending (BLOCK_MULTIDICT (block), m_file_symbols);
+ mdict_add_pending (block->multidict (), m_file_symbols);
}
if (m_global_symbols != NULL)
@@ -1158,8 +1159,8 @@ buildsym_compunit::augment_type_symtab ()
to the primary symtab. */
set_missing_symtab (m_global_symbols, cust);
- mdict_add_pending (BLOCK_MULTIDICT (block),
- m_global_symbols);
+ mdict_add_pending (block->multidict (),
+ m_global_symbols);
}
}
diff --git a/gdb/jit.c b/gdb/jit.c
index 1283d2edc500..4ff180d48733 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -580,8 +580,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
TARGET_CHAR_BIT,
"void");
- BLOCK_MULTIDICT (new_block)
- = mdict_create_linear (&objfile->objfile_obstack, NULL);
+ new_block->set_multidict
+ (mdict_create_linear (&objfile->objfile_obstack, NULL));
/* The address range. */
new_block->set_start (gdb_block_iter.begin);
new_block->set_end (gdb_block_iter.end);
@@ -618,8 +618,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
new_block = (i == GLOBAL_BLOCK
? allocate_global_block (&objfile->objfile_obstack)
: allocate_block (&objfile->objfile_obstack));
- BLOCK_MULTIDICT (new_block)
- = mdict_create_linear (&objfile->objfile_obstack, NULL);
+ new_block->set_multidict
+ (mdict_create_linear (&objfile->objfile_obstack, NULL));
new_block->set_superblock (block_iter);
block_iter = new_block;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ddf3cd582534..cd242967ab7d 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4489,7 +4489,7 @@ static void
add_symbol (struct symbol *s, struct symtab *symtab, struct block *b)
{
s->set_symtab (symtab);
- mdict_add_symbol (BLOCK_MULTIDICT (b), s);
+ mdict_add_symbol (b->multidict (), s);
}
/* Add a new block B to a symtab S. */
@@ -4733,9 +4733,9 @@ new_block (enum block_type type, enum language language)
struct block *retval = XCNEW (struct block);
if (type == FUNCTION_BLOCK)
- BLOCK_MULTIDICT (retval) = mdict_create_linear_expandable (language);
+ retval->set_multidict (mdict_create_linear_expandable (language));
else
- BLOCK_MULTIDICT (retval) = mdict_create_hashed_expandable (language);
+ retval->set_multidict (mdict_create_hashed_expandable (language));
return retval;
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index e664bcd2da97..a709d947da00 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -689,7 +689,7 @@ objfile_relocate1 (struct objfile *objfile,
/* We only want to iterate over the local symbols, not any
symbols in included symtabs. */
- ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym)
+ ALL_DICT_SYMBOLS (b->multidict (), miter, sym)
{
relocate_one_symbol (sym, objfile, delta);
}
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index e49322c2a84a..3699e82d0c42 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -294,7 +294,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
even if we're using a hashtable, but nothing else but this message
wants it. */
gdb_printf (outfile, ", %d syms/buckets in ",
- mdict_size (BLOCK_MULTIDICT (b)));
+ mdict_size (b->multidict ()));
gdb_puts (paddress (gdbarch, b->start ()), outfile);
gdb_printf (outfile, "..");
gdb_puts (paddress (gdbarch, b->end ()), outfile);
@@ -312,7 +312,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
/* Now print each symbol in this block (in no particular order, if
we're using a hashtable). Note that we only want this
block, not any blocks from included symtabs. */
- ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym)
+ ALL_DICT_SYMBOLS (b->multidict (), miter, sym)
{
try
{
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 05/14] gdb: remove BLOCK_NAMESPACE macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (2 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 06/14] gdb: remove BLOCK_RANGE_{START,END} macros Simon Marchi
` (5 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods.
Change-Id: If86b8cbdfb0f52e22c929614cd53e73358bab76a
---
gdb/block.c | 20 ++++++++++----------
gdb/block.h | 14 +++++++++++---
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gdb/block.c b/gdb/block.c
index 5a6282bd1a97..2d28f9de7926 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -297,9 +297,9 @@ block_scope (const struct block *block)
{
for (; block != NULL; block = block->superblock ())
{
- if (BLOCK_NAMESPACE (block) != NULL
- && BLOCK_NAMESPACE (block)->scope != NULL)
- return BLOCK_NAMESPACE (block)->scope;
+ if (block->namespace_info () != NULL
+ && block->namespace_info ()->scope != NULL)
+ return block->namespace_info ()->scope;
}
return "";
@@ -315,7 +315,7 @@ block_set_scope (struct block *block, const char *scope,
{
block_initialize_namespace (block, obstack);
- BLOCK_NAMESPACE (block)->scope = scope;
+ block->namespace_info ()->scope = scope;
}
/* This returns the using directives list associated with BLOCK, if
@@ -324,10 +324,10 @@ block_set_scope (struct block *block, const char *scope,
struct using_direct *
block_using (const struct block *block)
{
- if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
+ if (block == NULL || block->namespace_info () == NULL)
return NULL;
else
- return BLOCK_NAMESPACE (block)->using_decl;
+ return block->namespace_info ()->using_decl;
}
/* Set BLOCK's using member to USING; if needed, allocate memory via
@@ -341,17 +341,17 @@ block_set_using (struct block *block,
{
block_initialize_namespace (block, obstack);
- BLOCK_NAMESPACE (block)->using_decl = using_decl;
+ block->namespace_info ()->using_decl = using_decl;
}
-/* If BLOCK_NAMESPACE (block) is NULL, allocate it via OBSTACK and
+/* If block->namespace_info () is NULL, allocate it via OBSTACK and
initialize its members to zero. */
static void
block_initialize_namespace (struct block *block, struct obstack *obstack)
{
- if (BLOCK_NAMESPACE (block) == NULL)
- BLOCK_NAMESPACE (block) = new (obstack) struct block_namespace_info ();
+ if (block->namespace_info () == NULL)
+ block->set_namespace_info (new (obstack) struct block_namespace_info ());
}
/* Return the static block associated to BLOCK. Return NULL if block
diff --git a/gdb/block.h b/gdb/block.h
index 9119963ddc64..4d513782ce3f 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -140,6 +140,16 @@ struct block
m_multidict = multidict;
}
+ block_namespace_info *namespace_info () const
+ {
+ return m_namespace_info;
+ }
+
+ void set_namespace_info (block_namespace_info *namespace_info)
+ {
+ m_namespace_info = namespace_info;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -165,7 +175,7 @@ struct block
/* Contains information about namespace-related info relevant to this block:
using directives and the current namespace scope. */
- struct block_namespace_info *namespace_info;
+ struct block_namespace_info *m_namespace_info;
/* Address ranges for blocks with non-contiguous ranges. If this
is NULL, then there is only one range which is specified by
@@ -188,8 +198,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-#define BLOCK_NAMESPACE(bl) (bl)->namespace_info
-
/* Accessor for ranges field within block BL. */
#define BLOCK_RANGES(bl) (bl)->ranges
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 06/14] gdb: remove BLOCK_RANGE_{START,END} macros
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (3 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 05/14] gdb: remove BLOCK_NAMESPACE macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Simon Marchi
` (4 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with equivalent methods on blockrange.
Change-Id: I20fd8f624e0129782c36768291891e7582d77c74
---
gdb/block.h | 32 ++++++++++++++++++--------------
gdb/blockframe.c | 16 ++++++++--------
gdb/cli/cli-cmds.c | 4 ++--
gdb/objfiles.c | 5 +++--
4 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index 4d513782ce3f..473abde5b3d9 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -38,19 +38,31 @@ struct addrmap;
struct blockrange
{
- blockrange (CORE_ADDR startaddr_, CORE_ADDR endaddr_)
- : startaddr (startaddr_),
- endaddr (endaddr_)
+ blockrange (CORE_ADDR start, CORE_ADDR end)
+ : m_start (start),
+ m_end (end)
{
}
+ CORE_ADDR start () const
+ { return m_start; }
+
+ void set_start (CORE_ADDR start)
+ { m_start = start; }
+
+ CORE_ADDR end () const
+ { return m_end; }
+
+ void set_end (CORE_ADDR end)
+ { m_end = end; }
+
/* Lowest address in this range. */
- CORE_ADDR startaddr;
+ CORE_ADDR m_start;
/* One past the highest address in the range. */
- CORE_ADDR endaddr;
+ CORE_ADDR m_end;
};
/* Two or more non-contiguous ranges in the same order as that provided
@@ -215,14 +227,6 @@ struct global_block
#define BLOCK_CONTIGUOUS_P(bl) (BLOCK_RANGES (bl) == nullptr \
|| BLOCK_NRANGES (bl) <= 1)
-/* Obtain the start address of the Nth range for block BL. */
-
-#define BLOCK_RANGE_START(bl,n) (BLOCK_RANGE (bl)[n].startaddr)
-
-/* Obtain the end address of the Nth range for block BL. */
-
-#define BLOCK_RANGE_END(bl,n) (BLOCK_RANGE (bl)[n].endaddr)
-
/* Define the "entry pc" for a block BL to be the lowest (start) address
for the block when all addresses within the block are contiguous. If
non-contiguous, then use the start address for the first range in the
@@ -239,7 +243,7 @@ struct global_block
#define BLOCK_ENTRY_PC(bl) (BLOCK_CONTIGUOUS_P (bl) \
? bl->start () \
- : BLOCK_RANGE_START (bl,0))
+ : BLOCK_RANGE (bl)[0].start ())
struct blockvector
{
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index cfc4fd2fd704..e91faaa98b1b 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -286,11 +286,11 @@ find_pc_partial_function_sym (CORE_ADDR pc,
int i;
for (i = 0; i < BLOCK_NRANGES (b); i++)
{
- if (BLOCK_RANGE_START (b, i) <= mapped_pc
- && mapped_pc < BLOCK_RANGE_END (b, i))
+ if (BLOCK_RANGE (b)[i].start () <= mapped_pc
+ && mapped_pc < BLOCK_RANGE (b)[i].end ())
{
- cache_pc_function_low = BLOCK_RANGE_START (b, i);
- cache_pc_function_high = BLOCK_RANGE_END (b, i);
+ cache_pc_function_low = BLOCK_RANGE (b)[i].start ();
+ cache_pc_function_high = BLOCK_RANGE (b)[i].end ();
break;
}
}
@@ -396,14 +396,14 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
for (int i = 0; i < BLOCK_NRANGES (block); i++)
{
- if (BLOCK_RANGE_START (block, i) <= entry_pc
- && entry_pc < BLOCK_RANGE_END (block, i))
+ if (BLOCK_RANGE (block)[i].start () <= entry_pc
+ && entry_pc < BLOCK_RANGE (block)[i].end ())
{
if (address != nullptr)
- *address = BLOCK_RANGE_START (block, i);
+ *address = BLOCK_RANGE (block)[i].start ();
if (endaddr != nullptr)
- *endaddr = BLOCK_RANGE_END (block, i);
+ *endaddr = BLOCK_RANGE (block)[i].end ();
return status;
}
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2b4becc97b22..f7c556a4e0cf 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1444,8 +1444,8 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
{
for (int i = 0; i < BLOCK_NRANGES (block); i++)
{
- CORE_ADDR range_low = BLOCK_RANGE_START (block, i);
- CORE_ADDR range_high = BLOCK_RANGE_END (block, i);
+ CORE_ADDR range_low = BLOCK_RANGE (block)[i].start ();
+ CORE_ADDR range_high = BLOCK_RANGE (block)[i].end ();
gdb_printf (_("Address range %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, range_low)),
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a709d947da00..9c7a30d9a60d 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -683,8 +683,9 @@ objfile_relocate1 (struct objfile *objfile,
if (BLOCK_RANGES (b) != nullptr)
for (int j = 0; j < BLOCK_NRANGES (b); j++)
{
- BLOCK_RANGE_START (b, j) += delta[block_line_section];
- BLOCK_RANGE_END (b, j) += delta[block_line_section];
+ blockrange &r = BLOCK_RANGE (b)[j];
+ r.set_start (r.start () + delta[block_line_section]);
+ r.set_end (r.end () + delta[block_line_section]);
}
/* We only want to iterate over the local symbols, not any
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 07/14] gdb: remove BLOCK_RANGES macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (4 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 06/14] gdb: remove BLOCK_RANGE_{START,END} macros Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 18:16 ` Pedro Alves
2022-04-28 10:47 ` Andrew Burgess
2022-04-21 14:59 ` [PATCH 08/14] gdb: remove BLOCK_NRANGES macro Simon Marchi
` (3 subsequent siblings)
9 siblings, 2 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with an equivalent method on struct block.
Change-Id: I6dcf13e9464ba8a08ade85c89e7329c300fd6c2a
---
gdb/block.h | 28 +++++++++++++++++++---------
gdb/dwarf2/read.c | 2 +-
gdb/objfiles.c | 12 +++++-------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index 473abde5b3d9..3935e263f929 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -21,6 +21,7 @@
#define BLOCK_H
#include "dictionary.h"
+#include "gdbsupport/array-view.h"
/* Opaque declarations. */
@@ -162,6 +163,19 @@ struct block
m_namespace_info = namespace_info;
}
+ gdb::array_view<blockrange> ranges () const
+ {
+ if (m_ranges != nullptr)
+ return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
+ else
+ return {};
+ }
+
+ void set_ranges (blockranges *ranges)
+ {
+ m_ranges = ranges;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -193,7 +207,7 @@ struct block
is NULL, then there is only one range which is specified by
startaddr and endaddr above. */
- struct blockranges *ranges;
+ struct blockranges *m_ranges;
};
/* The global block is singled out so that we can provide a back-link
@@ -210,22 +224,18 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-/* Accessor for ranges field within block BL. */
-
-#define BLOCK_RANGES(bl) (bl)->ranges
-
/* Number of ranges within a block. */
-#define BLOCK_NRANGES(bl) (bl)->ranges->nranges
+#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
/* Access range array for block BL. */
-#define BLOCK_RANGE(bl) (bl)->ranges->range
+#define BLOCK_RANGE(bl) (bl)->ranges ().data ()
/* Are all addresses within a block contiguous? */
-#define BLOCK_CONTIGUOUS_P(bl) (BLOCK_RANGES (bl) == nullptr \
- || BLOCK_NRANGES (bl) <= 1)
+#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () == 0 \
+ || (bl)->ranges ().size () == 1)
/* Define the "entry pc" for a block BL to be the lowest (start) address
for the block when all addresses within the block are contiguous. If
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bb72e0e4791b..c62d4be72a12 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13198,7 +13198,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
blockvec.emplace_back (start, end);
});
- BLOCK_RANGES(block) = make_blockranges (objfile, blockvec);
+ block->set_ranges (make_blockranges (objfile, blockvec));
}
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 9c7a30d9a60d..c4b054a70d57 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -680,13 +680,11 @@ objfile_relocate1 (struct objfile *objfile,
b->set_start (b->start () + delta[block_line_section]);
b->set_end (b->end () + delta[block_line_section]);
- if (BLOCK_RANGES (b) != nullptr)
- for (int j = 0; j < BLOCK_NRANGES (b); j++)
- {
- blockrange &r = BLOCK_RANGE (b)[j];
- r.set_start (r.start () + delta[block_line_section]);
- r.set_end (r.end () + delta[block_line_section]);
- }
+ for (blockrange &r : b->ranges ())
+ {
+ r.set_start (r.start () + delta[block_line_section]);
+ r.set_end (r.end () + delta[block_line_section]);
+ }
/* We only want to iterate over the local symbols, not any
symbols in included symtabs. */
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 08/14] gdb: remove BLOCK_NRANGES macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (5 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 17:38 ` Lancelot SIX
2022-04-21 14:59 ` [PATCH 09/14] gdb: remove BLOCK_RANGE macro Simon Marchi
` (2 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with range for loops.
Change-Id: Icbe04f9b6f9e6ddae2e15b2409c61f7a336bc3e3
---
gdb/block.h | 4 ----
gdb/blockframe.c | 23 +++++++++++------------
gdb/cli/cli-cmds.c | 7 ++++---
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index 3935e263f929..bc5978734f38 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -224,10 +224,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-/* Number of ranges within a block. */
-
-#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
-
/* Access range array for block BL. */
#define BLOCK_RANGE(bl) (bl)->ranges ().data ()
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index e91faaa98b1b..b3265f2b032c 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -283,19 +283,19 @@ find_pc_partial_function_sym (CORE_ADDR pc,
}
else
{
- int i;
- for (i = 0; i < BLOCK_NRANGES (b); i++)
+ bool found = false;
+ for (blockrange &range : b->ranges ())
{
- if (BLOCK_RANGE (b)[i].start () <= mapped_pc
- && mapped_pc < BLOCK_RANGE (b)[i].end ())
+ if (range.start () <= mapped_pc && mapped_pc < range.end ())
{
- cache_pc_function_low = BLOCK_RANGE (b)[i].start ();
- cache_pc_function_high = BLOCK_RANGE (b)[i].end ();
+ cache_pc_function_low = range.start ();
+ cache_pc_function_high = range.end ();
+ found = true;
break;
}
}
/* Above loop should exit via the break. */
- gdb_assert (i < BLOCK_NRANGES (b));
+ gdb_assert (found);
}
@@ -394,16 +394,15 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
{
CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
- for (int i = 0; i < BLOCK_NRANGES (block); i++)
+ for (blockrange &range : block->ranges ())
{
- if (BLOCK_RANGE (block)[i].start () <= entry_pc
- && entry_pc < BLOCK_RANGE (block)[i].end ())
+ if (range.start () <= entry_pc && entry_pc < range.end ())
{
if (address != nullptr)
- *address = BLOCK_RANGE (block)[i].start ();
+ *address = range.start ();
if (endaddr != nullptr)
- *endaddr = BLOCK_RANGE (block)[i].end ();
+ *endaddr = range.end ();
return status;
}
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index f7c556a4e0cf..3d49166c971c 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1442,10 +1442,11 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
}
else
{
- for (int i = 0; i < BLOCK_NRANGES (block); i++)
+ for (blockrange &range : block->ranges ())
{
- CORE_ADDR range_low = BLOCK_RANGE (block)[i].start ();
- CORE_ADDR range_high = BLOCK_RANGE (block)[i].end ();
+ CORE_ADDR range_low = range.start ();
+ CORE_ADDR range_high = range.end ();
+
gdb_printf (_("Address range %ps to %ps:\n"),
styled_string (address_style.style (),
paddress (gdbarch, range_low)),
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 09/14] gdb: remove BLOCK_RANGE macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (6 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 08/14] gdb: remove BLOCK_NRANGES macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro Simon Marchi
2022-04-28 2:39 ` [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with access through the block::ranges method.
Change-Id: I50f3ed433b997c9f354e49bc6583f540ae4b6121
---
gdb/block.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index bc5978734f38..b0f1ff04ff74 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -224,10 +224,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-/* Access range array for block BL. */
-
-#define BLOCK_RANGE(bl) (bl)->ranges ().data ()
-
/* Are all addresses within a block contiguous? */
#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () == 0 \
@@ -249,7 +245,7 @@ struct global_block
#define BLOCK_ENTRY_PC(bl) (BLOCK_CONTIGUOUS_P (bl) \
? bl->start () \
- : BLOCK_RANGE (bl)[0].start ())
+ : bl->ranges ()[0].start ())
struct blockvector
{
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (7 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 09/14] gdb: remove BLOCK_RANGE macro Simon Marchi
@ 2022-04-21 14:59 ` Simon Marchi
2022-04-21 18:16 ` Lancelot SIX
2022-04-28 2:39 ` [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
9 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 14:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Replace with an equivalent method.
Change-Id: I60fd3be7b4c2601c2a74328f635fa48ed80eb7f5
---
gdb/block.h | 14 ++++++++------
gdb/blockframe.c | 4 ++--
gdb/cli/cli-cmds.c | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index b0f1ff04ff74..96ceea23020e 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -176,6 +176,13 @@ struct block
m_ranges = ranges;
}
+ /* Are all addresses within a block contiguous? */
+
+ bool is_contiguous () const
+ {
+ return this->ranges ().size () == 0 || this->ranges ().size () == 1;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -224,11 +231,6 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-/* Are all addresses within a block contiguous? */
-
-#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () == 0 \
- || (bl)->ranges ().size () == 1)
-
/* Define the "entry pc" for a block BL to be the lowest (start) address
for the block when all addresses within the block are contiguous. If
non-contiguous, then use the start address for the first range in the
@@ -243,7 +245,7 @@ struct global_block
the entry_pc field can be set from the dwarf reader (and other readers
too). BLOCK_ENTRY_PC can then be redefined to be less DWARF-centric. */
-#define BLOCK_ENTRY_PC(bl) (BLOCK_CONTIGUOUS_P (bl) \
+#define BLOCK_ENTRY_PC(bl) (bl->is_contiguous () \
? bl->start () \
: bl->ranges ()[0].start ())
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index b3265f2b032c..1b7381b5617e 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -276,7 +276,7 @@ find_pc_partial_function_sym (CORE_ADDR pc,
comment preceding declaration of find_pc_partial_function
in symtab.h for more information. */
- if (BLOCK_CONTIGUOUS_P (b))
+ if (b->is_contiguous ())
{
cache_pc_function_low = b->start ();
cache_pc_function_high = b->end ();
@@ -390,7 +390,7 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
const struct block *block;
bool status = find_pc_partial_function (pc, name, address, endaddr, &block);
- if (status && block != nullptr && !BLOCK_CONTIGUOUS_P (block))
+ if (status && block != nullptr && !block->is_contiguous ())
{
CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3d49166c971c..d8627680a9e3 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1428,7 +1428,7 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
if (name != NULL)
gdb_printf (_("for function %ps:\n"),
styled_string (function_name_style.style (), name));
- if (block == nullptr || BLOCK_CONTIGUOUS_P (block))
+ if (block == nullptr || block->is_contiguous ())
{
if (name == NULL)
gdb_printf (_("from %ps to %ps:\n"),
--
2.26.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro
2022-04-21 14:59 ` [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro Simon Marchi
@ 2022-04-21 17:33 ` Lancelot SIX
2022-04-21 17:49 ` Simon Marchi
0 siblings, 1 reply; 20+ messages in thread
From: Lancelot SIX @ 2022-04-21 17:33 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
> @@ -1158,8 +1159,8 @@ buildsym_compunit::augment_type_symtab ()
> to the primary symtab. */
> set_missing_symtab (m_global_symbols, cust);
>
> - mdict_add_pending (BLOCK_MULTIDICT (block),
> - m_global_symbols);
> + mdict_add_pending (block->multidict (),
> + m_global_symbols);
Hi, I just skimmed through and noticed that here tabs are replaced with
spaces. (yes, my mail reader highlights this)
Best,
Lancelot.
> }
> }
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 08/14] gdb: remove BLOCK_NRANGES macro
2022-04-21 14:59 ` [PATCH 08/14] gdb: remove BLOCK_NRANGES macro Simon Marchi
@ 2022-04-21 17:38 ` Lancelot SIX
2022-04-21 17:52 ` Simon Marchi
0 siblings, 1 reply; 20+ messages in thread
From: Lancelot SIX @ 2022-04-21 17:38 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
Hi,
On Thu, Apr 21, 2022 at 10:59:04AM -0400, Simon Marchi via Gdb-patches wrote:
> Replace with range for loops.
>
> Change-Id: Icbe04f9b6f9e6ddae2e15b2409c61f7a336bc3e3
> ---
> gdb/block.h | 4 ----
> gdb/blockframe.c | 23 +++++++++++------------
> gdb/cli/cli-cmds.c | 7 ++++---
> 3 files changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/gdb/block.h b/gdb/block.h
> index 3935e263f929..bc5978734f38 100644
> --- a/gdb/block.h
> +++ b/gdb/block.h
> @@ -224,10 +224,6 @@ struct global_block
> struct compunit_symtab *compunit_symtab;
> };
>
> -/* Number of ranges within a block. */
> -
> -#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
> -
> /* Access range array for block BL. */
>
> #define BLOCK_RANGE(bl) (bl)->ranges ().data ()
> diff --git a/gdb/blockframe.c b/gdb/blockframe.c
> index e91faaa98b1b..b3265f2b032c 100644
> --- a/gdb/blockframe.c
> +++ b/gdb/blockframe.c
> @@ -283,19 +283,19 @@ find_pc_partial_function_sym (CORE_ADDR pc,
> }
> else
> {
> - int i;
> - for (i = 0; i < BLOCK_NRANGES (b); i++)
> + bool found = false;
> + for (blockrange &range : b->ranges ())
Could this be "const blockrange &"?
> {
> - if (BLOCK_RANGE (b)[i].start () <= mapped_pc
> - && mapped_pc < BLOCK_RANGE (b)[i].end ())
> + if (range.start () <= mapped_pc && mapped_pc < range.end ())
> {
> - cache_pc_function_low = BLOCK_RANGE (b)[i].start ();
> - cache_pc_function_high = BLOCK_RANGE (b)[i].end ();
> + cache_pc_function_low = range.start ();
> + cache_pc_function_high = range.end ();
> + found = true;
> break;
> }
> }
> /* Above loop should exit via the break. */
> - gdb_assert (i < BLOCK_NRANGES (b));
> + gdb_assert (found);
> }
>
>
> @@ -394,16 +394,15 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
> {
> CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
>
> - for (int i = 0; i < BLOCK_NRANGES (block); i++)
> + for (blockrange &range : block->ranges ())
Same question.
> {
> - if (BLOCK_RANGE (block)[i].start () <= entry_pc
> - && entry_pc < BLOCK_RANGE (block)[i].end ())
> + if (range.start () <= entry_pc && entry_pc < range.end ())
> {
> if (address != nullptr)
> - *address = BLOCK_RANGE (block)[i].start ();
> + *address = range.start ();
>
> if (endaddr != nullptr)
> - *endaddr = BLOCK_RANGE (block)[i].end ();
> + *endaddr = range.end ();
>
> return status;
> }
> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
> index f7c556a4e0cf..3d49166c971c 100644
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -1442,10 +1442,11 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
> }
> else
> {
> - for (int i = 0; i < BLOCK_NRANGES (block); i++)
> + for (blockrange &range : block->ranges ())
Here also.
Best,
Lancelot.
> {
> - CORE_ADDR range_low = BLOCK_RANGE (block)[i].start ();
> - CORE_ADDR range_high = BLOCK_RANGE (block)[i].end ();
> + CORE_ADDR range_low = range.start ();
> + CORE_ADDR range_high = range.end ();
> +
> gdb_printf (_("Address range %ps to %ps:\n"),
> styled_string (address_style.style (),
> paddress (gdbarch, range_low)),
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro
2022-04-21 17:33 ` Lancelot SIX
@ 2022-04-21 17:49 ` Simon Marchi
0 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 17:49 UTC (permalink / raw)
To: Lancelot SIX, Simon Marchi; +Cc: gdb-patches
On 2022-04-21 13:33, Lancelot SIX via Gdb-patches wrote:
>> @@ -1158,8 +1159,8 @@ buildsym_compunit::augment_type_symtab ()
>> to the primary symtab. */
>> set_missing_symtab (m_global_symbols, cust);
>>
>> - mdict_add_pending (BLOCK_MULTIDICT (block),
>> - m_global_symbols);
>> + mdict_add_pending (block->multidict (),
>> + m_global_symbols);
>
> Hi, I just skimmed through and noticed that here tabs are replaced with
> spaces. (yes, my mail reader highlights this)
Hmm strange, thanks for pointing it out. This fits on a single line anyway.
Fixed locally.
Simon
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 08/14] gdb: remove BLOCK_NRANGES macro
2022-04-21 17:38 ` Lancelot SIX
@ 2022-04-21 17:52 ` Simon Marchi
0 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 17:52 UTC (permalink / raw)
To: Lancelot SIX, Simon Marchi; +Cc: gdb-patches
On 2022-04-21 13:38, Lancelot SIX via Gdb-patches wrote:
> Hi,
>
> On Thu, Apr 21, 2022 at 10:59:04AM -0400, Simon Marchi via Gdb-patches wrote:
>> Replace with range for loops.
>>
>> Change-Id: Icbe04f9b6f9e6ddae2e15b2409c61f7a336bc3e3
>> ---
>> gdb/block.h | 4 ----
>> gdb/blockframe.c | 23 +++++++++++------------
>> gdb/cli/cli-cmds.c | 7 ++++---
>> 3 files changed, 15 insertions(+), 19 deletions(-)
>>
>> diff --git a/gdb/block.h b/gdb/block.h
>> index 3935e263f929..bc5978734f38 100644
>> --- a/gdb/block.h
>> +++ b/gdb/block.h
>> @@ -224,10 +224,6 @@ struct global_block
>> struct compunit_symtab *compunit_symtab;
>> };
>>
>> -/* Number of ranges within a block. */
>> -
>> -#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
>> -
>> /* Access range array for block BL. */
>>
>> #define BLOCK_RANGE(bl) (bl)->ranges ().data ()
>> diff --git a/gdb/blockframe.c b/gdb/blockframe.c
>> index e91faaa98b1b..b3265f2b032c 100644
>> --- a/gdb/blockframe.c
>> +++ b/gdb/blockframe.c
>> @@ -283,19 +283,19 @@ find_pc_partial_function_sym (CORE_ADDR pc,
>> }
>> else
>> {
>> - int i;
>> - for (i = 0; i < BLOCK_NRANGES (b); i++)
>> + bool found = false;
>> + for (blockrange &range : b->ranges ())
>
> Could this be "const blockrange &"?
Yes, done.
>
>> {
>> - if (BLOCK_RANGE (b)[i].start () <= mapped_pc
>> - && mapped_pc < BLOCK_RANGE (b)[i].end ())
>> + if (range.start () <= mapped_pc && mapped_pc < range.end ())
>> {
>> - cache_pc_function_low = BLOCK_RANGE (b)[i].start ();
>> - cache_pc_function_high = BLOCK_RANGE (b)[i].end ();
>> + cache_pc_function_low = range.start ();
>> + cache_pc_function_high = range.end ();
>> + found = true;
>> break;
>> }
>> }
>> /* Above loop should exit via the break. */
>> - gdb_assert (i < BLOCK_NRANGES (b));
>> + gdb_assert (found);
>> }
>>
>>
>> @@ -394,16 +394,15 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name,
>> {
>> CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
>>
>> - for (int i = 0; i < BLOCK_NRANGES (block); i++)
>> + for (blockrange &range : block->ranges ())
>
> Same question.
Done.
>> {
>> - if (BLOCK_RANGE (block)[i].start () <= entry_pc
>> - && entry_pc < BLOCK_RANGE (block)[i].end ())
>> + if (range.start () <= entry_pc && entry_pc < range.end ())
>> {
>> if (address != nullptr)
>> - *address = BLOCK_RANGE (block)[i].start ();
>> + *address = range.start ();
>>
>> if (endaddr != nullptr)
>> - *endaddr = BLOCK_RANGE (block)[i].end ();
>> + *endaddr = range.end ();
>>
>> return status;
>> }
>> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
>> index f7c556a4e0cf..3d49166c971c 100644
>> --- a/gdb/cli/cli-cmds.c
>> +++ b/gdb/cli/cli-cmds.c
>> @@ -1442,10 +1442,11 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
>> }
>> else
>> {
>> - for (int i = 0; i < BLOCK_NRANGES (block); i++)
>> + for (blockrange &range : block->ranges ())
>
> Here also.
Done.
I made the changes locally.
Simon
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/14] gdb: remove BLOCK_RANGES macro
2022-04-21 14:59 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Simon Marchi
@ 2022-04-21 18:16 ` Pedro Alves
2022-04-21 18:57 ` Simon Marchi
2022-04-28 10:47 ` Andrew Burgess
1 sibling, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2022-04-21 18:16 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 2022-04-21 15:59, Simon Marchi via Gdb-patches wrote:
> + gdb::array_view<blockrange> ranges () const
> + {
> + if (m_ranges != nullptr)
> + return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
Given this is a const method, shouldn't this be:
gdb::array_view<const blockrange> ranges () const
?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro
2022-04-21 14:59 ` [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro Simon Marchi
@ 2022-04-21 18:16 ` Lancelot SIX
2022-04-21 18:59 ` Simon Marchi
0 siblings, 1 reply; 20+ messages in thread
From: Lancelot SIX @ 2022-04-21 18:16 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On Thu, Apr 21, 2022 at 10:59:06AM -0400, Simon Marchi via Gdb-patches wrote:
> Replace with an equivalent method.
>
> Change-Id: I60fd3be7b4c2601c2a74328f635fa48ed80eb7f5
> ---
> gdb/block.h | 14 ++++++++------
> gdb/blockframe.c | 4 ++--
> gdb/cli/cli-cmds.c | 2 +-
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/block.h b/gdb/block.h
> index b0f1ff04ff74..96ceea23020e 100644
> --- a/gdb/block.h
> +++ b/gdb/block.h
> @@ -176,6 +176,13 @@ struct block
> m_ranges = ranges;
> }
>
> + /* Are all addresses within a block contiguous? */
> +
> + bool is_contiguous () const
> + {
> + return this->ranges ().size () == 0 || this->ranges ().size () == 1;
I guess that since gdb::array_view::size_type is size_t, so unsigned,
this can be simplified into
return this->ranges ().size () <= 1;
I do not see that changing, but if this is a possibility (why would it
be?), we can add a static assert like
gdb_static_assert (std::is_unsigned<decltype (this->ranges ().size ())>::value);
Best,
Lancelot.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/14] gdb: remove BLOCK_RANGES macro
2022-04-21 18:16 ` Pedro Alves
@ 2022-04-21 18:57 ` Simon Marchi
0 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 18:57 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 2022-04-21 14:16, Pedro Alves wrote:
> On 2022-04-21 15:59, Simon Marchi via Gdb-patches wrote:
>> + gdb::array_view<blockrange> ranges () const
>> + {
>> + if (m_ranges != nullptr)
>> + return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
>
> Given this is a const method, shouldn't this be:
>
> gdb::array_view<const blockrange> ranges () const
>
> ?
Hmm indeed. It needs both a const and a non-const version. Fixed locally.
Simon
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro
2022-04-21 18:16 ` Lancelot SIX
@ 2022-04-21 18:59 ` Simon Marchi
0 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-21 18:59 UTC (permalink / raw)
To: Lancelot SIX; +Cc: gdb-patches
On 2022-04-21 14:16, Lancelot SIX wrote:
> On Thu, Apr 21, 2022 at 10:59:06AM -0400, Simon Marchi via Gdb-patches wrote:
>> Replace with an equivalent method.
>>
>> Change-Id: I60fd3be7b4c2601c2a74328f635fa48ed80eb7f5
>> ---
>> gdb/block.h | 14 ++++++++------
>> gdb/blockframe.c | 4 ++--
>> gdb/cli/cli-cmds.c | 2 +-
>> 3 files changed, 11 insertions(+), 9 deletions(-)
>>
>> diff --git a/gdb/block.h b/gdb/block.h
>> index b0f1ff04ff74..96ceea23020e 100644
>> --- a/gdb/block.h
>> +++ b/gdb/block.h
>> @@ -176,6 +176,13 @@ struct block
>> m_ranges = ranges;
>> }
>>
>> + /* Are all addresses within a block contiguous? */
>> +
>> + bool is_contiguous () const
>> + {
>> + return this->ranges ().size () == 0 || this->ranges ().size () == 1;
>
> I guess that since gdb::array_view::size_type is size_t, so unsigned,
> this can be simplified into
>
> return this->ranges ().size () <= 1;
I made this change.
>
> I do not see that changing, but if this is a possibility (why would it
> be?), we can add a static assert like
>
> gdb_static_assert (std::is_unsigned<decltype (this->ranges ().size ())>::value);
I don't think we need to worry about array sizes becoming negative.
Simon
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/14] gdb: remove BLOCK_{START,END} macros
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
` (8 preceding siblings ...)
2022-04-21 14:59 ` [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro Simon Marchi
@ 2022-04-28 2:39 ` Simon Marchi
9 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2022-04-28 2:39 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 2022-04-21 10:58, Simon Marchi via Gdb-patches wrote:
> Replace with equivalent methods.
>
> Change-Id: I10a6c8a2a86462d9d4a6a6409a3f07a6bea66310
I pushed this series.
Simon
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/14] gdb: remove BLOCK_RANGES macro
2022-04-21 14:59 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Simon Marchi
2022-04-21 18:16 ` Pedro Alves
@ 2022-04-28 10:47 ` Andrew Burgess
1 sibling, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2022-04-28 10:47 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches, gdb-patches; +Cc: Simon Marchi
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> Replace with an equivalent method on struct block.
>
> Change-Id: I6dcf13e9464ba8a08ade85c89e7329c300fd6c2a
> ---
> gdb/block.h | 28 +++++++++++++++++++---------
> gdb/dwarf2/read.c | 2 +-
> gdb/objfiles.c | 12 +++++-------
> 3 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/gdb/block.h b/gdb/block.h
> index 473abde5b3d9..3935e263f929 100644
> --- a/gdb/block.h
> +++ b/gdb/block.h
> @@ -21,6 +21,7 @@
> #define BLOCK_H
>
> #include "dictionary.h"
> +#include "gdbsupport/array-view.h"
>
> /* Opaque declarations. */
>
> @@ -162,6 +163,19 @@ struct block
> m_namespace_info = namespace_info;
> }
>
> + gdb::array_view<blockrange> ranges () const
> + {
> + if (m_ranges != nullptr)
> + return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
> + else
> + return {};
> + }
> +
> + void set_ranges (blockranges *ranges)
> + {
> + m_ranges = ranges;
> + }
> +
> /* Addresses in the executable code that are in this block. */
>
> CORE_ADDR m_start;
> @@ -193,7 +207,7 @@ struct block
> is NULL, then there is only one range which is specified by
> startaddr and endaddr above. */
>
> - struct blockranges *ranges;
> + struct blockranges *m_ranges;
> };
>
> /* The global block is singled out so that we can provide a back-link
> @@ -210,22 +224,18 @@ struct global_block
> struct compunit_symtab *compunit_symtab;
> };
>
> -/* Accessor for ranges field within block BL. */
> -
> -#define BLOCK_RANGES(bl) (bl)->ranges
> -
> /* Number of ranges within a block. */
>
> -#define BLOCK_NRANGES(bl) (bl)->ranges->nranges
> +#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
>
> /* Access range array for block BL. */
>
> -#define BLOCK_RANGE(bl) (bl)->ranges->range
> +#define BLOCK_RANGE(bl) (bl)->ranges ().data ()
>
> /* Are all addresses within a block contiguous? */
>
> -#define BLOCK_CONTIGUOUS_P(bl) (BLOCK_RANGES (bl) == nullptr \
> - || BLOCK_NRANGES (bl) <= 1)
> +#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () == 0 \
> + || (bl)->ranges ().size () == 1)
>
I think this is dropping a nullptr check. Previously the
BLOCK_RANGES(bl) check would ensure that block::ranges (now
block::m_ranges) was not nullptr, but now we just call block::ranges()
in all cases, which assumes block::m_ranges is not nullptr. This is not
always the case.
I posted a possible fix here:
https://sourceware.org/pipermail/gdb-patches/2022-April/188487.html
Thanks,
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2022-04-28 10:47 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
2022-04-21 14:58 ` [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro Simon Marchi
2022-04-21 14:58 ` [PATCH 03/14] gdb: remove BLOCK_SUPERBLOCK macro Simon Marchi
2022-04-21 14:59 ` [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro Simon Marchi
2022-04-21 17:33 ` Lancelot SIX
2022-04-21 17:49 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 05/14] gdb: remove BLOCK_NAMESPACE macro Simon Marchi
2022-04-21 14:59 ` [PATCH 06/14] gdb: remove BLOCK_RANGE_{START,END} macros Simon Marchi
2022-04-21 14:59 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Simon Marchi
2022-04-21 18:16 ` Pedro Alves
2022-04-21 18:57 ` Simon Marchi
2022-04-28 10:47 ` Andrew Burgess
2022-04-21 14:59 ` [PATCH 08/14] gdb: remove BLOCK_NRANGES macro Simon Marchi
2022-04-21 17:38 ` Lancelot SIX
2022-04-21 17:52 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 09/14] gdb: remove BLOCK_RANGE macro Simon Marchi
2022-04-21 14:59 ` [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro Simon Marchi
2022-04-21 18:16 ` Lancelot SIX
2022-04-21 18:59 ` Simon Marchi
2022-04-28 2:39 ` [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
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).