diff options
author | Martin Oberhuber | 2013-03-27 17:22:25 +0000 |
---|---|---|
committer | Martin Oberhuber | 2013-03-27 17:22:25 +0000 |
commit | 4cb8e6259f061b7a564983e14b1836c8144b0dac (patch) | |
tree | 93d9eb592887c47d690c13435fa6d800d5153144 /agent | |
parent | b7e3d629e1fc3d90ff002f7bd30342ffb3d11860 (diff) | |
parent | 9872d7e7082c357f81c7f615fdae4ad0a23f4c30 (diff) | |
download | org.eclipse.tcf.agent-4cb8e6259f061b7a564983e14b1836c8144b0dac.tar.gz org.eclipse.tcf.agent-4cb8e6259f061b7a564983e14b1836c8144b0dac.tar.xz org.eclipse.tcf.agent-4cb8e6259f061b7a564983e14b1836c8144b0dac.zip |
Merge branch 'master' of ssh://git.eclipse.org:29418/tcf/org.eclipse.tcf.agent
Diffstat (limited to 'agent')
-rw-r--r-- | agent/tcf/services/profiler.c | 6 | ||||
-rw-r--r-- | agent/tcf/services/tcf_elf.c | 46 |
2 files changed, 31 insertions, 21 deletions
diff --git a/agent/tcf/services/profiler.c b/agent/tcf/services/profiler.c index c9724e3f..e4c4a146 100644 --- a/agent/tcf/services/profiler.c +++ b/agent/tcf/services/profiler.c @@ -240,10 +240,8 @@ static void event_context_exited(Context * ctx, void * args) { static void event_context_disposed(Context * ctx, void * args) { ContextExtensionPF * ext = EXT(ctx); - LINK * l = ext->list.next; - while (l != &ext->list) { - ProfilerRegistration * prf = link_ctx2prf(l); - l = l->next; + while (!list_is_empty(&ext->list)) { + ProfilerRegistration * prf = link_ctx2prf(ext->list.next); list_remove(&prf->link_ctx); loc_free(prf); } diff --git a/agent/tcf/services/tcf_elf.c b/agent/tcf/services/tcf_elf.c index c2cdb8cd..0bccf7a4 100644 --- a/agent/tcf/services/tcf_elf.c +++ b/agent/tcf/services/tcf_elf.c @@ -224,7 +224,7 @@ static void elf_cleanup_event(void * arg) { while (file != NULL) { file->age++; #if SERVICE_MemoryMap - if (!file->debug_info_file && file->age % max_file_age / 2 == 0 && is_file_mapped(file)) { + if (!file->mtime_changed && file->age > max_file_age && is_file_mapped(file)) { file->age = 0; if (file->debug_info_file_name) { find_open_file_by_name(file->debug_info_file_name); @@ -451,10 +451,20 @@ static int is_debug_info_file(ELF_File * file) { static void create_symbol_names_hash(ELF_Section * tbl); static void reopen_file(ELF_File * file) { + int error = 0; if (file->fd >= 0) return; if (file->error != NULL) return; - if ((file->fd = open(file->name, O_RDONLY | O_BINARY, 0)) < 0) { - int error = errno; + if ((file->fd = open(file->name, O_RDONLY | O_BINARY, 0)) < 0) error = errno; + if (!error) { + struct stat st; + if (fstat(file->fd, &st) < 0) error = errno; + else if (st.st_mtime != file->mtime) error = set_errno(ERR_OTHER, "Invalid file mtime"); + } + if (error) { + if (file->fd >= 0) { + close(file->fd); + file->fd = -1; + } trace(LOG_ELF, "Error re-opening ELF file: %d %s", error, errno_to_str(error)); file->error = get_error_report(error); } @@ -468,10 +478,7 @@ static ELF_File * create_elf_cache(const char * file_name) { char * real_name = NULL; file = find_open_file_by_name(file_name); - if (file != NULL) { - reopen_file(file); - return file; - } + if (file != NULL) return file; if (stat(file_name, &st) < 0) { error = errno; @@ -485,7 +492,6 @@ static ELF_File * create_elf_cache(const char * file_name) { file = find_open_file_by_inode(st.st_dev, st.st_ino, st.st_mtime); if (file != NULL) { add_file_name(file, file_name); - reopen_file(file); return file; } } @@ -494,10 +500,6 @@ static ELF_File * create_elf_cache(const char * file_name) { file = (ELF_File *)loc_alloc_zero(sizeof(ELF_File)); file->fd = -1; - file->dev = st.st_dev; - file->ino = st.st_ino; - file->mtime = st.st_mtime; - file->size = st.st_size; if (error == 0) real_name = canonicalize_file_name(file_name); @@ -510,6 +512,12 @@ static ELF_File * create_elf_cache(const char * file_name) { } if (error == 0 && (file->fd = open(file->name, O_RDONLY | O_BINARY, 0)) < 0) error = errno; + if (error == 0 && fstat(file->fd, &st) < 0) error = errno; + + file->dev = st.st_dev; + file->ino = st.st_ino; + file->mtime = st.st_mtime; + file->size = st.st_size; if (error == 0) { Elf32_Ehdr hdr; @@ -902,13 +910,18 @@ int elf_load(ELF_Section * s) { if (s->data == NULL) { ELF_File * file = s->file; - if (lseek(file->fd, s->offset, SEEK_SET) == (off_t)-1) return -1; + reopen_file(file); + if (file->error) { + set_error_report_errno(file->error); + return -1; + } s->data = loc_alloc((size_t)s->size); - if (read(file->fd, s->data, (size_t)s->size) < 0) { - int err = errno; + if (lseek(file->fd, s->offset, SEEK_SET) == (off_t)-1 || + read(file->fd, s->data, (size_t)s->size) < 0) { + int error = errno; loc_free(s->data); s->data = NULL; - set_errno(err, "Cannot read symbol file"); + set_errno(error, "Cannot read symbol file"); return -1; } trace(LOG_ELF, "Section %s in ELF file %s is loaded", s->name, s->file->name); @@ -942,7 +955,6 @@ ELF_File * elf_open_memory_region_file(MemoryRegion * r, int * error) { if (file->error == NULL) { if (r->dev != 0 && file->dev != r->dev) return NULL; if (r->ino != 0 && file->ino != r->ino) return NULL; - reopen_file(file); return file; } if (error != NULL && *error == 0) { |