diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c2fb85..486aab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ # limitations under the License. cmake_policy(SET CMP0048 NEW) -project(cppdap VERSION 1.58.0 LANGUAGES CXX C) +project(cppdap VERSION 1.59.0 LANGUAGES CXX C) cmake_minimum_required(VERSION 3.13) @@ -198,7 +198,7 @@ function(cppdap_set_target_options target) "$" ) cppdap_set_json_links(${target}) - target_link_libraries(cppdap PRIVATE ${CPPDAP_OS_LIBS}) + target_link_libraries(${target} PRIVATE ${CPPDAP_OS_LIBS}) endfunction(cppdap_set_target_options) ########################################################### @@ -334,7 +334,7 @@ if(CPPDAP_BUILD_EXAMPLES) FOLDER "Examples" ) cppdap_set_target_options(${target}) - target_link_libraries(${target} cppdap "${CPPDAP_OS_LIBS}") + target_link_libraries(${target} PRIVATE cppdap) if(CPPDAP_INSTALL_VSCODE_EXAMPLES) if(CMAKE_SYSTEM_NAME MATCHES "Windows") diff --git a/include/dap/protocol.h b/include/dap/protocol.h index 0962d37..e4c479e 100644 --- a/include/dap/protocol.h +++ b/include/dap/protocol.h @@ -15,7 +15,7 @@ // Generated with protocol_gen.go -- do not edit this file. // go run scripts/protocol_gen/protocol_gen.go // -// DAP version 1.58.0 +// DAP version 1.59.0 #ifndef dap_protocol_h #define dap_protocol_h @@ -593,11 +593,17 @@ DAP_DECLARE_STRUCT_TYPEINFO(DataBreakpointInfoResponse); // corresponding capability `supportsDataBreakpoints` is true. struct DataBreakpointInfoRequest : public Request { using Response = DataBreakpointInfoResponse; + // When `name` is an expression, evaluate it in the scope of this stack frame. + // If not specified, the expression is evaluated in the global scope. When + // `variablesReference` is specified, this property has no effect. + optional frameId; // The name of the variable's child to obtain data breakpoint information for. // If `variablesReference` isn't specified, this can be an expression. string name; // Reference to the variable container if the data breakpoint is requested for - // a child of the container. + // a child of the container. The `variablesReference` must have been obtained + // in the current suspended state. See 'Lifetime of Object References' in the + // Overview section for details. optional variablesReference; }; @@ -709,7 +715,11 @@ struct Message { // If variable name starts with an underscore character, the variable does not // contain user data (PII) and can be safely used for telemetry purposes. string format; - // Unique identifier for the message. + // Unique (within a debug adapter implementation) identifier for the message. + // The purpose of these error IDs is to help extension authors that have the + // requirement that every user visible error message needs a corresponding + // error number, so that users or customer support can find information about + // the specific error more easily. integer id; // If true send to telemetry. optional sendTelemetry; @@ -795,8 +805,8 @@ struct EvaluateResponse : public Response { optional type; // If `variablesReference` is > 0, the evaluate result is structured and its // children can be retrieved by passing `variablesReference` to the - // `variables` request. The value should be less than or equal to 2147483647 - // (2^31-1). + // `variables` request as long as execution remains suspended. See 'Lifetime + // of Object References' in the Overview section for details. integer variablesReference; }; @@ -817,7 +827,7 @@ struct EvaluateRequest : public Request { // The context in which the evaluate request is used. // // May be one of the following enumeration values: - // 'variables', 'watch', 'repl', 'hover', 'clipboard' + // 'watch', 'repl', 'hover', 'clipboard', 'variables' optional context; // The expression to evaluate. string expression; @@ -1390,8 +1400,9 @@ struct OutputEvent : public Event { optional source; // If an attribute `variablesReference` exists and its value is > 0, the // output contains objects which can be retrieved by passing - // `variablesReference` to the `variables` request. The value should be less - // than or equal to 2147483647 (2^31-1). + // `variablesReference` to the `variables` request as long as execution + // remains suspended. See 'Lifetime of Object References' in the Overview + // section for details. optional variablesReference; }; @@ -1507,7 +1518,10 @@ struct ReadMemoryResponse : public Response { // Treated as a hex value if prefixed with `0x`, or as a decimal value // otherwise. string address; - // The bytes read from memory, encoded using base64. + // The bytes read from memory, encoded using base64. If the decoded length of + // `data` is less than the requested `count` in the original `readMemory` + // request, and `unreadableBytes` is zero or omitted, then the client should + // assume it's reached the end of readable memory. optional data; // The number of unreadable bytes encountered after the last successfully read // byte. This can be used to determine the number of bytes that should be @@ -1539,13 +1553,15 @@ struct RestartFrameResponse : public Response {}; DAP_DECLARE_STRUCT_TYPEINFO(RestartFrameResponse); -// The request restarts execution of the specified stackframe. +// The request restarts execution of the specified stack frame. // The debug adapter first sends the response and then a `stopped` event (with // reason `restart`) after the restart has completed. Clients should only call // this request if the corresponding capability `supportsRestartFrame` is true. struct RestartFrameRequest : public Request { using Response = RestartFrameResponse; - // Restart this stackframe. + // Restart the stack frame identified by `frameId`. The `frameId` must have + // been obtained in the current suspended state. See 'Lifetime of Object + // References' in the Overview section for details. integer frameId; }; @@ -1557,33 +1573,6 @@ struct RestartResponse : public Response {}; DAP_DECLARE_STRUCT_TYPEINFO(RestartResponse); -// Arguments for `launch` request. Additional attributes are implementation -// specific. -struct LaunchRequestArguments { - // Arbitrary data from the previous, restarted session. - // The data is sent as the `restart` attribute of the `terminated` event. - // The client should leave the data intact. - optional, boolean, integer, null, number, object, string>> - restart; - // If true, the launch request should launch the program without enabling - // debugging. - optional noDebug; -}; - -DAP_DECLARE_STRUCT_TYPEINFO(LaunchRequestArguments); - -// Arguments for `attach` request. Additional attributes are implementation -// specific. -struct AttachRequestArguments { - // Arbitrary data from the previous, restarted session. - // The data is sent as the `restart` attribute of the `terminated` event. - // The client should leave the data intact. - optional, boolean, integer, null, number, object, string>> - restart; -}; - -DAP_DECLARE_STRUCT_TYPEINFO(AttachRequestArguments); - // Restarts a debug session. Clients should only call this request if the // corresponding capability `supportsRestartRequest` is true. If the capability // is missing or has the value false, a typical client emulates `restart` by @@ -1591,7 +1580,7 @@ DAP_DECLARE_STRUCT_TYPEINFO(AttachRequestArguments); struct RestartRequest : public Request { using Response = RestartResponse; // The latest version of the `launch` or `attach` configuration. - optional> arguments; + optional arguments; }; DAP_DECLARE_STRUCT_TYPEINFO(RestartRequest); @@ -1666,7 +1655,7 @@ struct RunInTerminalRequest : public Request { // Environment key-value pairs that are added to or removed from the default // environment. optional env; - // What kind of terminal to launch. + // What kind of terminal to launch. Defaults to `integrated` if not specified. // // Must be one of the following enumeration values: // 'integrated', 'external' @@ -1715,7 +1704,9 @@ struct Scope { // The source for this scope. optional source; // The variables of this scope can be retrieved by passing the value of - // `variablesReference` to the `variables` request. + // `variablesReference` to the `variables` request as long as execution + // remains suspended. See 'Lifetime of Object References' in the Overview + // section for details. integer variablesReference; }; @@ -1723,17 +1714,19 @@ DAP_DECLARE_STRUCT_TYPEINFO(Scope); // Response to `scopes` request. struct ScopesResponse : public Response { - // The scopes of the stackframe. If the array has length zero, there are no + // The scopes of the stack frame. If the array has length zero, there are no // scopes available. array scopes; }; DAP_DECLARE_STRUCT_TYPEINFO(ScopesResponse); -// The request returns the variable scopes for a given stackframe ID. +// The request returns the variable scopes for a given stack frame ID. struct ScopesRequest : public Request { using Response = ScopesResponse; - // Retrieve the scopes for this stackframe. + // Retrieve the scopes for the stack frame identified by `frameId`. The + // `frameId` must have been obtained in the current suspended state. See + // 'Lifetime of Object References' in the Overview section for details. integer frameId; }; @@ -1767,14 +1760,19 @@ struct SourceBreakpoint { // The expression that controls how many hits of the breakpoint are ignored. // The debug adapter is expected to interpret the expression as needed. // The attribute is only honored by a debug adapter if the corresponding - // capability `supportsHitConditionalBreakpoints` is true. + // capability `supportsHitConditionalBreakpoints` is true. If both this + // property and `condition` are specified, `hitCondition` should be evaluated + // only if the `condition` is met, and the debug adapter should stop only if + // both conditions are met. optional hitCondition; // The source line of the breakpoint or logpoint. integer line; // If this attribute exists and is non-empty, the debug adapter must not // 'break' (stop) but log the message instead. Expressions within `{}` are // interpolated. The attribute is only honored by a debug adapter if the - // corresponding capability `supportsLogPoints` is true. + // corresponding capability `supportsLogPoints` is true. If either + // `hitCondition` or `condition` is specified, then the message should only be + // logged if those conditions are met. optional logMessage; }; @@ -1953,9 +1951,10 @@ struct SetExpressionResponse : public Response { optional type; // The new value of the expression. string value; - // If `variablesReference` is > 0, the value is structured and its children - // can be retrieved by passing `variablesReference` to the `variables` - // request. The value should be less than or equal to 2147483647 (2^31-1). + // If `variablesReference` is > 0, the evaluate result is structured and its + // children can be retrieved by passing `variablesReference` to the + // `variables` request as long as execution remains suspended. See 'Lifetime + // of Object References' in the Overview section for details. optional variablesReference; }; @@ -2088,8 +2087,8 @@ struct SetVariableResponse : public Response { string value; // If `variablesReference` is > 0, the new value is structured and its // children can be retrieved by passing `variablesReference` to the - // `variables` request. The value should be less than or equal to 2147483647 - // (2^31-1). + // `variables` request as long as execution remains suspended. See 'Lifetime + // of Object References' in the Overview section for details. optional variablesReference; }; @@ -2108,7 +2107,9 @@ struct SetVariableRequest : public Request { string name; // The value of the variable. string value; - // The reference of the variable container. + // The reference of the variable container. The `variablesReference` must have + // been obtained in the current suspended state. See 'Lifetime of Object + // References' in the Overview section for details. integer variablesReference; }; @@ -2143,6 +2144,8 @@ struct StackFrame { // Indicates whether this frame can be restarted with the `restart` request. // Clients should only use this if the debug adapter supports the `restart` // request and the corresponding capability `supportsRestartRequest` is true. + // If a debug adapter has this capability, then `canRestart` defaults to + // `true` if the property is absent. optional canRestart; // Start position of the range covered by the stack frame. It is measured in // UTF-16 code units and the client capability `columnsStartAt1` determines @@ -2157,7 +2160,7 @@ struct StackFrame { optional endLine; // An identifier for the stack frame. It must be unique across all threads. // This id can be used to retrieve the scopes of the frame with the `scopes` - // request or to restart the execution of a stackframe. + // request or to restart the execution of a stack frame. integer id; // A memory reference for the current instruction pointer in this frame. optional instructionPointerReference; @@ -2184,8 +2187,8 @@ DAP_DECLARE_STRUCT_TYPEINFO(StackFrame); // Response to `stackTrace` request. struct StackTraceResponse : public Response { - // The frames of the stackframe. If the array has length zero, there are no - // stackframes available. This means that there is no location information + // The frames of the stack frame. If the array has length zero, there are no + // stack frames available. This means that there is no location information // available. array stackFrames; // The total number of frames available in the stack. If omitted or if @@ -2591,8 +2594,9 @@ struct Variable { // should be shown in the UI. string value; // If `variablesReference` is > 0, the variable is structured and its children - // can be retrieved by passing `variablesReference` to the `variables` - // request. + // can be retrieved by passing `variablesReference` to the `variables` request + // as long as execution remains suspended. See 'Lifetime of Object References' + // in the Overview section for details. integer variablesReference; }; @@ -2626,7 +2630,9 @@ struct VariablesRequest : public Request { optional format; // The index of the first variable to return; if omitted children start at 0. optional start; - // The Variable reference. + // The variable for which to retrieve its children. The `variablesReference` + // must have been obtained in the current suspended state. See 'Lifetime of + // Object References' in the Overview section for details. integer variablesReference; }; diff --git a/src/protocol_events.cpp b/src/protocol_events.cpp index 4ad1a85..9deb85f 100644 --- a/src/protocol_events.cpp +++ b/src/protocol_events.cpp @@ -15,7 +15,7 @@ // Generated with protocol_gen.go -- do not edit this file. // go run scripts/protocol_gen/protocol_gen.go // -// DAP version 1.58.0 +// DAP version 1.59.0 #include "dap/protocol.h" diff --git a/src/protocol_requests.cpp b/src/protocol_requests.cpp index 0517223..a3b33ec 100644 --- a/src/protocol_requests.cpp +++ b/src/protocol_requests.cpp @@ -15,7 +15,7 @@ // Generated with protocol_gen.go -- do not edit this file. // go run scripts/protocol_gen/protocol_gen.go // -// DAP version 1.58.0 +// DAP version 1.59.0 #include "dap/protocol.h" @@ -54,6 +54,7 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(ContinueRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(DataBreakpointInfoRequest, "dataBreakpointInfo", + DAP_FIELD(frameId, "frameId"), DAP_FIELD(name, "name"), DAP_FIELD(variablesReference, "variablesReference")); diff --git a/src/protocol_response.cpp b/src/protocol_response.cpp index 79816a7..bab8ebb 100644 --- a/src/protocol_response.cpp +++ b/src/protocol_response.cpp @@ -15,7 +15,7 @@ // Generated with protocol_gen.go -- do not edit this file. // go run scripts/protocol_gen/protocol_gen.go // -// DAP version 1.58.0 +// DAP version 1.59.0 #include "dap/protocol.h" diff --git a/src/protocol_types.cpp b/src/protocol_types.cpp index cc1126c..d9a9e36 100644 --- a/src/protocol_types.cpp +++ b/src/protocol_types.cpp @@ -15,7 +15,7 @@ // Generated with protocol_gen.go -- do not edit this file. // go run scripts/protocol_gen/protocol_gen.go // -// DAP version 1.58.0 +// DAP version 1.59.0 #include "dap/protocol.h" @@ -202,15 +202,6 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(Module, DAP_FIELD(symbolStatus, "symbolStatus"), DAP_FIELD(version, "version")); -DAP_IMPLEMENT_STRUCT_TYPEINFO(LaunchRequestArguments, - "", - DAP_FIELD(restart, "__restart"), - DAP_FIELD(noDebug, "noDebug")); - -DAP_IMPLEMENT_STRUCT_TYPEINFO(AttachRequestArguments, - "", - DAP_FIELD(restart, "__restart")); - DAP_IMPLEMENT_STRUCT_TYPEINFO(Scope, "", DAP_FIELD(column, "column"), diff --git a/tools/protocol_gen/protocol_gen.go b/tools/protocol_gen/protocol_gen.go index 22bae31..4f6b9ea 100644 --- a/tools/protocol_gen/protocol_gen.go +++ b/tools/protocol_gen/protocol_gen.go @@ -487,8 +487,8 @@ func (r *root) getType(def *definition) (builtType cppType, err error) { return ref.def.cppType, nil } + // The DAP spec introduces ambiguities with its particular uses of OneOf, just set to object if len(def.OneOf) != 0 { - args := make([]string, len(def.OneOf)) deps := make([]cppType, len(def.OneOf)) for i, oneOf := range def.OneOf { if oneOf == nil { @@ -499,10 +499,9 @@ func (r *root) getType(def *definition) (builtType cppType, err error) { return nil, err } deps[i] = elTy - args[i] = elTy.Name() } return &cppBasicType{ - name: "variant<" + strings.Join(args, ", ") + ">", + name: "object", desc: def.Description, deps: deps, }, nil @@ -681,11 +680,15 @@ func run() error { return fmt.Errorf("Failed to load JSON file from '%v': %w", protocolURL, err) } - hPath, cppPaths := outputPaths() + hPath, cppPaths, cMakeListsPath := outputPaths() if err := emitFiles(&protocol, hPath, cppPaths, pkg.Version); err != nil { return fmt.Errorf("Failed to emit files: %w", err) } + if err := updateCMakePackageVersion(cMakeListsPath, pkg.Version); err != nil { + return fmt.Errorf("Failed to update CMakeLists.txt: %w", err) + } + if clangfmt, err := exec.LookPath("clang-format"); err == nil { if out, err := exec.Command(clangfmt, "-i", hPath).CombinedOutput(); err != nil { return fmt.Errorf("Failed to run clang-format on '%v':\n%v\n%w", hPath, string(out), err) @@ -702,6 +705,23 @@ func run() error { return nil } +// Updates package version in CMakeLists.txt to current +func updateCMakePackageVersion(cMakeListsPath string, version string) error { + text, err := os.ReadFile(cMakeListsPath) + if err != nil { + return err + } + lines := strings.Split(string(text), "\n") + for i, line := range lines { + if strings.Contains(line, "project(cppdap") { + lines[i] = "project(cppdap VERSION " + version + " LANGUAGES CXX C)" + break + } + } + output := strings.Join(lines, "\n") + return os.WriteFile(cMakeListsPath, []byte(output), 0644) +} + // emitFiles() opens each of the C++ files, generates the cppType definitions // from the schema root, then writes the types to the C++ files in dependency // order. @@ -790,8 +810,8 @@ func loadJSONFile(url string, obj interface{}) error { return nil } -// outputPaths() returns a path to the target C++ .h file and .cpp files -func outputPaths() (string, cppTargetFilePaths) { +// outputPaths() returns a path to the target C++ .h file and .cpp files, and the CMakeLists.txt +func outputPaths() (string, cppTargetFilePaths, string) { _, thisFile, _, _ := runtime.Caller(1) thisDir := path.Dir(thisFile) h := path.Join(thisDir, "../../include/dap/protocol.h") @@ -801,5 +821,6 @@ func outputPaths() (string, cppTargetFilePaths) { event: path.Join(thisDir, "../../src/protocol_events.cpp"), types: path.Join(thisDir, "../../src/protocol_types.cpp"), } - return h, cpp + CMakeLists := path.Join(thisDir, "../../CMakeLists.txt") + return h, cpp, CMakeLists }