mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-15 20:58:13 +01:00
Fix compiler warnings on x86_64
This commit is contained in:
parent
af9daf66af
commit
491d576529
5 changed files with 128 additions and 118 deletions
|
@ -178,6 +178,11 @@ typedef sigset_t intrmask_t;
|
||||||
|
|
||||||
extern intrmask_t unwi_full_mask;
|
extern intrmask_t unwi_full_mask;
|
||||||
|
|
||||||
|
/* Silence compiler warnings about variables which are used only if libunwind
|
||||||
|
is configured in a certain way */
|
||||||
|
static inline void mark_as_used(void *v) {
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_BLOCK_SIGNALS)
|
#if defined(CONFIG_BLOCK_SIGNALS)
|
||||||
# define SIGPROCMASK(how, new_mask, old_mask) \
|
# define SIGPROCMASK(how, new_mask, old_mask) \
|
||||||
sigprocmask((how), (new_mask), (old_mask))
|
sigprocmask((how), (new_mask), (old_mask))
|
||||||
|
@ -191,11 +196,13 @@ extern intrmask_t unwi_full_mask;
|
||||||
#define lock_acquire(l,m) \
|
#define lock_acquire(l,m) \
|
||||||
do { \
|
do { \
|
||||||
SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &(m)); \
|
SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &(m)); \
|
||||||
|
mark_as_used(&(m)); \
|
||||||
mutex_lock (l); \
|
mutex_lock (l); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define lock_release(l,m) \
|
#define lock_release(l,m) \
|
||||||
do { \
|
do { \
|
||||||
mutex_unlock (l); \
|
mutex_unlock (l); \
|
||||||
|
mark_as_used(&(m)); \
|
||||||
SIGPROCMASK (SIG_SETMASK, &(m), NULL); \
|
SIGPROCMASK (SIG_SETMASK, &(m), NULL); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -272,10 +279,10 @@ do { \
|
||||||
# define Dprintf(format...)
|
# define Dprintf(format...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ALWAYS_INLINE void
|
static ALWAYS_INLINE int
|
||||||
print_error (const char *string)
|
print_error (const char *string)
|
||||||
{
|
{
|
||||||
write (2, string, strlen (string));
|
return write (2, string, strlen (string));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define mi_init UNWI_ARCH_OBJ(mi_init)
|
#define mi_init UNWI_ARCH_OBJ(mi_init)
|
||||||
|
|
|
@ -416,7 +416,6 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
|
||||||
struct dwarf_eh_frame_hdr *hdr;
|
struct dwarf_eh_frame_hdr *hdr;
|
||||||
unw_accessors_t *a;
|
unw_accessors_t *a;
|
||||||
long n;
|
long n;
|
||||||
struct unw_debug_frame_list *fdesc = 0;
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
ip = cb_data->ip;
|
ip = cb_data->ip;
|
||||||
|
@ -576,139 +575,141 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FRAME
|
#ifdef CONFIG_DEBUG_FRAME
|
||||||
|
{
|
||||||
|
struct unw_debug_frame_list *fdesc = 0;
|
||||||
|
Debug (15, "Trying to find .debug_frame\n");
|
||||||
|
di = &cb_data->di_debug;
|
||||||
|
fdesc = locate_debug_info (unw_local_addr_space, info, ip, info->dlpi_name);
|
||||||
|
|
||||||
Debug (15, "Trying to find .debug_frame\n");
|
if (!fdesc)
|
||||||
di = &cb_data->di_debug;
|
{
|
||||||
fdesc = locate_debug_info (unw_local_addr_space, info, ip, info->dlpi_name);
|
Debug (15, "couldn't load .debug_frame\n");
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
size_t bufsize;
|
||||||
|
unw_word_t item_start, item_end = 0;
|
||||||
|
uint32_t u32val = 0;
|
||||||
|
uint64_t cie_id = 0;
|
||||||
|
struct debug_frame_tab *tab;
|
||||||
|
|
||||||
if (!fdesc)
|
Debug (15, "loaded .debug_frame\n");
|
||||||
{
|
|
||||||
Debug (15, "couldn't load .debug_frame\n");
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *buf;
|
|
||||||
size_t bufsize;
|
|
||||||
unw_word_t item_start, item_end = 0;
|
|
||||||
uint32_t u32val = 0;
|
|
||||||
uint64_t cie_id = 0;
|
|
||||||
struct debug_frame_tab *tab;
|
|
||||||
|
|
||||||
Debug (15, "loaded .debug_frame\n");
|
buf = fdesc->debug_frame;
|
||||||
|
bufsize = fdesc->debug_frame_size;
|
||||||
|
|
||||||
buf = fdesc->debug_frame;
|
if (bufsize == 0)
|
||||||
bufsize = fdesc->debug_frame_size;
|
{
|
||||||
|
Debug (15, "zero-length .debug_frame\n");
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
if (bufsize == 0)
|
/* Now create a binary-search table, if it does not already exist. */
|
||||||
{
|
if (!fdesc->index)
|
||||||
Debug (15, "zero-length .debug_frame\n");
|
{
|
||||||
return found;
|
addr = (unw_word_t) (uintptr_t) buf;
|
||||||
}
|
|
||||||
|
|
||||||
/* Now create a binary-search table, if it does not already exist. */
|
a = unw_get_accessors (unw_local_addr_space);
|
||||||
if (!fdesc->index)
|
|
||||||
{
|
|
||||||
addr = (unw_word_t) (uintptr_t) buf;
|
|
||||||
|
|
||||||
a = unw_get_accessors (unw_local_addr_space);
|
/* Find all FDE entries in debug_frame, and make into a sorted
|
||||||
|
index. */
|
||||||
|
|
||||||
/* Find all FDE entries in debug_frame, and make into a sorted
|
tab = debug_frame_tab_new (16);
|
||||||
index. */
|
|
||||||
|
|
||||||
tab = debug_frame_tab_new (16);
|
while (addr < (unw_word_t) (uintptr_t) (buf + bufsize))
|
||||||
|
{
|
||||||
|
uint64_t id_for_cie;
|
||||||
|
item_start = addr;
|
||||||
|
|
||||||
while (addr < (unw_word_t) (uintptr_t) (buf + bufsize))
|
dwarf_readu32 (unw_local_addr_space, a, &addr, &u32val, NULL);
|
||||||
{
|
|
||||||
uint64_t id_for_cie;
|
|
||||||
item_start = addr;
|
|
||||||
|
|
||||||
dwarf_readu32 (unw_local_addr_space, a, &addr, &u32val, NULL);
|
if (u32val == 0)
|
||||||
|
break;
|
||||||
|
else if (u32val != 0xffffffff)
|
||||||
|
{
|
||||||
|
uint32_t cie_id32 = 0;
|
||||||
|
item_end = addr + u32val;
|
||||||
|
dwarf_readu32 (unw_local_addr_space, a, &addr, &cie_id32,
|
||||||
|
NULL);
|
||||||
|
cie_id = cie_id32;
|
||||||
|
id_for_cie = 0xffffffff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint64_t u64val = 0;
|
||||||
|
/* Extended length. */
|
||||||
|
dwarf_readu64 (unw_local_addr_space, a, &addr, &u64val, NULL);
|
||||||
|
item_end = addr + u64val;
|
||||||
|
|
||||||
if (u32val == 0)
|
dwarf_readu64 (unw_local_addr_space, a, &addr, &cie_id, NULL);
|
||||||
break;
|
id_for_cie = 0xffffffffffffffffull;
|
||||||
else if (u32val != 0xffffffff)
|
}
|
||||||
{
|
|
||||||
uint32_t cie_id32 = 0;
|
|
||||||
item_end = addr + u32val;
|
|
||||||
dwarf_readu32 (unw_local_addr_space, a, &addr, &cie_id32,
|
|
||||||
NULL);
|
|
||||||
cie_id = cie_id32;
|
|
||||||
id_for_cie = 0xffffffff;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint64_t u64val = 0;
|
|
||||||
/* Extended length. */
|
|
||||||
dwarf_readu64 (unw_local_addr_space, a, &addr, &u64val, NULL);
|
|
||||||
item_end = addr + u64val;
|
|
||||||
|
|
||||||
dwarf_readu64 (unw_local_addr_space, a, &addr, &cie_id, NULL);
|
/*Debug (1, "CIE/FDE id = %.8x\n", (int) cie_id);*/
|
||||||
id_for_cie = 0xffffffffffffffffull;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Debug (1, "CIE/FDE id = %.8x\n", (int) cie_id);*/
|
if (cie_id == id_for_cie)
|
||||||
|
;
|
||||||
|
/*Debug (1, "Found CIE at %.8x.\n", item_start);*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unw_word_t fde_addr = item_start;
|
||||||
|
unw_proc_info_t this_pi;
|
||||||
|
int err;
|
||||||
|
|
||||||
if (cie_id == id_for_cie)
|
/*Debug (1, "Found FDE at %.8x\n", item_start);*/
|
||||||
;
|
|
||||||
/*Debug (1, "Found CIE at %.8x.\n", item_start);*/
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unw_word_t fde_addr = item_start;
|
|
||||||
unw_proc_info_t this_pi;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
/*Debug (1, "Found FDE at %.8x\n", item_start);*/
|
err = dwarf_extract_proc_info_from_fde (unw_local_addr_space,
|
||||||
|
a, &fde_addr,
|
||||||
|
&this_pi, 0,
|
||||||
|
(uintptr_t) buf,
|
||||||
|
NULL);
|
||||||
|
if (err == 0)
|
||||||
|
{
|
||||||
|
Debug (15, "start_ip = %x, end_ip = %x\n",
|
||||||
|
(int) this_pi.start_ip, (int) this_pi.end_ip);
|
||||||
|
debug_frame_tab_append (tab,
|
||||||
|
item_start - (unw_word_t) (uintptr_t) buf,
|
||||||
|
this_pi.start_ip);
|
||||||
|
}
|
||||||
|
/*else
|
||||||
|
Debug (1, "FDE parse failed\n");*/
|
||||||
|
}
|
||||||
|
|
||||||
err = dwarf_extract_proc_info_from_fde (unw_local_addr_space,
|
addr = item_end;
|
||||||
a, &fde_addr,
|
}
|
||||||
&this_pi, 0,
|
|
||||||
(uintptr_t) buf,
|
|
||||||
NULL);
|
|
||||||
if (err == 0)
|
|
||||||
{
|
|
||||||
Debug (15, "start_ip = %x, end_ip = %x\n",
|
|
||||||
(int) this_pi.start_ip, (int) this_pi.end_ip);
|
|
||||||
debug_frame_tab_append (tab,
|
|
||||||
item_start - (unw_word_t) (uintptr_t) buf,
|
|
||||||
this_pi.start_ip);
|
|
||||||
}
|
|
||||||
/*else
|
|
||||||
Debug (1, "FDE parse failed\n");*/
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = item_end;
|
debug_frame_tab_shrink (tab);
|
||||||
}
|
qsort (tab->tab, tab->length, sizeof (struct table_entry),
|
||||||
|
debug_frame_tab_compare);
|
||||||
|
/* for (i = 0; i < tab->length; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ip %x, fde offset %x\n",
|
||||||
|
(int) tab->tab[i].start_ip_offset,
|
||||||
|
(int) tab->tab[i].fde_offset);
|
||||||
|
}*/
|
||||||
|
fdesc->index = tab->tab;
|
||||||
|
fdesc->index_size = tab->length;
|
||||||
|
free (tab);
|
||||||
|
}
|
||||||
|
|
||||||
debug_frame_tab_shrink (tab);
|
di->format = UNW_INFO_FORMAT_TABLE;
|
||||||
qsort (tab->tab, tab->length, sizeof (struct table_entry),
|
di->start_ip = fdesc->start;
|
||||||
debug_frame_tab_compare);
|
di->end_ip = fdesc->end;
|
||||||
/* for (i = 0; i < tab->length; i++)
|
di->u.ti.name_ptr = (unw_word_t) (uintptr_t) info->dlpi_name;
|
||||||
{
|
di->u.ti.table_data = (unw_word_t *) fdesc;
|
||||||
fprintf (stderr, "ip %x, fde offset %x\n",
|
di->u.ti.table_len = sizeof (*fdesc) / sizeof (unw_word_t);
|
||||||
(int) tab->tab[i].start_ip_offset,
|
di->u.ti.segbase = (unw_word_t) (uintptr_t) info->dlpi_addr;
|
||||||
(int) tab->tab[i].fde_offset);
|
|
||||||
}*/
|
|
||||||
fdesc->index = tab->tab;
|
|
||||||
fdesc->index_size = tab->length;
|
|
||||||
free (tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
di->format = UNW_INFO_FORMAT_TABLE;
|
found = 1;
|
||||||
di->start_ip = fdesc->start;
|
Debug (15, "found debug_frame table `%s': segbase=0x%lx, len=%lu, "
|
||||||
di->end_ip = fdesc->end;
|
"gp=0x%lx, table_data=0x%lx\n",
|
||||||
di->u.ti.name_ptr = (unw_word_t) (uintptr_t) info->dlpi_name;
|
(char *) (uintptr_t) di->u.ti.name_ptr,
|
||||||
di->u.ti.table_data = (unw_word_t *) fdesc;
|
(long) di->u.ti.segbase, (long) di->u.ti.table_len,
|
||||||
di->u.ti.table_len = sizeof (*fdesc) / sizeof (unw_word_t);
|
(long) di->gp, (long) di->u.ti.table_data);
|
||||||
di->u.ti.segbase = (unw_word_t) (uintptr_t) info->dlpi_addr;
|
}
|
||||||
|
}
|
||||||
found = 1;
|
|
||||||
Debug (15, "found debug_frame table `%s': segbase=0x%lx, len=%lu, "
|
|
||||||
"gp=0x%lx, table_data=0x%lx\n",
|
|
||||||
(char *) (uintptr_t) di->u.ti.name_ptr,
|
|
||||||
(long) di->u.ti.segbase, (long) di->u.ti.table_len,
|
|
||||||
(long) di->gp, (long) di->u.ti.table_data);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_DEBUG_FRAME */
|
#endif /* CONFIG_DEBUG_FRAME */
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
|
|
|
@ -29,7 +29,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
HIDDEN int
|
HIDDEN int
|
||||||
dwarf_step (struct dwarf_cursor *c)
|
dwarf_step (struct dwarf_cursor *c)
|
||||||
{
|
{
|
||||||
unw_word_t prev_cfa = c->cfa;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = dwarf_find_save_locs (c)) >= 0) {
|
if ((ret = dwarf_find_save_locs (c)) >= 0) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
|
||||||
{
|
{
|
||||||
Debug (8, "resuming at ip=%llx via setcontext()\n",
|
Debug (8, "resuming at ip=%llx via setcontext()\n",
|
||||||
(unsigned long long) c->dwarf.ip);
|
(unsigned long long) c->dwarf.ip);
|
||||||
_Ux86_64_setcontext (uc);
|
setcontext (uc);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# warning Implement me!
|
# warning Implement me!
|
||||||
|
|
|
@ -58,6 +58,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
#define x86_64_lock UNW_OBJ(lock)
|
#define x86_64_lock UNW_OBJ(lock)
|
||||||
#define x86_64_local_resume UNW_OBJ(local_resume)
|
#define x86_64_local_resume UNW_OBJ(local_resume)
|
||||||
#define x86_64_local_addr_space_init UNW_OBJ(local_addr_space_init)
|
#define x86_64_local_addr_space_init UNW_OBJ(local_addr_space_init)
|
||||||
|
#define setcontext UNW_ARCH_OBJ (setcontext)
|
||||||
#if 0
|
#if 0
|
||||||
#define x86_64_scratch_loc UNW_OBJ(scratch_loc)
|
#define x86_64_scratch_loc UNW_OBJ(scratch_loc)
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,6 +66,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
extern void x86_64_local_addr_space_init (void);
|
extern void x86_64_local_addr_space_init (void);
|
||||||
extern int x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor,
|
extern int x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
extern int setcontext (const ucontext_t *ucp);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
extern dwarf_loc_t x86_64_scratch_loc (struct cursor *c, unw_regnum_t reg);
|
extern dwarf_loc_t x86_64_scratch_loc (struct cursor *c, unw_regnum_t reg);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue