My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unwinder.cpp 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /***************************************************************************
  2. * ARM Stack Unwinder, Michael.McTernan.2001@cs.bris.ac.uk
  3. * Updated, adapted and several bug fixes on 2018 by Eduardo José Tagle
  4. *
  5. * This program is PUBLIC DOMAIN.
  6. * This means that there is no copyright and anyone is able to take a copy
  7. * for free and use it as they wish, with or without modifications, and in
  8. * any context, commercially or otherwise. The only limitation is that I
  9. * don't guarantee that the software is fit for any purpose or accept any
  10. * liability for its use or misuse - this software is without warranty.
  11. ***************************************************************************
  12. * File Description: Implementation of the interface into the ARM unwinder.
  13. **************************************************************************/
  14. #if defined(__arm__) || defined(__thumb__)
  15. #define MODULE_NAME "UNWINDER"
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include "unwinder.h"
  19. #include "unwarm.h"
  20. #include "unwarmbytab.h"
  21. /* These symbols point to the unwind index and should be provide by the linker script */
  22. extern "C" const UnwTabEntry __exidx_start[];
  23. extern "C" const UnwTabEntry __exidx_end[];
  24. // Detect if unwind information is present or not
  25. static int HasUnwindTableInfo() {
  26. // > 16 because there are default entries we can't supress
  27. return ((char*)(&__exidx_end) - (char*)(&__exidx_start)) > 16 ? 1 : 0;
  28. }
  29. UnwResult UnwindStart(UnwindFrame* frame, const UnwindCallbacks *cb, void *data) {
  30. if (HasUnwindTableInfo()) {
  31. /* We have unwind information tables */
  32. return UnwindByTableStart(frame, cb, data);
  33. }
  34. else {
  35. /* We don't have unwind information tables */
  36. UnwState state;
  37. /* Initialize the unwinding state */
  38. UnwInitState(&state, cb, data, frame->pc, frame->sp);
  39. /* Check the Thumb bit */
  40. return (frame->pc & 0x1) ? UnwStartThumb(&state) : UnwStartArm(&state);
  41. }
  42. }
  43. #endif