aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-08-13 11:39:58 -0600
committerTom Tromey <tromey@adacore.com>2019-08-19 10:32:03 -0600
commitf21c2bd7b7ef2a9c47e5713cabaa784bcf5c2bee (patch)
treeb59e02ba87703ec277f2f63dbc1e6b617d3b6b92 /gdb/block.c
parentd806ea2d0ef362fcddd2c1659f537b68aa114203 (diff)
downloadbinutils-f21c2bd7b7ef2a9c47e5713cabaa784bcf5c2bee.zip
binutils-f21c2bd7b7ef2a9c47e5713cabaa784bcf5c2bee.tar.gz
binutils-f21c2bd7b7ef2a9c47e5713cabaa784bcf5c2bee.tar.bz2
Fix Fortran regression with variables in nested functions
Sergio pointed out that commit commit aa3b6533 ("Allow nested function displays") regressed a few gdb.fortran tests. I was able to reproduce these failures with gcc head. The bug is that some spots calling contained_in will in fact do the wrong thing if nested functions are considered as contained. In the particular case of the Fortran regression, it was the call in block_innermost_frame, being called from get_hosting_frame -- in this case, the caller is specifically trying to avoid the nested case. This patch fixes the problem by adding an "allow_nested" parameter to contained_in, essentially reverting the change for most callers. gdb/ChangeLog 2019-08-19 Tom Tromey <tromey@adacore.com> * printcmd.c (do_one_display, info_display_command): Update. * block.h (contained_in): Return bool. Add allow_nested parameter. * block.c (contained_in): Return bool. Add allow_nested parameter.
Diffstat (limited to 'gdb/block.c')
-rw-r--r--gdb/block.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 5c6faa8..ca4dc22 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -65,25 +65,28 @@ block_gdbarch (const struct block *block)
return get_objfile_arch (block_objfile (block));
}
-/* Return Nonzero if block a is lexically nested within block b,
- or if a and b have the same pc range.
- Return zero otherwise. */
+/* See block.h. */
-int
-contained_in (const struct block *a, const struct block *b)
+bool
+contained_in (const struct block *a, const struct block *b,
+ bool allow_nested)
{
if (!a || !b)
- return 0;
+ return false;
do
{
if (a == b)
- return 1;
+ 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))
+ return false;
a = BLOCK_SUPERBLOCK (a);
}
while (a != NULL);
- return 0;
+ return true;
}