本文整理汇总了C++中dwarf_tag函数的典型用法代码示例。如果您正苦于以下问题:C++ dwarf_tag函数的具体用法?C++ dwarf_tag怎么用?C++ dwarf_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dwarf_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: refl_deref
struct refl_object *
refl_deref (struct refl *refl, struct refl_object *obj)
{
struct refl_type *type = refl_object_type (obj);
Dwarf_Die die = type->die;
if (__refl_die_strip_cvq (&die, &die) == NULL)
return NULL;
/* Cannot dereference non-pointer type. */
if (dwarf_tag (&die) != DW_TAG_pointer_type)
{
__refl_seterr_2 (REFL_E_REFL, REFL_ME_MISMATCH);
return NULL;
}
if (__refl_die_type (&die, &die) == NULL)
return NULL;
/* Cannot dereference function pointer. */
if (dwarf_tag (&die) == DW_TAG_subroutine_type)
{
__refl_seterr_2 (REFL_E_REFL, REFL_ME_MISMATCH);
return NULL;
}
struct refl_type *ntype = __refl_type_begin (&die);
if (ntype == NULL)
return NULL;
void *ndata = *(void **)refl_object_cdata (obj);
return __refl_object_begin (ntype, ndata);
}
示例3: MC_dwarf_subrange_element_count
/** \brief Finds the number of elements in a DW_TAG_subrange_type or DW_TAG_enumeration_type DIE
*
* \param die the DIE
* \param unit DIE of the compilation unit
* \return number of elements in the range
* */
static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die * die,
Dwarf_Die * unit)
{
xbt_assert(dwarf_tag(die) == DW_TAG_enumeration_type
|| dwarf_tag(die) == DW_TAG_subrange_type,
"MC_dwarf_subrange_element_count called with DIE of type %s",
simgrid::dwarf::tagname(die));
// Use DW_TAG_count if present:
if (dwarf_hasattr_integrate(die, DW_AT_count))
return MC_dwarf_attr_integrate_uint(die, DW_AT_count, 0);
// Otherwise compute DW_TAG_upper_bound-DW_TAG_lower_bound + 1:
if (not dwarf_hasattr_integrate(die, DW_AT_upper_bound))
// This is not really 0, but the code expects this (we do not know):
return 0;
uint64_t upper_bound = MC_dwarf_attr_integrate_uint(die, DW_AT_upper_bound, static_cast<uint64_t>(-1));
uint64_t lower_bound = 0;
if (dwarf_hasattr_integrate(die, DW_AT_lower_bound))
lower_bound = MC_dwarf_attr_integrate_uint(die, DW_AT_lower_bound, static_cast<uint64_t>(-1));
else
lower_bound = MC_dwarf_default_lower_bound(dwarf_srclang(unit));
return upper_bound - lower_bound + 1;
}
示例4: line_range_search_cb
static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
{
struct dwarf_callback_param *param = data;
struct line_finder *lf = param->data;
struct line_range *lr = lf->lr;
if (lr->file && strtailcmp(lr->file, dwarf_decl_file(sp_die)))
return DWARF_CB_OK;
if (dwarf_tag(sp_die) == DW_TAG_subprogram &&
die_compare_name(sp_die, lr->function)) {
lf->fname = dwarf_decl_file(sp_die);
dwarf_decl_line(sp_die, &lr->offset);
pr_debug("fname: %s, lineno:%d\n", lf->fname, lr->offset);
lf->lno_s = lr->offset + lr->start;
if (lf->lno_s < 0)
lf->lno_s = INT_MAX;
lf->lno_e = lr->offset + lr->end;
if (lf->lno_e < 0)
lf->lno_e = INT_MAX;
pr_debug("New line range: %d to %d\n", lf->lno_s, lf->lno_e);
lr->start = lf->lno_s;
lr->end = lf->lno_e;
if (dwarf_func_inline(sp_die))
param->retval = die_walk_instances(sp_die,
line_range_inline_cb, lf);
else
param->retval = find_line_range_by_line(sp_die, lf);
return DWARF_CB_ABORT;
}
return DWARF_CB_OK;
}
示例5: 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;
}
示例6: MC_dwarf_handle_die
static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die * die,
Dwarf_Die * unit, simgrid::mc::Frame* frame,
const char *ns)
{
int tag = dwarf_tag(die);
simgrid::dwarf::TagClass klass = simgrid::dwarf::classify_tag(tag);
switch (klass) {
// Type:
case simgrid::dwarf::TagClass::Type:
MC_dwarf_handle_type_die(info, die, unit, frame, ns);
break;
// Subprogram or scope:
case simgrid::dwarf::TagClass::Subprogram:
case simgrid::dwarf::TagClass::Scope:
MC_dwarf_handle_scope_die(info, die, unit, frame, ns);
return;
// Variable:
case simgrid::dwarf::TagClass::Variable:
MC_dwarf_handle_variable_die(info, die, unit, frame, ns);
break;
case simgrid::dwarf::TagClass::Namespace:
mc_dwarf_handle_namespace_die(info, die, unit, frame, ns);
break;
default:
break;
}
}
示例7: print_die_and_children
/* recursively follow the die tree */
extern void
print_die_and_children(Dwarf_Debug dbg, Dwarf_Die in_die_in,
char **srcfiles, Dwarf_Signed cnt)
{
Dwarf_Die child;
Dwarf_Die sibling;
Dwarf_Error err;
int tres;
int cdres;
Dwarf_Die in_die = in_die_in;
for (;;) {
PUSH_DIE_STACK(in_die);
if (check_tag_tree) {
tag_tree_result.checks++;
if (indent_level == 0) {
Dwarf_Half tag;
tres = dwarf_tag(in_die, &tag, &err);
if (tres != DW_DLV_OK) {
tag_tree_result.errors++;
DWARF_CHECK_ERROR
("Tag-tree root is not DW_TAG_compile_unit")
} else if (tag == DW_TAG_compile_unit) {
/* OK */
} else {
tag_tree_result.errors++;
DWARF_CHECK_ERROR
("tag-tree root is not DW_TAG_compile_unit")
}
} else {
示例8: rd_die_new
static VALUE rd_die_new(rd_shared_data_t *sd, VALUE top, VALUE cu, Dwarf_Die die)
{
rd_die_t *rd_die;
Dwarf_Off off;
Dwarf_Half tag;
Dwarf_Error err;
VALUE obj;
VALUE klass;
chkerr1(dwarf_dieoffset(die, &off, &err), &err, Qnil);
obj = rb_hash_aref(sd->off2die, LL2NUM(off));
if (!NIL_P(obj)) {
return obj;
}
chkerr1(dwarf_tag(die, &tag, &err), &err, Qnil);
klass = rb_hash_aref(rdwarf_tag2class, INT2FIX(tag));
if (NIL_P(klass)) {
rb_raise(rb_eRuntimeError, "unknown tag %d\n", tag);
}
obj = rd_die_s_alloc(klass);
rd_die = GetDie(obj);
rd_die->shared_data = rd_shared_data_ref(sd);
rd_die->die = die;
rb_ivar_set(obj, id_at_top, top);
rb_ivar_set(obj, id_at_cu, NIL_P(cu) ? obj : cu);
rb_hash_aset(sd->off2die, LL2NUM(off), obj);
return obj;
}
示例9: 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));
}
示例10: 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);
}
示例11: dwarf_getsrcfiles
int
dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files, size_t *nfiles)
{
if (unlikely (cudie == NULL || dwarf_tag (cudie) != DW_TAG_compile_unit))
return -1;
int res = -1;
/* Get the information if it is not already known. */
struct Dwarf_CU *const cu = cudie->cu;
if (cu->lines == NULL)
{
Dwarf_Lines *lines;
size_t nlines;
/* Let the more generic function do the work. It'll create more
data but that will be needed in an real program anyway. */
res = dwarf_getsrclines (cudie, &lines, &nlines);
}
else if (cu->files != (void *) -1l)
/* We already have the information. */
res = 0;
if (likely (res == 0))
{
assert (cu->files != NULL && cu->files != (void *) -1l);
*files = cu->files;
if (nfiles != NULL)
*nfiles = cu->files->nfiles;
}
// XXX Eventually: unlocking here.
return res;
}
示例12: print_die_data
static void
print_die_data(Dwarf_Debug dbg, Dwarf_Die print_me,int level)
{
char *name = 0;
Dwarf_Error error = 0;
Dwarf_Half tag = 0;
const char *tagname = 0;
int res = dwarf_diename(print_me,&name,&error);
if(res == DW_DLV_ERROR) {
printf("Error in dwarf_diename , level %d \n",level);
exit(1);
}
if(res == DW_DLV_NO_ENTRY) {
return;
}
res = dwarf_tag(print_me,&tag,&error);
if(res != DW_DLV_OK) {
printf("Error in dwarf_tag , level %d \n",level);
exit(1);
}
res = dwarf_get_TAG_name(tag,&tagname);
if(res != DW_DLV_OK) {
printf("Error in dwarf_get_TAG_name , level %d \n",level);
exit(1);
}
printf("<%d> tag: %d %s name: %s\n",level,tag,tagname,name);
dwarf_dealloc(dbg,name,DW_DLA_STRING);
}
示例13: 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);
}
}
示例14: __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;
}
示例15: __die_get_real_type
/**
* die_get_real_type - Get a type die, but skip qualifiers and typedef
* @vr_die: a DIE of a variable
* @die_mem: where to store a type DIE
*
* Get a DIE of the type of given variable (@vr_die), and store
* it to die_mem. Return NULL if fails to get a type DIE.
* If the type is qualifiers (e.g. const) or typedef, this skips it
* and tries to find real type (structure or basic types, e.g. int).
*/
Dwarf_Die *die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem)
{
do {
vr_die = __die_get_real_type(vr_die, die_mem);
} while (vr_die && dwarf_tag(vr_die) == DW_TAG_typedef);
return vr_die;
}