aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-impl.h
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-06-19 12:20:47 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-06-21 13:04:02 +0100
commit65365aa856e5a258329dc350b02bbb51f84b4c16 (patch)
tree41b87c9af496cfda18bb854e3166f3ca002a080d /libctf/ctf-impl.h
parent24865428034f44d9fffe6b2d9a318e1bd507c63a (diff)
downloadgdb-65365aa856e5a258329dc350b02bbb51f84b4c16.zip
gdb-65365aa856e5a258329dc350b02bbb51f84b4c16.tar.gz
gdb-65365aa856e5a258329dc350b02bbb51f84b4c16.tar.bz2
libctf: drop mmap()-based CTF data allocator
This allocator has the ostensible benefit that it lets us mprotect() the memory used for CTF storage: but in exchange for this it adds considerable complexity, since we have to track allocation sizes ourselves for use at freeing time, note whether the data we are storing was ctf_data_alloc()ed or not so we know if we can safely mprotect() it... and while the mprotect()ing has found few bugs, it *has* been the cause of more than one due to errors in all this tracking leading to us mprotect()ing bits of the heap and stuff like that. We are about to start composing CTF buffers from pieces so that we can do usage-based optimizations on the strtab. This means we need realloc(), which needs nonportable mremap() and *more* tracking of the *original* allocation size, and the complexity and bureaucracy of all of this is just too high for its negligible benefits. Drop the whole thing and just use malloc() like everyone else. It knows better than we do when it is safe to use mmap() under the covers, anyway. While we're at it, don't leak the entire buffer if ctf_compress_write() fails to compress it. libctf/ * ctf-subr.c (_PAGESIZE): Remove. (ctf_data_alloc): Likewise. (ctf_data_free): Likewise. (ctf_data_protect): Likewise. * ctf-impl.h: Remove declarations. * ctf-create.c (ctf_update): No longer call ctf_data_protect: use ctf_free, not ctf_data_free. (ctf_compress_write): Use ctf_data_alloc, not ctf_alloc. Free the buffer again on compression error. * ctf-open.c (ctf_set_base): No longer track the size: call ctf_free, not ctf_data_free. (upgrade_types): Likewise. Call ctf_alloc, not ctf_data_alloc. (ctf_bufopen): Likewise. No longer call ctf_data_protect.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r--libctf/ctf-impl.h5
1 files changed, 0 insertions, 5 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 52aef24..44f0493 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -343,11 +343,6 @@ extern void *ctf_set_open_errno (int *, int);
extern unsigned long ctf_set_errno (ctf_file_t *, int);
_libctf_malloc_
-extern void *ctf_data_alloc (size_t);
-extern void ctf_data_free (void *, size_t);
-extern void ctf_data_protect (void *, size_t);
-
-_libctf_malloc_
extern void *ctf_mmap (size_t length, size_t offset, int fd);
extern void ctf_munmap (void *, size_t);
extern ssize_t ctf_pread (int fd, void *buf, ssize_t count, off_t offset);