Class: RDwarf::Attribute::Base
- Inherits:
-
Object
- Object
- RDwarf::Attribute::Base
- Defined in:
- lib/rdwarf.rb,
ext/rdwarf/rdwarf.c
Direct Known Subclasses
CallFile, DataMemberLocation, DeclFile, Encoding, HighPc, Inline, Language, Location, LowPc
Instance Method Summary collapse
- #dump(padding = '') ⇒ Object
- #form ⇒ Object
- #inspect ⇒ Object
- #raw_value ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #value ⇒ Object
Instance Method Details
#dump(padding = '') ⇒ Object
92 93 94 |
# File 'lib/rdwarf.rb', line 92 def dump(padding = '') "#{padding}#{type}(#{form}): #{value}" end |
#form ⇒ Object
567 568 569 570 571 572 573 574 575 |
# File 'ext/rdwarf/rdwarf.c', line 567
static VALUE rd_attr_form(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
Dwarf_Half form_type;
Dwarf_Error err;
chkerr1(dwarf_whatform(attr->attr, &form_type, &err), &err, self);
return rb_hash_aref(rdwarf_form2name, INT2FIX(form_type));
}
|
#inspect ⇒ Object
626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'ext/rdwarf/rdwarf.c', line 626
static VALUE rd_attr_inspect(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
Dwarf_Half form;
Dwarf_Error err;
const char *form_name = "?";
if (dwarf_whatform(attr->attr, &form, &err) == DW_DLV_OK) {
dwarf_get_FORM_name(form, &form_name);
}
return rb_sprintf("#<%s: %s>", rb_obj_classname(self), form_name);
}
|
#raw_value ⇒ Object
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'ext/rdwarf/rdwarf.c', line 577
static VALUE rd_attr_raw_value(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
Dwarf_Half form;
Dwarf_Error err;
union {
Dwarf_Addr addr;
Dwarf_Off off;
Dwarf_Unsigned udata;
Dwarf_Signed sdata;
Dwarf_Bool bool;
char *str;
} val;
VALUE top;
chkerr1(dwarf_whatform(attr->attr, &form, &err), &err, self);
switch (form) {
case DW_FORM_addr:
chkerr1(dwarf_formaddr(attr->attr, &val.addr, &err), &err, self);
return ULL2NUM(val.addr);
case DW_FORM_ref1:
case DW_FORM_ref2:
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
chkerr1(dwarf_global_formref(attr->attr, &val.off, &err), &err, self);
top = rb_ivar_get(self, id_at_top);
return rdwarf_die_at(top, LL2NUM(val.off));
case DW_FORM_data1:
case DW_FORM_data2:
case DW_FORM_data4:
case DW_FORM_data8:
case DW_FORM_udata:
chkerr1(dwarf_formudata(attr->attr, &val.udata, &err), &err, self);
return ULL2NUM(val.udata);
case DW_FORM_sdata:
chkerr1(dwarf_formsdata(attr->attr, &val.sdata, &err), &err, self);
return LL2NUM(val.sdata);
case DW_FORM_flag:
chkerr1(dwarf_formflag(attr->attr, &val.bool, &err), &err, self);
return val.bool ? Qtrue : Qfalse;
case DW_FORM_strp:
case DW_FORM_string:
chkerr1(dwarf_formstring(attr->attr, &val.str, &err), &err, self);
return rb_str_new_cstr(val.str);
}
return sym_unsupported_type;
}
|
#to_s ⇒ Object
626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'ext/rdwarf/rdwarf.c', line 626
static VALUE rd_attr_inspect(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
Dwarf_Half form;
Dwarf_Error err;
const char *form_name = "?";
if (dwarf_whatform(attr->attr, &form, &err) == DW_DLV_OK) {
dwarf_get_FORM_name(form, &form_name);
}
return rb_sprintf("#<%s: %s>", rb_obj_classname(self), form_name);
}
|
#type ⇒ Object
561 562 563 564 565 |
# File 'ext/rdwarf/rdwarf.c', line 561
static VALUE rd_attr_type(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
return rb_hash_aref(rdwarf_at2name, INT2FIX(attr->attr_type));
}
|
#value ⇒ Object
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'ext/rdwarf/rdwarf.c', line 577
static VALUE rd_attr_raw_value(VALUE self)
{
rd_attr_t *attr = GetAttr(self);
Dwarf_Half form;
Dwarf_Error err;
union {
Dwarf_Addr addr;
Dwarf_Off off;
Dwarf_Unsigned udata;
Dwarf_Signed sdata;
Dwarf_Bool bool;
char *str;
} val;
VALUE top;
chkerr1(dwarf_whatform(attr->attr, &form, &err), &err, self);
switch (form) {
case DW_FORM_addr:
chkerr1(dwarf_formaddr(attr->attr, &val.addr, &err), &err, self);
return ULL2NUM(val.addr);
case DW_FORM_ref1:
case DW_FORM_ref2:
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
chkerr1(dwarf_global_formref(attr->attr, &val.off, &err), &err, self);
top = rb_ivar_get(self, id_at_top);
return rdwarf_die_at(top, LL2NUM(val.off));
case DW_FORM_data1:
case DW_FORM_data2:
case DW_FORM_data4:
case DW_FORM_data8:
case DW_FORM_udata:
chkerr1(dwarf_formudata(attr->attr, &val.udata, &err), &err, self);
return ULL2NUM(val.udata);
case DW_FORM_sdata:
chkerr1(dwarf_formsdata(attr->attr, &val.sdata, &err), &err, self);
return LL2NUM(val.sdata);
case DW_FORM_flag:
chkerr1(dwarf_formflag(attr->attr, &val.bool, &err), &err, self);
return val.bool ? Qtrue : Qfalse;
case DW_FORM_strp:
case DW_FORM_string:
chkerr1(dwarf_formstring(attr->attr, &val.str, &err), &err, self);
return rb_str_new_cstr(val.str);
}
return sym_unsupported_type;
}
|