diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-07-10 11:38:31 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-07-10 11:38:31 -0700 |
commit | a7cdbea0f43f3c59bf3137efb9fead4238072d01 (patch) | |
tree | 051059b3e7848c7736346adfa20f46ca43638762 /libdw/dwarf_entry_breakpoints.c | |
parent | 101941576c52a1270c9c2d63ea95d48729d6cf96 (diff) | |
download | android_external_elfutils-cm-10.1.tar.gz android_external_elfutils-cm-10.1.tar.bz2 android_external_elfutils-cm-10.1.zip |
Add support for clang:cm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1
elfutils seems to exclusively use a gcc extension, nested functions.
clang does not implement this extension, but does have a similar
feature, blocks.
They both function in essentially the same way: closures in C.
Change-Id: I75aba2a37145ef3942d4f1b2019949cfbbdc55a9
Diffstat (limited to 'libdw/dwarf_entry_breakpoints.c')
-rw-r--r-- | libdw/dwarf_entry_breakpoints.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libdw/dwarf_entry_breakpoints.c b/libdw/dwarf_entry_breakpoints.c index 578464f3..f6baaf6f 100644 --- a/libdw/dwarf_entry_breakpoints.c +++ b/libdw/dwarf_entry_breakpoints.c @@ -60,11 +60,19 @@ dwarf_entry_breakpoints (die, bkpts) Dwarf_Die *die; Dwarf_Addr **bkpts; { +#ifdef __clang__ + __block int nbkpts = 0; +#else int nbkpts = 0; +#endif *bkpts = NULL; /* Add one breakpoint location to the result vector. */ +#ifdef __clang__ + int (^add_bkpt) (Dwarf_Addr) = ^int (Dwarf_Addr pc) +#else inline int add_bkpt (Dwarf_Addr pc) +#endif { Dwarf_Addr *newlist = realloc (*bkpts, ++nbkpts * sizeof newlist[0]); if (newlist == NULL) @@ -77,14 +85,18 @@ dwarf_entry_breakpoints (die, bkpts) newlist[nbkpts - 1] = pc; *bkpts = newlist; return nbkpts; - } + }; /* Fallback result, break at the entrypc/lowpc value. */ +#ifdef __clang__ + int (^entrypc_bkpt) (void) = ^int (void) +#else inline int entrypc_bkpt (void) +#endif { Dwarf_Addr pc; return INTUSE(dwarf_entrypc) (die, &pc) < 0 ? -1 : add_bkpt (pc); - } + }; /* Fetch the CU's line records to look for this DIE's addresses. */ Dwarf_Die cudie = CUDIE (die->cu); @@ -102,8 +114,14 @@ dwarf_entry_breakpoints (die, bkpts) /* Search a contiguous PC range for prologue-end markers. If DWARF, look for proper markers. Failing that, if ADHOC, look for the ad hoc convention. */ +#ifdef __clang__ + int (^search_range) (Dwarf_Addr, Dwarf_Addr, + bool, bool) = ^int (Dwarf_Addr low, Dwarf_Addr high, + bool dwarf, bool adhoc) +#else inline int search_range (Dwarf_Addr low, Dwarf_Addr high, bool dwarf, bool adhoc) +#endif { size_t l = 0, u = nlines; while (l < u) @@ -136,7 +154,7 @@ dwarf_entry_breakpoints (die, bkpts) } __libdw_seterrno (DWARF_E_INVALID_DWARF); return -1; - } + }; /* Search each contiguous address range for DWARF prologue_end markers. */ |