*/
#include <config.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "libdwarf_private.h"
0x01, 0x11, 0x01, 0x25, 0x0e, 0x13, 0x0b, 0x03, 0x08, 0x1b,
0x0e, 0x11, 0x01, 0x12, 0x01, 0x10, 0x06, 0x00, 0x00, 0x02,
0x2e, 0x01, 0x3f, 0x0c, 0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b,
0x39, 0x0b, 0x27, 0x0c, 0x11, 0x01, 0x12, 0x01, 0x40, 0x06,
0x97, 0x42, 0x0c, 0x01, 0x13, 0x00, 0x00, 0x03, 0x34, 0x00,
0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b, 0x39, 0x0b, 0x49, 0x13,
0x02, 0x0a, 0x00, 0x00, 0x04, 0x24, 0x00, 0x0b, 0x0b, 0x3e,
0x0b, 0x03, 0x08, 0x00, 0x00, 0x00, };
0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x74, 0x2e, 0x63,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x66, 0x00, 0x01,
0x02, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x69,
0x00, 0x01, 0x03, 0x08, 0x5c, 0x00, 0x00, 0x00, 0x02, 0x91,
0x6c, 0x00, 0x04, 0x04, 0x05, 0x69, 0x6e, 0x74, 0x00, 0x00, };
0x47, 0x4e, 0x55, 0x20, 0x43, 0x31, 0x37, 0x20, 0x39, 0x2e,
0x33, 0x2e, 0x30, 0x20, 0x2d, 0x6d, 0x74, 0x75, 0x6e, 0x65,
0x3d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, 0x2d,
0x6d, 0x61, 0x72, 0x63, 0x68, 0x3d, 0x78, 0x38, 0x36, 0x2d,
0x36, 0x34, 0x20, 0x2d, 0x67, 0x64, 0x77, 0x61, 0x72, 0x66,
0x2d, 0x32, 0x20, 0x2d, 0x4f, 0x30, 0x20, 0x2d, 0x66, 0x61,
0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x6f, 0x75,
0x73, 0x2d, 0x75, 0x6e, 0x77, 0x69, 0x6e, 0x64, 0x2d, 0x74,
0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x2d, 0x66, 0x73, 0x74,
0x61, 0x63, 0x6b, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63,
0x74, 0x6f, 0x72, 0x2d, 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67,
0x20, 0x2d, 0x66, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x63,
0x6c, 0x61, 0x73, 0x68, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2d, 0x66, 0x63, 0x66,
0x2d, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x00, 0x2f, 0x76, 0x61, 0x72, 0x2f, 0x74, 0x6d, 0x70,
0x2f, 0x74, 0x69, 0x6e, 0x79, 0x64, 0x77, 0x61, 0x72, 0x66,
0x00, };
#define SECCOUNT 4
struct sectiondata_s {
unsigned int sd_addr;
unsigned int sd_objoffsetlen;
unsigned int sd_objpointersize;
const char * sd_secname;
};
static struct sectiondata_s sectiondata[SECCOUNT] = {
{0,0,0,0,"",0},
{0,32,32,sizeof(abbrevbytes),".debug_abbrev",abbrevbytes},
{0,32,32,sizeof(infobytes),".debug_info",infobytes},
{0,32,32,sizeof(strbytes),".debug_str",strbytes}
};
typedef struct special_filedata_s {
int f_is_64bit;
unsigned f_pointersize;
unsigned f_offsetsize;
struct sectiondata_s * f_sectarray;
} special_filedata_internals_t;
static special_filedata_internals_t base_internals =
{ FALSE,DW_END_little,32,32,200,SECCOUNT, sectiondata };
static
int gsinfo(void* obj,
int* error )
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
struct sectiondata_s *finfo = 0;
*error = 0;
if (section_index >= SECCOUNT) {
return DW_DLV_NO_ENTRY;
}
finfo = internals->f_sectarray + section_index;
return_section->as_name = finfo->sd_secname;
return_section->as_type = 0;
return_section->as_flags = 0;
return_section->as_addr = finfo->sd_addr;
return_section->as_offset = 0;
return_section->as_size = finfo->sd_sectionsize;
return_section->as_link = 0;
return_section->as_info = 0;
return_section->as_addralign = 0;
return_section->as_entrysize = 1;
return DW_DLV_OK;
}
gborder(void * obj)
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
return internals->f_object_endian;
}
static
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
return internals->f_offsetsize/8;
}
static
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
return internals->f_pointersize/8;
}
static
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
return internals->f_filesize;
}
static
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
return internals->f_sectioncount;
}
static
int gloadsec(void * obj,
int *error)
{
special_filedata_internals_t *internals =
(special_filedata_internals_t *)(obj);
struct sectiondata_s *secp = 0;
*error = 0;
if (secindex >= internals->f_sectioncount) {
return DW_DLV_NO_ENTRY;
}
secp = secindex +internals->f_sectarray;
*rdata = secp->sd_content;
return DW_DLV_OK;
}
gsinfo,
gborder,
glensize,
gptrsize,
gfilesize,
gseccount,
gloadsec,
0
};
{ &base_internals,&methods };
static int
{
switch(form) {
case DW_FORM_string: return TRUE;
case DW_FORM_GNU_strp_alt: return TRUE;
case DW_FORM_GNU_str_index: return TRUE;
case DW_FORM_strx: return TRUE;
case DW_FORM_strx1: return TRUE;
case DW_FORM_strx2: return TRUE;
case DW_FORM_strx3: return TRUE;
case DW_FORM_strx4: return TRUE;
case DW_FORM_strp: return TRUE;
default: break;
};
return FALSE;
}
static int
{
int res = 0;
char *str = 0;
const char *attrname = 0;
const char *formname = 0;
if (res != DW_DLV_OK) {
printf("dwarf_whatform failed! res %d\n",res);
return res;
}
if (res != DW_DLV_OK) {
printf("dwarf_whatattr failed! res %d\n",res);
return res;
}
if (res == DW_DLV_NO_ENTRY) {
printf("Bogus attrnum 0x%x\n",attrnum);
attrname = "<internal error ?>";
}
if (res == DW_DLV_NO_ENTRY) {
printf("Bogus form 0x%x\n",attrnum);
attrname = "<internal error ?>";
}
if (!isformstring(form)) {
printf(" [%2d] Attr: %-15s Form: %-15s\n",
(int)anumber,attrname,formname);
return DW_DLV_OK;
}
if (res != DW_DLV_OK) {
printf("dwarf_formstring failed! res %d\n",res);
return res;
}
printf(" [%2d] Attr: %-15s Form: %-15s %s\n",
(int)anumber,attrname,formname,str);
return DW_DLV_OK;
}
static int
{
const char * tagname = 0;
int res = 0;
if (res != DW_DLV_OK) {
printf("dwarf_tag failed! res %d\n",res);
return res;
}
if (res != DW_DLV_OK) {
tagname = "<bogus tag>";
}
printf("%3d: Die: %s\n",level,tagname);
if (res != DW_DLV_OK) {
printf("dwarf_attrlist failed! res %d\n",res);
return res;
}
for (i = 0; i <attrcount;++i) {
res =print_attr(attrbuf[i],i,error);
if (res != DW_DLV_OK) {
printf("dwarf_attr print failed! res %d\n",res);
return res;
}
}
return DW_DLV_OK;
}
static int
{
int res = 0;
int level = 0;
type_signature = zerosignature;
is_info,
&cu_header_length,
&version_stamp,
&abbrev_offset,
&address_size,
&length_size,
&extension_size,
&type_signature,
&typeoffset,
&next_cu_header_offset,
&header_cu_type,
error);
if (res != DW_DLV_OK) {
printf("Next cu header result %d. "
"Something is wrong FAIL, line %d\n",res,__LINE__);
if (res == DW_DLV_ERROR) {
}
exit(1);
}
printf("CU header length..........0x%lx\n",
(unsigned long)cu_header_length);
printf("Version stamp.............%d\n",version_stamp);
printf("Address size .............%d\n",address_size);
printf("Offset size...............%d\n",length_size);
printf("Next cu header offset.....0x%lx\n",
(unsigned long)next_cu_header_offset);
if (res != DW_DLV_OK) {
if (res == DW_DLV_ERROR) {
printf("ERROR: dwarf_siblingof_b failed, no CU die\n");
return res;
} else {
printf("ERROR: dwarf_siblingof_b got NO_ENTRY, "
"no CU die\n");
return res;
}
}
res = print_one_die(cu_die,level,error);
if (res != DW_DLV_OK) {
printf("print_one_die failed! %d\n",res);
if (res == DW_DLV_ERROR) {
}
exit(1);
}
return DW_DLV_OK;
}
int main(void)
{
int res = 0;
int fail = FALSE;
0,0,DW_GROUPNUMBER_ANY,&dbg,
&error);
if (res != DW_DLV_OK) {
if (res == DW_DLV_NO_ENTRY) {
printf("FAIL Cannot dwarf_object_init_b() NO ENTRY. \n");
} else {
printf("FAIL Cannot dwarf_object_init_b(). \n");
}
exit(1);
}
res = print_object_info(dbg,&error);
if (res != DW_DLV_OK) {
printf("FAIL printing, res %d line %d\n",res,__LINE__);
exit(1);
}
if (fail) {
printf("FAIL objectaccess.c\n");
exit(1);
}
return 0;
}