Handle DAP evaluate request without a frame ID

DAP specifies that if an evaluate request does not have a frameID
parameter, then the expression is evaluated in the global scope.
This commit is contained in:
Tom Tromey
2023-04-28 09:14:09 -06:00
parent 125862f0f2
commit ef7a143133
3 changed files with 89 additions and 1 deletions

View File

@ -30,10 +30,12 @@ class EvaluateResult(VariableReference):
# Helper function to evaluate an expression in a certain frame.
@in_gdb_thread
def _evaluate(expr, frame_id):
global_context = True
if frame_id is not None:
frame = frame_for_id(frame_id)
frame.select()
val = gdb.parse_and_eval(expr)
global_context = False
val = gdb.parse_and_eval(expr, global_context=global_context)
ref = EvaluateResult(val)
return ref.to_object()