17d62b00eSchristos /* Platform independent shared object routines for GDB. 27d62b00eSchristos 3*6881a400Schristos Copyright (C) 2011-2023 Free Software Foundation, Inc. 47d62b00eSchristos 57d62b00eSchristos This file is part of GDB. 67d62b00eSchristos 77d62b00eSchristos This program is free software; you can redistribute it and/or modify 87d62b00eSchristos it under the terms of the GNU General Public License as published by 97d62b00eSchristos the Free Software Foundation; either version 3 of the License, or 107d62b00eSchristos (at your option) any later version. 117d62b00eSchristos 127d62b00eSchristos This program is distributed in the hope that it will be useful, 137d62b00eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 147d62b00eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157d62b00eSchristos GNU General Public License for more details. 167d62b00eSchristos 177d62b00eSchristos You should have received a copy of the GNU General Public License 187d62b00eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 197d62b00eSchristos 207d62b00eSchristos #ifndef GDB_DLFCN_H 217d62b00eSchristos #define GDB_DLFCN_H 227d62b00eSchristos 237d62b00eSchristos /* A deleter that closes an open dynamic library. */ 247d62b00eSchristos 257d62b00eSchristos struct dlclose_deleter 267d62b00eSchristos { 277d62b00eSchristos void operator() (void *handle) const; 287d62b00eSchristos }; 297d62b00eSchristos 307d62b00eSchristos /* A unique pointer that points to a dynamic library. */ 317d62b00eSchristos 327d62b00eSchristos typedef std::unique_ptr<void, dlclose_deleter> gdb_dlhandle_up; 337d62b00eSchristos 347d62b00eSchristos /* Load the dynamic library file named FILENAME, and return a handle 357d62b00eSchristos for that dynamic library. Throw an error if the loading fails for 367d62b00eSchristos any reason. */ 377d62b00eSchristos 387d62b00eSchristos gdb_dlhandle_up gdb_dlopen (const char *filename); 397d62b00eSchristos 407d62b00eSchristos /* Return the address of the symbol named SYMBOL inside the shared 417d62b00eSchristos library whose handle is HANDLE. Return NULL when the symbol could 427d62b00eSchristos not be found. */ 437d62b00eSchristos 447d62b00eSchristos void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol); 457d62b00eSchristos 467d62b00eSchristos /* Return non-zero if the dynamic library functions are available on 477d62b00eSchristos this platform. */ 487d62b00eSchristos 497d62b00eSchristos int is_dl_available(void); 507d62b00eSchristos 517d62b00eSchristos #endif /* GDB_DLFCN_H */ 52