aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-11-19 08:02:38 -0700
committerTom Tromey <tromey@adacore.com>2022-03-28 13:07:42 -0600
commit394d8c59ea961e1dcf89ec6c8b6d6606b361590a (patch)
tree771df40888b2cb17f465518236664007415378b2 /gdb/dwarf2
parent797662d7ef6705f9c300cb3e9a78f17f0f2aedad (diff)
downloadgdb-394d8c59ea961e1dcf89ec6c8b6d6606b361590a.zip
gdb-394d8c59ea961e1dcf89ec6c8b6d6606b361590a.tar.gz
gdb-394d8c59ea961e1dcf89ec6c8b6d6606b361590a.tar.bz2
Constify chain_candidate
While investigating this bug, I wasn't sure if chain_candidate might update 'chain'. I changed it to accept a const reference, making it clear that it cannot. This simplifies the code a tiny bit as well.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/loc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index acb7b86..addf611 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -835,9 +835,9 @@ tailcall_dump (struct gdbarch *gdbarch, const struct call_site *call_site)
static void
chain_candidate (struct gdbarch *gdbarch,
gdb::unique_xmalloc_ptr<struct call_site_chain> *resultp,
- std::vector<struct call_site *> *chain)
+ const std::vector<struct call_site *> &chain)
{
- long length = chain->size ();
+ long length = chain.size ();
int callers, callees, idx;
if (*resultp == NULL)
@@ -850,8 +850,8 @@ chain_candidate (struct gdbarch *gdbarch,
+ sizeof (*result->call_site) * (length - 1)));
result->length = length;
result->callers = result->callees = length;
- if (!chain->empty ())
- memcpy (result->call_site, chain->data (),
+ if (!chain.empty ())
+ memcpy (result->call_site, chain.data (),
sizeof (*result->call_site) * length);
resultp->reset (result);
@@ -870,7 +870,7 @@ chain_candidate (struct gdbarch *gdbarch,
{
fprintf_unfiltered (gdb_stdlog, "tailcall: compare:");
for (idx = 0; idx < length; idx++)
- tailcall_dump (gdbarch, chain->at (idx));
+ tailcall_dump (gdbarch, chain[idx]);
fputc_unfiltered ('\n', gdb_stdlog);
}
@@ -878,7 +878,7 @@ chain_candidate (struct gdbarch *gdbarch,
callers = std::min ((long) (*resultp)->callers, length);
for (idx = 0; idx < callers; idx++)
- if ((*resultp)->call_site[idx] != chain->at (idx))
+ if ((*resultp)->call_site[idx] != chain[idx])
{
(*resultp)->callers = idx;
break;
@@ -889,7 +889,7 @@ chain_candidate (struct gdbarch *gdbarch,
callees = std::min ((long) (*resultp)->callees, length);
for (idx = 0; idx < callees; idx++)
if ((*resultp)->call_site[(*resultp)->length - 1 - idx]
- != chain->at (length - 1 - idx))
+ != chain[length - 1 - idx])
{
(*resultp)->callees = idx;
break;
@@ -970,7 +970,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
if (target_func_addr == callee_pc)
{
- chain_candidate (gdbarch, &retval, &chain);
+ chain_candidate (gdbarch, &retval, chain);
if (retval == NULL)
break;