[CODIFF]: Use ftype__snprintf

And with this the only user of parameter__names is gone, so ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-01-09 13:34:15 -02:00
parent 8b797ddc38
commit bd62cad409
3 changed files with 14 additions and 99 deletions

View File

@ -907,71 +907,6 @@ out:
return size;
}
size_t parameter__names(const struct parameter *self, const struct cu *cu,
char *class_name, size_t class_name_size,
char *parameter_name, size_t parameter_name_size)
{
struct tag *type = cu__find_tag_by_id(cu, self->tag.type);
size_t size = -1;
snprintf(parameter_name, parameter_name_size, "%s", self->name ?: "");
if (type == NULL)
snprintf(class_name, class_name_size, "<%llx>",
self->tag.type);
else {
if (type->tag == DW_TAG_const_type)
type = cu__find_tag_by_id(cu, type->type);
size = tag__size(type, cu);
/* Is it a function pointer? */
if (type->tag == DW_TAG_pointer_type) {
struct tag *ptype = cu__find_tag_by_id(cu, type->type);
if (ptype != NULL &&
ptype->tag == DW_TAG_subroutine_type) {
/* function has no return value (void) */
if (ptype->type == 0)
snprintf(class_name,
class_name_size, "void");
else {
struct tag *ret_type =
cu__find_tag_by_id(cu, ptype->type);
tag__name(ret_type, cu,
class_name, class_name_size);
}
snprintf(parameter_name, parameter_name_size,
"(*%s)(void /* FIXME: add "
"parameter list */)",
self->name ?: "");
goto out;
}
}
tag__name(type, cu, class_name, class_name_size);
if (type->tag == DW_TAG_array_type) {
struct array_type *array = tag__array_type(type);
int i = 0;
size_t n = snprintf(parameter_name,
parameter_name_size,
"%s", self->name);
parameter_name += n;
parameter_name_size -= n;
for (i = 0; i < array->dimensions; ++i) {
n = snprintf(parameter_name,
parameter_name_size, "[%u]",
array->nr_entries[i]);
parameter_name += n;
parameter_name_size -= n;
}
}
}
out:
return size;
}
static size_t class_member__print(struct class_member *self,
const struct cu *cu)
{

View File

@ -359,11 +359,4 @@ extern const char *variable__type_name(const struct variable *self,
char *bf, size_t len);
extern const char *dwarf_tag_name(const uint32_t tag);
extern size_t parameter__names(const struct parameter *self,
const struct cu *cu,
char *class_name, size_t class_name_size,
char *parameter_name,
size_t parameter_name_size);
#endif /* _PAHOLE_CLASSES_H_ */

View File

@ -63,31 +63,18 @@ static int cu_find_methods_iterator(struct cu *cu, void *cookie)
static int function__emit_kprobes(struct function *self, const struct cu *cu,
const struct tag *target)
{
char bf[128];
size_t bodyl = 2048, printed;
char body[bodyl], *bodyp = body;
char class_name[128], parm_name[256];
char bf[2048];
char jprobe_name[256];
struct parameter *pos;
struct tag *type = cu__find_tag_by_id(cu, self->proto.tag.type);
const char *stype = tag__name(type, cu, bf, sizeof(bf));
const char *name = function__name(self, cu);
int first = 1;
body[0] = '\0';
printf("static %s jprobe_entry__%s(", stype, name);
snprintf(jprobe_name, sizeof(jprobe_name), "jprobe_entry__%s", name);
ftype__snprintf(&self->proto, cu, bf, sizeof(bf), jprobe_name, 0, 0, 0);
printf("static %s\n"
"{\n", bf);
list_for_each_entry(pos, &self->proto.parms, tag.node) {
type = cu__find_tag_by_id(cu, pos->tag.type);
parameter__names(pos, cu, class_name, sizeof(class_name),
parm_name, sizeof(parm_name));
if (!first)
fputs(", ", stdout);
else
first = 0;
printf("%s %s", class_name, parm_name);
struct tag *type = cu__find_tag_by_id(cu, pos->tag.type);
if (type->tag != DW_TAG_pointer_type)
continue;
@ -96,14 +83,14 @@ static int function__emit_kprobes(struct function *self, const struct cu *cu,
if (type == NULL || type->id != target->id)
continue;
printed = snprintf(bodyp, bodyl,
"\tprintk(\"-> %s: %s=%%p\\n\", %s);\n",
name, pos->name, pos->name);
bodyp += printed;
bodyl -= printed;
printf("\tprintk(\"-> %s: %s=%%p\\n\", %s);\n",
name, pos->name, pos->name);
}
printf(")\n{\n%s\n\tjprobe_return();\n\t/* NOTREACHED */%s\n}\n\n",
body, self->proto.tag.type != 0 ? "\n\treturn 0;" : "");
printf("\n\tjprobe_return();\n"
"\t/* NOTREACHED */%s\n}\n\n",
self->proto.tag.type != 0 ? "\n\treturn 0;" : "");
printf("static struct jprobe jprobe__%s = {\n"
"\t.kp = { .symbol_name = \"%s\", },\n"
"\t.entry = (kprobe_opcode_t *)jprobe_entry__%s,\n"