1#
2# Copyright 2021 Espressif Systems (Shanghai) PTE LTD
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17__version__ = '0.4-dev'
18
19from abc import abstractmethod
20
21
22class ESPCoreDumpError(RuntimeError):
23    pass
24
25
26class ESPCoreDumpLoaderError(ESPCoreDumpError):
27    pass
28
29
30class _TargetMethodsBase(object):
31    @staticmethod
32    @abstractmethod
33    def tcb_is_sane(tcb_addr, tcb_size):
34        """
35        Check tcb address if it is correct
36        """
37        return False
38
39    @staticmethod
40    @abstractmethod
41    def stack_is_sane(sp):
42        """
43        Check stack address if it is correct
44        """
45        return False
46
47    @staticmethod
48    @abstractmethod
49    def addr_is_fake(addr):
50        """
51        Check if address is in fake area
52        """
53        return False
54
55
56class _ArchMethodsBase(object):
57    @staticmethod
58    @abstractmethod
59    def get_registers_from_stack(data, grows_down):
60        """
61        Returns list of registers (in GDB format) from stack frame
62        """
63        return [], {}
64
65    @staticmethod
66    @abstractmethod
67    def build_prstatus_data(tcb_addr, task_regs):
68        return b''
69