__init__.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. __version__ = '0.4-dev'
  17. from abc import abstractmethod
  18. class ESPCoreDumpError(RuntimeError):
  19. pass
  20. class ESPCoreDumpLoaderError(ESPCoreDumpError):
  21. pass
  22. class _TargetMethodsBase(object):
  23. @staticmethod
  24. @abstractmethod
  25. def tcb_is_sane(tcb_addr, tcb_size):
  26. """
  27. Check tcb address if it is correct
  28. """
  29. return False
  30. @staticmethod
  31. @abstractmethod
  32. def stack_is_sane(sp):
  33. """
  34. Check stack address if it is correct
  35. """
  36. return False
  37. @staticmethod
  38. @abstractmethod
  39. def addr_is_fake(addr):
  40. """
  41. Check if address is in fake area
  42. """
  43. return False
  44. class _ArchMethodsBase(object):
  45. @staticmethod
  46. @abstractmethod
  47. def get_registers_from_stack(data, grows_down):
  48. """
  49. Returns list of registers (in GDB format) from stack frame
  50. """
  51. return [], {}
  52. @staticmethod
  53. @abstractmethod
  54. def build_prstatus_data(tcb_addr, task_regs):
  55. return b''