1 /* Platform independent shared object routines for GDB.
3 Copyright (C) 2011 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "gdb_assert.h"
23 #include "gdb-dlfcn.h"
30 /* Unsupported configuration. */
37 gdb_dlopen (const char *filename)
39 gdb_assert_not_reached ("gdb_dlopen should not be called on this platform.");
43 gdb_dlsym (void *handle, const char *symbol)
45 gdb_assert_not_reached ("gdb_dlsym should not be called on this platform.");
49 make_cleanup_dlclose (void *handle)
51 gdb_assert_not_reached ("make_cleanup_dlclose should not be called on this "
56 gdb_dlclose (void *handle)
58 gdb_assert_not_reached ("gdb_dlclose should not be called on this platform.");
62 is_dl_available (void)
67 #else /* NO_SHARED_LIB */
70 gdb_dlopen (const char *filename)
74 result = dlopen (filename, RTLD_NOW);
76 result = (void *) LoadLibrary (filename);
82 error (_("Could not load %s: %s"), filename, dlerror());
90 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
91 FORMAT_MESSAGE_IGNORE_INSERTS,
92 NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
96 error (_("Could not load %s: %s"), filename, (char *) buffer);
102 gdb_dlsym (void *handle, const char *symbol)
105 return dlsym (handle, symbol);
107 return (void *) GetProcAddress (handle, symbol);
112 gdb_dlclose (void *handle)
115 return dlclose (handle);
117 return !((int) FreeLibrary (handle));
122 do_dlclose_cleanup (void *handle)
124 gdb_dlclose (handle);
128 make_cleanup_dlclose (void *handle)
130 return make_cleanup (do_dlclose_cleanup, handle);
134 is_dl_available (void)
139 #endif /* NO_SHARED_LIB */