@@ -341,9 +341,9 @@ def do_test_scopes_variables_setVariable_evaluate(
341
341
342
342
verify_locals ["argc" ]["equals" ]["value" ] = "123"
343
343
verify_locals ["pt" ]["children" ]["x" ]["equals" ]["value" ] = "111"
344
- verify_locals ["x @ main.cpp:17 " ] = {"equals" : {"type" : "int" , "value" : "89" }}
345
- verify_locals ["x @ main.cpp:19 " ] = {"equals" : {"type" : "int" , "value" : "42" }}
346
- verify_locals ["x @ main.cpp:21 " ] = {"equals" : {"type" : "int" , "value" : "72" }}
344
+ verify_locals ["x @ main.cpp:19 " ] = {"equals" : {"type" : "int" , "value" : "89" }}
345
+ verify_locals ["x @ main.cpp:21 " ] = {"equals" : {"type" : "int" , "value" : "42" }}
346
+ verify_locals ["x @ main.cpp:23 " ] = {"equals" : {"type" : "int" , "value" : "72" }}
347
347
348
348
self .verify_variables (verify_locals , self .dap_server .get_local_variables ())
349
349
@@ -353,32 +353,32 @@ def do_test_scopes_variables_setVariable_evaluate(
353
353
self .dap_server .request_setVariable (1 , "x @ main.cpp:0" , 9 )["success" ]
354
354
)
355
355
356
- self .assertTrue (
357
- self .dap_server .request_setVariable (1 , "x @ main.cpp:17" , 17 )["success" ]
358
- )
359
356
self .assertTrue (
360
357
self .dap_server .request_setVariable (1 , "x @ main.cpp:19" , 19 )["success" ]
361
358
)
362
359
self .assertTrue (
363
360
self .dap_server .request_setVariable (1 , "x @ main.cpp:21" , 21 )["success" ]
364
361
)
362
+ self .assertTrue (
363
+ self .dap_server .request_setVariable (1 , "x @ main.cpp:23" , 23 )["success" ]
364
+ )
365
365
366
366
# The following should have no effect
367
367
self .assertFalse (
368
- self .dap_server .request_setVariable (1 , "x @ main.cpp:21 " , "invalid" )[
368
+ self .dap_server .request_setVariable (1 , "x @ main.cpp:23 " , "invalid" )[
369
369
"success"
370
370
]
371
371
)
372
372
373
- verify_locals ["x @ main.cpp:17" ]["equals" ]["value" ] = "17"
374
373
verify_locals ["x @ main.cpp:19" ]["equals" ]["value" ] = "19"
375
374
verify_locals ["x @ main.cpp:21" ]["equals" ]["value" ] = "21"
375
+ verify_locals ["x @ main.cpp:23" ]["equals" ]["value" ] = "23"
376
376
377
377
self .verify_variables (verify_locals , self .dap_server .get_local_variables ())
378
378
379
379
# The plain x variable shold refer to the innermost x
380
380
self .assertTrue (self .dap_server .request_setVariable (1 , "x" , 22 )["success" ])
381
- verify_locals ["x @ main.cpp:21 " ]["equals" ]["value" ] = "22"
381
+ verify_locals ["x @ main.cpp:23 " ]["equals" ]["value" ] = "22"
382
382
383
383
self .verify_variables (verify_locals , self .dap_server .get_local_variables ())
384
384
@@ -394,10 +394,10 @@ def do_test_scopes_variables_setVariable_evaluate(
394
394
locals = self .dap_server .get_local_variables ()
395
395
names = [var ["name" ] for var in locals ]
396
396
# The first shadowed x shouldn't have a suffix anymore
397
- verify_locals ["x" ] = {"equals" : {"type" : "int" , "value" : "17" }}
398
- self .assertNotIn ("x @ main.cpp:17" , names )
397
+ verify_locals ["x" ] = {"equals" : {"type" : "int" , "value" : "19" }}
399
398
self .assertNotIn ("x @ main.cpp:19" , names )
400
399
self .assertNotIn ("x @ main.cpp:21" , names )
400
+ self .assertNotIn ("x @ main.cpp:23" , names )
401
401
402
402
self .verify_variables (verify_locals , locals )
403
403
@@ -663,6 +663,54 @@ def do_test_indexedVariables(self, enableSyntheticChildDebugging: bool):
663
663
]["variables" ]
664
664
self .verify_variables (verify_children , children )
665
665
666
+ def test_return_variables (self ):
667
+ """
668
+ Test the stepping out of a function with return value show the variable correctly.
669
+ """
670
+ program = self .getBuildArtifact ("a.out" )
671
+ self .build_and_launch (program )
672
+
673
+ return_name = "(Return Value)"
674
+ verify_locals = {
675
+ return_name : {"equals" : {"type" : "int" , "value" : "300" }},
676
+ "argc" : {},
677
+ "argv" : {},
678
+ "pt" : {},
679
+ "x" : {},
680
+ "return_result" : {"equals" : {"type" : "int" }},
681
+ }
682
+
683
+ function_name = "test_return_variable"
684
+ breakpoint_ids = self .set_function_breakpoints ([function_name ])
685
+
686
+ self .assertEqual (len (breakpoint_ids ), 1 )
687
+ self .continue_to_breakpoints (breakpoint_ids )
688
+
689
+ threads = self .dap_server .get_threads ()
690
+ for thread in threads :
691
+ if thread .get ("reason" ) == "breakpoint" :
692
+ thread_id = thread ["id" ]
693
+
694
+ self .stepOut (threadId = thread_id )
695
+
696
+ local_variables = self .dap_server .get_local_variables ()
697
+ varref_dict = {}
698
+
699
+ # `verify_variable` function only checks if the local variables
700
+ # are in the `verify_dict` passed this will cause this test to pass
701
+ # even if there is no return value.
702
+ local_variable_names = [
703
+ variable ["name" ] for variable in local_variables
704
+ ]
705
+ self .assertIn (
706
+ return_name ,
707
+ local_variable_names ,
708
+ "return variable is not in local variables" ,
709
+ )
710
+
711
+ self .verify_variables (verify_locals , local_variables , varref_dict )
712
+ break
713
+
666
714
@skipIfWindows
667
715
def test_indexedVariables (self ):
668
716
self .do_test_indexedVariables (enableSyntheticChildDebugging = False )
0 commit comments