diff options
| author | Peter Zotov <whitequark@whitequark.org> | 2015-11-09 06:57:29 +0000 |
|---|---|---|
| committer | Peter Zotov <whitequark@whitequark.org> | 2015-11-09 06:57:29 +0000 |
| commit | b0342a66a005b72d42bdbf858969c208c08595ca (patch) | |
| tree | 6d457896c5fdd3881a8412fc9fdfb7f3d6863769 /libunwind/src/UnwindCursor.hpp | |
| parent | 7a6e292d865f5e510648bb1928bbbd7ea3026b40 (diff) | |
| download | bcm5719-llvm-b0342a66a005b72d42bdbf858969c208c08595ca.tar.gz bcm5719-llvm-b0342a66a005b72d42bdbf858969c208c08595ca.zip | |
Make it possible to use libunwind without heap.
This patch allows to use libunwind on bare-metal systems that do not
include malloc/free by conditionally turning off nonessential
functionality that requires these functions.
The disabled functionality includes:
* the .cfi_remember_state and .cfi_restore_state instructions;
* the DWARF FDE cache.
The .cfi_{remember,restore}_state instructions don't seem to be used
by contemporary compilers. None of the LLVM backends emit it.
The DWARF FDE cache is bypassed if _LIBUNWIND_NO_HEAP is defined.
Specifically, entries are never added to it, so the search begins
and ends at the statically allocated, empty initial cache.
Such heap-less libunwind on a bare metal system is successfully used
in the ARTIQ project[1], and it is my hope that it will be useful
elsewhere.
[1]: http://m-labs.hk/artiq
Differential Revision: http://reviews.llvm.org/D11897
llvm-svn: 252452
Diffstat (limited to 'libunwind/src/UnwindCursor.hpp')
| -rw-r--r-- | libunwind/src/UnwindCursor.hpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 040d13e9256..90683164ff2 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -114,6 +114,7 @@ typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { template <typename A> void DwarfFDECache<A>::add(pint_t mh, pint_t ip_start, pint_t ip_end, pint_t fde) { +#if !defined(_LIBUNWIND_NO_HEAP) _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_wrlock(&_lock)); if (_bufferUsed >= _bufferEnd) { size_t oldSize = (size_t)(_bufferEnd - _buffer); @@ -139,6 +140,7 @@ void DwarfFDECache<A>::add(pint_t mh, pint_t ip_start, pint_t ip_end, } #endif _LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock)); +#endif } template <typename A> |

