ctf_encoder: Add void entries for variables not found on DWARF

Temporary hack till I figure out how to do more filtering on the variables on
the symtab that aren't in the DWARF info.

Problem is that if we don't put something on the table at encode time, we won't
find it at decode time, when we don't have DWARF to notice that its not there
because its not in DWARF.

We then discard it at load time, as "void foo;" doesn't make sense.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-04-02 12:41:01 -03:00
parent c93fff6743
commit 495c70ae14
2 changed files with 26 additions and 19 deletions

View File

@ -270,17 +270,19 @@ int cu__encode_ctf(struct cu *self)
cu__cache_symtab(self);
uint64_t addr;
GElf_Sym sym;
const char *sym_name;
cu__for_each_cached_symtab_entry(self, id, sym, sym_name) {
if (ctf__ignore_symtab_function(&sym, sym_name))
continue;
uint64_t addr = elf_sym__value(&sym);
addr = elf_sym__value(&sym);
int64_t position;
function = hashaddr__find_function(hash_addr, addr);
if (function == NULL) {
fprintf(stderr, "%4d: %-20s %#llx %5u NOT FOUND!\n",
fprintf(stderr,
"function %4d: %-20s %#llx %5u NOT FOUND!\n",
id, sym_name,
(unsigned long long)addr, elf_sym__size(&sym));
err = ctf__add_function(ctf, 0, 0, 0, &position);
@ -294,14 +296,8 @@ int cu__encode_ctf(struct cu *self)
ftype->nr_parms,
ftype->unspec_parms, &position);
if (err != 0) {
out_err_ctf:
fprintf(stderr,
"%4d: %-20s %#llx %5u failed encoding, "
"ABORTING!\n", id, sym_name,
(unsigned long long)addr, elf_sym__size(&sym));
goto out_delete;
}
if (err != 0)
goto out_err_ctf;
struct parameter *pos;
ftype__for_each_parameter(ftype, pos)
@ -323,23 +319,23 @@ out_err_ctf:
cu__for_each_cached_symtab_entry(self, id, sym, sym_name) {
if (ctf__ignore_symtab_object(&sym, sym_name))
continue;
uint64_t addr = elf_sym__value(&sym);
addr = elf_sym__value(&sym);
var = hashaddr__find_variable(hash_addr, addr);
if (var == NULL) {
fprintf(stderr, "%4d: %-20s %#llx %5u NOT FOUND!\n",
fprintf(stderr,
"variable %4d: %-20s %#llx %5u NOT FOUND!\n",
id, sym_name, (unsigned long long)addr,
elf_sym__size(&sym));
err = ctf__add_object(ctf, 0);
if (err != 0)
goto out_err_ctf;
continue;
}
err = ctf__add_object(ctf, var->tag.type);
if (err != 0) {
fprintf(stderr, "%4d: %-20s %#llx %5u failed encoding, "
"aborting!\n", id, sym_name,
(unsigned long long)addr, elf_sym__size(&sym));
goto out_delete;
}
if (err != 0)
goto out_err_ctf;
}
ctf__encode(ctf, CTF_FLAGS_COMPR);
@ -349,4 +345,10 @@ out_delete:
ctf__delete(ctf);
out:
return err;
out_err_ctf:
fprintf(stderr,
"%4d: %-20s %#llx %5u failed encoding, "
"ABORTING!\n", id, sym_name,
(unsigned long long)addr, elf_sym__size(&sym));
goto out_delete;
}

View File

@ -589,7 +589,12 @@ static int ctf__load_objects(struct ctf *self)
GElf_Sym sym;
uint32_t idx;
ctf__for_each_symtab_object(self, idx, sym) {
if (variable__new(*objp, &sym, self) == NULL)
const uint16_t type = *objp;
/*
* Discard void objects, probably was an object
* we didn't found DWARF info for when encoding.
*/
if (type && variable__new(type, &sym, self) == NULL)
return -ENOMEM;
++objp;
}