forked from jupyter-xeus/xeus-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdebugpy_client.cpp
56 lines (47 loc) · 1.93 KB
/
xdebugpy_client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/***************************************************************************
* Copyright (c) 2018, Martin Renou, Johan Mabille, Sylvain Corlay, and *
* Wolf Vollprecht *
* Copyright (c) 2018, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#include "nlohmann/json.hpp"
#include "xeus/xmessage.hpp"
#include "xdebugpy_client.hpp"
#include <thread>
#include <chrono>
namespace nl = nlohmann;
namespace xpyt
{
xdebugpy_client::xdebugpy_client(xeus::xcontext& context,
const xeus::xconfiguration& config,
int socket_linger,
const xdap_tcp_configuration& dap_config,
const event_callback& cb)
: base_type(context, config, socket_linger, dap_config, cb)
{
}
void xdebugpy_client::handle_event(nl::json message)
{
forward_event(std::move(message));
}
nl::json xdebugpy_client::get_stack_frames(int thread_id, int seq)
{
nl::json request = {
{"type", "request"},
{"seq", seq},
{"command", "stackTrace"},
{"arguments", {
{"threadId", thread_id}
}}
};
send_dap_request(std::move(request));
nl::json reply = wait_for_message([](const nl::json& message)
{
return message["type"] == "response" && message["command"] == "stackTrace";
});
return reply["body"]["stackFrames"];
}
}