Git Product home page Git Product logo

cppdap's Introduction

cppdap

About

cppdap is a C++11 library ("SDK") implementation of the Debug Adapter Protocol, providing an API for implementing a DAP client or server.

cppdap provides C++ type-safe structures for the full DAP specification, and provides a simple way to add custom protocol messages.

Fetching dependencies

cppdap provides CMake build files to build the library, unit tests and examples.

cppdap depends on the nlohmann/json library, and the unit tests depend on the googletest library. Both are referenced as a git submodules.

Before building, fetch the git submodules with:

cd <path-to-cppdap>
git submodule update --init

Alternatively, cppdap can use the RapidJSON library or the JsonCpp library for JSON serialization. Use the CPPDAP_USE_EXTERNAL_NLOHMANN_JSON_PACKAGE, CPPDAP_USE_EXTERNAL_RAPIDJSON_PACKAGE, and CPPDAP_USE_EXTERNAL_JSONCPP_PACKAGE CMake cache variables to select which library to use.

Building

Linux and macOS

Next, generate the build files:

cd <path-to-cppdap>
mkdir build
cd build
cmake ..

You may wish to suffix the cmake .. line with any of the following flags:

  • -DCPPDAP_BUILD_TESTS=1 - Builds the cppdap unit tests
  • -DCPPDAP_BUILD_EXAMPLES=1 - Builds the cppdap examples
  • -DCPPDAP_INSTALL_VSCODE_EXAMPLES=1 - Installs the cppdap examples as Visual Studio Code extensions
  • -DCPPDAP_WARNINGS_AS_ERRORS=1 - Treats all compiler warnings as errors.

Finally, build the project:

make

Windows

cppdap can be built using Visual Studio 2019's CMake integration.

Using cppdap in your CMake project

You can build and link cppdap using add_subdirectory() in your project's CMakeLists.txt file:

set(CPPDAP_DIR <path-to-cppdap>) # example <path-to-cppdap>: "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cppdap"
add_subdirectory(${CPPDAP_DIR})

This will define the cppdap library target, which you can pass to target_link_libraries():

target_link_libraries(<target> cppdap) # replace <target> with the name of your project's target

You may also wish to specify your own paths to the third party libraries used by cppdap. You can do this by setting any of the following variables before the call to add_subdirectory():

set(CPPDAP_THIRD_PARTY_DIR <third-party-root-directory>) # defaults to ${CPPDAP_DIR}/third_party
set(CPPDAP_JSON_DIR        <path-to-nlohmann-json>)      # defaults to ${CPPDAP_THIRD_PARTY_DIR}/json
set(CPPDAP_GOOGLETEST_DIR  <path-to-googletest>)         # defaults to ${CPPDAP_THIRD_PARTY_DIR}/googletest
add_subdirectory(${CPPDAP_DIR})

Note: This is not an officially supported Google product

cppdap's People

Contributors

ben-clayton avatar benmcmorran avatar bradking avatar deepin-mozart avatar gjasny avatar gruenich avatar jschueller avatar kuafuwang avatar mcnulty avatar nikitalita avatar puneetha-ramachandra avatar qmfrederik avatar sgn avatar topazus avatar zhouyi-u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppdap's Issues

Any client sample?

Hi
Thanks for this project.
I saw this issue and tried to implement as it mentioned.However I failed.
I was using debugpy as a dap server . When dap::AttachRequest was sending, It stucked into the function dap::Session::send and I did not know why.
It would be kind of you giving a client sample or some suggestions, thanks

possibly memory leak reported by valgrind

Hi all,
I created a demo application based on the 1.58.0-a version of this DAP implementation.
After doing the memory check by the valgrind tool, I get a possibly lost report as following:

--------------------------------------------------------
  672 bytes in 2 blocks are possibly lost in loss record 578 of 581
--------------------------------------------------------
	at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
	 by 0x40147D9: calloc (rtld-malloc.h:44)
	 by 0x40147D9: allocate_dtv (dl-tls.c:375)
	 by 0x40147D9: _dl_allocate_tls (dl-tls.c:634)
	 by 0x819E7B4: allocate_stack (allocatestack.c:430)
	 by 0x819E7B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647)
	 by 0x7EB2328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (no file available)
	 by 0x7CB3AA9: std::thread::thread<(anonymous namespace)::Impl::startProcessingMessages(std::function<void ()> const&)::{lambda()#1}, , void>((anonymous namespace)::Impl::startProcessingMessages(std::function<void ()> const&)::{lambda()#1}&&) (std_thread.h:143)
	 by 0x7CAF1AD: (anonymous namespace)::Impl::startProcessingMessages(std::function<void ()> const&) (session.cpp:86)
	 by 0x4BAEEE: dap::Session::bind(std::shared_ptr<dap::Reader> const&, std::shared_ptr<dap::Writer> const&, std::function<void ()> const&) (session.h:450)
	 by 0x4BAF57: dap::Session::bind(std::shared_ptr<dap::ReaderWriter> const&, std::function<void ()> const&) (session.h:455)

When I investigated the call stack, I found it was caused by a termination of the dispatchingThread and recvThread without join procedure.

Finally, I found the root cause is destructor method at "session.cpp:~Impl()" missing the virtual keyword.
After modifying ~Impl() to virtual ~Impl(), the issue disappeared.

Update CMake version to 2.8.12

With CMake 3.22.1, when generating the project, CMake now outputs the following:

C:\code\cppdap\build>cmake ..
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

The current min version is set to 2.8. Can we bump it to 2.8.12 to get rid of this warning?

Include missing header in cpp/dap/io.h

Hi there,

struct FILE is used here https://github.com/google/cppdap/blob/main/include/dap/io.h#L74, but the header to include this symbol is missing from the file. This produced a build error when compiling clang onto Fuchsia OS, which includes cppdap as a third party library:

In file included from ../../third_party/github.com/google/cppdap/src/io.cpp:15:
../../third_party/github.com/google/cppdap/include/dap/io.h:74:36: error: unknown type name 'FILE'
std::shared_ptr<ReaderWriter> file(FILE* file, bool closable = true);

The build failure can be seen here: https://luci-milo.appspot.com/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.x64-host_test_only-mac/b8782262413740663777/overview.

And a related LLVM-clang issue is here: llvm/llvm-project#62505

I think what's needed is:

diff --git a/include/dap/io.h b/include/dap/io.h
index 22a638f..61681cc 100644
--- a/include/dap/io.h
+++ b/include/dap/io.h
@@ -16,6 +16,7 @@
 #define dap_io_h
 
 #include <stddef.h>  // size_t
+#include <stdio.h>   // FILE
 #include <memory>    // std::unique_ptr
 #include <utility>   // std::pair

Projects with Cppdap

Hi!

Could you please add a list of existing projects that use cppdap as clients or servers to the README?
That would be beneficial for all who would also like to use cppdap.

Thanks!
Regards,
Mihail.

A closed Socket::Shared reads indefinitely

It looks like when the remote endpoint closes a socket, recv() returns 0, but the reader thread continues to execute as if the socket is still open.

The socket test ends the thread when recv() is 0:

auto conn = server.accept();
ASSERT_TRUE(conn != nullptr);
char c;
while (conn->read(&c, 1) != 0) {
read += c;
}

... whereas the reader thread ends the thread only when isOpen() is false:

cppdap/src/session.cpp

Lines 83 to 90 in 5981969

while (reader.isOpen()) {
if (auto payload = getPayload()) {
inbox.put(std::move(payload));
}
}
if (onClose) {
onClose();
}

... and the underlying errored() returns false, so isOpen() is always true. I think the read() call should close the socket if the bytes received is 0?

Rename default branch `master` to `main`

main is more inclusive and is being increasingly adopted as the default branch name. Let's switch.

Tasks:

  • Create new main branch from master
  • Update all CI / package references to point to main
  • Merge any late landing changes from master to main
  • Delete master branch

TSAN error when a socket is closed

TSAN doesn't like one thread calling close() while another is in a blocking send() or recv().

Note that shutdown() is called before close(), but there's nothing ensuring that the blocking calls return before calling close(), which upsets TSAN.

Fix.

MSVC compiler warning with /W3 warning level

With /W3 on in MSVC I get a warning:

rapid_json_serializer.cpp(71,17): warning C4458: declaration of 'val' hides class member

I hope this does not come accross as nit-picking that is not the intention. We use /W3 /WX (equivalent of something along the lines of -Werror -Wshadow) in our codebase so this breaks the build at the moment. I've just re-named the local in our codebase.

Cheers,

Tom

Building DAP version 1.58.0

When trying to run the script tools\protocol_gen\protocol_gen.go to get the new DAP version files, I get the error:

E:\cppdap\tools\protocol_gen> go run .\protocol_gen.go
panic: reflect: call of reflect.Value.Interface on zero Value

goroutine 1 [running]:
reflect.valueInterface({0x0?, 0x0?, 0xc000145020?}, 0x30?)
        C:/Program Files/Go/src/reflect/value.go:1483 +0x10e
reflect.Value.Interface(...)
        C:/Program Files/Go/src/reflect/value.go:1478
main.(*root).getType.func2({0x0?, 0x0?, 0xc000040800?})
        E:/cppdap/tools/protocol_gen/protocol_gen.go:559 +0x529
main.(*root).getType(0xc0003e0060?, 0xc0000d9980?)
        E:/cppdap/tools/protocol_gen/protocol_gen.go:562 +0x1be
main.(*root).buildRootStruct.func1({0xc0000935a0, 0x9}, 0xc000344c00)
        E:/cppdap/tools/protocol_gen/protocol_gen.go:450 +0x68
main.(*properties).foreach(0xc000344b78, 0xc000145520)
        E:/cppdap/tools/protocol_gen/protocol_gen.go:176 +0x273
main.(*root).buildRootStruct(0xc000070000, 0xc0003bbae0, 0xc0003778c0?)
        E:/cppdap/tools/protocol_gen/protocol_gen.go:449 +0x97b
main.(*root).buildTypes(0xc000145a30?)
        E:/cppdap/tools/protocol_gen/protocol_gen.go:621 +0x245
main.emitFiles(0x731689?, {0xc00009d280?, 0x6f1f00?}, 0xc000070000?, {0xc000014090, 0x6})
        E:/cppdap/tools/protocol_gen/protocol_gen.go:707 +0x430
main.run()
        E:/cppdap/tools/protocol_gen/protocol_gen.go:663 +0x1c6
main.main()
        E:/cppdap/tools/protocol_gen/protocol_gen.go:101 +0x65
exit status 2

Any idea how to do it?

Windows compile error

Hi

I get a compile error on Windows in traits.h due to TRUE being a macro, I fixed my version by changing the template parameter TRUE to T_TRUE

// If `BASE` is a base of `T` then EnableIfIsType resolves to type `TRUE`,
// otherwise an invalid type.
template <typename BASE, typename T, typename T_TRUE = void>
using EnableIfIsType = EnableIf<IsTypeOrDerived<BASE, T>::value, T_TRUE>;

// If the function-like `F` has a matching signature to the function-like `S`
// then EnableIfHasSignature resolves to type `TRUE`, otherwise an invalid type.
template <typename F, typename S, typename T_TRUE = void>
using EnableIfHasSignature = EnableIf<HasSignature<F, S>::value, T_TRUE>;

number cast to int , loss of precision

In https://microsoft.github.io/debug-adapter-protocol/specification#Types_Thread , all the number using type number.

interface Thread {
  /**
   * Unique identifier for the thread.
   */
  id: number;

  /**
   * A name of the thread.
   */
  name: string;
}

in vscode-java-deubg
in Types.java
some id using long type.

public static class Thread {
        public long id;
        public String name;

        /**
         * Constructor.
         */
        public Thread(long l, String name) {
            this.id = l;
            if (name == null || name.length() == 0) {
                this.name = String.format("Thread #%d", l);
            } else {
                this.name = name;
            }
        }
    }

in cppdap ,we using interger.
In som case , long cast to int , will loss of precision. I think we need to change dap::interger type to dap::number type .
I think all the threadid ,all need to change dap::interger type to dap::number type .Because in vscode-java-deubg all the threadid using long type.

I can't close socket once i bind socket to a session.

On my side. i implement a DAP client.

Why? because session is start when bind a socket to session.
Then it start to read. It will only return when the socket is close by DAP server or a message come from server.
At the same time , i can't close the socket ,because , it lock in read function.
size_t read(void* buffer, size_t bytes) {
RLock lock(mutex); // lock here.
if (s == InvalidSocket) {
return 0;
}
auto len =
recv(s, reinterpret_cast<char*>(buffer), static_cast(bytes), 0);
return (len < 0) ? 0 : len;
}

void close() {
#if !defined(_WIN32)
{
RLock l(mutex);
if (s != InvalidSocket) {
::shutdown(s, SHUT_RDWR);
}
}
#endif

**WLock l(mutex);// wait here**
if (s != InvalidSocket) {

#if defined(_WIN32)
closesocket(s);
#else
::close(s);
#endif
s = InvalidSocket;
}
}

intermittent unreleased lock in `Socket::Socket`

There is a lock owned by a shared_ptr<dap::Socket::Shared> which seems to be never released if shared_ptr::reset is called while the lock is held.

The resets are called when bind or listen fails. I was trying to connect to an already in-use socket when this happened. Instead of ending up in the onError handler, the program became unresponsive.

shared.reset();

expose virtual bool send(const TypeInfo*, const void* event) to allow customising type deduction

Hi

I'm looking to something like the following, whereby the IDebug interface does not need to know about the implementation details of dap::Session and the type deduction happens somewhere in the IDebug interface implementation rather than the dap::Session send template.

struct IDebug 
{
      void SetEventSink( const std::function< void(const dap::TypeInfo*, const void* event) >& ) = 0;
}

At the moment I have simply exposed the following on the dap::Session interface

virtual bool send(const TypeInfo*, const void* event) = 0;

If this is a valid use-case, would it be possible for you to expose this method on dap::Session interface in the library?

Can't get response when send dap::ThreadsRequest to vscode.java.debug

My code :
dap::ThreadsRequest thread_request; auto thread_response = d_ptr->session->send(thread_request).get(); if (thread_response.error) { return; }
And i can't get the respone or error.
And the vscode.debug return some tip:
2020-1-5 15:23:05 Error parsing message: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonNull Expected a com.google.gson.JsonObject but was com.google.gson.JsonNull com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonNull at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.java:896) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.Gson.fromJson(Gson.java:888) at com.google.gson.Gson.fromJson(Gson.java:853) at com.google.gson.Gson.fromJson(Gson.java:802) at com.google.gson.Gson.fromJson(Gson.java:774) at com.microsoft.java.debug.core.protocol.JsonUtils.fromJson(JsonUtils.java:26) at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.processData(AbstractProtocolServer.java:219) at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.run(AbstractProtocolServer.java:98) at com.microsoft.java.debug.core.adapter.ProtocolServer.run(ProtocolServer.java:61) at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:136) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Now i have two way to solve the my problem.
One :
make request to vscode.debug to change they code to make argument as an opiton filed .
mu issue

Two:
Add option filed to dap::ThreadsRequest to make the argument field isn't nulll.

I want to know ,do i have another way to solve my problme?

Async response support

This is great library!
I am curious is there any support for asynchronous response? It looks like registered handlers have to return response synchronously which blocks processing any other requests in between? Would it make sense to add support for that?

Can you add an interface for timeout connections?

Can you add an interface for timeout connections?
When an exception occurs in the DAP server, sometimes the client is blocked due to the blocking connection.
If you can add an interface such as
std::shared_ptr connect(const char* addr, int port,int time_out);
That would be great

Accessing empty struct types

How would one use InvalidatedAreas and SteppingGranularity?

these get generated as follows -

struct SteppingGranularity {};

DAP_DECLARE_STRUCT_TYPEINFO(SteppingGranularity);

and

struct InvalidatedAreas {};

DAP_DECLARE_STRUCT_TYPEINFO(InvalidatedAreas);

looking for a way to check dap::NextRequest req; req.granularity.value() == 'instruction' or something similar

How can i catch the json error in method which name processMessage

Payload processMessage(const std::string& str) {
auto d = dap::json::Deserializer(str);
dap::string type;
if (!d.field("type", &type)) {
handlers.error("Message missing string 'type' field");
return {};
}

dap::integer sequence = 0;
if (!d.field("seq", &sequence)) {
  handlers.error("Message missing number 'seq' field");
  return {};
}

if (type == "request") {
  return processRequest(&d, sequence);
} else if (type == "event") {
  return processEvent(&d);
} else if (type == "response") {
  processResponse(&d);
  return {};
} else {
  handlers.error("Unknown message type '%s'", type.c_str());
}

return {};

}

dap::json::Deserializer this method , it can throw some json exception. How can i catch exception.

AttachRequest custom parameters

In the protocol description it seems that the AttachRequest can have custom parameters which are given by the DAP client.

The attach request is sent from the client to the debug adapter to attach to
a debuggee that is already running. Since attaching is debugger/runtime
specific, the arguments for this request are not part of this specification.

Is there a way to extend the AttachRequest struct to be able to have them available in the callback?

P.s. Great library, thank you!

Allow network loop to run indefinitely

Currently the network loop quits after the first connection is accepted:

running = true;
    thread = std::thread([=] {
      do {
        if (auto rw = socket->accept()) {
          onConnect(rw);
          continue;
        }
        if (!isRunning()) {
          onError("Failed to accept connection");
        }
      } while (false);
    });

For various reasons associated with my debug adaptor, which allows re-connection, I have had to modify this code to always run while isRunning() is true.

running = true;
    thread = std::thread([=] {
      do {
        if (auto rw = socket->accept()) {
          onConnect(rw);
          continue;
        }
        if (!isRunning()) {
          onError("Failed to accept connection");
        }
      } while (isRunning());
    });

Would it be possible to add an overloaded start function which allows you to specify a flag indicating if the loop should continue to run, or use the original behaviour of quitting after the first socket connection accept?

virtual bool start(int port,
                           const OnConnect& onConnect,
                           const OnError& onError) = 0;

virtual bool start(int port,
                           const OnConnect& onConnect,
                           const OnError& onError,
                           bool bMultipleConnect ) = 0;

Using of hello_debugger with VSCode on Windows

Hello Ben,

thank you very much for your project! Could you clarify whether it is possible to use hello_debugger with VSCode on Windows? It built and installed without errors. So I can find google.cppdap-example-hello_debugger-1.0.0 in my .vscode\extensions and VSCode shows that google.cppdap-example-hello_debugger-1.0.0 is enabled. My launch.json looks like this:

{
"version": "0.2.0",
"configurations": [
{
"name": "cppdap: hello_debugger",
"type": "hello_debugger",
"request": "launch"
}
]
}

However, when I choose "cppdap: hello_debugger" and start debugging, nothing happens. Log (Window) reports the following errror:

[2020-01-17 15:24:36.857] [renderer1] [error] timeout after 500 ms: Error: timeout after 500 ms
at t.RawDebugSession.handleErrorResponse (file:///C:/Users/Elias/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2821:819)
at file:///C:/Users/Elias/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2821:250
at async t.RawDebugSession.shutdown (file:///C:/Users/Elias/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2819:336)

--
Thanks Elias.

failed to compile on linux

hi,
trying to compile and install on linux :
cmake : 3.17.4
GNU Make : 4.2.1

LANG=EN
rm -rf /tmp/debug; mkdir /tmp/debug; cd /tmp/debug
git clone [email protected]:google/cppdap.git
cd cppdap
git submodule update --init

mkdir build; cd build
cmake .. -DCPPDAP_BUILD_TESTS=1 -DCPPDAP_BUILD_EXAMPLES=1 -DCPPDAP_INSTALL=ON
make
make install

problem :

cmake .. -DCPPDAP_BUILD_TESTS=1 -DCPPDAP_BUILD_EXAMPLES=1 -DCPPDAP_INSTALL=ON

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error in CMakeLists.txt:
  Target "cppdap" INTERFACE_INCLUDE_DIRECTORIES property contains path:
    "/tmp/debug/cppdap/include"
  which is prefixed in the source directory.
-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

workaround:

< set(CPPDAP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
---
> set(CPPDAP_INCLUDE_DIR  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

but

make install

[ 46%] Built target cppdap
[ 93%] Built target cppdap-unittests
[100%] Built target hello_debugger
Install the project...
-- Install configuration: ""
CMake Error at cmake_install.cmake:41 (file):
  file INSTALL cannot find "/tmp/debug/cppdap/include/cppdap": No such file or directory.
make: *** [Makefile:106: install] Error 1

assigning to dap::optional may destroy the original

Example:

std::string foo = "hello";
dap::optional<std::string> opt;
opt = foo; // foo is _moved_ into opt and is now empty

Looks like some of the assignment operator and constructors in optional are incorrectly moving, e.g.:

template <typename T>
template <typename U /* = T */, typename>
optional<T>& optional<T>::operator=(U&& value) {
  val = std::move(value); // this should be std::forward, not a std::move
  set = true;
  return *this;
}

The constructor that takes a U&& also has this problem.

Support for Server::start(host, port, callback, OnError)

dap::net::Server::start right now always binds to "localhost", which is a fine default; but I ran into trying to build this into a javaagent, to be used on a JVM inside a docker container (so debug client is running on host, cppdap is in a container). Apparently, docker container's port forwarding from host<->container requires the applications inside the container to be listening to 0.0.0.0.

Easy fix on the surface -- add an overload that accepts const char* host -- curious if this has drawbacks I don't see, or there is already a built-in solution I am overlooking.

Add GitHub CI workflows?

Since most contributions to this repo are going to come from community contributors for the foreseeable future, and nobody except Google employees can see the Kokoro build logs, it would be nice to add GitHub workflows in addition to the Kokoro CI.

Ideally, the GitHub runners would mirror the configurations of those used in the Kokoro CI (same distro, same compiler versions, cmake, etc.). However, the configuration for the Kokoro runners seems to be rather opaque. the only things I can only see from my end seems to be the CMake and gcc versions for the Ubuntu CI.

if you are allowed to, and you think that this is a good idea, can you post the configurations of the Kokoro runners? If so, I can put together workflows for the GitHub CI.

Create DAP Server which listen a tcp port

I use dap::net::Server::create() create a tcp server. just like:
auto server = dap::net::Server::create();
and
auto session = dap::Session::create()
. How to bind the server and session together.
can use just like:
void OnConnect()
{
// create a debug session when a client connection was accpeted
auto session = dap::Session::create();

   / / register handlers

}

Deserializer fails to deserialize Int64

I was having an issue with parsing a variables request, whereby I had encoded a thread id and a stack frame id into a 64 bit integer. This id was being serialized and sent OK to the debugger by cppdap, however receipt of a variables request in the dap session was failing to parse. I have tracked it down to the rapid json deserializer, below is my fix:

bool RapidDeserializer::deserialize(dap::integer* v) const {
    
  if (json()->IsInt())
  {
    *v = json()->GetInt();
    return true;
  } 
  else if (json()->IsInt64())
  {
    *v = json()->GetInt64();
    return true;
  }

  return false;
}

NOTE: May also want to include Uint64 here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.