bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath) { assert(filepath, "null file path"); assert(buf != NULL && buflen > 0, "Invalid buffer"); if (has_error()) return false; ElfFile* file = get_elf_file(filepath); if (file == NULL) { return false; } if (!file->decode(addr, buf, buflen, offset)) { return false; } if (buf[0] != '\0') { demangle(buf, buf, buflen); } return true; }
Decoder::decoder_status Decoder::decode(address addr, const char* filepath, char *buf, int buflen, int *offset) { if (_decoder_status != no_error) { return _decoder_status; } ElfFile* file = get_elf_file(filepath); if (_decoder_status != no_error) { return _decoder_status; } const char* symbol = file->decode(addr, offset); if (file->get_status() == out_of_memory) { _decoder_status = out_of_memory; return _decoder_status; } else if (symbol != NULL) { if (!demangle(symbol, buf, buflen)) { jio_snprintf(buf, buflen, "%s", symbol); } return no_error; } else { return symbol_not_found; } }