本文整理汇总了C++中dwarf_siblingof函数的典型用法代码示例。如果您正苦于以下问题:C++ dwarf_siblingof函数的具体用法?C++ dwarf_siblingof怎么用?C++ dwarf_siblingof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dwarf_siblingof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
static struct dwarf_subprogram_t *read_from_cus(Dwarf_Debug dbg)
{
Dwarf_Unsigned cu_header_length, abbrev_offset, next_cu_header;
Dwarf_Half version_stamp, address_size;
Dwarf_Error err;
Dwarf_Die no_die = 0, cu_die, child_die, next_die;
int ret = DW_DLV_OK;
int rc;
struct dwarf_subprogram_t *subprograms = NULL;
while (ret == DW_DLV_OK) {
ret = dwarf_next_cu_header(
dbg,
&cu_header_length,
&version_stamp,
&abbrev_offset,
&address_size,
&next_cu_header,
&err);
DWARF_ASSERT(ret, err);
if (ret == DW_DLV_NO_ENTRY)
continue;
/* TODO: If the CU can provide an address range then we can skip over
* all the entire die if none of our addresses match */
/* Expect the CU to have a single sibling - a DIE */
ret = dwarf_siblingof(dbg, no_die, &cu_die, &err);
if (ret == DW_DLV_ERROR) {
continue;
}
DWARF_ASSERT(ret, err);
/* Expect the CU DIE to have children */
ret = dwarf_child(cu_die, &child_die, &err);
DWARF_ASSERT(ret, err);
next_die = child_die;
/* Now go over all children DIEs */
do {
subprograms = read_cu_entry(subprograms, dbg, cu_die, child_die);
rc = dwarf_siblingof(dbg, child_die, &next_die, &err);
DWARF_ASSERT(rc, err);
dwarf_dealloc(dbg, child_die, DW_DLA_DIE);
child_die = next_die;
} while (rc != DW_DLV_NO_ENTRY);
dwarf_dealloc(dbg, cu_die, DW_DLA_DIE);
}
return subprograms;
}
示例2: rdwarf_compile_units
static VALUE rdwarf_compile_units(VALUE self)
{
rdwarf_t *rd = GetRDwarf(self);
Dwarf_Unsigned cu_header_length = 0;
Dwarf_Unsigned abbrev_offset = 0;
Dwarf_Half version_stamp = 0;
Dwarf_Half address_size = 0;
Dwarf_Unsigned next_cu_offset = 0;
Dwarf_Error err;
Dwarf_Die die;
VALUE ary;
if (rd->compile_units != Qfalse) {
return rd->compile_units;
}
ary = rb_ary_new();
while (dwarf_next_cu_header(rd->shared_data->dbg, &cu_header_length, &version_stamp, &abbrev_offset,
&address_size, &next_cu_offset, &err) == DW_DLV_OK) {
if (!chkerr2(dwarf_siblingof(rd->shared_data->dbg, NULL, &die, &err), &err)) {
continue;
}
rb_ary_push(ary, rd_die_new(rd->shared_data, self, Qnil, die));
}
rd->compile_units = ary;
return ary;
}
示例3: process_CUs
/* process each compilation unit(CU) in .debug_info */
static int process_CUs(Dwarf_Debug dbg)
{
Dwarf_Unsigned next_cu_header;
int ret;
while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, &next_cu_header, NULL)) == DW_DLV_OK)
{
/* process a single compilation unit in .debug_info. */
Dwarf_Die cu_die;
ret = dwarf_siblingof(dbg, NULL, &cu_die, NULL);
if (ret != DW_DLV_OK)
{
fprintf(stderr, "SET dwarf: Error in dwarf_siblingof()\n");
return 1;
}
ret = process_die_and_children(dbg, cu_die);
dwarf_dealloc(dbg, cu_die, DW_DLA_DIE);
if (ret != 0)
return 1;
}
if (ret == DW_DLV_ERROR)
{
fprintf(stderr, "SET dwarf: Error in dwarf_next_cu_header()\n");
return 1;
}
else
return 0;
}
示例4: handle_die
static void handle_die(
struct dwarf_subprogram_t **subprograms,
Dwarf_Debug dbg, Dwarf_Die cu_die, Dwarf_Die the_die, Dwarf_Unsigned language)
{
int rc;
Dwarf_Error err;
Dwarf_Die current_die = the_die;
Dwarf_Die child_die = NULL;
Dwarf_Die next_die;
do {
*subprograms = read_cu_entry(*subprograms, dbg, cu_die, current_die, language);
/* Recursive call handle_die with child, to continue searching within child dies */
rc = dwarf_child(current_die, &child_die, &err);
DWARF_ASSERT(rc, err);
if (rc == DW_DLV_OK && child_die)
handle_die(subprograms, dbg, cu_die, child_die, language);
rc = dwarf_siblingof(dbg, current_die, &next_die, &err);
DWARF_ASSERT(rc, err);
dwarf_dealloc(dbg, current_die, DW_DLA_DIE);
current_die = next_die;
} while (rc != DW_DLV_NO_ENTRY);
}
示例5: int
/**
* die_find_child - Generic DIE search function in DIE tree
* @rt_die: a root DIE
* @callback: a callback function
* @data: a user data passed to the callback function
* @die_mem: a buffer for result DIE
*
* Trace DIE tree from @rt_die and call @callback for each child DIE.
* If @callback returns DIE_FIND_CB_END, this stores the DIE into
* @die_mem and returns it. If @callback returns DIE_FIND_CB_CONTINUE,
* this continues to trace the tree. Optionally, @callback can return
* DIE_FIND_CB_CHILD and DIE_FIND_CB_SIBLING, those means trace only
* the children and trace only the siblings respectively.
* Returns NULL if @callback can't find any appropriate DIE.
*/
Dwarf_Die *die_find_child(Dwarf_Die *rt_die,
int (*callback)(Dwarf_Die *, void *),
void *data, Dwarf_Die *die_mem)
{
Dwarf_Die child_die;
int ret;
ret = dwarf_child(rt_die, die_mem);
if (ret != 0)
return NULL;
do {
ret = callback(die_mem, data);
if (ret == DIE_FIND_CB_END)
return die_mem;
if ((ret & DIE_FIND_CB_CHILD) &&
die_find_child(die_mem, callback, data, &child_die)) {
memcpy(die_mem, &child_die, sizeof(Dwarf_Die));
return die_mem;
}
} while ((ret & DIE_FIND_CB_SIBLING) &&
dwarf_siblingof(die_mem, die_mem) == 0);
return NULL;
}
示例6: child_variables
struct variable* child_variables(Dwarf_Die *parent, Dwarf_Files *files,
struct expr_context *ctx, bool params)
{
int ret;
Dwarf_Die die;
struct variable *var, *head = NULL, *tail = NULL;
int desired_tag = params ? DW_TAG_formal_parameter : DW_TAG_variable;
ret = dwarf_child(parent, &die);
if (ret != 0)
return NULL;
do
{
if (dwarf_tag(&die) == desired_tag)
{
var = analyze_variable(&die, files, ctx);
if (!var)
continue;
list_append(head, tail, var);
}
} while (dwarf_siblingof(&die, &die) == 0);
return head;
}
示例7: load_dbg
//file_cmd helper funcs
//DBG init and exit functions
error_t load_dbg(mygdb_info_t* gdb_info){
Dwarf_Error err;
Dwarf_Die no_die = 0;
Dwarf_Unsigned cu_header_length;
Dwarf_Half version_stamp;
Dwarf_Unsigned abbrev_offset;
Dwarf_Half addr_size;
Dwarf_Unsigned nxt_cu_hdr;
gdb_info->dbg_fd = open(gdb_info->src_file, O_RDONLY);
if( dwarf_init(gdb_info->dbg_fd,DW_DLC_READ,0,0, &gdb_info->dbg, &err) != DW_DLV_OK )
return E_FATAL;
printf("Succesfully loaded symbol info\n");
int res;
if( (res = dwarf_next_cu_header(gdb_info->dbg, &cu_header_length, &version_stamp, &abbrev_offset, &addr_size, &nxt_cu_hdr, &err)) == DW_DLV_ERROR ){
printf("failed to get next header\n");
return E_FATAL;
}
if( dwarf_siblingof(gdb_info->dbg, no_die, &gdb_info->cu_die, &err) == DW_DLV_ERROR){
printf("siblingof() failed\n");
return E_FATAL;
}
return E_NONE;
}
示例8: process_die_and_children
/* Recursively follow the DIE tree */
static int process_die_and_children(Dwarf_Debug dbg, Dwarf_Die in_die)
{
Dwarf_Die cur_die = in_die;
Dwarf_Die child;
Dwarf_Die sib_die;
int is_function;
int ret;
ret = process_one_DIE(dbg, in_die, &is_function);
if (ret != 0)
return 1;
while (1)
{
if (!is_function) /* Assume that there is no nested function, so we ignore the children of a function */
{
ret = dwarf_child(cur_die, &child, NULL);
if (ret == DW_DLV_ERROR)
{
fprintf(stderr, "SET dwarf: Error in dwarf_child()\n");
return 1;
}
/* Recursive call */
if (ret == DW_DLV_OK)
{
ret = process_die_and_children(dbg, child);
dwarf_dealloc(dbg, child, DW_DLA_DIE);
if (ret != 0)
return 1;
}
}
/* Current DIE has no children */
ret = dwarf_siblingof(dbg, cur_die, &sib_die, NULL);
if (ret == DW_DLV_ERROR)
{
fprintf(stderr, "SET dwarf: Error in dwarf_siblingof()\n");
return 1;
}
if (cur_die != in_die)
dwarf_dealloc(dbg, cur_die, DW_DLA_DIE);
if (ret == DW_DLV_NO_ENTRY)
{
/* Done at this level */
break;
}
/* ret == DW_DLV_OK */
cur_die = sib_die;
ret = process_one_DIE(dbg, cur_die, &is_function);
if (ret != 0)
return 1;
}
return 0;
}
示例9: handle_debug_info
/*
Return DW_DLV_OK, ERROR, or NO_ENTRY.
*/
static int
handle_debug_info(Dwarf_Debug dbg, int *errval)
{
Dwarf_Unsigned nxtoff = 1;
Dwarf_Unsigned hdr_length;
Dwarf_Half version_stamp;
Dwarf_Unsigned abbrev_offset;
Dwarf_Half addr_size;
Dwarf_Error err;
int terminate_now = 0;
int res = 0;
Dwarf_Die sibdie;
int sibres;
int nres = DW_DLV_OK;
for (nres = dwarf_next_cu_header(dbg, &hdr_length, &version_stamp,
&abbrev_offset,
&addr_size, &nxtoff, &err);
terminate_now == 0 && nres == DW_DLV_OK;
nres = dwarf_next_cu_header(dbg, &hdr_length, &version_stamp,
&abbrev_offset,
&addr_size, &nxtoff, &err)
) {
Dwarf_Die curdie = 0;
/* try to get the compilation unit die */
sibres = dwarf_siblingof(dbg, curdie, &sibdie, &err);
if (sibres == DW_DLV_OK) {
res = do_this_die_and_dealloc(dbg, sibdie, errval);
switch (res) {
case DW_DLV_OK:
break;
case DW_DLV_NO_ENTRY:
break;
default:
case DW_DLV_ERROR:
return DW_DLV_ERROR;
}
} else if (sibres == DW_DLV_ERROR) {
*errval = (int) dwarf_errno(err);
return DW_DLV_ERROR;
} else {
/* NO ENTRY! */
/* impossible? */
}
}
if (nres == DW_DLV_ERROR) {
int localerr = (int) dwarf_errno(err);
*errval = localerr;
return DW_DLV_ERROR;
}
return DW_DLV_OK;
}
示例10: DC_show_info_for_containing_pc_ranges
static void DC_show_info_for_containing_pc_ranges(Dwarf_Die die, int enclosing, unsigned long iaddr){
/*This function visits the children of a die in sequence,
*applying the action() function to each*/
Dwarf_Attribute highattr;
Dwarf_Attribute lowattr;
Dwarf_Addr loval,hival;
Dwarf_Bool has;
Dwarf_Error error;
Dwarf_Half tag;
loval = hival = 0x0;
int enc = 0;
dwarf_tag(die,&tag,&error);
if( tag == DW_TAG_variable ||
tag == DW_TAG_formal_parameter ){
if(enclosing){
char *name;
dwarf_diename(die,&name,&error);
fprintf(stderr,"%s, ",name);
//show_all_attrs(die,0,NULL);
}
}
if( tag == DW_TAG_lexical_block || tag == DW_TAG_subprogram ){
if( dwarf_lowpc(die,&loval,&error) == DW_DLV_OK && dwarf_highpc(die,&hival,&error) == DW_DLV_OK
&& iaddr >=loval && iaddr <= hival ){
enc = 1;
fprintf(stderr,"\n=================================\n");
show_all_attrs(die,0,NULL);
fprintf(stderr,"=================================\n");
}
}
Dwarf_Die kid;
if( dwarf_child(die,&kid,&error) == DW_DLV_NO_ENTRY ){
return;
}
DC_show_info_for_containing_pc_ranges(kid, enc, iaddr);
//visit_die(kid,level+1,action,adata);
int chret;
while( (chret = dwarf_siblingof(d,kid,&kid,&error)) != DW_DLV_NO_ENTRY &&
chret != DW_DLV_ERROR){
DC_show_info_for_containing_pc_ranges(kid, enc, iaddr);
//visit_die(kid,level+1,action,adata);
}
return;
}
示例11: while
static struct dwarf_subprogram_t *read_from_cus(Dwarf_Debug dbg)
{
Dwarf_Unsigned cu_header_length, abbrev_offset, next_cu_header;
Dwarf_Half version_stamp, address_size;
Dwarf_Error err;
Dwarf_Die no_die = 0, cu_die, child_die;
int ret = DW_DLV_OK;
struct dwarf_subprogram_t *subprograms = NULL;
Dwarf_Unsigned language = 0;
Dwarf_Attribute language_attr = 0;
while (ret == DW_DLV_OK) {
ret = dwarf_next_cu_header(
dbg,
&cu_header_length,
&version_stamp,
&abbrev_offset,
&address_size,
&next_cu_header,
&err);
DWARF_ASSERT(ret, err);
if (ret == DW_DLV_NO_ENTRY)
continue;
/* TODO: If the CU can provide an address range then we can skip over
* all the entire die if none of our addresses match */
/* Expect the CU to have a single sibling - a DIE */
ret = dwarf_siblingof(dbg, no_die, &cu_die, &err);
if (ret == DW_DLV_ERROR) {
continue;
}
DWARF_ASSERT(ret, err);
/* Get compilation unit language attribute */
ret = dwarf_attr(cu_die, DW_AT_language, &language_attr, &err);
DWARF_ASSERT(ret, err);
if (ret != DW_DLV_NO_ENTRY) {
/* Get language attribute data */
ret = dwarf_formudata(language_attr, &language, &err);
DWARF_ASSERT(ret, err);
dwarf_dealloc(dbg, language_attr, DW_DLA_ATTR);
}
/* Expect the CU DIE to have children */
ret = dwarf_child(cu_die, &child_die, &err);
DWARF_ASSERT(ret, err);
handle_die(&subprograms, dbg, cu_die, child_die, language);
dwarf_dealloc(dbg, cu_die, DW_DLA_DIE);
}
return subprograms;
}
示例12: DC_get_info_for_scoped_variable
static void DC_get_info_for_scoped_variable(Dwarf_Die die, int enclosing, unsigned long iaddr, const char *varname, Dwarf_Die *retDie){
/*This function visits the children of a die in sequence,
*applying the action() function to each*/
Dwarf_Attribute highattr;
Dwarf_Attribute lowattr;
Dwarf_Addr loval,hival;
Dwarf_Bool has;
Dwarf_Error error;
Dwarf_Half tag;
loval = hival = 0x0;
int enc = 0;
dwarf_tag(die,&tag,&error);
if( tag == DW_TAG_variable ||
tag == DW_TAG_formal_parameter ){
if(enclosing){
char *name;
dwarf_diename(die,&name,&error);
if(!strncmp(name,varname,strlen(name))){
*retDie = die;
return;
}
}
}
if( tag == DW_TAG_lexical_block || tag == DW_TAG_subprogram ){
if( dwarf_lowpc(die,&loval,&error) == DW_DLV_OK && dwarf_highpc(die,&hival,&error) == DW_DLV_OK
&& iaddr >=loval && iaddr <= hival ){
enc = 1;
}
}
Dwarf_Die kid;
if( dwarf_child(die,&kid,&error) == DW_DLV_NO_ENTRY ){
return;
}
DC_get_info_for_scoped_variable(kid, enc, iaddr,varname,retDie);
int chret;
while( (chret = dwarf_siblingof(d,kid,&kid,&error)) != DW_DLV_NO_ENTRY &&
chret != DW_DLV_ERROR){
DC_get_info_for_scoped_variable(kid, enc, iaddr,varname,retDie);
}
return;
}
示例13: read_cu_list
static void
read_cu_list(Dwarf_Debug dbg)
{
Dwarf_Unsigned cu_header_length = 0;
Dwarf_Half version_stamp = 0;
Dwarf_Unsigned abbrev_offset = 0;
Dwarf_Half address_size = 0;
Dwarf_Unsigned next_cu_header = 0;
Dwarf_Error error;
int cu_number = 0;
for(;;++cu_number) {
/*edit by liupo*/
//printf("\n--------------CU_NUMBER-%d-----------------\n", cu_number);
/*end edit*/
struct srcfilesdata sf;
sf.srcfilesres = DW_DLV_ERROR;
sf.srcfiles = 0;
sf.srcfilescount = 0;
Dwarf_Die no_die = 0;
Dwarf_Die cu_die = 0;
int res = DW_DLV_ERROR;
res = dwarf_next_cu_header(dbg,&cu_header_length,
&version_stamp, &abbrev_offset, &address_size,
&next_cu_header, &error);
if(res == DW_DLV_ERROR) {
printf("Error in dwarf_next_cu_header\n");
exit(1);
}
if(res == DW_DLV_NO_ENTRY) {
/*edit by liupo*/
//printf("\n-------------CU_NUMBER--------------\n");
/*end edit*/
/* Done. */
return;
}
/* The CU will have a single sibling, a cu_die. */
res = dwarf_siblingof(dbg,no_die,&cu_die,&error);
if(res == DW_DLV_ERROR) {
printf("Error in dwarf_siblingof on CU die \n");
exit(1);
}
if(res == DW_DLV_NO_ENTRY) {
/* Impossible case. */
printf("no entry! in dwarf_siblingof on CU die \n");
exit(1);
}
get_die_and_siblings(dbg,cu_die,0,&sf);
dwarf_dealloc(dbg,cu_die,DW_DLA_DIE);
resetsrcfiles(dbg,&sf);
}
}
示例14: MC_dwarf_handle_children
static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf_Die * die,
Dwarf_Die * unit, simgrid::mc::Frame* frame,
const char *ns)
{
// For each child DIE:
Dwarf_Die child;
int res;
for (res = dwarf_child(die, &child); res == 0;
res = dwarf_siblingof(&child, &child))
MC_dwarf_handle_die(info, &child, unit, frame, ns);
}
示例15: CHECK_DWERR2
Dwarf_Die DieHolder::get_sibling(void)
{
Dwarf_Die sibling_die = NULL;
Dwarf_Error err = NULL;
// there may be no sibling
CHECK_DWERR2(dwarf_siblingof(m_dbg, m_die, &sibling_die, &err) == DW_DLV_ERROR, err,
"error when asking for a DIE sibling");
return sibling_die;
}