MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / initialize

Method initialize

src/plugins/debugger/dap/debugsession.cpp:70–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool DebugSession::initialize(const char *ip, int port, dap::InitializeRequest &iniRequest)
71{
72 shutdown();
73
74 if (!raw) {
75 // if there was already a connection make sure to remove old listeners
76 // TODO(mozart):crashed when re-start debug.
77 rtCfgProvider.reset(new RunTimeCfgProvider(/*this*/));
78
79 constexpr int kMaxAttempts = 10;
80 bool connected = false;
81 // The socket might take a while to open - retry connecting.
82 for (int attempt = 0; attempt < kMaxAttempts; attempt++) {
83 auto connection = net::connect(ip, port);
84 if (!connection) {
85 std::this_thread::sleep_for(std::chrono::milliseconds(100));
86 continue;
87 }
88 // Socket opened. Create the debugger session and bind.
89 session.reset();
90 session = dap::Session::create();
91 session->bind(connection);
92
93 raw.reset(new RawDebugSession(session /*, this*/));
94
95 connected = true;
96 break;
97 }
98
99 if (!connected) {
100 return false;
101 }
102 }
103
104 auto init_res = raw->initialize(iniRequest).get();
105 if (init_res.error) {
106 initialized = false;
107 shutdown();
108 qDebug() << init_res.error.message.c_str();
109 return false;
110 } else {
111 initialized = true;
112 }
113
114 // Notify outter register handlers.
115 emit sigRegisterHandlers();
116
117 return initialized;
118}
119
120bool DebugSession::launch(dap::LaunchRequest &config)
121{

Callers 1

launchSessionMethod · 0.45

Calls 7

shutdownFunction · 0.85
connectFunction · 0.85
createFunction · 0.85
c_strMethod · 0.80
resetMethod · 0.45
bindMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected