aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-06 20:09:42 -0600
committerTom Tromey <tom@tromey.com>2017-04-12 11:16:17 -0600
commit0e8621a0bec2d0840b853c4104614f345f0569ca (patch)
treefa5779e127946671f39a06a99e53de560ff0272b /gdb/compile
parent67d89901506da74d00a482b7560237dce404b41c (diff)
downloadgdb-0e8621a0bec2d0840b853c4104614f345f0569ca.zip
gdb-0e8621a0bec2d0840b853c4104614f345f0569ca.tar.gz
gdb-0e8621a0bec2d0840b853c4104614f345f0569ca.tar.bz2
Introduce gdb_dlhandle_up
This introduces gdb_dlhandle_up, a unique_ptr that can close a dlopen'd library. All the functions working with dlopen handles are updated to use this new type. I did not try to build this on Windows. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * jit.c (struct jit_reader): Declare separately. Add constructor and destructor. Change type of "handle". (loaded_jit_reader): Define separately. (jit_reader_load): Update. New "new". (jit_reader_unload_command): Use "delete". * gdb-dlfcn.h (struct dlclose_deleter): New. (gdb_dlhandle_up): New typedef. (gdb_dlopen, gdb_dlsym): Update types. (gdb_dlclose): Remove. * gdb-dlfcn.c (gdb_dlopen): Return a gdb_dlhandle_up. (gdb_dlsym): Change type of "handle". (make_cleanup_dlclose): Remove. (dlclose_deleter::operator()): Rename from gdb_dlclose. * compile/compile-c-support.c (load_libcc): Update.
Diffstat (limited to 'gdb/compile')
-rw-r--r--gdb/compile/compile-c-support.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index c969b42..2614570 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -75,12 +75,11 @@ c_get_range_decl_name (const struct dynamic_prop *prop)
static gcc_c_fe_context_function *
load_libcc (void)
{
- void *handle;
gcc_c_fe_context_function *func;
/* gdb_dlopen will call error () on an error, so no need to check
value. */
- handle = gdb_dlopen (STRINGIFY (GCC_C_FE_LIBCC));
+ gdb_dlhandle_up handle = gdb_dlopen (STRINGIFY (GCC_C_FE_LIBCC));
func = (gcc_c_fe_context_function *) gdb_dlsym (handle,
STRINGIFY (GCC_C_FE_CONTEXT));
@@ -88,6 +87,9 @@ load_libcc (void)
error (_("could not find symbol %s in library %s"),
STRINGIFY (GCC_C_FE_CONTEXT),
STRINGIFY (GCC_C_FE_LIBCC));
+
+ /* Leave the library open. */
+ handle.release ();
return func;
}