This is an archive of the discontinued LLVM Phabricator instance.

[lldb-vscode] fix breakpoint result ordering
ClosedPublic

Authored by wallace on Mar 26 2020, 3:46 PM.

Details

Summary

The DAP specifies the following for the SetBreakpoints request:

The breakpoints returned are in the same order as the elements of the 'breakpoints' arguments

This was not followed, as lldb-vscode was returning the breakpoints in a different order, because they were first stored into a map, and then traversed. Of course, maps normally don't preserve ordering.

See this log I captured:

-->
{"command":"setBreakpoints",
 "arguments":{
   "source":{
     "name":"main.cpp",
     "path":"/Users/wallace/fbsource/xplat/sand/test-projects/buck-cpp/main.cpp"
   },
   "lines":[6,10,11],
   "breakpoints":[{"line":6},{"line":10},{"line":11}],
   "sourceModified":false
 },
 "type":"request",
 "seq":3 
}

<-- 
{"body":{
   "breakpoints":[
     {"id":1, "line":11,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true},
     {"id":2,"line":6,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true},
     {"id":3,"line":10,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true}]},
   "command":"setBreakpoints",
   "request_seq":3,
   "seq":0,
   "success":true,
   "type":"response"
}

As you can see, the order was not respected. This was causing the IDE not to be able to disable/enable breakpoints by clicking on them in the breakpoint view in the lower corner of the Debug tab.

This diff fixes the ordering problem. The traversal + querying was done very fast in O(nlogn) time. I'm keeping the same complexity.

I also updated a couple of tests to account for the ordering.

For example, after setting and unsetting breakpoints, some ended up being duplicated and the IDE stopped working properly

Diff Detail

Event Timeline

wallace created this revision.Mar 26 2020, 3:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2020, 3:46 PM
wallace edited the summary of this revision. (Show Details)Mar 26 2020, 3:50 PM
clayborg accepted this revision.Mar 26 2020, 5:19 PM

LGTM as long as all test are passing!

This revision is now accepted and ready to land.Mar 26 2020, 5:19 PM
This revision was automatically updated to reflect the committed changes.