Update DAP protocol to 1.41.0

Update the script to include the DAP version in the file headers.

Remove http file caching. Was never used.
diff --git a/include/dap/protocol.h b/include/dap/protocol.h
index 0fef586..7364bad 100644
--- a/include/dap/protocol.h
+++ b/include/dap/protocol.h
@@ -14,6 +14,8 @@
 
 // Generated with protocol_gen.go -- do not edit this file.
 //   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version 1.41.0
 
 #ifndef dap_protocol_h
 #define dap_protocol_h
@@ -125,8 +127,8 @@
 
 DAP_DECLARE_STRUCT_TYPEINFO(Source);
 
-// Information about a Breakpoint created in setBreakpoints or
-// setFunctionBreakpoints.
+// Information about a Breakpoint created in setBreakpoints,
+// setFunctionBreakpoints, setInstructionBreakpoints, or setDataBreakpoints.
 struct Breakpoint {
   Breakpoint();
   ~Breakpoint();
@@ -142,12 +144,17 @@
   // An optional identifier for the breakpoint. It is needed if breakpoint
   // events are used to update or remove breakpoints.
   optional<integer> id;
+  // An optional memory reference to where the breakpoint is set.
+  optional<string> instructionReference;
   // The start line of the actual range covered by the breakpoint.
   optional<integer> line;
   // An optional message about the state of the breakpoint.
   // This is shown to the user and can be used to explain why a breakpoint could
   // not be verified.
   optional<string> message;
+  // An optional offset from the instruction reference.
+  // This can be negative.
+  optional<integer> offset;
   // The source where the breakpoint is located.
   optional<Source> source;
   // If true breakpoint could be set (but not necessarily at the desired
@@ -374,6 +381,9 @@
   // The debug adapter supports breakpoints that break execution after a
   // specified number of hits.
   optional<boolean> supportsHitConditionalBreakpoints;
+  // The debug adapter supports adding breakpoints based on instruction
+  // references.
+  optional<boolean> supportsInstructionBreakpoints;
   // The debug adapter supports the 'loadedSources' request.
   optional<boolean> supportsLoadedSourcesRequest;
   // The debug adapter supports logpoints by interpreting the 'logMessage'
@@ -398,6 +408,9 @@
   optional<boolean> supportsStepBack;
   // The debug adapter supports the 'stepInTargets' request.
   optional<boolean> supportsStepInTargetsRequest;
+  // The debug adapter supports stepping granularities (argument 'granularity')
+  // for the stepping requests.
+  optional<boolean> supportsSteppingGranularity;
   // The debug adapter supports the 'terminate' request.
   optional<boolean> supportsTerminateRequest;
   // The debug adapter supports the 'terminateThreads' request.
@@ -1094,6 +1107,9 @@
   // The debug adapter supports breakpoints that break execution after a
   // specified number of hits.
   optional<boolean> supportsHitConditionalBreakpoints;
+  // The debug adapter supports adding breakpoints based on instruction
+  // references.
+  optional<boolean> supportsInstructionBreakpoints;
   // The debug adapter supports the 'loadedSources' request.
   optional<boolean> supportsLoadedSourcesRequest;
   // The debug adapter supports logpoints by interpreting the 'logMessage'
@@ -1118,6 +1134,9 @@
   optional<boolean> supportsStepBack;
   // The debug adapter supports the 'stepInTargets' request.
   optional<boolean> supportsStepInTargetsRequest;
+  // The debug adapter supports stepping granularities (argument 'granularity')
+  // for the stepping requests.
+  optional<boolean> supportsSteppingGranularity;
   // The debug adapter supports the 'terminate' request.
   optional<boolean> supportsTerminateRequest;
   // The debug adapter supports the 'terminateThreads' request.
@@ -1376,6 +1395,15 @@
 
 DAP_DECLARE_STRUCT_TYPEINFO(NextResponse);
 
+// The granularity of one 'step' in the stepping requests 'next', 'stepIn',
+// 'stepOut', and 'stepBack'.
+struct SteppingGranularity {
+  SteppingGranularity();
+  ~SteppingGranularity();
+};
+
+DAP_DECLARE_STRUCT_TYPEINFO(SteppingGranularity);
+
 // The request starts the debuggee to run again for one step.
 // The debug adapter first sends the response and then a 'stopped' event (with
 // reason 'step') after the step has completed.
@@ -1385,6 +1413,9 @@
   NextRequest();
   ~NextRequest();
 
+  // Optional granularity to step. If no granularity is specified, a granularity
+  // of 'statement' is assumed.
+  optional<SteppingGranularity> granularity;
   // Execute 'next' for this thread.
   integer threadId;
 };
@@ -2063,6 +2094,61 @@
 
 DAP_DECLARE_STRUCT_TYPEINFO(SetFunctionBreakpointsRequest);
 
+// Response to 'setInstructionBreakpoints' request
+struct SetInstructionBreakpointsResponse : public Response {
+  SetInstructionBreakpointsResponse();
+  ~SetInstructionBreakpointsResponse();
+
+  // Information about the breakpoints. The array elements correspond to the
+  // elements of the 'breakpoints' array.
+  array<Breakpoint> breakpoints;
+};
+
+DAP_DECLARE_STRUCT_TYPEINFO(SetInstructionBreakpointsResponse);
+
+// Properties of a breakpoint passed to the setInstructionBreakpoints request
+struct InstructionBreakpoint {
+  InstructionBreakpoint();
+  ~InstructionBreakpoint();
+
+  // An optional expression for conditional breakpoints.
+  // It is only honored by a debug adapter if the capability
+  // 'supportsConditionalBreakpoints' is true.
+  optional<string> condition;
+  // An optional expression that controls how many hits of the breakpoint are
+  // ignored. The backend is expected to interpret the expression as needed. The
+  // attribute is only honored by a debug adapter if the capability
+  // 'supportsHitConditionalBreakpoints' is true.
+  optional<string> hitCondition;
+  // The instruction reference of the breakpoint.
+  // This should be a memory or instruction pointer reference from an
+  // EvaluateResponse, Variable, StackFrame, GotoTarget, or Breakpoint.
+  string instructionReference;
+  // An optional offset from the instruction reference.
+  // This can be negative.
+  optional<integer> offset;
+};
+
+DAP_DECLARE_STRUCT_TYPEINFO(InstructionBreakpoint);
+
+// Replaces all existing instruction breakpoints. Typically, instruction
+// breakpoints would be set from a diassembly window. To clear all instruction
+// breakpoints, specify an empty array. When an instruction breakpoint is hit, a
+// 'stopped' event (with reason 'instruction breakpoint') is generated. Clients
+// should only call this request if the capability
+// 'supportsInstructionBreakpoints' is true.
+struct SetInstructionBreakpointsRequest : public Request {
+  using Response = SetInstructionBreakpointsResponse;
+
+  SetInstructionBreakpointsRequest();
+  ~SetInstructionBreakpointsRequest();
+
+  // The instruction references of the breakpoints
+  array<InstructionBreakpoint> breakpoints;
+};
+
+DAP_DECLARE_STRUCT_TYPEINFO(SetInstructionBreakpointsRequest);
+
 // Response to 'setVariable' request.
 struct SetVariableResponse : public Response {
   SetVariableResponse();
@@ -2263,6 +2349,9 @@
   StepBackRequest();
   ~StepBackRequest();
 
+  // Optional granularity to step. If no granularity is specified, a granularity
+  // of 'statement' is assumed.
+  optional<SteppingGranularity> granularity;
   // Execute 'stepBack' for this thread.
   integer threadId;
 };
@@ -2292,6 +2381,9 @@
   StepInRequest();
   ~StepInRequest();
 
+  // Optional granularity to step. If no granularity is specified, a granularity
+  // of 'statement' is assumed.
+  optional<SteppingGranularity> granularity;
   // Optional id of the target to step into.
   optional<integer> targetId;
   // Execute 'stepIn' for this thread.
@@ -2360,6 +2452,9 @@
   StepOutRequest();
   ~StepOutRequest();
 
+  // Optional granularity to step. If no granularity is specified, a granularity
+  // of 'statement' is assumed.
+  optional<SteppingGranularity> granularity;
   // Execute 'stepOut' for this thread.
   integer threadId;
 };
@@ -2368,7 +2463,7 @@
 
 // The event indicates that the execution of the debuggee has stopped due to
 // some condition. This can be caused by a break point previously set, a
-// stepping action has completed, by executing a debugger statement etc.
+// stepping request has completed, by executing a debugger statement etc.
 struct StoppedEvent : public Event {
   StoppedEvent();
   ~StoppedEvent();
@@ -2392,7 +2487,7 @@
   //
   // May be one of the following enumeration values:
   // 'step', 'breakpoint', 'exception', 'pause', 'entry', 'goto', 'function
-  // breakpoint', 'data breakpoint'
+  // breakpoint', 'data breakpoint', 'instruction breakpoint'
   string reason;
   // Additional information. E.g. if reason is 'exception', text contains the
   // exception name. This string is shown in the UI.
diff --git a/src/protocol_events.cpp b/src/protocol_events.cpp
index 35b4ac1..d5dc01b 100644
--- a/src/protocol_events.cpp
+++ b/src/protocol_events.cpp
@@ -14,6 +14,8 @@
 
 // Generated with protocol_gen.go -- do not edit this file.
 //   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version 1.41.0
 
 #include "dap/protocol.h"
 
diff --git a/src/protocol_requests.cpp b/src/protocol_requests.cpp
index 6906739..7ae4cd8 100644
--- a/src/protocol_requests.cpp
+++ b/src/protocol_requests.cpp
@@ -14,6 +14,8 @@
 
 // Generated with protocol_gen.go -- do not edit this file.
 //   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version 1.41.0
 
 #include "dap/protocol.h"
 
@@ -157,6 +159,7 @@
 NextRequest::~NextRequest() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(NextRequest,
                               "next",
+                              DAP_FIELD(granularity, "granularity"),
                               DAP_FIELD(threadId, "threadId"));
 
 PauseRequest::PauseRequest() = default;
@@ -242,6 +245,12 @@
                               "setFunctionBreakpoints",
                               DAP_FIELD(breakpoints, "breakpoints"));
 
+SetInstructionBreakpointsRequest::SetInstructionBreakpointsRequest() = default;
+SetInstructionBreakpointsRequest::~SetInstructionBreakpointsRequest() = default;
+DAP_IMPLEMENT_STRUCT_TYPEINFO(SetInstructionBreakpointsRequest,
+                              "setInstructionBreakpoints",
+                              DAP_FIELD(breakpoints, "breakpoints"));
+
 SetVariableRequest::SetVariableRequest() = default;
 SetVariableRequest::~SetVariableRequest() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableRequest,
@@ -272,12 +281,14 @@
 StepBackRequest::~StepBackRequest() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(StepBackRequest,
                               "stepBack",
+                              DAP_FIELD(granularity, "granularity"),
                               DAP_FIELD(threadId, "threadId"));
 
 StepInRequest::StepInRequest() = default;
 StepInRequest::~StepInRequest() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(StepInRequest,
                               "stepIn",
+                              DAP_FIELD(granularity, "granularity"),
                               DAP_FIELD(targetId, "targetId"),
                               DAP_FIELD(threadId, "threadId"));
 
@@ -291,6 +302,7 @@
 StepOutRequest::~StepOutRequest() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(StepOutRequest,
                               "stepOut",
+                              DAP_FIELD(granularity, "granularity"),
                               DAP_FIELD(threadId, "threadId"));
 
 TerminateRequest::TerminateRequest() = default;
diff --git a/src/protocol_response.cpp b/src/protocol_response.cpp
index a832fcc..ccf04cc 100644
--- a/src/protocol_response.cpp
+++ b/src/protocol_response.cpp
@@ -14,6 +14,8 @@
 
 // Generated with protocol_gen.go -- do not edit this file.
 //   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version 1.41.0
 
 #include "dap/protocol.h"
 
@@ -134,6 +136,7 @@
     DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"),
     DAP_FIELD(supportsHitConditionalBreakpoints,
               "supportsHitConditionalBreakpoints"),
+    DAP_FIELD(supportsInstructionBreakpoints, "supportsInstructionBreakpoints"),
     DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"),
     DAP_FIELD(supportsLogPoints, "supportsLogPoints"),
     DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"),
@@ -144,6 +147,7 @@
     DAP_FIELD(supportsSetVariable, "supportsSetVariable"),
     DAP_FIELD(supportsStepBack, "supportsStepBack"),
     DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"),
+    DAP_FIELD(supportsSteppingGranularity, "supportsSteppingGranularity"),
     DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"),
     DAP_FIELD(supportsTerminateThreadsRequest,
               "supportsTerminateThreadsRequest"),
@@ -240,6 +244,14 @@
                               "",
                               DAP_FIELD(breakpoints, "breakpoints"));
 
+SetInstructionBreakpointsResponse::SetInstructionBreakpointsResponse() =
+    default;
+SetInstructionBreakpointsResponse::~SetInstructionBreakpointsResponse() =
+    default;
+DAP_IMPLEMENT_STRUCT_TYPEINFO(SetInstructionBreakpointsResponse,
+                              "",
+                              DAP_FIELD(breakpoints, "breakpoints"));
+
 SetVariableResponse::SetVariableResponse() = default;
 SetVariableResponse::~SetVariableResponse() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableResponse,
diff --git a/src/protocol_types.cpp b/src/protocol_types.cpp
index 58eca28..7d30567 100644
--- a/src/protocol_types.cpp
+++ b/src/protocol_types.cpp
@@ -14,6 +14,8 @@
 
 // Generated with protocol_gen.go -- do not edit this file.
 //   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version 1.41.0
 
 #include "dap/protocol.h"
 
@@ -51,8 +53,11 @@
                               DAP_FIELD(endColumn, "endColumn"),
                               DAP_FIELD(endLine, "endLine"),
                               DAP_FIELD(id, "id"),
+                              DAP_FIELD(instructionReference,
+                                        "instructionReference"),
                               DAP_FIELD(line, "line"),
                               DAP_FIELD(message, "message"),
+                              DAP_FIELD(offset, "offset"),
                               DAP_FIELD(source, "source"),
                               DAP_FIELD(verified, "verified"));
 
@@ -112,6 +117,7 @@
     DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"),
     DAP_FIELD(supportsHitConditionalBreakpoints,
               "supportsHitConditionalBreakpoints"),
+    DAP_FIELD(supportsInstructionBreakpoints, "supportsInstructionBreakpoints"),
     DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"),
     DAP_FIELD(supportsLogPoints, "supportsLogPoints"),
     DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"),
@@ -122,6 +128,7 @@
     DAP_FIELD(supportsSetVariable, "supportsSetVariable"),
     DAP_FIELD(supportsStepBack, "supportsStepBack"),
     DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"),
+    DAP_FIELD(supportsSteppingGranularity, "supportsSteppingGranularity"),
     DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"),
     DAP_FIELD(supportsTerminateThreadsRequest,
               "supportsTerminateThreadsRequest"),
@@ -230,6 +237,10 @@
                               DAP_FIELD(symbolStatus, "symbolStatus"),
                               DAP_FIELD(version, "version"));
 
+SteppingGranularity::SteppingGranularity() = default;
+SteppingGranularity::~SteppingGranularity() = default;
+DAP_IMPLEMENT_STRUCT_TYPEINFO(SteppingGranularity, "");
+
 Scope::Scope() = default;
 Scope::~Scope() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(Scope,
@@ -288,6 +299,16 @@
                               DAP_FIELD(hitCondition, "hitCondition"),
                               DAP_FIELD(name, "name"));
 
+InstructionBreakpoint::InstructionBreakpoint() = default;
+InstructionBreakpoint::~InstructionBreakpoint() = default;
+DAP_IMPLEMENT_STRUCT_TYPEINFO(InstructionBreakpoint,
+                              "",
+                              DAP_FIELD(condition, "condition"),
+                              DAP_FIELD(hitCondition, "hitCondition"),
+                              DAP_FIELD(instructionReference,
+                                        "instructionReference"),
+                              DAP_FIELD(offset, "offset"));
+
 StackFrame::StackFrame() = default;
 StackFrame::~StackFrame() = default;
 DAP_IMPLEMENT_STRUCT_TYPEINFO(StackFrame,
diff --git a/tools/protocol_gen/protocol_gen.go b/tools/protocol_gen/protocol_gen.go
index d036418..781c053 100644
--- a/tools/protocol_gen/protocol_gen.go
+++ b/tools/protocol_gen/protocol_gen.go
@@ -33,29 +33,29 @@
 	"strings"
 )
 
-var (
-	cache = flag.String("cache", "", "File cache of the .json schema")
-)
-
 const (
-	jsonURL = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/debugProtocol.json"
+	protocolURL = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/debugProtocol.json"
+	packageURL  = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/protocol/package.json"
 
+	versionTag     = "${version}"
 	commonPrologue = `// Copyright 2019 Google LLC
-	//
-	// Licensed under the Apache License, Version 2.0 (the "License");
-	// you may not use this file except in compliance with the License.
-	// You may obtain a copy of the License at
-	//
-	//     https://www.apache.org/licenses/LICENSE-2.0
-	//
-	// Unless required by applicable law or agreed to in writing, software
-	// distributed under the License is distributed on an "AS IS" BASIS,
-	// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	// See the License for the specific language governing permissions and
-	// limitations under the License.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
-	// Generated with protocol_gen.go -- do not edit this file.
-	//   go run scripts/protocol_gen/protocol_gen.go
+// Generated with protocol_gen.go -- do not edit this file.
+//   go run scripts/protocol_gen/protocol_gen.go
+//
+// DAP version ${version}
 `
 
 	headerPrologue = commonPrologue + `
@@ -527,18 +527,20 @@
 type cppFiles map[structType]*os.File
 
 func run() error {
-	data, err := loadJSONFile()
-	if err != nil {
+	pkg := struct {
+		Version string `json:"version"`
+	}{}
+	if err := loadJSONFile(packageURL, &pkg); err != nil {
 		return err
 	}
-	r := root{}
-	d := json.NewDecoder(bytes.NewReader(data))
-	if err := d.Decode(&r); err != nil {
+
+	protocol := root{}
+	if err := loadJSONFile(protocolURL, &protocol); err != nil {
 		return err
 	}
 
 	hPath, cppPaths := outputPaths()
-	if err := emitFiles(&r, hPath, cppPaths); err != nil {
+	if err := emitFiles(&protocol, hPath, cppPaths, pkg.Version); err != nil {
 		return err
 	}
 
@@ -551,12 +553,14 @@
 				return err
 			}
 		}
+	} else {
+		fmt.Printf("clang-format not found on PATH. Please format before committing.")
 	}
 
 	return nil
 }
 
-func emitFiles(r *root, hPath string, cppPaths map[structType]string) error {
+func emitFiles(r *root, hPath string, cppPaths map[structType]string, version string) error {
 	h, err := os.Create(hPath)
 	if err != nil {
 		return err
@@ -572,9 +576,9 @@
 		defer f.Close()
 	}
 
-	h.WriteString(headerPrologue)
+	h.WriteString(strings.ReplaceAll(headerPrologue, versionTag, version))
 	for _, f := range cppFiles {
-		f.WriteString(cppPrologue)
+		f.WriteString(strings.ReplaceAll(cppPrologue, versionTag, version))
 	}
 
 	structs, err := buildStructs(r)
@@ -618,25 +622,19 @@
 	return nil
 }
 
-func loadJSONFile() ([]byte, error) {
-	if *cache != "" {
-		data, err := ioutil.ReadFile(*cache)
-		if err == nil {
-			return data, nil
-		}
-	}
-	resp, err := http.Get(jsonURL)
+func loadJSONFile(url string, obj interface{}) error {
+	resp, err := http.Get(url)
 	if err != nil {
-		return nil, err
+		return err
 	}
 	data, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
-		return nil, err
+		return err
 	}
-	if *cache != "" {
-		ioutil.WriteFile(*cache, data, 0777)
+	if err := json.NewDecoder(bytes.NewReader(data)).Decode(obj); err != nil {
+		return err
 	}
-	return data, nil
+	return nil
 }
 
 func outputPaths() (string, cppFilePaths) {