Skip to content

Commit

Permalink
Fix up compilation and test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun Sharma committed Mar 25, 2011
1 parent 44a14d1 commit 7ff83c0
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ tests/test-proc-info
tests/test-ptrace-misc
tests/test-varargs
tests/test-static-link
tests/[GL]test-trace
2 changes: 1 addition & 1 deletion include/libunwind-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ unw_tdep_frame_t;
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
extern int unw_tdep_is_fpreg (int);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
3 changes: 0 additions & 3 deletions include/libunwind-common.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ unw_save_loc_t;
#define unw_regname UNW_ARCH_OBJ(regname)
#define unw_flush_cache UNW_ARCH_OBJ(flush_cache)
#define unw_strerror UNW_ARCH_OBJ(strerror)
#define unw_backtrace UNW_OBJ(backtrace)

extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int);
extern void unw_destroy_addr_space (unw_addr_space_t);
Expand All @@ -254,6 +253,4 @@ extern int unw_handle_signal_frame (unw_cursor_t *);
extern int unw_get_proc_name (unw_cursor_t *, char *, size_t, unw_word_t *);
extern const char *unw_strerror (int);

extern int unw_backtrace (void **buffer, int size);

extern unw_addr_space_t unw_local_addr_space;
2 changes: 1 addition & 1 deletion include/libunwind-hppa.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ unw_tdep_proc_info_t;
#define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext)
extern int unw_tdep_getcontext (unw_tdep_context_t *);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion include/libunwind-ia64.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ extern unw_word_t _Uia64_find_dyn_list (unw_addr_space_t, unw_dyn_info_t *,
signal-safe. */
extern int _Uia64_get_kernel_table (unw_dyn_info_t *);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion include/libunwind-mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ extern int unw_tdep_getcontext (ucontext_t *uc);
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
extern int unw_tdep_is_fpreg (int);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion include/libunwind-ppc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ unw_tdep_frame_t;
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
extern int unw_tdep_is_fpreg (int);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion include/libunwind-ppc64.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ unw_tdep_frame_t;
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
extern int unw_tdep_is_fpreg (int);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion include/libunwind-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ extern int unw_tdep_getcontext (unw_tdep_context_t *);
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
extern int unw_tdep_is_fpreg (int);

#define unw_tdep_trace(cur,addr,n,c) (-UNW_ENOINFO)
#define unw_tdep_trace(cur,addr,n) (-UNW_ENOINFO)

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
47 changes: 33 additions & 14 deletions src/mi/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,51 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

/* See glibc manual for a description of this function. */

static inline int
slow_backtrace (void **buffer, int size)
{
unw_cursor_t cursor;
unw_context_t uc;
unw_word_t ip;
int n = 0;

unw_getcontext (&uc);
if (unw_init_local (&cursor, &uc) < 0)
return 0;

while (unw_step (&cursor) > 0)
{
if (n >= size)
return n;

if (unw_get_reg (&cursor, UNW_REG_IP, &ip) < 0)
return n;
buffer[n++] = (void *) (uintptr_t) ip;
}
return n;
}

int
unw_backtrace (void **buffer, int size)
backtrace (void **buffer, int size)
{
unw_cursor_t cursor;
unw_context_t uc, ucsave;
unw_context_t uc;
int n = size;
int ret;

unw_getcontext (&uc);
memcpy (&ucsave, &uc, sizeof(uc));

if (unw_init_local (&cursor, &uc) < 0)
return 0;

/* We don't need backtrace() to show up in buffer */
ret = unw_step (&cursor);
if (ret < 0)
return ret;

if (unw_tdep_trace (&cursor, buffer, &n) < 0)
{
n = 0;
unw_init_local (&cursor, &ucsave);
while (n < size)
{
unw_word_t ip;
if (unw_get_reg (&cursor, UNW_REG_IP, &ip) < 0)
return n;
buffer[n++] = (void *) (uintptr_t) ip;
if (unw_step (&cursor) <= 0)
break;
}
return slow_backtrace(buffer, size);
}

return n;
Expand Down
13 changes: 1 addition & 12 deletions tests/Gtest-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ char buf[512], name[256];
void *addresses[2][128];
unw_cursor_t cursor;
ucontext_t uc;
#if UNW_TARGET_X86_64
unw_tdep_frame_t *cache;
#endif

static void
do_backtrace (void)
Expand All @@ -73,7 +70,7 @@ do_backtrace (void)
panic ("unw_init_local failed!\n");

#if UNW_TARGET_X86_64
if ((ret = unw_tdep_trace (&cursor, addresses[0], &depth, cache)) < 0)
if ((ret = unw_tdep_trace (&cursor, addresses[0], &depth)) < 0)
{
unw_get_reg (&cursor, UNW_REG_IP, &ip);
printf ("FAILURE: unw_tdep_trace() returned %d for ip=%lx\n", ret, (long) ip);
Expand Down Expand Up @@ -211,10 +208,6 @@ main (int argc, char **argv)
struct sigaction act;
stack_t stk;

#if UNW_TARGET_X86_64
cache = unw_tdep_make_frame_cache (0);
#endif

verbose = (argc > 1);

if (verbose)
Expand Down Expand Up @@ -255,10 +248,6 @@ main (int argc, char **argv)
exit (-1);
}

#if UNW_TARGET_X86_64
unw_tdep_free_frame_cache (cache);
#endif

if (verbose)
printf ("SUCCESS.\n");
return 0;
Expand Down
3 changes: 3 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Gtest_exc_LDADD = $(LIBUNWIND)
Gtest_init_LDADD = $(LIBUNWIND)
Gtest_resume_sig_LDADD = $(LIBUNWIND)
Gperf_simple_LDADD = $(LIBUNWIND)
Gtest_trace_LDADD=$(LIBUNWIND)

Ltest_bt_LDADD = $(LIBUNWIND_local)
Ltest_concurrent_LDADD = $(LIBUNWIND_local) -lpthread
Expand All @@ -145,6 +146,8 @@ Ltest_init_LDADD = $(LIBUNWIND_local)
Ltest_nomalloc_LDADD = $(LIBUNWIND_local) @DLLIB@
Ltest_resume_sig_LDADD = $(LIBUNWIND)
Lperf_simple_LDADD = $(LIBUNWIND_local)
Ltest_trace_LDADD = $(LIBUNWIND_local)

test_setjmp_LDADD = $(LIBUNWIND_setjmp)
ia64_test_setjmp_LDADD = $(LIBUNWIND_setjmp)

4 changes: 0 additions & 4 deletions tests/check-namespace.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ check_local_unw_abi () {
match _U${plat}_is_fpreg
match _UL${plat}_dwarf_search_unwind_table
match _U${plat}_setcontext
match _UL${plat}_free_frame_cache
match _UL${plat}_make_frame_cache
match _UL${plat}_trace
;;
*)
Expand Down Expand Up @@ -189,8 +187,6 @@ check_generic_unw_abi () {
match _U${plat}_get_elf_image
match _U${plat}_is_fpreg
match _U${plat}_dwarf_search_unwind_table
match _U${plat}_free_frame_cache
match _U${plat}_make_frame_cache
match _U${plat}_trace
;;
*)
Expand Down

0 comments on commit 7ff83c0

Please sign in to comment.