• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dwarf_attr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dwarf_attr函数的典型用法代码示例。如果您正苦于以下问题:C++ dwarf_attr函数的具体用法?C++ dwarf_attr怎么用?C++ dwarf_attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dwarf_attr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: DC_resolve_type

static void DC_resolve_type(Dwarf_Die v, DC_type *t){
 
  /*TODO: Error Handling*/ 
  Dwarf_Error error;
  Dwarf_Attribute type;
  Dwarf_Off off;
  Dwarf_Die typeDie;
  Dwarf_Half tag = 0; 
  
 /*
 * Start with the variable,  not its type.  The loop
 * unwraps all the types.
 */
  dwarf_attr(v, DW_AT_type, &type, &error);
  dwarf_formref(type, &off, &error);
  DC_get_die_from_CU_relative_offset(v, off, &typeDie);

  int points = 0;
  int arrs = 0;
  while( 1 ){

    Dwarf_Bool has;
    dwarf_hasattr(typeDie,DW_AT_type,&has,&error);
    if(!has){ 

      /*We've reached a base or structure type*/
      dwarf_diename(typeDie,&(t->name),&error);
  
      Dwarf_Attribute bsize;
      dwarf_attr(typeDie,DW_AT_byte_size,&bsize,&error);
      dwarf_formudata(bsize,(Dwarf_Unsigned*)(&t->byteSize),&error);
      t->indirectionLevel = points;
      t->arrayLevel = arrs;
      return;
      /*Note: I am assuming this must happen eventually.  can there
 *            be mutually referencing types?*/

    }

    /*Otherwise: this type has a type, so it is a pointer or a typedef
 *               or an array type.  For now, we're only going to correctly
 *               handle pointer types.(TODO:)
 */
    dwarf_tag(typeDie,&tag,&error);
    if(tag == DW_TAG_pointer_type){
      points++;
    }
    if(tag == DW_TAG_array_type){
      arrs++;
    }
    
    dwarf_attr(typeDie, DW_AT_type, &type, &error);
    dwarf_formref(type, &off, &error);

    /*Note, the next line uses v, because it can use anything in the CU*/
    DC_get_die_from_CU_relative_offset(v, off, &typeDie);

  }

}
开发者ID:blucia0a,项目名称:Legerdemain,代码行数:60,代码来源:dwarfclient.c


示例2: dwarf_formref_die

char *get_type_str(Dwarf_Die *die)
{
	static char buf[256] = "";
	char *ptr = NULL;
	Dwarf_Die tdie;
	Dwarf_Attribute attr;

	if (!dwarf_attr(die, DW_AT_type, &attr))
		return "void";

	dwarf_formref_die(&attr, &tdie);

	if (dwarf_tag(&tdie) == DW_TAG_array_type)
		ptr = "[]";
	else if (dwarf_tag(&tdie) == DW_TAG_pointer_type)
		ptr = "*";
	else
		goto end_ok;

	dwarf_attr(&tdie, DW_AT_type, &attr);
	dwarf_formref_die(&attr, &tdie);

end_ok:
	sprintf(buf, "%s%s", dwarf_diename(&tdie), (ptr) ? ptr : "");

	return buf;
}
开发者ID:j3rgus,项目名称:pb173-bin,代码行数:27,代码来源:dwarf.c


示例3: print_base_type

/* BASE must be a base type DIE referenced by a typed DWARF expression op.  */
static void
print_base_type (Dwarf_Die *base)
{
  assert (dwarf_tag (base) == DW_TAG_base_type);

  Dwarf_Attribute encoding;
  Dwarf_Word enctype;
  if (dwarf_attr (base, DW_AT_encoding, &encoding) == NULL
      || dwarf_formudata (&encoding, &enctype) != 0)
    error (EXIT_FAILURE, 0, "base type without encoding");

  Dwarf_Attribute bsize;
  Dwarf_Word bits;
  if (dwarf_attr (base, DW_AT_byte_size, &bsize) != NULL
      && dwarf_formudata (&bsize, &bits) == 0)
    bits *= 8;
  else if (dwarf_attr (base, DW_AT_bit_size, &bsize) == NULL
	   || dwarf_formudata (&bsize, &bits) != 0)
    error (EXIT_FAILURE, 0, "base type without byte or bit size");

  printf ("{%s,%s,%" PRIu64 "@[%" PRIx64 "]}",
	  dwarf_diename (base),
	  dwarf_encoding_string (enctype),
	  bits,
	  dwarf_dieoffset (base));
}
开发者ID:bgamari,项目名称:elfutils,代码行数:27,代码来源:varlocs.c


示例4: _dwarf_internal_get_die_comp_dir

int
_dwarf_internal_get_die_comp_dir(Dwarf_Die die, const char **compdir_out,
    const char **compname_out,
    Dwarf_Error *error)
{
    Dwarf_Attribute comp_dir_attr = 0;
    Dwarf_Attribute comp_name_attr = 0;
    int resattr = 0;
    Dwarf_Debug dbg = 0;

    dbg = die->di_cu_context->cc_dbg;
    resattr = dwarf_attr(die, DW_AT_name, &comp_name_attr, error);
    if (resattr == DW_DLV_ERROR) {
        return resattr;
    }
    if (resattr == DW_DLV_OK) {
        int cres = DW_DLV_ERROR;
        char *name = 0;

        cres = dwarf_formstring(comp_name_attr, &name, error);
        if (cres == DW_DLV_ERROR) {
            dwarf_dealloc(dbg, comp_name_attr, DW_DLA_ATTR);
            return cres;
        } else if (cres == DW_DLV_OK) {
            *compname_out = (const char *)name;
        } else {
            /* FALL thru */
        }
    }
    if (resattr == DW_DLV_OK) {
        dwarf_dealloc(dbg, comp_name_attr, DW_DLA_ATTR);
    }
    resattr = dwarf_attr(die, DW_AT_comp_dir, &comp_dir_attr, error);
    if (resattr == DW_DLV_ERROR) {
        return resattr;
    }
    if (resattr == DW_DLV_OK) {
        int cres = DW_DLV_ERROR;
        char *cdir = 0;

        cres = dwarf_formstring(comp_dir_attr, &cdir, error);
        if (cres == DW_DLV_ERROR) {
            dwarf_dealloc(dbg, comp_dir_attr, DW_DLA_ATTR);
            return cres;
        } else if (cres == DW_DLV_OK) {
            *compdir_out = (const char *) cdir;
        } else {
            /* FALL thru */
        }
    }
    if (resattr == DW_DLV_OK) {
        dwarf_dealloc(dbg, comp_dir_attr, DW_DLA_ATTR);
    }
    return resattr;
}
开发者ID:finik,项目名称:libdwarf,代码行数:55,代码来源:dwarf_util.c


示例5: die_get_data_member_location

/**
 * die_get_data_member_location - Get the data-member offset
 * @mb_die: a DIE of a member of a data structure
 * @offs: The offset of the member in the data structure
 *
 * Get the offset of @mb_die in the data structure including @mb_die, and
 * stores result offset to @offs. If any error occurs this returns errno.
 */
int die_get_data_member_location(Dwarf_Die *mb_die, Dwarf_Word *offs)
{
	Dwarf_Attribute attr;
	Dwarf_Op *expr;
	size_t nexpr;
	int ret;

	if (dwarf_attr(mb_die, DW_AT_data_member_location, &attr) == NULL)
		return -ENOENT;

	if (dwarf_formudata(&attr, offs) != 0) {
		/* DW_AT_data_member_location should be DW_OP_plus_uconst */
		ret = dwarf_getlocation(&attr, &expr, &nexpr);
		if (ret < 0 || nexpr == 0)
			return -ENOENT;

		if (expr[0].atom != DW_OP_plus_uconst || nexpr != 1) {
			pr_debug("Unable to get offset:Unexpected OP %x (%zd)\n",
				 expr[0].atom, nexpr);
			return -ENOTSUP;
		}
		*offs = (Dwarf_Word)expr[0].number;
	}
	return 0;
}
开发者ID:19Dan01,项目名称:linux,代码行数:33,代码来源:dwarf-aux.c


示例6: dwarf_formstring

/**
 * cu_get_comp_dir - Get the path of compilation directory
 * @cu_die: a CU DIE
 *
 * Get the path of compilation directory of given @cu_die.
 * Since this depends on DW_AT_comp_dir, older gcc will not
 * embedded it. In that case, this returns NULL.
 */
const char *cu_get_comp_dir(Dwarf_Die *cu_die)
{
	Dwarf_Attribute attr;
	if (dwarf_attr(cu_die, DW_AT_comp_dir, &attr) == NULL)
		return NULL;
	return dwarf_formstring(&attr);
}
开发者ID:19Dan01,项目名称:linux,代码行数:15,代码来源:dwarf-aux.c


示例7: CHECK_DWERR2

Dwarf_Attribute DieHolder::get_attr(int attr)
{
  Dwarf_Attribute attrib = NULL;
  MapAttrs::const_iterator iter = m_attrs.find(attr);

  if(iter == m_attrs.end())
  {
    Dwarf_Error err = NULL;

    // atribute may be NULL
    CHECK_DWERR2(dwarf_attr(m_die, attr, &attrib, &err) == DW_DLV_ERROR, err,
                 "cannot get DIE attribute %d", attr);

    if(attrib != NULL)
    {
      m_attrs[attr] = attrib;
    }
    else if(m_origin_holder.get() != NULL)
    {
      attrib = m_origin_holder->get_attr(attr);
    }
  }
  else
  {
    attrib = iter->second;
  }

  return attrib;
}
开发者ID:IDA-RE-things,项目名称:idadwarf,代码行数:29,代码来源:die_utils.cpp


示例8: supported_language

bool supported_language(Dwarf_Die *cu)
{
    int ret;
    Dwarf_Word lang;
    Dwarf_Attribute at;

    if (dwarf_attr(cu, DW_AT_language, &at) == NULL)
    {
        warn("CU %s: unknown language", dwarf_diename(cu));
        return false;
    }

    ret = dwarf_formudata(&at, &lang);
    fail_if(ret == -1, "dwarf_formudata");

    switch (lang)
    {
    case DW_LANG_C89:
    case DW_LANG_C:
    case DW_LANG_C99:
        /* good! */
        break;
    case DW_LANG_C_plus_plus:
        warn("CU %s: C++ not supported", dwarf_diename(cu));
        return false;
        break;
    default:
        debug("CU %s: unsupported language: 0x%lx",
             dwarf_diename(cu), (unsigned long)lang);
        return false;
        break;
    }

    return true;
}
开发者ID:mmilata,项目名称:seecore,代码行数:35,代码来源:stack.c


示例9: __die_walk_instances_cb

static int __die_walk_instances_cb(Dwarf_Die *inst, void *data)
{
	struct __instance_walk_param *iwp = data;
	Dwarf_Attribute attr_mem;
	Dwarf_Die origin_mem;
	Dwarf_Attribute *attr;
	Dwarf_Die *origin;
	int tmp;

	attr = dwarf_attr(inst, DW_AT_abstract_origin, &attr_mem);
	if (attr == NULL)
		return DIE_FIND_CB_CONTINUE;

	origin = dwarf_formref_die(attr, &origin_mem);
	if (origin == NULL || origin->addr != iwp->addr)
		return DIE_FIND_CB_CONTINUE;

	/* Ignore redundant instances */
	if (dwarf_tag(inst) == DW_TAG_inlined_subroutine) {
		dwarf_decl_line(origin, &tmp);
		if (die_get_call_lineno(inst) == tmp) {
			tmp = die_get_decl_fileno(origin);
			if (die_get_call_fileno(inst) == tmp)
				return DIE_FIND_CB_CONTINUE;
		}
	}

	iwp->retval = iwp->callback(inst, iwp->data);

	return (iwp->retval) ? DIE_FIND_CB_END : DIE_FIND_CB_CONTINUE;
}
开发者ID:19Dan01,项目名称:linux,代码行数:31,代码来源:dwarf-aux.c


示例10: get_size

/* Get the size (in words) */
static int get_size(Dwarf_Debug dbg, Dwarf_Die die)
{
    Dwarf_Attribute attr;
    Dwarf_Unsigned size;
    int ret;

    ret = dwarf_attr(die, DW_AT_byte_size, &attr, NULL);
    if (ret != DW_DLV_OK)
    {
        fprintf(stderr, "SET dwarf: Error in dwarf_attr()\n");
        return 1;
    }

    ret = dwarf_formudata(attr, &size, NULL);
    dwarf_dealloc(dbg, attr, DW_DLA_ATTR);
    if (ret != DW_DLV_OK)
    {
        fprintf(stderr, "SET dwarf: Error in dwarf_formudata()\n");
        return 1;
    }

    /* Increment the parameter number of the function */
    func_dwarf[local_func_idx].param_size += (size + 3) >> 2;

    return 0;
}
开发者ID:converse2006,项目名称:M2M,代码行数:27,代码来源:SET_dwarf.c


示例11: die_is_func_def

/**
 * die_is_func_def - Ensure that this DIE is a subprogram and definition
 * @dw_die: a DIE
 *
 * Ensure that this DIE is a subprogram and NOT a declaration. This
 * returns true if @dw_die is a function definition.
 **/
bool die_is_func_def(Dwarf_Die *dw_die)
{
	Dwarf_Attribute attr;

	return (dwarf_tag(dw_die) == DW_TAG_subprogram &&
		dwarf_attr(dw_die, DW_AT_declaration, &attr) == NULL);
}
开发者ID:19Dan01,项目名称:linux,代码行数:14,代码来源:dwarf-aux.c


示例12: get_cu_by_iaddr

static Dwarf_Die get_cu_by_iaddr(unsigned long iaddr){
 
  Dwarf_Unsigned cu_h_len;
  Dwarf_Half verstamp;
  Dwarf_Unsigned abbrev_offset;
  Dwarf_Half addrsize;
  Dwarf_Unsigned next_cu;
  Dwarf_Error error; 
  while( dwarf_next_cu_header(d,
                              &cu_h_len,
                              &verstamp,
                              &abbrev_offset,
                              &addrsize,
                              &next_cu,
                              &error) == DW_DLV_OK ){

    Dwarf_Die cu_die = NULL;
    int sibret;
 
    int dieno = 0; 
    while((sibret = 
           dwarf_siblingof(d,cu_die,&cu_die,&error)) != DW_DLV_NO_ENTRY &&
           sibret                                    != DW_DLV_ERROR){

      Dwarf_Attribute lowattr;
      if( dwarf_attr(cu_die, DW_AT_low_pc, &lowattr, &error) != DW_DLV_OK ){
        continue;
      }
      Dwarf_Attribute highattr;
      if( dwarf_attr(cu_die, DW_AT_high_pc, &highattr, &error) != DW_DLV_OK ){
        continue;
      }

      Dwarf_Addr loval,hival;
      dwarf_formaddr(lowattr,&loval,&error); 
      dwarf_formaddr(highattr,&hival,&error); 
      if(iaddr >= loval && iaddr <= hival){
        return cu_die;
      }

    }

  }
  return (Dwarf_Die)-1;
  
}
开发者ID:blucia0a,项目名称:Legerdemain,代码行数:46,代码来源:dwarfclient.c


示例13: bt_dwarf_die_get_call_file

BT_HIDDEN
int bt_dwarf_die_get_call_file(struct bt_dwarf_die *die, char **filename)
{
	int ret;
	Dwarf_Sword file_no;
	const char *_filename = NULL;
	Dwarf_Files *src_files = NULL;
	Dwarf_Attribute *file_attr = NULL;
	struct bt_dwarf_die *cu_die = NULL;

	if (!die || !filename) {
		goto error;
	}

	file_attr = g_new0(Dwarf_Attribute, 1);
	if (!file_attr) {
		goto error;
	}

	file_attr = dwarf_attr(die->dwarf_die, DW_AT_call_file, file_attr);
	if (!file_attr) {
		goto error;
	}

	ret = dwarf_formsdata(file_attr, &file_no);
	if (ret) {
		goto error;
	}

	cu_die = bt_dwarf_die_create(die->cu);
	if (!cu_die) {
		goto error;
	}

	ret = dwarf_getsrcfiles(cu_die->dwarf_die, &src_files, NULL);
	if (ret) {
		goto error;
	}

	_filename = dwarf_filesrc(src_files, file_no, NULL, NULL);
	if (!_filename) {
		goto error;
	}

	*filename = strdup(_filename);

	bt_dwarf_die_destroy(cu_die);
	g_free(file_attr);

	return 0;

error:
	bt_dwarf_die_destroy(cu_die);
	g_free(file_attr);

	return -1;
}
开发者ID:eepp,项目名称:babeltrace,代码行数:57,代码来源:dwarf.c


示例14: 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;
}
开发者ID:AppBlade,项目名称:atosl,代码行数:56,代码来源:subprograms.c


示例15: die_get_attr_sdata

/* Get attribute and translate it as a sdata */
static int die_get_attr_sdata(Dwarf_Die *tp_die, unsigned int attr_name,
			      Dwarf_Sword *result)
{
	Dwarf_Attribute attr;

	if (dwarf_attr(tp_die, attr_name, &attr) == NULL ||
	    dwarf_formsdata(&attr, result) != 0)
		return -ENOENT;

	return 0;
}
开发者ID:19Dan01,项目名称:linux,代码行数:12,代码来源:dwarf-aux.c


示例16: die_get_call_lineno

/**
 * die_get_call_lineno - Get callsite line number of inline-function instance
 * @in_die: a DIE of an inlined function instance
 *
 * Get call-site line number of @in_die. This means from where the inline
 * function is called.
 */
int die_get_call_lineno(Dwarf_Die *in_die)
{
	Dwarf_Attribute attr;
	Dwarf_Word ret;

	if (!dwarf_attr(in_die, DW_AT_call_line, &attr))
		return -ENOENT;

	dwarf_formudata(&attr, &ret);
	return (int)ret;
}
开发者ID:19Dan01,项目名称:linux,代码行数:18,代码来源:dwarf-aux.c


示例17: handle_attr_addr

/*
	Return DW_DLV_OK if handling this went ok.
*/
static int
handle_attr_addr(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attrnum,
		 Dwarf_Error * perr)
{
    int res = DW_DLV_OK;
    Dwarf_Off offset;
    Dwarf_Addr addr;
    Dwarf_Half form;
    int ares;

    Dwarf_Attribute attr;

    ares = dwarf_attr(die, attrnum, &attr, perr);
    if (ares == DW_DLV_OK) {
	int formres = dwarf_whatform(attr, &form, perr);

	switch (formres) {
	case DW_DLV_OK:
	    break;
	case DW_DLV_ERROR:
	case DW_DLV_NO_ENTRY:	/* impossible. */
	    return formres;

	}

	switch (form) {
	case DW_FORM_ref_addr:
	case DW_FORM_addr:
	    res = dwarf_attr_offset(die, attr, &offset, perr);
	    if (res == DW_DLV_OK) {
		ares = dwarf_formaddr(attr, &addr, perr);
		if (ares == DW_DLV_OK) {
		    send_addr_note(DW_SECTION_INFO, offset, addr);
		} else if (ares == DW_DLV_ERROR) {
		    return ares;
		}		/* no entry: ok. */
	    } else {
		res = DW_DLV_ERROR;	/* NO_ENTRY is impossible. */
	    }
	    break;

	default:
	    /* surprising! An error? */

	    ;			/* do nothing */
	}
	dwarf_dealloc(dbg, attr, DW_DLA_ATTR);

    } else {
	res = ares;
    }
    return res;
}
开发者ID:Leon555,项目名称:Mac-src-essentials,代码行数:56,代码来源:dwarf_addr_finder.c


示例18: MC_dwarf_attr_flag

static bool MC_dwarf_attr_flag(Dwarf_Die * die, int attribute, bool integrate)
{
  Dwarf_Attribute attr;
  if ((integrate ? dwarf_attr_integrate(die, attribute, &attr)
       : dwarf_attr(die, attribute, &attr)) == 0)
    return false;

  bool result;
  if (dwarf_formflag(&attr, &result))
    xbt_die("Unexpected form for attribute %s",
      simgrid::dwarf::attrname(attribute));
  return result;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:13,代码来源:mc_dwarf.cpp


示例19: call_probe_finder

static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
{
	Dwarf_Attribute fb_attr;
	size_t nops;
	int ret;

	if (!sc_die) {
		pr_err("Caller must pass a scope DIE. Program error.\n");
		return -EINVAL;
	}

	
	if (dwarf_tag(sc_die) != DW_TAG_subprogram) {
		if (!die_find_realfunc(&pf->cu_die, pf->addr, &pf->sp_die)) {
			pr_warning("Failed to find probe point in any "
				   "functions.\n");
			return -ENOENT;
		}
	} else
		memcpy(&pf->sp_die, sc_die, sizeof(Dwarf_Die));

	
	dwarf_attr(&pf->sp_die, DW_AT_frame_base, &fb_attr);
	ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
	if (ret <= 0 || nops == 0) {
		pf->fb_ops = NULL;
#if _ELFUTILS_PREREQ(0, 142)
	} else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
		   pf->cfi != NULL) {
		Dwarf_Frame *frame;
		if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 ||
		    dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
			pr_warning("Failed to get call frame on 0x%jx\n",
				   (uintmax_t)pf->addr);
			return -ENOENT;
		}
#endif
	}

	
	ret = pf->callback(sc_die, pf);

	
	pf->fb_ops = NULL;

	return ret;
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:47,代码来源:probe-finder.c


示例20: call_probe_finder

/* Call probe_finder callback with scope DIE */
static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
{
	Dwarf_Attribute fb_attr;
	size_t nops;
	int ret;

	if (!sc_die) {
		pr_err("Caller must pass a scope DIE. Program error.\n");
		return -EINVAL;
	}

	/* If not a real subprogram, find a real one */
	if (!die_is_func_def(sc_die)) {
		if (!die_find_realfunc(&pf->cu_die, pf->addr, &pf->sp_die)) {
			pr_warning("Failed to find probe point in any "
				   "functions.\n");
			return -ENOENT;
		}
	} else
		memcpy(&pf->sp_die, sc_die, sizeof(Dwarf_Die));

	/* Get the frame base attribute/ops from subprogram */
	dwarf_attr(&pf->sp_die, DW_AT_frame_base, &fb_attr);
	ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
	if (ret <= 0 || nops == 0) {
		pf->fb_ops = NULL;
#if _ELFUTILS_PREREQ(0, 142)
	} else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
		   pf->cfi != NULL) {
		Dwarf_Frame *frame;
		if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 ||
		    dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
			pr_warning("Failed to get call frame on 0x%jx\n",
				   (uintmax_t)pf->addr);
			return -ENOENT;
		}
#endif
	}

	/* Call finder's callback handler */
	ret = pf->callback(sc_die, pf);

	/* *pf->fb_ops will be cached in libdw. Don't free it. */
	pf->fb_ops = NULL;

	return ret;
}
开发者ID:Abhi1919,项目名称:ath,代码行数:48,代码来源:probe-finder.c



注:本文中的dwarf_attr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dwarf_dealloc函数代码示例发布时间:2022-05-30
下一篇:
C++ dw函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap