[0/7] Handle nested functions in DAP

Message ID 20231101-dap-nested-function-v1-0-0b0c3b228ac7@adacore.com
Headers
Series Handle nested functions in DAP |

Message

Tom Tromey Nov. 1, 2023, 5:09 p.m. UTC
  DAP doesn't really describe what to do for nested functions.  We
discussed it internally a little, and I came up with this series.  The
idea here is that variables from the outer scope ought to be visible,
so this series lets Python code follow a frame's static link, and then
changes the DAP frame decorators to use this ability.

At some point I think we'll need a "frame decorator v2", like we added
for pretty-printers.  But, I've been putting this off a little and
still haven't done it here.

Regression tested on x86-64 Fedora 36.

---
Tom Tromey (7):
      Add two convenience methods to block
      Add block::function_block
      Move follow_static_link to frame.c
      Add gdb.Frame.static_link method
      Fix a bug in DAP scopes code
      Handle the static link in FrameDecorator
      Update gdb.Symbol.is_variable documentation

 gdb/NEWS                                  |  3 +
 gdb/block.c                               | 13 +++++
 gdb/block.h                               | 21 +++++++
 gdb/doc/python.texi                       | 14 ++++-
 gdb/findvar.c                             | 64 +++-------------------
 gdb/frame.c                               | 40 ++++++++++++++
 gdb/frame.h                               |  7 +++
 gdb/python/lib/gdb/FrameDecorator.py      | 64 +++++++++++++++++-----
 gdb/python/lib/gdb/dap/scopes.py          |  8 ++-
 gdb/python/py-frame.c                     | 26 +++++++++
 gdb/testsuite/gdb.dap/ada-nested.exp      | 91 +++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.dap/ada-nested/prog.adb | 32 +++++++++++
 12 files changed, 311 insertions(+), 72 deletions(-)
---
base-commit: 5fbee060e807fbc317aa265eb7e25d1cf94a4dad
change-id: 20231101-dap-nested-function-28a2595863ad

Best regards,
  

Comments

Tom Tromey Nov. 14, 2023, 3:39 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> DAP doesn't really describe what to do for nested functions.  We
Tom> discussed it internally a little, and I came up with this series.  The
Tom> idea here is that variables from the outer scope ought to be visible,
Tom> so this series lets Python code follow a frame's static link, and then
Tom> changes the DAP frame decorators to use this ability.

I'm going to check this in.

I'm also going to backport it to gdb-14, since it is a change for DAP;
and the generic changes should be pretty harmless.

Tom> At some point I think we'll need a "frame decorator v2", like we added
Tom> for pretty-printers.  But, I've been putting this off a little and
Tom> still haven't done it here.

I think this is a bit trickier than it first appears, because frame
filters not only generate objects that conform to the decorator API --
they also use them.

So I'm not sure what to do, if the need really arises.  Maybe we need to
break the API a little.

Tom
  
Tom Tromey Nov. 14, 2023, 4:11 p.m. UTC | #2
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> I'm also going to backport it to gdb-14, since it is a change for DAP;
Tom> and the generic changes should be pretty harmless.

I regression tested the backport on x86-64 Fedora 38.

Tom