emdbg.debug.backend

 1# Copyright (c) 2020-2022, Niklas Hauser
 2# Copyright (c) 2023, Auterion AG
 3# SPDX-License-Identifier: BSD-3-Clause
 4
 5from __future__ import annotations
 6from pathlib import Path
 7from contextlib import contextmanager
 8
 9
10class ProbeBackend:
11    """
12    Base class for starting and stopping debug probes and attaching GDB to them.
13    """
14    def __init__(self, remote: str = None):
15        """
16        :param remote: Extended remote location.
17        """
18        self.remote = remote
19        self.name = "remote"
20
21    def init(self, elf: Path) -> list[str]:
22        """
23        Returns a list of GDB commands that connect GDB to the debug probe.
24        The default implementation returns `target extended-remote {self.remote}`.
25        """
26        return ["target extended-remote {}".format(self.remote)] if self.remote else []
27
28    def start(self):
29        """
30        Starts the debug probe as a non-blocking subprocess.
31        """
32        pass
33
34    def stop(self):
35        """
36        Halts the debug probe process.
37        """
38        pass
39
40    @contextmanager
41    def scope(self):
42        """
43        Starts and stops the debug probe process within this scope.
44        """
45        try:
46            self.start()
47            yield
48        finally:
49            self.stop()
class ProbeBackend:
11class ProbeBackend:
12    """
13    Base class for starting and stopping debug probes and attaching GDB to them.
14    """
15    def __init__(self, remote: str = None):
16        """
17        :param remote: Extended remote location.
18        """
19        self.remote = remote
20        self.name = "remote"
21
22    def init(self, elf: Path) -> list[str]:
23        """
24        Returns a list of GDB commands that connect GDB to the debug probe.
25        The default implementation returns `target extended-remote {self.remote}`.
26        """
27        return ["target extended-remote {}".format(self.remote)] if self.remote else []
28
29    def start(self):
30        """
31        Starts the debug probe as a non-blocking subprocess.
32        """
33        pass
34
35    def stop(self):
36        """
37        Halts the debug probe process.
38        """
39        pass
40
41    @contextmanager
42    def scope(self):
43        """
44        Starts and stops the debug probe process within this scope.
45        """
46        try:
47            self.start()
48            yield
49        finally:
50            self.stop()

Base class for starting and stopping debug probes and attaching GDB to them.

ProbeBackend(remote: str = None)
15    def __init__(self, remote: str = None):
16        """
17        :param remote: Extended remote location.
18        """
19        self.remote = remote
20        self.name = "remote"
Parameters
  • remote: Extended remote location.
remote
name
def init(self, elf: pathlib.Path) -> list[str]:
22    def init(self, elf: Path) -> list[str]:
23        """
24        Returns a list of GDB commands that connect GDB to the debug probe.
25        The default implementation returns `target extended-remote {self.remote}`.
26        """
27        return ["target extended-remote {}".format(self.remote)] if self.remote else []

Returns a list of GDB commands that connect GDB to the debug probe. The default implementation returns target extended-remote {self.remote}.

def start(self):
29    def start(self):
30        """
31        Starts the debug probe as a non-blocking subprocess.
32        """
33        pass

Starts the debug probe as a non-blocking subprocess.

def stop(self):
35    def stop(self):
36        """
37        Halts the debug probe process.
38        """
39        pass

Halts the debug probe process.

@contextmanager
def scope(self):
41    @contextmanager
42    def scope(self):
43        """
44        Starts and stops the debug probe process within this scope.
45        """
46        try:
47            self.start()
48            yield
49        finally:
50            self.stop()

Starts and stops the debug probe process within this scope.