about summary refs log tree commit diff
path: root/src/rt/rust_crate_reader.cpp
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <respindola@mozilla.com>2011-05-25 14:12:09 -0400
committerRafael Ávila de Espíndola <respindola@mozilla.com>2011-05-25 14:12:09 -0400
commit9a3624466b1a1ff0908be0efdaca631f9a3bab7a (patch)
tree47cf073c84ea4cb57fa61d89fb005f5690c6f4b4 /src/rt/rust_crate_reader.cpp
parent2306fb19f21921194175d3204eb59f094264e782 (diff)
downloadrust-9a3624466b1a1ff0908be0efdaca631f9a3bab7a.tar.gz
rust-9a3624466b1a1ff0908be0efdaca631f9a3bab7a.zip
Dead code.
Diffstat (limited to 'src/rt/rust_crate_reader.cpp')
-rw-r--r--src/rt/rust_crate_reader.cpp347
1 files changed, 1 insertions, 346 deletions
diff --git a/src/rt/rust_crate_reader.cpp b/src/rt/rust_crate_reader.cpp
index bf8e96c10aa..9462e36a7c6 100644
--- a/src/rt/rust_crate_reader.cpp
+++ b/src/rt/rust_crate_reader.cpp
@@ -225,361 +225,16 @@ rust_crate_reader::attr::is_unknown() const {
   return !(is_numeric() || is_string());
 }
 
-rust_crate_reader::rdr_sess::rdr_sess(die_reader *rdr) : rdr(rdr)
-{
-  I(rdr->mem.dom, !rdr->in_use);
-  rdr->in_use = true;
-}
-
-rust_crate_reader::rdr_sess::~rdr_sess()
-{
-  rdr->in_use = false;
-}
-
-rust_crate_reader::die::die(die_reader *rdr, uintptr_t off)
-  : rdr(rdr),
-    off(off),
-    using_rdr(false)
-{
-  rust_dom *dom = rdr->mem.dom;
-  rdr_sess use(rdr);
-
-  rdr->reset();
-  rdr->seek_off(off);
-  if (!rdr->is_ok()) {
-    ab = NULL;
-    return;
-  }
-  size_t ab_idx;
-  rdr->get_uleb(ab_idx);
-  if (!ab_idx) {
-    ab = NULL;
-    DLOG(dom, dwarf, "DIE <0x%" PRIxPTR "> (null)", off);
-  } else {
-    ab = rdr->abbrevs.get_abbrev(ab_idx);
-    if (!ab) {
-        DLOG(dom, dwarf, "  bad abbrev number: 0x%"
-                 PRIxPTR, ab_idx);
-        rdr->fail();
-    } else {
-        DLOG(dom, dwarf, "DIE <0x%" PRIxPTR "> abbrev 0x%"
-                 PRIxPTR, off, ab_idx);
-        DLOG(dom, dwarf, "  tag 0x%x, has children: %d",
-                 ab->tag, ab->has_children);
-    }
-  }
-}
-
-bool
-rust_crate_reader::die::is_null() const
-{
-  return ab == NULL;
-}
-
-bool
-rust_crate_reader::die::has_children() const
-{
-  return (!is_null()) && ab->has_children;
-}
-
-dw_tag
-rust_crate_reader::die::tag() const
-{
-  if (is_null())
-    return (dw_tag) (-1);
-  return (dw_tag) ab->tag;
-}
-
-bool
-rust_crate_reader::die::start_attrs() const
-{
-  if (is_null())
-    return false;
-  rdr->reset();
-  rdr->seek_off(off + 1);
-  rdr->abbrevs.reset();
-  rdr->abbrevs.seek_off(ab->body_off);
-  return rdr->is_ok();
-}
-
-bool
-rust_crate_reader::die::step_attr(attr &a) const
-{
-  uintptr_t ai, fi;
-  if (rdr->abbrevs.step_attr_form_pair(ai, fi) && rdr->is_ok()) {
-    a.at = (dw_at)ai;
-    a.form = (dw_form)fi;
-
-    uint32_t u32 = 0;
-    uint8_t u8 = 0;
-
-    switch (a.form) {
-    case DW_FORM_string:
-      return rdr->get_zstr(a.val.str.s, a.val.str.sz);
-      break;
-
-    case DW_FORM_ref_addr:
-      I(rdr->mem.dom, sizeof(uintptr_t) == 4);
-    case DW_FORM_addr:
-    case DW_FORM_data4:
-      rdr->get(u32);
-      a.val.num = (uintptr_t)u32;
-      return rdr->is_ok() || rdr->at_end();
-      break;
-
-    case DW_FORM_data1:
-    case DW_FORM_flag:
-      rdr->get(u8);
-      a.val.num = u8;
-      return rdr->is_ok() || rdr->at_end();
-      break;
-
-    case DW_FORM_block1:
-      rdr->get(u8);
-      rdr->adv(u8);
-      return rdr->is_ok() || rdr->at_end();
-      break;
-
-    case DW_FORM_block4:
-      rdr->get(u32);
-      rdr->adv(u32);
-      return rdr->is_ok() || rdr->at_end();
-      break;
-
-    case DW_FORM_udata:
-      rdr->get_uleb(u32);
-      return rdr->is_ok() || rdr->at_end();
-      break;
-
-    default:
-      DLOG(rdr->mem.dom, dwarf, "  unknown dwarf form: 0x%"
-                        PRIxPTR, a.form);
-      rdr->fail();
-      break;
-    }
-  }
-  return false;
-}
-
-bool
-rust_crate_reader::die::find_str_attr(dw_at at, char const *&c)
-{
-  rdr_sess use(rdr);
-  if (is_null())
-    return false;
-  if (start_attrs()) {
-    attr a;
-    while (step_attr(a)) {
-      if (a.at == at && a.is_string()) {
-        c = a.get_str(rdr->mem.dom);
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
-bool
-rust_crate_reader::die::find_num_attr(dw_at at, uintptr_t &n)
-{
-  rdr_sess use(rdr);
-  if (is_null())
-    return false;
-  if (start_attrs()) {
-    attr a;
-    while (step_attr(a)) {
-      if (a.at == at && a.is_numeric()) {
-        n = a.get_num(rdr->mem.dom);
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
-bool
-rust_crate_reader::die::is_transparent()
-{
-  // "semantically transparent" DIEs are those with
-  // children that serve to structure the tree but have
-  // tags that don't reflect anything in the rust-module
-  // name hierarchy.
-  switch (tag()) {
-  case DW_TAG_compile_unit:
-  case DW_TAG_lexical_block:
-    return (has_children());
-  default:
-    break;
-  }
-  return false;
-}
-
-bool
-rust_crate_reader::die::find_child_by_name(char const *c,
-                                                       die &child,
-                                                       bool exact)
-{
-  rust_dom *dom = rdr->mem.dom;
-  I(dom, has_children());
-  I(dom, !is_null());
-
-  for (die ch = next(); !ch.is_null(); ch = ch.next_sibling()) {
-    char const *ac;
-    if (!exact && ch.is_transparent()) {
-      if (ch.find_child_by_name(c, child, exact)) {
-        return true;
-      }
-    }
-    else if (ch.find_str_attr(DW_AT_name, ac)) {
-      if (strcmp(ac, c) == 0) {
-        child = ch;
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
-bool
-rust_crate_reader::die::find_child_by_tag(dw_tag tag, die &child)
-{
-  rust_dom *dom = rdr->mem.dom;
-  I(dom, has_children());
-  I(dom, !is_null());
-
-  for (child = next(); !child.is_null();
-       child = child.next_sibling()) {
-    if (child.tag() == tag)
-      return true;
-  }
-  return false;
-}
-
-rust_crate_reader::die
-rust_crate_reader::die::next() const
-{
-  rust_dom *dom = rdr->mem.dom;
-
-  if (is_null()) {
-    rdr->seek_off(off + 1);
-    return die(rdr, rdr->tell_off());
-  }
-
-  {
-    rdr_sess use(rdr);
-    if (start_attrs()) {
-        attr a;
-        while (step_attr(a)) {
-            I(dom, !(a.is_numeric() && a.is_string()));
-            if (a.is_numeric())
-                DLOG(dom, dwarf, "  attr num: 0x%"
-                         PRIxPTR, a.get_num(dom));
-            else if (a.is_string())
-                DLOG(dom, dwarf, "  attr str: %s",
-                         a.get_str(dom));
-            else
-                DLOG(dom, dwarf, "  attr ??:");
-        }
-    }
-  }
-  return die(rdr, rdr->tell_off());
-}
-
-rust_crate_reader::die
-rust_crate_reader::die::next_sibling() const
-{
-  // FIXME: use DW_AT_sibling, when present.
-  if (has_children()) {
-    // DLOG(rdr->mem.dom, dwarf, "+++ children of die 0x%"
-    //                   PRIxPTR, off);
-    die child = next();
-    while (!child.is_null())
-      child = child.next_sibling();
-    // DLOG(rdr->mem.dom, dwarf, "--- children of die 0x%"
-    //                   PRIxPTR, off);
-    return child.next();
-  } else {
-    return next();
-  }
-}
-
-
-rust_crate_reader::die
-rust_crate_reader::die_reader::first_die()
-{
-  reset();
-  seek_off(cu_base
-           + sizeof(dwarf_vers)
-           + sizeof(cu_abbrev_off)
-           + sizeof(sizeof_addr));
-  return die(this, tell_off());
-}
-
-void
-rust_crate_reader::die_reader::dump()
-{
-  rust_dom *dom = mem.dom;
-  die d = first_die();
-  while (!d.is_null())
-    d = d.next_sibling();
-  I(dom, d.is_null());
-  I(dom, d.off == mem.lim - mem.base);
-}
-
-
-rust_crate_reader::die_reader::die_reader(rust_crate::mem_area &die_mem,
-                              abbrev_reader &abbrevs)
-  : mem_reader(die_mem),
-    abbrevs(abbrevs),
-    cu_unit_length(0),
-    cu_base(0),
-    dwarf_vers(0),
-    cu_abbrev_off(0),
-    sizeof_addr(0),
-    in_use(false)
-{
-  rust_dom *dom = mem.dom;
-
-  rdr_sess use(this);
-
-  get(cu_unit_length);
-  cu_base = tell_off();
-
-  get(dwarf_vers);
-  get(cu_abbrev_off);
-  get(sizeof_addr);
-
-  if (is_ok()) {
-    DLOG(dom, dwarf, "new root CU at 0x%" PRIxPTR, die_mem.base);
-    DLOG(dom, dwarf, "CU unit length: %" PRId32, cu_unit_length);
-    DLOG(dom, dwarf, "dwarf version: %" PRId16, dwarf_vers);
-    DLOG(dom, dwarf, "CU abbrev off: %" PRId32, cu_abbrev_off);
-    DLOG(dom, dwarf, "size of address: %" PRId8, sizeof_addr);
-    I(dom, sizeof_addr == sizeof(uintptr_t));
-    I(dom, dwarf_vers >= 2);
-    I(dom, cu_base + cu_unit_length == die_mem.lim - die_mem.base);
-  } else {
-    DLOG(dom, dwarf, "failed to read root CU header");
-  }
-}
-
-rust_crate_reader::die_reader::~die_reader() {
-}
-
-
 rust_crate_reader::rust_crate_reader(rust_dom *dom,
                                      rust_crate const *crate)
   : dom(dom),
     abbrev_mem(crate->get_debug_abbrev(dom)),
     abbrevs(abbrev_mem),
-    die_mem(crate->get_debug_info(dom)),
-    dies(die_mem, abbrevs)
+    die_mem(crate->get_debug_info(dom))
 {
   DLOG(dom, mem, "crate_reader on crate: 0x%" PRIxPTR, this);
   DLOG(dom, mem, "debug_abbrev: 0x%" PRIxPTR, abbrev_mem.base);
   DLOG(dom, mem, "debug_info: 0x%" PRIxPTR, die_mem.base);
-  // For now, perform diagnostics only.
-  dies.dump();
 }