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: ...@@ -202,6 +202,12 @@ private:
elf = elf_begin(fd, ELF_C_READ, NULL); elf = elf_begin(fd, ELF_C_READ, NULL);
gelf_getehdr(elf, &ehdr); 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); sym_offset = (ehdr.e_type == ET_DYN ? (start_addr - offset) : 0);
while ((scn = elf_nextscn(elf, scn)) != NULL) { while ((scn = elf_nextscn(elf, scn)) != NULL) {
...@@ -213,27 +219,22 @@ private: ...@@ -213,27 +219,22 @@ private:
} }
} }
if (shdr.sh_entsize == 0) { if (scn == NULL || shdr.sh_entsize == 0) {
//debug Log(1).stream() << chn->name() << ": DcdbPusher: \"" << filename
Log(1).stream() << chn->name() << ": DcdbPusher: No symbol table present" << std::endl; << "\": No symbol table present. Falling back to dynamic symtab." << std::endl;
scn = NULL;
if (ehdr.e_type == ET_DYN) { while ((scn = elf_nextscn(elf, scn)) != NULL) {
Log(1).stream() << chn->name() << ": DcdbPusher: Falling back to dynamic symtab" << std::endl; gelf_getshdr(scn, &shdr);
scn = NULL; if (shdr.sh_type == SHT_DYNSYM) {
while ((scn = elf_nextscn(elf, scn)) != NULL) { /* found dynamic symbol table */
gelf_getshdr(scn, &shdr); data = elf_getdata(scn, NULL);
if (shdr.sh_type == SHT_DYNSYM) { break;
/* found dynamic symbol table */
data = elf_getdata(scn, NULL);
break;
}
} }
}
if (scn == NULL || shdr.sh_entsize == 0) { if (scn == NULL || shdr.sh_entsize == 0) {
Log(1).stream() << chn->name() << ": DcdbPusher: Absolutely no symbols found" << std::endl; Log(1).stream() << chn->name() << ": DcdbPusher: Absolutely no symbols found in \""
return 0; << filename << "\"" << std::endl;
}
} else {
return 0; return 0;
} }
} }
...@@ -252,7 +253,7 @@ private: ...@@ -252,7 +253,7 @@ private:
// continue; // 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_UNDEF || //external symbol
sym.st_shndx == SHN_ABS) { //absolute symbol, unlikely for STT_FUNC sym.st_shndx == SHN_ABS) { //absolute symbol, unlikely for STT_FUNC
continue; continue;
...@@ -285,7 +286,7 @@ private: ...@@ -285,7 +286,7 @@ private:
//resolve symbol value aka its address in this' process virtual memory //resolve symbol value aka its address in this' process virtual memory
symdat.start_addr = sym_offset + sym.st_value; 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 && if (symdat.start_addr >= start_addr &&
symdat.start_addr <= end_addr) { symdat.start_addr <= end_addr) {
...@@ -316,6 +317,7 @@ private: ...@@ -316,6 +317,7 @@ private:
} }
//debug //debug
// printf("%s:\n", filename);
// if (shdr.sh_type == SHT_DYNSYM) { // if (shdr.sh_type == SHT_DYNSYM) {
// printf("Retrieved %d symbols of dynsym\n", entryCnt); // printf("Retrieved %d symbols of dynsym\n", entryCnt);
// } else { // } else {
...@@ -334,7 +336,7 @@ private: ...@@ -334,7 +336,7 @@ private:
* symbol data. * symbol data.
* TODO demangle different languages? (C -> no mangling, * TODO demangle different languages? (C -> no mangling,
* C++ -> demangling implemented, * C++ -> demangling implemented,
* Fortran -> mangling compiler dependent, * Fortran -> mangling compiler dependent; no demangling implemented,
* other languages?) * other languages?)
*/ */
bool setup_shm(Channel* chn) { bool setup_shm(Channel* chn) {
...@@ -583,7 +585,7 @@ private: ...@@ -583,7 +585,7 @@ private:
return; return;
} }
print_debug_shm(); //print_debug_shm();
//tell pusher plugin our PID so it can access our shared memory //tell pusher plugin our PID so it can access our shared memory
//UNIX socket used for communication //UNIX socket used for communication
......
...@@ -262,7 +262,8 @@ void CaliperSensorGroup::read() { ...@@ -262,7 +262,8 @@ void CaliperSensorGroup::read() {
reinterpret_cast<const char* const>(addrs) + addrs[j].fsym_offset); reinterpret_cast<const char* const>(addrs) + addrs[j].fsym_offset);
for(size_t k = 0; k < addrs[j].fsym_count; ++k) { for(size_t k = 0; k < addrs[j].fsym_count; ++k) {
if (pc >= fsyms[k].start_addr && pc <= fsyms[k].end_addr) { if (pc >= fsyms[k].start_addr && pc <= fsyms[k].end_addr) {
sName += ':' + fsyms[k].name; sName += "::";
sName += fsyms[k].name;
break; break;
} }
} //It's OK if we found no symbol. There are possibly none } //It's OK if we found no symbol. There are possibly none
......
...@@ -46,7 +46,7 @@ class CaliperSensorGroup : public SensorGroupTemplate<CaliperSensorBase> { ...@@ -46,7 +46,7 @@ class CaliperSensorGroup : public SensorGroupTemplate<CaliperSensorBase> {
/******************************************************************************* /*******************************************************************************
* Common defines. Keep in sync with DcdbPusher Caliper service * 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_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 MAX_PATH_SIZE 4096 //linux paths are not allowed to be longer than 4096 chars
#define MSGQ_SIZE 8192 #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