78 Commits

Author SHA1 Message Date
Ben Clayton
c9187480d1 Fix short reads in ContentReader::buffer()
The actual length of data read by `dap::Reader::read()` was not being correctly inspected.

Fixed, added test.

Bug identified by @kuafuwang.

Fixes #27
2020-05-27 18:40:48 +01:00
Ben Clayton
ad9b4588f2 Fix dap::Socket::read() when recv() errors
Identified by @kuafuwang.

Fixes #29
2020-05-27 18:40:08 +01:00
Ben Clayton
9e313445bb Kokoro Ubuntu: Switch to docker image
presubmit.sh now runs presubmit-docker.sh using the new radial
docker image which contains various toolchains.

The `/bin/using.sh` bash script exports the `using` bash function
which can be called to configure toolchains at specific versions.
2020-05-07 13:55:54 +01:00
Ben Clayton
4bc690cba8 Update DAP protocol to Version 1.40
Updated with:
 `go run scripts/protocol_gen/protocol_gen.go`
2020-05-05 13:03:20 +01:00
Ben Clayton
4dcca57756 Socket: Enable TCP_NODELAY
DAP usually consists of small packet requests, with small packet responses. When there are many frequent, blocking requests made, Nagle's algorithm can dramatically limit the request->response rates.
2020-03-13 07:01:42 +00:00
Ben Clayton
c4358807e2 Fix new gcc 9 'deprecated-copy' warning.
Example warning:

cppdap/include/dap/future.h:172:14: error: implicitly-declared ‘dap::ResponseOrError<dap::StackTraceResponse>& dap::ResponseOrError<dap::StackTraceResponse>::operator=(const dap::ResponseOrError<dap::StackTraceResponse>&)’ is deprecated [-Werror=deprecated-copy]

Add missing constructors and assignment operators.
This probably adds more than is absolutely necessary, but there's no
harm in being thorough.
2020-02-06 13:37:41 +00:00
Ben Clayton
de7dffaf66 Socket: Use SO_REUSEADDR, disable SO_LINGER
Use these to avoid "socket in use" errors when restarting a DAP that uses the same port.
2020-01-28 14:44:35 +00:00
Ben Clayton
9a9d46f6b6 Fix bad usage of std::move
Issue #16 describes the problem and solution perfectly.

Updated tests to cover this.

Fixes #16
2020-01-24 15:21:26 +00:00
Ben Clayton
3e6cfd6c2f CMake: Make the cppdap target's include directory public
Avoids having to pull this in as an explicit include directory for projects that depend on cppdap.
2020-01-24 12:53:20 +00:00
Ben Clayton
4abe43c131 optional: Remove the value() method that returns non-const-ref.
I'm not convinced that `opt.value() = foo` is a desirable pattern,
and worse still it confuses some compilers about which overload to
use.

Just remove it.
2020-01-24 07:25:33 +00:00
Ben Clayton
ced82a0501 examples: Change stdin and stdout to binary mode
On windows text mode for these plays with newline escape sequences, breaking the ContextStream encoding.

Fixes: #12
2020-01-17 20:07:55 +00:00
Ben Clayton
96b25aafe0 src/io.cpp: Fix uninitialized variable.
`std::atomic<bool>` does not default initialize to `false`.

Bug: #12
2020-01-17 20:07:55 +00:00
Ben Clayton
93b861004e examples: Suffix package exe with .exe on Windows
Without this the vscode extension cannot find the example executable, and the example fails.

Also use $USERPROFILE instead of  $HOME for finding the `.vscode` user directory for installing the extension.

Bug: #12
2020-01-17 20:07:55 +00:00
Ben Clayton
cdc19ac4d9 Serialization: Correctly encode structs with no fields
Empty structs were being serialized as `null`, when they should have been serialized as `{}`.

This was due to the type inference on the serializer - where no calls to `field()` would result in the default `null` type.

To solve this, the `serialize(const void* object, const std::initializer_list<Field>&)` inline helper has been promoted to a virtual function (and renamed to `fields()`).
The JSON serializer implementation of this now first sets the object type to `object`, even if there are no fields to serialize.

Added test for this.

Fixes: #10
2020-01-06 15:00:24 +00:00
Ben Clayton
3a10d4cabd Format all source files 2020-01-06 15:00:24 +00:00
Ben Clayton
8633abaf88 Add clang-format-all.sh to format all project sources 2020-01-06 15:00:24 +00:00
Ben Clayton
1be9bb6712 launch.json - fix name of unittests to launch 2020-01-06 15:00:24 +00:00
Ben Clayton
d19d8f83c9
Address #7 nits and fix compiler warning (#9)
Compiler warning was signed / unsigned compare.
2019-12-31 21:04:57 +00:00
kuafuwang
73d697eac4 Fix Response type info, make response 'body' field optional
The `body` field of the Response is optional. Do not error if it is missing.

If the typeinfo of the response. This was incorrectly using the Request type.

Authored by kuafuwang, squashed by ben-clayton.
2019-12-31 20:58:33 +00:00
Ben Clayton
eab43f3518 net::Server: Fix onError parameter default.
The onError parameter of Server::start was default initialized with
OnError(), which is an 'invalid target', not a no-op implementation.

Replace with a true no-op implementation.
2019-12-05 15:12:56 +00:00
Ben Clayton
cc7b68a365 CMakeLists.txt: Make it easier to control options from dependee projects. 2019-12-02 13:55:45 +00:00
Ben Clayton
dc3b3eaeb3 CMakeLists.txt: Disable MSVC warning from third_party
`nlohmann/json` raises a `size_t` to `int` MSVC warning that will fail the build if `CPPDAP_WARNINGS_AS_ERRORS` is enabled.
Given that this is not our code, the best we can do is to make an exception for this warning.
2019-11-26 17:59:58 +00:00
Ben Clayton
010e3e3c86 CMakeLists.txt: Make it easier to specify third_party vars.
Only set the third_party directory variables if they're not already set
(by the dependee project).
2019-11-18 13:00:26 +00:00
Ben Clayton
44d158805c Reimplement std::future and std::promise to workaround TSAN false positives 2019-11-14 08:10:16 +00:00
Ben Clayton
1f7f48904a Fix memory leak in src/socket.cpp 2019-11-14 00:37:38 +00:00
Ben Clayton
d13d4a4151 GCC build fixes 2019-11-14 00:29:38 +00:00
Ben Clayton
a4b9640ffc Add Kokoro presubmit scripts 2019-11-14 00:09:46 +00:00
Ben Clayton
2dfd15462f Initial drop of cppdap 2019-11-08 21:58:50 +00:00