Skip to content

Commit 9a36244

Browse files
committed
Dead code.
1 parent 2306fb1 commit 9a36244

File tree

2 files changed

+1
-398
lines changed

2 files changed

+1
-398
lines changed

src/rt/rust_crate_reader.cpp

Lines changed: 1 addition & 346 deletions
Original file line numberDiff line numberDiff line change
@@ -225,361 +225,16 @@ rust_crate_reader::attr::is_unknown() const {
225225
return !(is_numeric() || is_string());
226226
}
227227

228-
rust_crate_reader::rdr_sess::rdr_sess(die_reader *rdr) : rdr(rdr)
229-
{
230-
I(rdr->mem.dom, !rdr->in_use);
231-
rdr->in_use = true;
232-
}
233-
234-
rust_crate_reader::rdr_sess::~rdr_sess()
235-
{
236-
rdr->in_use = false;
237-
}
238-
239-
rust_crate_reader::die::die(die_reader *rdr, uintptr_t off)
240-
: rdr(rdr),
241-
off(off),
242-
using_rdr(false)
243-
{
244-
rust_dom *dom = rdr->mem.dom;
245-
rdr_sess use(rdr);
246-
247-
rdr->reset();
248-
rdr->seek_off(off);
249-
if (!rdr->is_ok()) {
250-
ab = NULL;
251-
return;
252-
}
253-
size_t ab_idx;
254-
rdr->get_uleb(ab_idx);
255-
if (!ab_idx) {
256-
ab = NULL;
257-
DLOG(dom, dwarf, "DIE <0x%" PRIxPTR "> (null)", off);
258-
} else {
259-
ab = rdr->abbrevs.get_abbrev(ab_idx);
260-
if (!ab) {
261-
DLOG(dom, dwarf, " bad abbrev number: 0x%"
262-
PRIxPTR, ab_idx);
263-
rdr->fail();
264-
} else {
265-
DLOG(dom, dwarf, "DIE <0x%" PRIxPTR "> abbrev 0x%"
266-
PRIxPTR, off, ab_idx);
267-
DLOG(dom, dwarf, " tag 0x%x, has children: %d",
268-
ab->tag, ab->has_children);
269-
}
270-
}
271-
}
272-
273-
bool
274-
rust_crate_reader::die::is_null() const
275-
{
276-
return ab == NULL;
277-
}
278-
279-
bool
280-
rust_crate_reader::die::has_children() const
281-
{
282-
return (!is_null()) && ab->has_children;
283-
}
284-
285-
dw_tag
286-
rust_crate_reader::die::tag() const
287-
{
288-
if (is_null())
289-
return (dw_tag) (-1);
290-
return (dw_tag) ab->tag;
291-
}
292-
293-
bool
294-
rust_crate_reader::die::start_attrs() const
295-
{
296-
if (is_null())
297-
return false;
298-
rdr->reset();
299-
rdr->seek_off(off + 1);
300-
rdr->abbrevs.reset();
301-
rdr->abbrevs.seek_off(ab->body_off);
302-
return rdr->is_ok();
303-
}
304-
305-
bool
306-
rust_crate_reader::die::step_attr(attr &a) const
307-
{
308-
uintptr_t ai, fi;
309-
if (rdr->abbrevs.step_attr_form_pair(ai, fi) && rdr->is_ok()) {
310-
a.at = (dw_at)ai;
311-
a.form = (dw_form)fi;
312-
313-
uint32_t u32 = 0;
314-
uint8_t u8 = 0;
315-
316-
switch (a.form) {
317-
case DW_FORM_string:
318-
return rdr->get_zstr(a.val.str.s, a.val.str.sz);
319-
break;
320-
321-
case DW_FORM_ref_addr:
322-
I(rdr->mem.dom, sizeof(uintptr_t) == 4);
323-
case DW_FORM_addr:
324-
case DW_FORM_data4:
325-
rdr->get(u32);
326-
a.val.num = (uintptr_t)u32;
327-
return rdr->is_ok() || rdr->at_end();
328-
break;
329-
330-
case DW_FORM_data1:
331-
case DW_FORM_flag:
332-
rdr->get(u8);
333-
a.val.num = u8;
334-
return rdr->is_ok() || rdr->at_end();
335-
break;
336-
337-
case DW_FORM_block1:
338-
rdr->get(u8);
339-
rdr->adv(u8);
340-
return rdr->is_ok() || rdr->at_end();
341-
break;
342-
343-
case DW_FORM_block4:
344-
rdr->get(u32);
345-
rdr->adv(u32);
346-
return rdr->is_ok() || rdr->at_end();
347-
break;
348-
349-
case DW_FORM_udata:
350-
rdr->get_uleb(u32);
351-
return rdr->is_ok() || rdr->at_end();
352-
break;
353-
354-
default:
355-
DLOG(rdr->mem.dom, dwarf, " unknown dwarf form: 0x%"
356-
PRIxPTR, a.form);
357-
rdr->fail();
358-
break;
359-
}
360-
}
361-
return false;
362-
}
363-
364-
bool
365-
rust_crate_reader::die::find_str_attr(dw_at at, char const *&c)
366-
{
367-
rdr_sess use(rdr);
368-
if (is_null())
369-
return false;
370-
if (start_attrs()) {
371-
attr a;
372-
while (step_attr(a)) {
373-
if (a.at == at && a.is_string()) {
374-
c = a.get_str(rdr->mem.dom);
375-
return true;
376-
}
377-
}
378-
}
379-
return false;
380-
}
381-
382-
bool
383-
rust_crate_reader::die::find_num_attr(dw_at at, uintptr_t &n)
384-
{
385-
rdr_sess use(rdr);
386-
if (is_null())
387-
return false;
388-
if (start_attrs()) {
389-
attr a;
390-
while (step_attr(a)) {
391-
if (a.at == at && a.is_numeric()) {
392-
n = a.get_num(rdr->mem.dom);
393-
return true;
394-
}
395-
}
396-
}
397-
return false;
398-
}
399-
400-
bool
401-
rust_crate_reader::die::is_transparent()
402-
{
403-
// "semantically transparent" DIEs are those with
404-
// children that serve to structure the tree but have
405-
// tags that don't reflect anything in the rust-module
406-
// name hierarchy.
407-
switch (tag()) {
408-
case DW_TAG_compile_unit:
409-
case DW_TAG_lexical_block:
410-
return (has_children());
411-
default:
412-
break;
413-
}
414-
return false;
415-
}
416-
417-
bool
418-
rust_crate_reader::die::find_child_by_name(char const *c,
419-
die &child,
420-
bool exact)
421-
{
422-
rust_dom *dom = rdr->mem.dom;
423-
I(dom, has_children());
424-
I(dom, !is_null());
425-
426-
for (die ch = next(); !ch.is_null(); ch = ch.next_sibling()) {
427-
char const *ac;
428-
if (!exact && ch.is_transparent()) {
429-
if (ch.find_child_by_name(c, child, exact)) {
430-
return true;
431-
}
432-
}
433-
else if (ch.find_str_attr(DW_AT_name, ac)) {
434-
if (strcmp(ac, c) == 0) {
435-
child = ch;
436-
return true;
437-
}
438-
}
439-
}
440-
return false;
441-
}
442-
443-
bool
444-
rust_crate_reader::die::find_child_by_tag(dw_tag tag, die &child)
445-
{
446-
rust_dom *dom = rdr->mem.dom;
447-
I(dom, has_children());
448-
I(dom, !is_null());
449-
450-
for (child = next(); !child.is_null();
451-
child = child.next_sibling()) {
452-
if (child.tag() == tag)
453-
return true;
454-
}
455-
return false;
456-
}
457-
458-
rust_crate_reader::die
459-
rust_crate_reader::die::next() const
460-
{
461-
rust_dom *dom = rdr->mem.dom;
462-
463-
if (is_null()) {
464-
rdr->seek_off(off + 1);
465-
return die(rdr, rdr->tell_off());
466-
}
467-
468-
{
469-
rdr_sess use(rdr);
470-
if (start_attrs()) {
471-
attr a;
472-
while (step_attr(a)) {
473-
I(dom, !(a.is_numeric() && a.is_string()));
474-
if (a.is_numeric())
475-
DLOG(dom, dwarf, " attr num: 0x%"
476-
PRIxPTR, a.get_num(dom));
477-
else if (a.is_string())
478-
DLOG(dom, dwarf, " attr str: %s",
479-
a.get_str(dom));
480-
else
481-
DLOG(dom, dwarf, " attr ??:");
482-
}
483-
}
484-
}
485-
return die(rdr, rdr->tell_off());
486-
}
487-
488-
rust_crate_reader::die
489-
rust_crate_reader::die::next_sibling() const
490-
{
491-
// FIXME: use DW_AT_sibling, when present.
492-
if (has_children()) {
493-
// DLOG(rdr->mem.dom, dwarf, "+++ children of die 0x%"
494-
// PRIxPTR, off);
495-
die child = next();
496-
while (!child.is_null())
497-
child = child.next_sibling();
498-
// DLOG(rdr->mem.dom, dwarf, "--- children of die 0x%"
499-
// PRIxPTR, off);
500-
return child.next();
501-
} else {
502-
return next();
503-
}
504-
}
505-
506-
507-
rust_crate_reader::die
508-
rust_crate_reader::die_reader::first_die()
509-
{
510-
reset();
511-
seek_off(cu_base
512-
+ sizeof(dwarf_vers)
513-
+ sizeof(cu_abbrev_off)
514-
+ sizeof(sizeof_addr));
515-
return die(this, tell_off());
516-
}
517-
518-
void
519-
rust_crate_reader::die_reader::dump()
520-
{
521-
rust_dom *dom = mem.dom;
522-
die d = first_die();
523-
while (!d.is_null())
524-
d = d.next_sibling();
525-
I(dom, d.is_null());
526-
I(dom, d.off == mem.lim - mem.base);
527-
}
528-
529-
530-
rust_crate_reader::die_reader::die_reader(rust_crate::mem_area &die_mem,
531-
abbrev_reader &abbrevs)
532-
: mem_reader(die_mem),
533-
abbrevs(abbrevs),
534-
cu_unit_length(0),
535-
cu_base(0),
536-
dwarf_vers(0),
537-
cu_abbrev_off(0),
538-
sizeof_addr(0),
539-
in_use(false)
540-
{
541-
rust_dom *dom = mem.dom;
542-
543-
rdr_sess use(this);
544-
545-
get(cu_unit_length);
546-
cu_base = tell_off();
547-
548-
get(dwarf_vers);
549-
get(cu_abbrev_off);
550-
get(sizeof_addr);
551-
552-
if (is_ok()) {
553-
DLOG(dom, dwarf, "new root CU at 0x%" PRIxPTR, die_mem.base);
554-
DLOG(dom, dwarf, "CU unit length: %" PRId32, cu_unit_length);
555-
DLOG(dom, dwarf, "dwarf version: %" PRId16, dwarf_vers);
556-
DLOG(dom, dwarf, "CU abbrev off: %" PRId32, cu_abbrev_off);
557-
DLOG(dom, dwarf, "size of address: %" PRId8, sizeof_addr);
558-
I(dom, sizeof_addr == sizeof(uintptr_t));
559-
I(dom, dwarf_vers >= 2);
560-
I(dom, cu_base + cu_unit_length == die_mem.lim - die_mem.base);
561-
} else {
562-
DLOG(dom, dwarf, "failed to read root CU header");
563-
}
564-
}
565-
566-
rust_crate_reader::die_reader::~die_reader() {
567-
}
568-
569-
570228
rust_crate_reader::rust_crate_reader(rust_dom *dom,
571229
rust_crate const *crate)
572230
: dom(dom),
573231
abbrev_mem(crate->get_debug_abbrev(dom)),
574232
abbrevs(abbrev_mem),
575-
die_mem(crate->get_debug_info(dom)),
576-
dies(die_mem, abbrevs)
233+
die_mem(crate->get_debug_info(dom))
577234
{
578235
DLOG(dom, mem, "crate_reader on crate: 0x%" PRIxPTR, this);
579236
DLOG(dom, mem, "debug_abbrev: 0x%" PRIxPTR, abbrev_mem.base);
580237
DLOG(dom, mem, "debug_info: 0x%" PRIxPTR, die_mem.base);
581-
// For now, perform diagnostics only.
582-
dies.dump();
583238
}
584239

585240

0 commit comments

Comments
 (0)