public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Constify chain_candidate
@ 2022-03-28 19:56 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-03-28 19:56 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=394d8c59ea961e1dcf89ec6c8b6d6606b361590a
commit 394d8c59ea961e1dcf89ec6c8b6d6606b361590a
Author: Tom Tromey <tromey@adacore.com>
Date: Fri Nov 19 08:02:38 2021 -0700
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.
Diff:
---
gdb/dwarf2/loc.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index acb7b863145..addf611d8f8 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-28 19:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 19:56 [binutils-gdb] Constify chain_candidate Tom Tromey
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).