From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/5] Fix oversights in frame decorator code
Date: Wed, 14 Jun 2023 10:30:49 -0600 [thread overview]
Message-ID: <20230614-dap-frame-decor-v1-3-af87db6467b2@adacore.com> (raw)
In-Reply-To: <20230614-dap-frame-decor-v1-0-af87db6467b2@adacore.com>
The frame decorator "FrameVars" code misses a couple of cases,
discovered when working on related DAP changes.
First, fetch_frame_locals does not stop when reaching a function
boundary. This means it would return locals from any enclosing
functions.
Second, fetch_frame_args assumes that all arguments are at the
outermost scope, but this doesn't seem to be required by gdb.
---
gdb/python/lib/gdb/FrameDecorator.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py
index 6773780735b..7293be86185 100644
--- a/gdb/python/lib/gdb/FrameDecorator.py
+++ b/gdb/python/lib/gdb/FrameDecorator.py
@@ -269,6 +269,11 @@ class FrameVars(object):
if self.fetch_b(sym):
lvars.append(SymValueWrapper(sym, None))
+ # Stop when the function itself is seen, to avoid showing
+ # variables from outer functions in a nested function.
+ if block.function is not None:
+ break
+
block = block.superblock
return lvars
@@ -286,14 +291,18 @@ class FrameVars(object):
block = None
while block is not None:
- if block.function is not None:
+ if block.is_global or block.is_static:
break
- block = block.superblock
-
- if block is not None:
for sym in block:
if not sym.is_argument:
continue
args.append(SymValueWrapper(sym, None))
+ # Stop when the function itself is seen, to avoid showing
+ # variables from outer functions in a nested function.
+ if block.function is not None:
+ break
+
+ block = block.superblock
+
return args
--
2.40.1
next prev parent reply other threads:[~2023-06-14 16:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 16:30 [PATCH 0/5] Reimplement DAP backtrace using frame filters Tom Tromey
2023-06-14 16:30 ` [PATCH 1/5] Fix execute_frame_filters doc string Tom Tromey
2023-06-14 16:30 ` [PATCH 2/5] Add new interface to frame filter iteration Tom Tromey
2023-06-14 16:30 ` Tom Tromey [this message]
2023-06-14 16:30 ` [PATCH 4/5] Simplify FrameVars Tom Tromey
2023-06-22 16:09 ` Tom Tromey
2023-06-14 16:30 ` [PATCH 5/5] Reimplement DAP stack traces using frame filters Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230614-dap-frame-decor-v1-3-af87db6467b2@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).