61 #include <sys/types.h> 89 int retval = fstat(fd, &sb);
90 if (retval == 0 && S_ISREG(sb.st_mode)) {
107 while (len < count) {
108 ret =
read(fd, ((
char *) buf) + len, count - len);
109 if (ret == 0 || (ret < 0 && errno != EINTR)) {
129 std::string &filename
132 this->filename = filename;
134 int file_fd = open(filename.c_str(), O_RDONLY);
137 DIAG_EMsg(
"unable to open input file: " << filename);
144 DIAG_EMsg(
"empty input file: " << filename);
148 char *file_buffer = (
char *)
malloc(f_size);
150 if (file_buffer == 0) {
151 DIAG_EMsg(
"unable to allocate file buffer of " << f_size <<
" bytes");
155 size_t bytes =
read_all(file_fd, file_buffer, f_size);
157 if (f_size != bytes) {
158 DIAG_EMsg(
"read only " << bytes <<
" bytes of " 159 << f_size <<
" bytes from file " << filename);
166 bool result = elfFile->
open(file_buffer, f_size, filename);
170 filevector->push_back(elfFile);
173 DIAG_EMsg(
"not an ELF binary: " << filename);
bool open(char *_memPtr, size_t _memLen, std::string _fileName)
bool findCubins(ElfFile *elfFile, ElfFileVector *elfFileVector)
ssize_t MONITOR_EXT_WRAP_NAME() read(int fd, void *buf, size_t count)
void *MONITOR_EXT_WRAP_NAME() malloc(size_t bytes)