Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205301
b: refs/heads/master
c: 73317b9
h: refs/heads/master
i:
  205299: 72682b7
v: v3
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Jul 5, 2010
1 parent f7e423a commit 4f2a476
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e09c8614b32915c16f68e039ac7040e602d73e35
refs/heads/master: 73317b954041031249e8968d2e9023ff4e960d99
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-probe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Each probe argument follows below syntax.
[NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE]

'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.)
'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo.
'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type.

LINE SYNTAX
-----------
Expand Down
59 changes: 48 additions & 11 deletions trunk/tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,61 @@ static int convert_location(Dwarf_Op *op, struct probe_finder *pf)
}

static int convert_variable_type(Dwarf_Die *vr_die,
struct kprobe_trace_arg *targ)
struct kprobe_trace_arg *tvar,
const char *cast)
{
struct kprobe_trace_arg_ref **ref_ptr = &tvar->ref;
Dwarf_Die type;
char buf[16];
int ret;

/* TODO: check all types */
if (cast && strcmp(cast, "string") != 0) {
/* Non string type is OK */
tvar->type = strdup(cast);
return (tvar->type == NULL) ? -ENOMEM : 0;
}

if (die_get_real_type(vr_die, &type) == NULL) {
pr_warning("Failed to get a type information of %s.\n",
dwarf_diename(vr_die));
return -ENOENT;
}

if (cast && strcmp(cast, "string") == 0) { /* String type */
ret = dwarf_tag(&type);
if (ret != DW_TAG_pointer_type &&
ret != DW_TAG_array_type) {
pr_warning("Failed to cast into string: "
"%s(%s) is not a pointer nor array.",
dwarf_diename(vr_die), dwarf_diename(&type));
return -EINVAL;
}
if (ret == DW_TAG_pointer_type) {
if (die_get_real_type(&type, &type) == NULL) {
pr_warning("Failed to get a type information.");
return -ENOENT;
}
while (*ref_ptr)
ref_ptr = &(*ref_ptr)->next;
/* Add new reference with offset +0 */
*ref_ptr = zalloc(sizeof(struct kprobe_trace_arg_ref));
if (*ref_ptr == NULL) {
pr_warning("Out of memory error\n");
return -ENOMEM;
}
}
if (die_compare_name(&type, "char") != 0 &&
die_compare_name(&type, "unsigned char") != 0) {
pr_warning("Failed to cast into string: "
"%s is not (unsigned) char *.",
dwarf_diename(vr_die));
return -EINVAL;
}
tvar->type = strdup(cast);
return (tvar->type == NULL) ? -ENOMEM : 0;
}

ret = die_get_byte_size(&type) * 8;
if (ret) {
/* Check the bitwidth */
Expand All @@ -495,8 +538,8 @@ static int convert_variable_type(Dwarf_Die *vr_die,
strerror(-ret));
return ret;
}
targ->type = strdup(buf);
if (targ->type == NULL)
tvar->type = strdup(buf);
if (tvar->type == NULL)
return -ENOMEM;
}
return 0;
Expand Down Expand Up @@ -606,14 +649,8 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
&die_mem);
vr_die = &die_mem;
}
if (ret == 0) {
if (pf->pvar->type) {
pf->tvar->type = strdup(pf->pvar->type);
if (pf->tvar->type == NULL)
ret = -ENOMEM;
} else
ret = convert_variable_type(vr_die, pf->tvar);
}
if (ret == 0)
ret = convert_variable_type(vr_die, pf->tvar, pf->pvar->type);
/* *expr will be cached in libdw. Don't free it. */
return ret;
error:
Expand Down

0 comments on commit 4f2a476

Please sign in to comment.