libctf: Encode VARARGS an extra 0 short at the end of the parm list

We'll see if this is how things should be, but its good enough for me 8)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-03-19 20:10:33 -03:00
parent 82d5dbe637
commit fedbfb60ff
4 changed files with 22 additions and 9 deletions

View File

@ -138,7 +138,7 @@ static int subroutine_type__encode(struct tag *self, uint16_t core_id,
int64_t position;
struct ftype *ftype = tag__ftype(self);
int ctf_id = ctf__add_function_type(ctf, self->type, ftype->nr_parms,
&position);
ftype->unspec_parms, &position);
if (ctf_id < 0 || tag__check_id_drift(self, core_id, ctf_id))
return -1;

View File

@ -469,11 +469,17 @@ static int create_new_subroutine_type(struct ctf_state *sp, void *ptr,
INIT_LIST_HEAD(&self->lexblock.tags);
for (i = 0; i < vlen; i++) {
struct parameter *p = tag__alloc(sizeof(*p));
uint16_t type = ctf__get16(sp->ctf, &args[i]);
p->tag.tag = DW_TAG_formal_parameter;
p->tag.type = ctf__get16(sp->ctf, &args[i]);
ftype__add_parameter(&self->proto, p);
if (type == 0)
self->proto.unspec_parms = 1;
else {
struct parameter *p = tag__alloc(sizeof(*p));
p->tag.tag = DW_TAG_formal_parameter;
p->tag.type = ctf__get16(sp->ctf, &args[i]);
ftype__add_parameter(&self->proto, p);
}
}
vlen *= sizeof(*args);

View File

@ -297,10 +297,10 @@ void ctf__add_parameter(struct ctf *self, uint16_t type, int64_t *position)
}
int ctf__add_function_type(struct ctf *self, uint16_t type, uint16_t nr_parms,
int64_t *position)
bool varargs, int64_t *position)
{
struct ctf_short_type t;
int len = sizeof(uint16_t) * nr_parms;
int len = sizeof(uint16_t) * (nr_parms + !!varargs);
/*
* Round up to next multiple of 4 to maintain 32-bit alignment.
@ -309,11 +309,18 @@ int ctf__add_function_type(struct ctf *self, uint16_t type, uint16_t nr_parms,
len += 0x2;
t.ctf_name = 0;
t.ctf_info = CTF_INFO_ENCODE(CTF_TYPE_KIND_FUNC, nr_parms, 0);
t.ctf_info = CTF_INFO_ENCODE(CTF_TYPE_KIND_FUNC,
nr_parms + !!varargs, 0);
t.ctf_type = type;
gobuffer__add(&self->types, &t, sizeof(t));
*position = gobuffer__allocate(&self->types, len);
if (varargs) {
unsigned int pos = *position + (nr_parms * sizeof(uint16_t));
uint16_t *end_of_args = gobuffer__ptr(&self->types, pos);
*end_of_args = 0;
}
return ++self->type_index;
}

View File

@ -30,7 +30,7 @@ int ctf__add_array(struct ctf *self, uint16_t type, uint16_t index_type,
uint32_t nelems);
void ctf__add_parameter(struct ctf *self, uint16_t type, int64_t *position);
int ctf__add_function_type(struct ctf *self, uint16_t type,
uint16_t nr_parameters, int64_t *position);
uint16_t nr_parms, bool varargs, int64_t *position);
int ctf__add_enumeration_type(struct ctf *self, uint32_t name,
uint16_t nr_entries, int64_t *position);
void ctf__add_enumerator(struct ctf *self, uint32_t name, uint32_t value,