From 0e324cad0a37bdaa0aebb864c3da28b25ad1ebf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 25 May 2011 15:08:31 -0400 Subject: [PATCH] Dead code. --- src/rt/rust_crate_reader.cpp | 171 +---------------------------------- src/rt/rust_internal.h | 69 -------------- 2 files changed, 1 insertion(+), 239 deletions(-) diff --git a/src/rt/rust_crate_reader.cpp b/src/rt/rust_crate_reader.cpp index 9462e36a7c6..bee15f50048 100644 --- a/src/rt/rust_crate_reader.cpp +++ b/src/rt/rust_crate_reader.cpp @@ -1,104 +1,6 @@ #include "rust_internal.h" -bool -rust_crate_reader::mem_reader::is_ok() -{ - return ok; -} - -bool -rust_crate_reader::mem_reader::at_end() -{ - return pos == mem.lim; -} - -void -rust_crate_reader::mem_reader::fail() -{ - ok = false; -} - -void -rust_crate_reader::mem_reader::reset() -{ - pos = mem.base; - ok = true; -} - -rust_crate_reader::mem_reader::mem_reader(rust_crate::mem_area &m) - : mem(m), - ok(true), - pos(m.base) -{} - -size_t -rust_crate_reader::mem_reader::tell_abs() -{ - return pos; -} - -size_t -rust_crate_reader::mem_reader::tell_off() -{ - return pos - mem.base; -} - -void -rust_crate_reader::mem_reader::seek_abs(uintptr_t p) -{ - if (!ok || p < mem.base || p >= mem.lim) - ok = false; - else - pos = p; -} - -void -rust_crate_reader::mem_reader::seek_off(uintptr_t p) -{ - seek_abs(p + mem.base); -} - - -bool -rust_crate_reader::mem_reader::adv_zstr(size_t sz) -{ - sz = 0; - while (ok) { - char c = 0; - get(c); - ++sz; - if (c == '\0') - return true; - } - return false; -} - -bool -rust_crate_reader::mem_reader::get_zstr(char const *&c, size_t &sz) -{ - if (!ok) - return false; - c = (char const *)(pos); - return adv_zstr(sz); -} - -void -rust_crate_reader::mem_reader::adv(size_t amt) -{ - if (pos < mem.base - || pos >= mem.lim - || pos + amt > mem.lim) - ok = false; - if (!ok) - return; - // mem.DLOG(dom, mem, "adv %d bytes", amt); - pos += amt; - ok &= !at_end(); - I(mem.dom, at_end() || (mem.base <= pos && pos < mem.lim)); -} - - rust_crate_reader::abbrev::abbrev(rust_dom *dom, uintptr_t body_off, size_t body_sz, @@ -111,72 +13,6 @@ rust_crate_reader::abbrev::abbrev(rust_dom *dom, idx(0) {} - -rust_crate_reader::abbrev_reader::abbrev_reader - (rust_crate::mem_area &abbrev_mem) - : mem_reader(abbrev_mem), - abbrevs(abbrev_mem.dom) -{ - rust_dom *dom = mem.dom; - while (is_ok() && !at_end()) { - - // DLOG(dom, dwarf, "reading new abbrev at 0x%" PRIxPTR, - // tell_off()); - - uintptr_t idx, tag; - uint8_t has_children = 0; - get_uleb(idx); - get_uleb(tag); - get(has_children); - - uintptr_t attr, form; - size_t body_off = tell_off(); - while (is_ok() && step_attr_form_pair(attr, form)); - - // DLOG(dom, dwarf, - // "finished scanning attr/form pairs, pos=0x%" - // PRIxPTR ", lim=0x%" PRIxPTR ", is_ok=%d, at_end=%d", - // pos, mem.lim, is_ok(), at_end()); - - if (is_ok() || at_end()) { - DLOG(dom, dwarf, "read abbrev: %" PRIdPTR, idx); - I(dom, idx = abbrevs.length() + 1); - abbrevs.push(new (dom) abbrev(dom, body_off, - tell_off() - body_off, - tag, has_children)); - } - } -} - -rust_crate_reader::abbrev * -rust_crate_reader::abbrev_reader::get_abbrev(size_t i) { - i -= 1; - if (i < abbrevs.length()) - return abbrevs[i]; - return NULL; -} - -bool -rust_crate_reader::abbrev_reader::step_attr_form_pair(uintptr_t &attr, - uintptr_t &form) -{ - attr = 0; - form = 0; - // mem.DLOG(dom, dwarf, "reading attr/form pair at 0x%" PRIxPTR, - // tell_off()); - get_uleb(attr); - get_uleb(form); - // mem.DLOG(dom, dwarf, "attr 0x%" PRIxPTR ", form 0x%" PRIxPTR, - // attr, form); - return ! (attr == 0 && form == 0); -} -rust_crate_reader::abbrev_reader::~abbrev_reader() { - while (abbrevs.length()) { - delete abbrevs.pop(); - } -} - - bool rust_crate_reader::attr::is_numeric() const { @@ -227,14 +63,9 @@ rust_crate_reader::attr::is_unknown() const { 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)) + : dom(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); } diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index 53d0e336a31..0f8b10c2bb1 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -312,60 +312,6 @@ public: class rust_crate_reader { - struct mem_reader - { - rust_crate::mem_area &mem; - bool ok; - uintptr_t pos; - - bool is_ok(); - bool at_end(); - void fail(); - void reset(); - mem_reader(rust_crate::mem_area &m); - size_t tell_abs(); - size_t tell_off(); - void seek_abs(uintptr_t p); - void seek_off(uintptr_t p); - - template - void get(T &out) { - if (pos < mem.base - || pos >= mem.lim - || pos + sizeof(T) > mem.lim) - ok = false; - if (!ok) - return; - out = *((T*)(pos)); - pos += sizeof(T); - ok &= !at_end(); - I(mem.dom, at_end() || (mem.base <= pos && pos < mem.lim)); - } - - template - void get_uleb(T &out) { - out = T(0); - for (size_t i = 0; i < sizeof(T) && ok; ++i) { - uint8_t byte = 0; - get(byte); - out <<= 7; - out |= byte & 0x7f; - if (!(byte & 0x80)) - break; - } - I(mem.dom, at_end() || (mem.base <= pos && pos < mem.lim)); - } - - template - void adv_sizeof(T &) { - adv(sizeof(T)); - } - - bool adv_zstr(size_t sz); - bool get_zstr(char const *&c, size_t &sz); - void adv(size_t amt); - }; - struct abbrev : dom_owned { @@ -379,24 +325,9 @@ rust_crate_reader uintptr_t tag, uint8_t has_children); }; - class - abbrev_reader : public mem_reader - { - ptr_vec abbrevs; - public: - abbrev_reader(rust_crate::mem_area &abbrev_mem); - abbrev *get_abbrev(size_t i); - bool step_attr_form_pair(uintptr_t &attr, uintptr_t &form); - ~abbrev_reader(); - }; - rust_dom *dom; size_t idx; - rust_crate::mem_area abbrev_mem; - abbrev_reader abbrevs; - - rust_crate::mem_area die_mem; public: