Filter out types from DAP scopes request

Message ID 20230410141908.2921047-1-tromey@adacore.com
State New
Headers
Series Filter out types from DAP scopes request |

Commit Message

Tom Tromey April 10, 2023, 2:19 p.m. UTC
  The DAP scopes request examines the symbols in a block tree, but
neglects to omit types.  This patch fixes the problem.
---
 gdb/python/lib/gdb/dap/scopes.py |  2 +-
 gdb/testsuite/gdb.dap/scopes.c   | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
  

Comments

Tom Tromey May 5, 2023, 7:55 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> The DAP scopes request examines the symbols in a block tree, but
Tom> neglects to omit types.  This patch fixes the problem.

I'm going to check this in.

Tom
  

Patch

diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py
index 9ab454aa57b..be4f8fc28a0 100644
--- a/gdb/python/lib/gdb/dap/scopes.py
+++ b/gdb/python/lib/gdb/dap/scopes.py
@@ -41,7 +41,7 @@  def _block_vars(block):
         for var in block:
             if var.is_argument:
                 args.append(var)
-            else:
+            elif var.is_variable or var.is_constant:
                 locs.append(var)
         if block.function is not None:
             break
diff --git a/gdb/testsuite/gdb.dap/scopes.c b/gdb/testsuite/gdb.dap/scopes.c
index 7b35036cce1..ce87db1f13d 100644
--- a/gdb/testsuite/gdb.dap/scopes.c
+++ b/gdb/testsuite/gdb.dap/scopes.c
@@ -15,14 +15,14 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-struct dei_struct
-{
-  int x;
-  int more[5];
-};
-
 int main ()
 {
+  struct dei_struct
+  {
+    int x;
+    int more[5];
+  };
+
   struct dei_struct dei = { 2, { 3, 5, 7, 11, 13 } };
 
   static int scalar = 23;