Class: RDwarf::DIE::Base
- Inherits:
-
Object
- Object
- RDwarf::DIE::Base
- Defined in:
- lib/rdwarf.rb,
ext/rdwarf/rdwarf.c
Instance Method Summary collapse
- #attributes ⇒ Object
- #children ⇒ Object
- #die_cu_offset ⇒ Object
- #die_offset ⇒ Object
- #dump(padding = '') ⇒ Object
- #inspect ⇒ Object
- #name ⇒ Object
- #source_files ⇒ Object
- #tag_name ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#attributes ⇒ Object
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'ext/rdwarf/rdwarf.c', line 453
static VALUE rd_die_attributes(VALUE self)
{
rd_die_t *die = GetDie(self);
Dwarf_Attribute *list;
Dwarf_Signed count;
Dwarf_Error err;
Dwarf_Signed idx;
VALUE top;
VALUE cu;
VALUE ary;
if (die->attributes != Qfalse) {
return die->attributes;
}
top = rb_ivar_get(self, id_at_top);
cu = rb_ivar_get(self, id_at_cu);
if (chkerr2(dwarf_attrlist(die->die, &list, &count, &err), &err)) {
ary = rb_ary_new_capa(count);
for (idx = 0; idx < count; idx++) {
rb_ary_store(ary, idx, rd_attr_new(die->shared_data, top, cu, list[idx]));
}
} else {
ary = rb_ary_new();
}
die->attributes = ary;
return ary;
}
|
#children ⇒ Object
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'ext/rdwarf/rdwarf.c', line 428
static VALUE rd_die_children(VALUE self)
{
rd_die_t *die = GetDie(self);
VALUE top;
VALUE cu;
VALUE ary;
Dwarf_Die child;
Dwarf_Error err;
if (die->children != Qfalse) {
return die->children;
}
top = rb_ivar_get(self, id_at_top);
cu = rb_ivar_get(self, id_at_cu);
ary = rb_ary_new();
if (chkerr2(dwarf_child(die->die, &child, &err), &err)) {
do {
rb_ary_push(ary, rd_die_new(die->shared_data, top, cu, child));
} while (chkerr2(dwarf_siblingof(die->shared_data->dbg, child, &child, &err), &err));
}
die->children = ary;
return ary;
}
|
#die_cu_offset ⇒ Object
418 419 420 421 422 423 424 425 426 |
# File 'ext/rdwarf/rdwarf.c', line 418
static VALUE rd_die_die_cu_offset(VALUE self)
{
rd_die_t *die = GetDie(self);
Dwarf_Off off;
Dwarf_Error err;
chkerr1(dwarf_die_CU_offset(die->die, &off, &err), &err, self);
return LL2NUM(off);
}
|
#die_offset ⇒ Object
408 409 410 411 412 413 414 415 416 |
# File 'ext/rdwarf/rdwarf.c', line 408
static VALUE rd_die_die_offset(VALUE self)
{
rd_die_t *die = GetDie(self);
Dwarf_Off off;
Dwarf_Error err;
chkerr1(dwarf_dieoffset(die->die, &off, &err), &err, self);
return LL2NUM(off);
}
|
#dump(padding = '') ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rdwarf.rb', line 62 def dump(padding = '') s = [] s << "#{padding}#{self}" if attributes.size != 0 s << "#{padding} attributes:" attributes.each do |attr| s << attr.dump(padding + ' ') end end if source_files s << "#{padding} source_files:" source_files.each_with_index do |file, idx| s << "#{padding} #{idx + 1}: #{file}" end end if children.size != 0 s << "#{padding} children:" children.each do |child| s << child.dump(padding + ' ') end end s.join("\n") end |
#inspect ⇒ Object
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'ext/rdwarf/rdwarf.c', line 510
static VALUE rd_die_inspect(VALUE self)
{
rd_die_t *die = GetDie(self);
char *name;
Dwarf_Off dieoff = 0;
Dwarf_Error err;
dwarf_dieoffset(die->die, &dieoff, &err);
switch (dwarf_diename(die->die, &name, &err)) {
case DW_DLV_OK:
return rb_sprintf("#<%s:(%llu) '%s'>", rb_obj_classname(self), dieoff, name);
default:
return rb_sprintf("#<%s:(%llu)>", rb_obj_classname(self), dieoff);
}
}
|
#name ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'ext/rdwarf/rdwarf.c', line 385
static VALUE rd_die_name(VALUE self)
{
rd_die_t *die = GetDie(self);
char *name;
Dwarf_Error err;
if (chkerr2(dwarf_diename(die->die, &name, &err), &err)) {
return rb_enc_str_new_cstr(name, rb_usascii_encoding());
} else {
return Qnil;
}
}
|
#source_files ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'ext/rdwarf/rdwarf.c', line 482
static VALUE rd_die_source_files(VALUE self)
{
rd_die_t *die = GetDie(self);
Dwarf_Signed cnt = 0;
char **srcfiles = 0;
Dwarf_Error err;
VALUE files = Qnil;
if (die->srcfiles != Qfalse) {
return die->srcfiles;
}
if (chkerr2(dwarf_srcfiles(die->die, &srcfiles, &cnt, &err), &err)) {
int i;
files = rb_ary_new_capa(cnt);
for (i = 0; i < cnt; i++) {
VALUE file = rb_str_new_cstr(srcfiles[i]);
OBJ_FREEZE(file);
rb_ary_store(files, i, file);
dwarf_dealloc(die->shared_data->dbg, srcfiles[i], DW_DLA_STRING);
}
dwarf_dealloc(die->shared_data->dbg, srcfiles, DW_DLA_LIST);
}
die->srcfiles = files;
return files;
}
|
#tag_name ⇒ Object
398 399 400 401 402 403 404 405 406 |
# File 'ext/rdwarf/rdwarf.c', line 398
static VALUE rd_die_tag_name(VALUE self)
{
rd_die_t *die = GetDie(self);
Dwarf_Half tag = 0;
Dwarf_Error err;
chkerr1(dwarf_tag(die->die, &tag, &err), &err, self);
return rb_hash_aref(rdwarf_tag2name, INT2FIX(tag));
}
|
#to_s ⇒ Object
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'ext/rdwarf/rdwarf.c', line 510
static VALUE rd_die_inspect(VALUE self)
{
rd_die_t *die = GetDie(self);
char *name;
Dwarf_Off dieoff = 0;
Dwarf_Error err;
dwarf_dieoffset(die->die, &dieoff, &err);
switch (dwarf_diename(die->die, &name, &err)) {
case DW_DLV_OK:
return rb_sprintf("#<%s:(%llu) '%s'>", rb_obj_classname(self), dieoff, name);
default:
return rb_sprintf("#<%s:(%llu)>", rb_obj_classname(self), dieoff);
}
}
|