def test_threads(setup_teardown, coredump_args):  # noqa: F811
    with TSession(coredump_args) as ts:
        ts.send_request(REQUEST_INIT)
        ts.send_request(REQUEST_LAUNCH)
        rq = schema.Request(command="threads")
        resp = ts.send_request(rq)
        assert len(resp.body.get("threads")) == 4
Ejemplo n.º 2
0
def restart(ts, timeout=10):
    rq = schema.Request(command="restart")
    resp = ts.send_request(rq)
    assert resp.success
    expectation = timeline.Event(event="stopped",
                                 body=some.dict.containing(
                                     {"reason": "breakpoint"}))
    result = ts.wait_for(expectation, timeout_s=timeout)
    assert result
Ejemplo n.º 3
0
 def session_stop(self):
     self.__stop = True
     while self.client_busy.locked():
         pass  # waiting for finishing of operations
     if self._adapter_obj:
         disconnect_rq = schema.Request(command="disconnect", seq=-1, arguments={"restart": False})
         self.send_request(disconnect_rq, False)
         self._adapter_obj.adapter_stop()
     if self._client_stream and not self._client_stream._closed:
         self._client_stream.close()
     if self._client_socket and not self._client_socket._closed:
         self._client_socket.close()
def test_stack(setup_teardown, coredump_args):  # noqa: F811
    with TSession(coredump_args) as ts:
        ts.send_request(REQUEST_INIT)
        ts.send_request(REQUEST_LAUNCH)
        rq = schema.Request(command="stackTrace",
                            arguments={
                                "format": {},
                                "levels": 20,
                                "startFrame": 0,
                                "threadId": 1
                            })
        resp = ts.send_request(rq)
        stack = resp.body.get("stackFrames")
        stack_sz = len(stack)
        assert stack[stack_sz - 1]["name"] == "app_main"
Ejemplo n.º 5
0
def test_threads_sequence(setup_teardown, hostapp_args):  # noqa: F811
    with TSession(hostapp_args, "test_threads_sequence") as ts:
        ts.send_request(REQUEST_INIT)
        ts.send_request(REQUEST_LAUNCH)
        set_breakpoints(ts, "test_app.c", [{"line": 11}])
        # run to the breakpoint at thread entry, 6 threads in total
        for tid in range(2, 8):
            continue_till_stopped(ts,
                                  stop_reason="breakpoint",
                                  thread_id=tid,
                                  timeout=None)
            rq = schema.Request(command="threads")
            resp = ts.send_request(rq)
            assert len(resp.body.get("threads")) == 2
            line, name = get_top_frame_info(ts, thread_id=tid)
            assert name == "print_hamlet_thread"
            assert line == 11
            line, name = get_top_frame_info(ts, thread_id=1)
            assert name == "main"
            assert line == 35
Ejemplo n.º 6
0
 def session_stop(self):
     self.__stop = True
     while self.client_busy.locked():
         pass  # waiting for finishing of operations
     if self._adapter_obj:
         disconnect_rq = schema.Request(command="disconnect",
                                        seq=-1,
                                        arguments={"restart": False})
         self.send_request(disconnect_rq, False)
         # give adapter time to cleanup
         time.sleep(2.0)
     if self._client_stream and not self._client_stream._closed:
         self._client_stream.close()
     if self._client_socket and not self._client_socket._closed:
         self._client_socket.close()
     # avoid errors due to unobserved responses and events
     # TODO: avoid using 'TSession.wait_for' in tests. Instead of it,
     # compose expected message sequences and use 'timeline.wait_until_realized'.
     # Using that approach we will ensure that communication is done as expected and
     # do not need to call `timeline.observe_all`
     with self.session_timeline.frozen():
         self.session_timeline.observe_all()
     self.session_timeline.close()
Ejemplo n.º 7
0
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# SPDX-License-Identifier: MIT

from debug_adapter import schema

REQUEST_INIT = schema.Request(command="initialize",
                              arguments={
                                  "adapterID": "espidf",
                                  "clientID": "vscode",
                                  "clientName": "Visual Studio Code",
                                  "columnsStartAt1": True,
                                  "linesStartAt1": True,
                                  "locale": "en-us",
                                  "pathFormat": "path",
                                  "supportsRunInTerminalRequest": True,
                                  "supportsVariablePaging": True,
                                  "supportsVariableType": True
                              })

REQUEST_LAUNCH = schema.Request(command="launch",
                                arguments={
                                    "__sessionId":
                                    "79b3673d-5b08-44e5-98ca-429a521464cb",
                                    "externalConsole": False,
                                    "logging": {
                                        "engineLogging": True
                                    },