[asterisk-commits] tilghman: branch tilghman/better_backtrace_1.4 r297950 - /team/tilghman/bette...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 9 02:30:39 CST 2010
Author: tilghman
Date: Thu Dec 9 02:30:31 2010
New Revision: 297950
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=297950
Log:
Progress: we now have module locals. Onto core locals, next.
Modified:
team/tilghman/better_backtrace_1.4/main/logger.c
Modified: team/tilghman/better_backtrace_1.4/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/better_backtrace_1.4/main/logger.c?view=diff&rev=297950&r1=297949&r2=297950
==============================================================================
--- team/tilghman/better_backtrace_1.4/main/logger.c (original)
+++ team/tilghman/better_backtrace_1.4/main/logger.c Thu Dec 9 02:30:31 2010
@@ -842,9 +842,13 @@
long allocsize;
asymbol **syms = NULL;
bfd_vma offset;
+ const char *last_slash;
+#if 0
asection *section;
- const char *last_slash, *file, *func;
+ const char *file, *func;
unsigned int line;
+#endif
+ int j;
#else
char **strings;
#endif
@@ -854,25 +858,23 @@
#if defined(HAVE_DLADDR) && defined(HAVE_BFD)
ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
for (i = 0; i < count; i++) {
- int found = 0;
+ int found = 0, symbolcount;
+ int bestmatch = -1;
+ long bestdiff = LONG_MAX;
if (!dladdr(addresses[i], &dli)) {
continue;
}
+ last_slash = strrchr(dli.dli_fname, '/');
if ( (bfdobj = bfd_openr(dli.dli_fname, NULL)) &&
bfd_check_format(bfdobj, bfd_object) &&
(allocsize = bfd_get_symtab_upper_bound(bfdobj)) > 0 &&
(syms = ast_malloc(allocsize)) &&
- bfd_canonicalize_symtab(bfdobj, syms)) {
-
- if (bfdobj->flags & BSF_DYNAMIC) {
- /* Convert library symbols from absolute address to offset address */
- offset = addresses[i] - dli.dli_fbase;
- } else {
- /* Core asterisk routine */
- offset = addresses[i] - (void *) 0;
- }
-
+ (symbolcount = bfd_canonicalize_symtab(bfdobj, syms))) {
+
+ offset = addresses[i] - dli.dli_fbase;
+
+#if 0
for (section = bfdobj->sections; section; section = section->next) {
if ( !bfd_get_section_flags(bfdobj, section) & SEC_ALLOC ||
section->vma > offset ||
@@ -904,8 +906,26 @@
break;
}
- }
- last_slash = strrchr(dli.dli_fname, '/');
+#else
+ for (j = 0; j < symbolcount; j++) {
+ asymbol *s = syms[j];
+ if (s->value + s->section->vma > offset) {
+ /* Past the symbol we want */
+ continue;
+ }
+ if (offset - (s->value + s->section->vma) < bestdiff) {
+ bestmatch = j;
+ bestdiff = offset - (s->value + s->section->vma);
+ }
+ }
+ found++;
+ ast_log(LOG_DEBUG, "#%d: [%08lX] %s %s (%08lX+%lX) %d\n", i,
+ (unsigned long) addresses[i],
+ last_slash ? last_slash + 1 : dli.dli_fname, syms[bestmatch]->name,
+ (unsigned long) dli.dli_saddr,
+ (unsigned long) (addresses[i] - dli.dli_saddr), j);
+#endif
+ }
if (bfdobj) {
bfd_close(bfdobj);
if (syms) {
More information about the asterisk-commits
mailing list