Commit 412ac0dd authored by Micha Müller's avatar Micha Müller
Browse files

Caliper-service rework WIP9

Only minor improvements today
It seems that dynamic symbol address are currently not computed correctly
parent de3a4abd
......@@ -202,6 +202,12 @@ private:
elf = elf_begin(fd, ELF_C_READ, NULL);
gelf_getehdr(elf, &ehdr);
if (ehdr.e_type != ET_DYN && ehdr.e_type != ET_EXEC) {
// we should only encounter executables and shared libraries during runtime
// we could not process other types anyway
Log(1).stream() << chn->name() << ": DcdbPusher: Unknown ELF type" << std::endl;
return 0;
}
sym_offset = (ehdr.e_type == ET_DYN ? (start_addr - offset) : 0);
while ((scn = elf_nextscn(elf, scn)) != NULL) {
......@@ -213,27 +219,22 @@ private:
}
}
if (shdr.sh_entsize == 0) {
//debug
Log(1).stream() << chn->name() << ": DcdbPusher: No symbol table present" << std::endl;
if (ehdr.e_type == ET_DYN) {
Log(1).stream() << chn->name() << ": DcdbPusher: Falling back to dynamic symtab" << std::endl;
scn = NULL;
while ((scn = elf_nextscn(elf, scn)) != NULL) {
gelf_getshdr(scn, &shdr);
if (shdr.sh_type == SHT_DYNSYM) {
/* found dynamic symbol table */
data = elf_getdata(scn, NULL);
break;
}
if (scn == NULL || shdr.sh_entsize == 0) {
Log(1).stream() << chn->name() << ": DcdbPusher: \"" << filename
<< "\": No symbol table present. Falling back to dynamic symtab." << std::endl;
scn = NULL;
while ((scn = elf_nextscn(elf, scn)) != NULL) {
gelf_getshdr(scn, &shdr);
if (shdr.sh_type == SHT_DYNSYM) {
/* found dynamic symbol table */
data = elf_getdata(scn, NULL);
break;
}
}
if (scn == NULL || shdr.sh_entsize == 0) {
Log(1).stream() << chn->name() << ": DcdbPusher: Absolutely no symbols found" << std::endl;
return 0;
}
} else {
if (scn == NULL || shdr.sh_entsize == 0) {
Log(1).stream() << chn->name() << ": DcdbPusher: Absolutely no symbols found in \""
<< filename << "\"" << std::endl;
return 0;
}
}
......@@ -252,7 +253,7 @@ private:
// continue;
//}
if (GELF_ST_TYPE(sym.st_info) != STT_FUNC || //only interested in symbols related to executable code
if (GELF_ST_TYPE(sym.st_info) != STT_FUNC || //only interested in symbols related to executable code
sym.st_shndx == SHN_UNDEF || //external symbol
sym.st_shndx == SHN_ABS) { //absolute symbol, unlikely for STT_FUNC
continue;
......@@ -285,7 +286,7 @@ private:
//resolve symbol value aka its address in this' process virtual memory
symdat.start_addr = sym_offset + sym.st_value;
symdat.end_addr = symdat.start_addr + sym.st_size - 1;
symdat.end_addr = symdat.start_addr + sym.st_size - 1;
if (symdat.start_addr >= start_addr &&
symdat.start_addr <= end_addr) {
......@@ -316,6 +317,7 @@ private:
}
//debug
// printf("%s:\n", filename);
// if (shdr.sh_type == SHT_DYNSYM) {
// printf("Retrieved %d symbols of dynsym\n", entryCnt);
// } else {
......@@ -334,7 +336,7 @@ private:
* symbol data.
* TODO demangle different languages? (C -> no mangling,
* C++ -> demangling implemented,
* Fortran -> mangling compiler dependent,
* Fortran -> mangling compiler dependent; no demangling implemented,
* other languages?)
*/
bool setup_shm(Channel* chn) {
......@@ -583,7 +585,7 @@ private:
return;
}
print_debug_shm();
//print_debug_shm();
//tell pusher plugin our PID so it can access our shared memory
//UNIX socket used for communication
......
......@@ -262,7 +262,8 @@ void CaliperSensorGroup::read() {
reinterpret_cast<const char* const>(addrs) + addrs[j].fsym_offset);
for(size_t k = 0; k < addrs[j].fsym_count; ++k) {
if (pc >= fsyms[k].start_addr && pc <= fsyms[k].end_addr) {
sName += ':' + fsyms[k].name;
sName += "::";
sName += fsyms[k].name;
break;
}
} //It's OK if we found no symbol. There are possibly none
......
......@@ -46,7 +46,7 @@ class CaliperSensorGroup : public SensorGroupTemplate<CaliperSensorBase> {
/*******************************************************************************
* Common defines. Keep in sync with DcdbPusher Caliper service
******************************************************************************/
#define SHM_MAX_RETRIES 10 //TODO make configurable
#define SHM_MAX_RETRIES 15 //TODO make configurable
#define MAX_SYMBOL_SIZE 512 //symbol names are not limited by any means but our memory is
#define MAX_PATH_SIZE 4096 //linux paths are not allowed to be longer than 4096 chars
#define MSGQ_SIZE 8192
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment