Ejemplo n.º 1
0
bool StackTraceBase::Addr2line(const char *filename, const char *address,
                           Frame *frame, void *adata,
                           void *bfds, unsigned bfds_size) {
  Lock lock(s_bfdMutex);
  addr2line_data *data = reinterpret_cast<addr2line_data*>(adata);
  data->filename = nullptr;
  data->functionname = nullptr;
  data->line = 0;
  bool ret;

  if (!bfds) {
    bfd_cache_ptr p = get_bfd_cache(filename);
    if (!p) return false;
    data->syms = p->syms;
    ret = translate_addresses(p->abfd, address, data);
  } else {
    // don't let bfd_cache_ptr malloc behind the scenes in this case
    bfd_cache *q = get_bfd_cache(filename, (NamedBfd*)bfds, bfds_size);
    if (!q) return false;
    data->syms = q->syms;
    ret = translate_addresses(q->abfd, address, data);
  }

  if (ret) {
    frame->lineno = data->line;
  }
  return ret;
}
Ejemplo n.º 2
0
bool StackTraceBase::Addr2line(const char *filename, const char *address,
                           Frame *frame, void *adata) {
#ifndef MAC_OS_X
  Lock lock(s_bfdMutex);
  addr2line_data *data = reinterpret_cast<addr2line_data*>(adata);
  bfd_cache_ptr p = get_bfd_cache(filename);
  if (!p) return false;

  data->filename = NULL;
  data->functionname = NULL;
  data->line = 0;
  data->syms = p->syms;
  bool ret = translate_addresses(p->abfd, address, data);
  if (ret) {
    frame->lineno = data->line;
  }
  return ret;
#else
  return false;
#endif
}