@@ -812,7 +812,7 @@ func TestPreSetBreakpoint(t *testing.T) {
812812// wantFrames - number of frames returned (length of StackTraceResponse.Body.StackFrames array).
813813// wantTotalFrames - total number of stack frames available (StackTraceResponse.Body.TotalFrames).
814814func checkStackFramesExact (t * testing.T , got * dap.StackTraceResponse ,
815- wantStartName string , wantStartLine , wantStartID , wantFrames , wantTotalFrames int ) {
815+ wantStartName string , wantStartLine interface {} , wantStartID , wantFrames , wantTotalFrames int ) {
816816 t .Helper ()
817817 checkStackFramesNamed ("" , t , got , wantStartName , wantStartLine , wantStartID , wantFrames , wantTotalFrames , true )
818818}
@@ -930,7 +930,7 @@ func checkStackFramesHasMore(t *testing.T, got *dap.StackTraceResponse,
930930 checkStackFramesNamed ("" , t , got , wantStartName , wantStartLine , wantStartID , wantFrames , wantTotalFrames , false )
931931}
932932func checkStackFramesNamed (testName string , t * testing.T , got * dap.StackTraceResponse ,
933- wantStartName string , wantStartLine , wantStartID , wantFrames , wantTotalFrames int , totalExact bool ) {
933+ wantStartName string , wantStartLine interface {} , wantStartID , wantFrames , wantTotalFrames int , totalExact bool ) {
934934 t .Helper ()
935935 if totalExact && got .Body .TotalFrames != wantTotalFrames {
936936 t .Errorf ("%s\n got %#v\n want TotalFrames=%d" , testName , got .Body .TotalFrames , wantTotalFrames )
@@ -949,9 +949,26 @@ func checkStackFramesNamed(testName string, t *testing.T, got *dap.StackTraceRes
949949 }
950950 // Verify the name and line corresponding to the first returned frame (if any).
951951 // This is useful when the first frame is the frame corresponding to the breakpoint at
952- // a predefined line. Line values < 0 are a signal to skip the check (which can be useful
953- // for frames in the third-party code, where we do not control the lines).
954- if wantFrames > 0 && wantStartLine > 0 && got .Body .StackFrames [0 ].Line != wantStartLine {
952+ // a predefined line.
953+
954+ startLineOk := true
955+
956+ switch wantStartLine := wantStartLine .(type ) {
957+ case int :
958+ if wantStartLine > 0 {
959+ startLineOk = got .Body .StackFrames [0 ].Line == wantStartLine
960+ }
961+ case []int :
962+ startLineOk = false
963+ for _ , ln := range wantStartLine {
964+ if got .Body .StackFrames [0 ].Line == ln {
965+ startLineOk = true
966+ break
967+ }
968+ }
969+ }
970+
971+ if wantFrames > 0 && ! startLineOk {
955972 t .Errorf ("%s\n got Line=%d\n want %d" , testName , got .Body .StackFrames [0 ].Line , wantStartLine )
956973 }
957974 if wantFrames > 0 && wantStartName != "" && got .Body .StackFrames [0 ].Name != wantStartName {
@@ -1454,15 +1471,7 @@ func TestScopesAndVariablesRequests(t *testing.T) {
14541471 client .StackTraceRequest (1 , 0 , 20 )
14551472 stack := client .ExpectStackTraceResponse (t )
14561473
1457- startLineno := 66
1458- if runtime .GOOS == "windows" && goversion .VersionAfterOrEqual (runtime .Version (), 1 , 15 ) {
1459- // Go1.15 on windows inserts a NOP after the call to
1460- // runtime.Breakpoint and marks it same line as the
1461- // runtime.Breakpoint call, making this flaky, so skip the line check.
1462- startLineno = - 1
1463- }
1464-
1465- checkStackFramesExact (t , stack , "main.foobar" , startLineno , 1000 , 4 , 4 )
1474+ checkStackFramesExact (t , stack , "main.foobar" , []int {65 , 66 }, 1000 , 4 , 4 )
14661475
14671476 client .ScopesRequest (1000 )
14681477 scopes := client .ExpectScopesResponse (t )
@@ -2338,10 +2347,12 @@ func TestVariablesLoading(t *testing.T) {
23382347 // variables in any frame, not just topmost.
23392348 loadvars (1000 /*first topmost frame*/ )
23402349 // step into another function
2341- client .StepInRequest (1 )
2342- client .ExpectStepInResponse (t )
2350+ client .SetFunctionBreakpointsRequest ([]dap.FunctionBreakpoint {{Name : "main.barfoo" }})
2351+ client .ExpectSetFunctionBreakpointsResponse (t )
2352+ client .ContinueRequest (1 )
2353+ client .ExpectContinueResponse (t )
23432354 client .ExpectStoppedEvent (t )
2344- checkStop (t , client , 1 , "main.barfoo" , 24 )
2355+ checkStop (t , client , 1 , "main.barfoo" , - 1 )
23452356 loadvars (1001 /*second frame here is same as topmost above*/ )
23462357 },
23472358 disconnect : true ,
@@ -3902,7 +3913,7 @@ func TestEvaluateRequest(t *testing.T) {
39023913 fixture .Source , []int {}, // Breakpoint set in the program
39033914 []onBreakpoint {{ // Stop at first breakpoint
39043915 execute : func () {
3905- checkStop (t , client , 1 , "main.foobar" , 66 )
3916+ checkStop (t , client , 1 , "main.foobar" , [] int { 65 , 66 } )
39063917
39073918 // Variable lookup
39083919 client .EvaluateRequest ("a2" , 1000 , "this context will be ignored" )
@@ -4073,7 +4084,7 @@ func TestEvaluateCommandRequest(t *testing.T) {
40734084 fixture .Source , []int {}, // Breakpoint set in the program
40744085 []onBreakpoint {{ // Stop at first breakpoint
40754086 execute : func () {
4076- checkStop (t , client , 1 , "main.foobar" , 66 )
4087+ checkStop (t , client , 1 , "main.foobar" , [] int { 65 , 66 } )
40774088
40784089 // Request help.
40794090 const dlvHelp = `The following commands are available:
@@ -5164,7 +5175,7 @@ func TestFatalThrowBreakpoint(t *testing.T) {
51645175// The details have been tested by other tests,
51655176// so this is just a sanity check.
51665177// Skips line check if line is -1.
5167- func checkStop (t * testing.T , client * daptest.Client , thread int , fname string , line int ) {
5178+ func checkStop (t * testing.T , client * daptest.Client , thread int , fname string , line interface {} ) {
51685179 t .Helper ()
51695180 client .ThreadsRequest ()
51705181 client .ExpectThreadsResponse (t )
@@ -5983,15 +5994,7 @@ func TestSetVariable(t *testing.T) {
59835994 execute : func () {
59845995 tester := & helperForSetVariable {t , client }
59855996
5986- startLineno := 66 // after runtime.Breakpoint
5987- if runtime .GOOS == "windows" && goversion .VersionAfterOrEqual (runtime .Version (), 1 , 15 ) {
5988- // Go1.15 on windows inserts a NOP after the call to
5989- // runtime.Breakpoint and marks it same line as the
5990- // runtime.Breakpoint call, making this flaky, so skip the line check.
5991- startLineno = - 1
5992- }
5993-
5994- checkStop (t , client , 1 , "main.foobar" , startLineno )
5997+ checkStop (t , client , 1 , "main.foobar" , []int {65 , 66 })
59955998
59965999 // Local variables
59976000 locals := tester .variables (localsScope )
@@ -6160,20 +6163,12 @@ func TestSetVariableWithCall(t *testing.T) {
61606163 "mode" : "exec" , "program" : fixture .Path , "showGlobalVariables" : true ,
61616164 })
61626165 },
6163- fixture .Source , []int {66 , 67 },
6166+ fixture .Source , []int {},
61646167 []onBreakpoint {{
61656168 execute : func () {
61666169 tester := & helperForSetVariable {t , client }
61676170
6168- startLineno := 66
6169- if runtime .GOOS == "windows" && goversion .VersionAfterOrEqual (runtime .Version (), 1 , 15 ) {
6170- // Go1.15 on windows inserts a NOP after the call to
6171- // runtime.Breakpoint and marks it same line as the
6172- // runtime.Breakpoint call, making this flaky, so skip the line check.
6173- startLineno = - 1
6174- }
6175-
6176- checkStop (t , client , 1 , "main.foobar" , startLineno )
6171+ checkStop (t , client , 1 , "main.foobar" , []int {65 , 66 })
61776172
61786173 // Local variables
61796174 locals := tester .variables (localsScope )
@@ -6196,16 +6191,16 @@ func TestSetVariableWithCall(t *testing.T) {
61966191
61976192 tester .expectSetVariable (a6Ref , "Bur" , `"sentence"` )
61986193 tester .evaluate ("a6" , `main.FooBar {Baz: 8, Bur: "sentence"}` , hasChildren )
6199- },
6200- }, {
6201- // Stop at second breakpoint and set a1.
6202- execute : func () {
6203- tester := & helperForSetVariable {t , client }
62046194
6195+ // stop inside main.barfoo
6196+ client .ContinueRequest (1 )
6197+ client .ExpectContinueResponse (t )
6198+ client .ExpectStoppedEvent (t )
62056199 checkStop (t , client , 1 , "main.barfoo" , - 1 )
6200+
62066201 // Test: set string 'a1' in main.barfoo.
62076202 // This shouldn't affect 'a1' in main.foobar - we will check that in the next breakpoint.
6208- locals : = tester .variables (localsScope )
6203+ locals = tester .variables (localsScope )
62096204 checkVarExact (t , locals , - 1 , "a1" , "a1" , `"bur"` , "string" , noChildren )
62106205 tester .expectSetVariable (localsScope , "a1" , `"fur"` )
62116206 tester .evaluate ("a1" , `"fur"` , noChildren )
0 commit comments