1 /* Handle shared libraries for GDB, the GNU Debugger.
3 Copyright (C) 1990-2015 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/>. */
22 #include <sys/types.h>
32 #include "gdb_regex.h"
37 #include "completer.h"
38 #include "filenames.h" /* for DOSish file names */
42 #include "readline/readline.h"
46 #include "filesystem.h"
48 #include "filestuff.h"
50 /* Architecture-specific operations. */
52 /* Per-architecture data key. */
53 static struct gdbarch_data
*solib_data
;
56 solib_init (struct obstack
*obstack
)
58 struct target_so_ops
**ops
;
60 ops
= OBSTACK_ZALLOC (obstack
, struct target_so_ops
*);
61 *ops
= current_target_so_ops
;
65 static const struct target_so_ops
*
66 solib_ops (struct gdbarch
*gdbarch
)
68 const struct target_so_ops
**ops
= gdbarch_data (gdbarch
, solib_data
);
73 /* Set the solib operations for GDBARCH to NEW_OPS. */
76 set_solib_ops (struct gdbarch
*gdbarch
, const struct target_so_ops
*new_ops
)
78 const struct target_so_ops
**ops
= gdbarch_data (gdbarch
, solib_data
);
84 /* external data declarations */
86 /* FIXME: gdbarch needs to control this variable, or else every
87 configuration needs to call set_solib_ops. */
88 struct target_so_ops
*current_target_so_ops
;
90 /* List of known shared objects */
91 #define so_list_head current_program_space->so_list
93 /* Local function prototypes */
95 /* If non-empty, this is a search path for loading non-absolute shared library
96 symbol files. This takes precedence over the environment variables PATH
97 and LD_LIBRARY_PATH. */
98 static char *solib_search_path
= NULL
;
100 show_solib_search_path (struct ui_file
*file
, int from_tty
,
101 struct cmd_list_element
*c
, const char *value
)
103 fprintf_filtered (file
, _("The search path for loading non-absolute "
104 "shared library symbol files is %s.\n"),
108 /* Same as HAVE_DOS_BASED_FILE_SYSTEM, but useable as an rvalue. */
109 #if (HAVE_DOS_BASED_FILE_SYSTEM)
110 # define DOS_BASED_FILE_SYSTEM 1
112 # define DOS_BASED_FILE_SYSTEM 0
115 /* Returns the full pathname of the shared library file, or NULL if
116 not found. (The pathname is malloc'ed; it needs to be freed by the
117 caller.) *FD is set to either -1 or an open file handle for the
120 Global variable GDB_SYSROOT is used as a prefix directory
121 to search for shared libraries if they have an absolute path.
122 If GDB_SYSROOT starts with "target:" and target filesystem
123 is the local filesystem then the "target:" prefix will be
124 stripped before the search starts. This ensures that the
125 same search algorithm is used for local files regardless of
126 whether a "target:" prefix was used.
128 Global variable SOLIB_SEARCH_PATH is used as a prefix directory
129 (or set of directories, as in LD_LIBRARY_PATH) to search for all
130 shared libraries if not found in either the sysroot (if set) or
131 the local filesystem.
134 * If a sysroot is set and path is absolute:
135 * Search for sysroot/path.
137 * Look for it literally (unmodified).
138 * Look in SOLIB_SEARCH_PATH.
139 * If available, use target defined search function.
140 * If NO sysroot is set, perform the following two searches:
141 * Look in inferior's $PATH.
142 * Look in inferior's $LD_LIBRARY_PATH.
144 * The last check avoids doing this search when targetting remote
145 * machines since a sysroot will almost always be set.
149 solib_find (char *in_pathname
, int *fd
)
151 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
153 char *temp_pathname
= NULL
;
154 const char *solib_symbols_extension
155 = gdbarch_solib_symbols_extension (target_gdbarch ());
156 const char *fskind
= effective_target_file_system_kind ();
157 struct cleanup
*old_chain
= make_cleanup (null_cleanup
, NULL
);
158 char *sysroot
= gdb_sysroot
;
160 /* If solib_symbols_extension is set, replace the file's
162 if (solib_symbols_extension
)
164 char *p
= in_pathname
+ strlen (in_pathname
);
166 while (p
> in_pathname
&& *p
!= '.')
173 new_pathname
= alloca (p
- in_pathname
+ 1
174 + strlen (solib_symbols_extension
) + 1);
175 memcpy (new_pathname
, in_pathname
, p
- in_pathname
+ 1);
176 strcpy (new_pathname
+ (p
- in_pathname
) + 1,
177 solib_symbols_extension
);
179 in_pathname
= new_pathname
;
185 /* If the absolute prefix starts with "target:" but the
186 filesystem accessed by the target_fileio_* methods
187 is the local filesystem then we strip the "target:"
188 prefix now and work with the local filesystem. This
189 ensures that the same search algorithm is used for
190 all local files regardless of whether a "target:"
192 if (is_target_filename (sysroot
) && target_filesystem_is_local ())
193 sysroot
+= strlen (TARGET_SYSROOT_PREFIX
);
195 if (*sysroot
== '\0')
201 int prefix_len
= strlen (sysroot
);
203 /* Remove trailing slashes from absolute prefix. */
204 while (prefix_len
> 0
205 && IS_DIR_SEPARATOR (sysroot
[prefix_len
- 1]))
208 sysroot
= savestring (sysroot
, prefix_len
);
209 make_cleanup (xfree
, sysroot
);
212 /* If we're on a non-DOS-based system, backslashes won't be
213 understood as directory separator, so, convert them to forward
214 slashes, iff we're supposed to handle DOS-based file system
215 semantics for target paths. */
216 if (!DOS_BASED_FILE_SYSTEM
&& fskind
== file_system_kind_dos_based
)
220 /* Avoid clobbering our input. */
221 p
= alloca (strlen (in_pathname
) + 1);
222 strcpy (p
, in_pathname
);
232 /* Note, we're interested in IS_TARGET_ABSOLUTE_PATH, not
233 IS_ABSOLUTE_PATH. The latter is for host paths only, while
234 IN_PATHNAME is a target path. For example, if we're supposed to
235 be handling DOS-like semantics we want to consider a
236 'c:/foo/bar.dll' path as an absolute path, even on a Unix box.
237 With such a path, before giving up on the sysroot, we'll try:
239 1st attempt, c:/foo/bar.dll ==> /sysroot/c:/foo/bar.dll
240 2nd attempt, c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll
241 3rd attempt, c:/foo/bar.dll ==> /sysroot/foo/bar.dll
244 if (!IS_TARGET_ABSOLUTE_PATH (fskind
, in_pathname
) || sysroot
== NULL
)
245 temp_pathname
= xstrdup (in_pathname
);
248 int need_dir_separator
;
250 /* Concatenate the sysroot and the target reported filename. We
251 may need to glue them with a directory separator. Cases to
254 | sysroot | separator | in_pathname |
255 |-----------------+-----------+----------------|
256 | /some/dir | / | c:/foo/bar.dll |
257 | /some/dir | | /foo/bar.dll |
258 | target: | | c:/foo/bar.dll |
259 | target: | | /foo/bar.dll |
260 | target:some/dir | / | c:/foo/bar.dll |
261 | target:some/dir | | /foo/bar.dll |
263 IOW, we don't need to add a separator if IN_PATHNAME already
264 has one, or when the the sysroot is exactly "target:".
265 There's no need to check for drive spec explicitly, as we only
266 get here if IN_PATHNAME is considered an absolute path. */
267 need_dir_separator
= !(IS_DIR_SEPARATOR (in_pathname
[0])
268 || strcmp (TARGET_SYSROOT_PREFIX
, sysroot
) == 0);
270 /* Cat the prefixed pathname together. */
271 temp_pathname
= concat (sysroot
,
272 need_dir_separator
? SLASH_STRING
: "",
273 in_pathname
, (char *) NULL
);
276 /* Handle files to be accessed via the target. */
277 if (is_target_filename (temp_pathname
))
280 do_cleanups (old_chain
);
281 return temp_pathname
;
284 /* Now see if we can open it. */
285 found_file
= gdb_open_cloexec (temp_pathname
, O_RDONLY
| O_BINARY
, 0);
287 xfree (temp_pathname
);
289 /* If the search in gdb_sysroot failed, and the path name has a
290 drive spec (e.g, c:/foo), try stripping ':' from the drive spec,
291 and retrying in the sysroot:
292 c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll. */
296 && HAS_TARGET_DRIVE_SPEC (fskind
, in_pathname
))
298 int need_dir_separator
= !IS_DIR_SEPARATOR (in_pathname
[2]);
299 char *drive
= savestring (in_pathname
, 1);
301 temp_pathname
= concat (sysroot
,
304 need_dir_separator
? SLASH_STRING
: "",
305 in_pathname
+ 2, (char *) NULL
);
308 found_file
= gdb_open_cloexec (temp_pathname
, O_RDONLY
| O_BINARY
, 0);
311 xfree (temp_pathname
);
313 /* If the search in gdb_sysroot still failed, try fully
314 stripping the drive spec, and trying once more in the
315 sysroot before giving up.
317 c:/foo/bar.dll ==> /sysroot/foo/bar.dll. */
319 temp_pathname
= concat (sysroot
,
320 need_dir_separator
? SLASH_STRING
: "",
321 in_pathname
+ 2, (char *) NULL
);
323 found_file
= gdb_open_cloexec (temp_pathname
, O_RDONLY
| O_BINARY
, 0);
325 xfree (temp_pathname
);
329 do_cleanups (old_chain
);
331 /* We try to find the library in various ways. After each attempt,
332 either found_file >= 0 and temp_pathname is a malloc'd string, or
333 found_file < 0 and temp_pathname does not point to storage that
334 needs to be freed. */
337 temp_pathname
= NULL
;
339 /* If the search in gdb_sysroot failed, and the path name is
340 absolute at this point, make it relative. (openp will try and open the
341 file according to its absolute path otherwise, which is not what we want.)
342 Affects subsequent searches for this solib. */
343 if (found_file
< 0 && IS_TARGET_ABSOLUTE_PATH (fskind
, in_pathname
))
345 /* First, get rid of any drive letters etc. */
346 while (!IS_TARGET_DIR_SEPARATOR (fskind
, *in_pathname
))
349 /* Next, get rid of all leading dir separators. */
350 while (IS_TARGET_DIR_SEPARATOR (fskind
, *in_pathname
))
354 /* If not found, search the solib_search_path (if any). */
355 if (found_file
< 0 && solib_search_path
!= NULL
)
356 found_file
= openp (solib_search_path
,
357 OPF_TRY_CWD_FIRST
| OPF_RETURN_REALPATH
,
358 in_pathname
, O_RDONLY
| O_BINARY
, &temp_pathname
);
360 /* If not found, next search the solib_search_path (if any) for the basename
361 only (ignoring the path). This is to allow reading solibs from a path
362 that differs from the opened path. */
363 if (found_file
< 0 && solib_search_path
!= NULL
)
364 found_file
= openp (solib_search_path
,
365 OPF_TRY_CWD_FIRST
| OPF_RETURN_REALPATH
,
366 target_lbasename (fskind
, in_pathname
),
367 O_RDONLY
| O_BINARY
, &temp_pathname
);
369 /* If not found, try to use target supplied solib search method. */
370 if (found_file
< 0 && ops
->find_and_open_solib
)
371 found_file
= ops
->find_and_open_solib (in_pathname
, O_RDONLY
| O_BINARY
,
374 /* If not found, next search the inferior's $PATH environment variable. */
375 if (found_file
< 0 && sysroot
== NULL
)
376 found_file
= openp (get_in_environ (current_inferior ()->environment
,
378 OPF_TRY_CWD_FIRST
| OPF_RETURN_REALPATH
, in_pathname
,
379 O_RDONLY
| O_BINARY
, &temp_pathname
);
381 /* If not found, next search the inferior's $LD_LIBRARY_PATH
382 environment variable. */
383 if (found_file
< 0 && sysroot
== NULL
)
384 found_file
= openp (get_in_environ (current_inferior ()->environment
,
386 OPF_TRY_CWD_FIRST
| OPF_RETURN_REALPATH
, in_pathname
,
387 O_RDONLY
| O_BINARY
, &temp_pathname
);
390 return temp_pathname
;
393 /* Open and return a BFD for the shared library PATHNAME. If FD is not -1,
394 it is used as file handle to open the file. Throws an error if the file
395 could not be opened. Handles both local and remote file access.
397 PATHNAME must be malloc'ed by the caller. It will be freed by this
398 function. If unsuccessful, the FD will be closed (unless FD was
402 solib_bfd_fopen (char *pathname
, int fd
)
404 bfd
*abfd
= gdb_bfd_open (pathname
, gnutarget
, fd
);
406 if (abfd
!= NULL
&& !gdb_bfd_has_target_filename (abfd
))
407 bfd_set_cacheable (abfd
, 1);
411 make_cleanup (xfree
, pathname
);
412 error (_("Could not open `%s' as an executable file: %s"),
413 pathname
, bfd_errmsg (bfd_get_error ()));
421 /* Find shared library PATHNAME and open a BFD for it. */
424 solib_bfd_open (char *pathname
)
426 char *found_pathname
;
429 const struct bfd_arch_info
*b
;
431 /* Search for shared library file. */
432 found_pathname
= solib_find (pathname
, &found_file
);
433 if (found_pathname
== NULL
)
435 /* Return failure if the file could not be found, so that we can
436 accumulate messages about missing libraries. */
440 perror_with_name (pathname
);
443 /* Open bfd for shared library. */
444 abfd
= solib_bfd_fopen (found_pathname
, found_file
);
446 /* Check bfd format. */
447 if (!bfd_check_format (abfd
, bfd_object
))
449 make_cleanup_bfd_unref (abfd
);
450 error (_("`%s': not in executable format: %s"),
451 bfd_get_filename (abfd
), bfd_errmsg (bfd_get_error ()));
454 /* Check bfd arch. */
455 b
= gdbarch_bfd_arch_info (target_gdbarch ());
456 if (!b
->compatible (b
, bfd_get_arch_info (abfd
)))
457 warning (_("`%s': Shared library architecture %s is not compatible "
458 "with target architecture %s."), bfd_get_filename (abfd
),
459 bfd_get_arch_info (abfd
)->printable_name
, b
->printable_name
);
464 /* Given a pointer to one of the shared objects in our list of mapped
465 objects, use the recorded name to open a bfd descriptor for the
466 object, build a section table, relocate all the section addresses
467 by the base address at which the shared object was mapped, and then
468 add the sections to the target's section table.
470 FIXME: In most (all?) cases the shared object file name recorded in
471 the dynamic linkage tables will be a fully qualified pathname. For
472 cases where it isn't, do we really mimic the systems search
473 mechanism correctly in the below code (particularly the tilde
474 expansion stuff?). */
477 solib_map_sections (struct so_list
*so
)
479 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
481 struct target_section
*p
;
482 struct cleanup
*old_chain
;
485 filename
= tilde_expand (so
->so_name
);
486 old_chain
= make_cleanup (xfree
, filename
);
487 abfd
= ops
->bfd_open (filename
);
488 do_cleanups (old_chain
);
493 /* Leave bfd open, core_xfer_memory and "info files" need it. */
496 /* Copy the full path name into so_name, allowing symbol_file_add
497 to find it later. This also affects the =library-loaded GDB/MI
498 event, and in particular the part of that notification providing
499 the library's host-side path. If we let the target dictate
500 that objfile's path, and the target is different from the host,
501 GDB/MI will not provide the correct host-side path. */
502 if (strlen (bfd_get_filename (abfd
)) >= SO_NAME_MAX_PATH_SIZE
)
503 error (_("Shared library file name is too long."));
504 strcpy (so
->so_name
, bfd_get_filename (abfd
));
506 if (build_section_table (abfd
, &so
->sections
, &so
->sections_end
))
508 error (_("Can't find the file sections in `%s': %s"),
509 bfd_get_filename (abfd
), bfd_errmsg (bfd_get_error ()));
512 for (p
= so
->sections
; p
< so
->sections_end
; p
++)
514 /* Relocate the section binding addresses as recorded in the shared
515 object's file by the base address to which the object was actually
517 ops
->relocate_section_addresses (so
, p
);
519 /* If the target didn't provide information about the address
520 range of the shared object, assume we want the location of
521 the .text section. */
522 if (so
->addr_low
== 0 && so
->addr_high
== 0
523 && strcmp (p
->the_bfd_section
->name
, ".text") == 0)
525 so
->addr_low
= p
->addr
;
526 so
->addr_high
= p
->endaddr
;
530 /* Add the shared object's sections to the current set of file
531 section tables. Do this immediately after mapping the object so
532 that later nodes in the list can query this object, as is needed
534 add_target_sections (so
, so
->sections
, so
->sections_end
);
539 /* Free symbol-file related contents of SO and reset for possible reloading
540 of SO. If we have opened a BFD for SO, close it. If we have placed SO's
541 sections in some target's section table, the caller is responsible for
544 This function doesn't mess with objfiles at all. If there is an
545 objfile associated with SO that needs to be removed, the caller is
546 responsible for taking care of that. */
549 clear_so (struct so_list
*so
)
551 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
555 xfree (so
->sections
);
556 so
->sections
= so
->sections_end
= NULL
;
559 gdb_bfd_unref (so
->abfd
);
562 /* Our caller closed the objfile, possibly via objfile_purge_solibs. */
563 so
->symbols_loaded
= 0;
566 so
->addr_low
= so
->addr_high
= 0;
568 /* Restore the target-supplied file name. SO_NAME may be the path
569 of the symbol file. */
570 strcpy (so
->so_name
, so
->so_original_name
);
572 /* Do the same for target-specific data. */
573 if (ops
->clear_so
!= NULL
)
577 /* Free the storage associated with the `struct so_list' object SO.
578 If we have opened a BFD for SO, close it.
580 The caller is responsible for removing SO from whatever list it is
581 a member of. If we have placed SO's sections in some target's
582 section table, the caller is responsible for removing them.
584 This function doesn't mess with objfiles at all. If there is an
585 objfile associated with SO that needs to be removed, the caller is
586 responsible for taking care of that. */
589 free_so (struct so_list
*so
)
591 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
600 /* Return address of first so_list entry in master shared object list. */
602 master_so_list (void)
607 /* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
608 be chatty about it. Return non-zero if any symbols were actually
612 solib_read_symbols (struct so_list
*so
, int flags
)
614 if (so
->symbols_loaded
)
616 /* If needed, we've already warned in our caller. */
618 else if (so
->abfd
== NULL
)
620 /* We've already warned about this library, when trying to open
626 flags
|= current_inferior ()->symfile_flags
;
630 struct section_addr_info
*sap
;
632 /* Have we already loaded this shared object? */
633 ALL_OBJFILES (so
->objfile
)
635 if (filename_cmp (objfile_name (so
->objfile
), so
->so_name
) == 0
636 && so
->objfile
->addr_low
== so
->addr_low
)
639 if (so
->objfile
!= NULL
)
642 sap
= build_section_addr_info_from_section_table (so
->sections
,
644 so
->objfile
= symbol_file_add_from_bfd (so
->abfd
, so
->so_name
,
645 flags
, sap
, OBJF_SHARED
,
647 so
->objfile
->addr_low
= so
->addr_low
;
648 free_section_addr_info (sap
);
650 so
->symbols_loaded
= 1;
652 CATCH (e
, RETURN_MASK_ERROR
)
654 exception_fprintf (gdb_stderr
, e
, _("Error while reading shared"
655 " library symbols for %s:\n"),
666 /* Return 1 if KNOWN->objfile is used by any other so_list object in the
667 SO_LIST_HEAD list. Return 0 otherwise. */
670 solib_used (const struct so_list
*const known
)
672 const struct so_list
*pivot
;
674 for (pivot
= so_list_head
; pivot
!= NULL
; pivot
= pivot
->next
)
675 if (pivot
!= known
&& pivot
->objfile
== known
->objfile
)
680 /* Synchronize GDB's shared object list with inferior's.
682 Extract the list of currently loaded shared objects from the
683 inferior, and compare it with the list of shared objects currently
684 in GDB's so_list_head list. Edit so_list_head to bring it in sync
685 with the inferior's new list.
687 If we notice that the inferior has unloaded some shared objects,
688 free any symbolic info GDB had read about those shared objects.
690 Don't load symbolic info for any new shared objects; just add them
691 to the list, and leave their symbols_loaded flag clear.
693 If FROM_TTY is non-null, feel free to print messages about what
696 If TARGET is non-null, add the sections of all new shared objects
697 to TARGET's section table. Note that this doesn't remove any
698 sections for shared objects that have been unloaded, and it
699 doesn't check to see if the new shared objects are already present in
700 the section table. But we only use this for core files and
701 processes we've just attached to, so that's okay. */
704 update_solib_list (int from_tty
, struct target_ops
*target
)
706 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
707 struct so_list
*inferior
= ops
->current_sos();
708 struct so_list
*gdb
, **gdb_link
;
710 /* We can reach here due to changing solib-search-path or the
711 sysroot, before having any inferior. */
712 if (target_has_execution
&& !ptid_equal (inferior_ptid
, null_ptid
))
714 struct inferior
*inf
= current_inferior ();
716 /* If we are attaching to a running process for which we
717 have not opened a symbol file, we may be able to get its
719 if (inf
->attach_flag
&& symfile_objfile
== NULL
)
720 catch_errors (ops
->open_symbol_file_object
, &from_tty
,
721 "Error reading attached process's symbol file.\n",
725 /* GDB and the inferior's dynamic linker each maintain their own
726 list of currently loaded shared objects; we want to bring the
727 former in sync with the latter. Scan both lists, seeing which
728 shared objects appear where. There are three cases:
730 - A shared object appears on both lists. This means that GDB
731 knows about it already, and it's still loaded in the inferior.
732 Nothing needs to happen.
734 - A shared object appears only on GDB's list. This means that
735 the inferior has unloaded it. We should remove the shared
736 object from GDB's tables.
738 - A shared object appears only on the inferior's list. This
739 means that it's just been loaded. We should add it to GDB's
742 So we walk GDB's list, checking each entry to see if it appears
743 in the inferior's list too. If it does, no action is needed, and
744 we remove it from the inferior's list. If it doesn't, the
745 inferior has unloaded it, and we remove it from GDB's list. By
746 the time we're done walking GDB's list, the inferior's list
747 contains only the new shared objects, which we then add. */
750 gdb_link
= &so_list_head
;
753 struct so_list
*i
= inferior
;
754 struct so_list
**i_link
= &inferior
;
756 /* Check to see whether the shared object *gdb also appears in
757 the inferior's current list. */
762 if (ops
->same (gdb
, i
))
767 if (! filename_cmp (gdb
->so_original_name
, i
->so_original_name
))
775 /* If the shared object appears on the inferior's list too, then
776 it's still loaded, so we don't need to do anything. Delete
777 it from the inferior's list, and leave it on GDB's list. */
782 gdb_link
= &gdb
->next
;
786 /* If it's not on the inferior's list, remove it from GDB's tables. */
789 /* Notify any observer that the shared object has been
790 unloaded before we remove it from GDB's tables. */
791 observer_notify_solib_unloaded (gdb
);
793 VEC_safe_push (char_ptr
, current_program_space
->deleted_solibs
,
794 xstrdup (gdb
->so_name
));
796 *gdb_link
= gdb
->next
;
798 /* Unless the user loaded it explicitly, free SO's objfile. */
799 if (gdb
->objfile
&& ! (gdb
->objfile
->flags
& OBJF_USERLOADED
)
800 && !solib_used (gdb
))
801 free_objfile (gdb
->objfile
);
803 /* Some targets' section tables might be referring to
804 sections from so->abfd; remove them. */
805 remove_target_sections (gdb
);
812 /* Now the inferior's list contains only shared objects that don't
813 appear in GDB's list --- those that are newly loaded. Add them
814 to GDB's shared object list. */
818 const char *not_found_filename
= NULL
;
822 /* Add the new shared objects to GDB's list. */
823 *gdb_link
= inferior
;
825 /* Fill in the rest of each of the `struct so_list' nodes. */
826 for (i
= inferior
; i
; i
= i
->next
)
829 i
->pspace
= current_program_space
;
830 VEC_safe_push (so_list_ptr
, current_program_space
->added_solibs
, i
);
834 /* Fill in the rest of the `struct so_list' node. */
835 if (!solib_map_sections (i
))
838 if (not_found_filename
== NULL
)
839 not_found_filename
= i
->so_original_name
;
843 CATCH (e
, RETURN_MASK_ERROR
)
845 exception_fprintf (gdb_stderr
, e
,
846 _("Error while mapping shared "
847 "library sections:\n"));
851 /* Notify any observer that the shared object has been
852 loaded now that we've added it to GDB's tables. */
853 observer_notify_solib_loaded (i
);
856 /* If a library was not found, issue an appropriate warning
857 message. We have to use a single call to warning in case the
858 front end does something special with warnings, e.g., pop up
859 a dialog box. It Would Be Nice if we could get a "warning: "
860 prefix on each line in the CLI front end, though - it doesn't
864 warning (_("Could not load shared library symbols for %s.\n"
865 "Do you need \"set solib-search-path\" "
866 "or \"set sysroot\"?"),
868 else if (not_found
> 1)
870 Could not load shared library symbols for %d libraries, e.g. %s.\n\
871 Use the \"info sharedlibrary\" command to see the complete listing.\n\
872 Do you need \"set solib-search-path\" or \"set sysroot\"?"),
873 not_found
, not_found_filename
);
878 /* Return non-zero if NAME is the libpthread shared library.
880 Uses a fairly simplistic heuristic approach where we check
881 the file name against "/libpthread". This can lead to false
882 positives, but this should be good enough in practice. */
885 libpthread_name_p (const char *name
)
887 return (strstr (name
, "/libpthread") != NULL
);
890 /* Return non-zero if SO is the libpthread shared library. */
893 libpthread_solib_p (struct so_list
*so
)
895 return libpthread_name_p (so
->so_name
);
898 /* Read in symbolic information for any shared objects whose names
899 match PATTERN. (If we've already read a shared object's symbol
900 info, leave it alone.) If PATTERN is zero, read them all.
902 If READSYMS is 0, defer reading symbolic information until later
903 but still do any needed low level processing.
905 FROM_TTY and TARGET are as described for update_solib_list, above. */
908 solib_add (const char *pattern
, int from_tty
,
909 struct target_ops
*target
, int readsyms
)
913 if (print_symbol_loading_p (from_tty
, 0, 0))
917 printf_unfiltered (_("Loading symbols for shared libraries: %s\n"),
921 printf_unfiltered (_("Loading symbols for shared libraries.\n"));
924 current_program_space
->solib_add_generation
++;
928 char *re_err
= re_comp (pattern
);
931 error (_("Invalid regexp: %s"), re_err
);
934 update_solib_list (from_tty
, target
);
936 /* Walk the list of currently loaded shared libraries, and read
937 symbols for any that match the pattern --- or any whose symbols
938 aren't already loaded, if no pattern was given. */
941 int loaded_any_symbols
= 0;
943 SYMFILE_DEFER_BP_RESET
| (from_tty
? SYMFILE_VERBOSE
: 0);
945 for (gdb
= so_list_head
; gdb
; gdb
= gdb
->next
)
946 if (! pattern
|| re_exec (gdb
->so_name
))
948 /* Normally, we would read the symbols from that library
949 only if READSYMS is set. However, we're making a small
950 exception for the pthread library, because we sometimes
951 need the library symbols to be loaded in order to provide
952 thread support (x86-linux for instance). */
953 const int add_this_solib
=
954 (readsyms
|| libpthread_solib_p (gdb
));
959 if (gdb
->symbols_loaded
)
961 /* If no pattern was given, be quiet for shared
962 libraries we have already loaded. */
963 if (pattern
&& (from_tty
|| info_verbose
))
964 printf_unfiltered (_("Symbols already loaded for %s\n"),
967 else if (solib_read_symbols (gdb
, flags
))
968 loaded_any_symbols
= 1;
972 if (loaded_any_symbols
)
973 breakpoint_re_set ();
975 if (from_tty
&& pattern
&& ! any_matches
)
977 ("No loaded shared libraries match the pattern `%s'.\n", pattern
);
979 if (loaded_any_symbols
)
981 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
983 /* Getting new symbols may change our opinion about what is
985 reinit_frame_cache ();
987 ops
->special_symbol_handling ();
992 /* Implement the "info sharedlibrary" command. Walk through the
993 shared library list and print information about each attached
994 library matching PATTERN. If PATTERN is elided, print them
998 info_sharedlibrary_command (char *pattern
, int from_tty
)
1000 struct so_list
*so
= NULL
; /* link map state variable */
1001 int so_missing_debug_info
= 0;
1004 struct cleanup
*table_cleanup
;
1005 struct gdbarch
*gdbarch
= target_gdbarch ();
1006 struct ui_out
*uiout
= current_uiout
;
1010 char *re_err
= re_comp (pattern
);
1013 error (_("Invalid regexp: %s"), re_err
);
1016 /* "0x", a little whitespace, and two hex digits per byte of pointers. */
1017 addr_width
= 4 + (gdbarch_ptr_bit (gdbarch
) / 4);
1019 update_solib_list (from_tty
, 0);
1021 /* make_cleanup_ui_out_table_begin_end needs to know the number of
1022 rows, so we need to make two passes over the libs. */
1024 for (nr_libs
= 0, so
= so_list_head
; so
; so
= so
->next
)
1028 if (pattern
&& ! re_exec (so
->so_name
))
1035 make_cleanup_ui_out_table_begin_end (uiout
, 4, nr_libs
,
1036 "SharedLibraryTable");
1038 /* The "- 1" is because ui_out adds one space between columns. */
1039 ui_out_table_header (uiout
, addr_width
- 1, ui_left
, "from", "From");
1040 ui_out_table_header (uiout
, addr_width
- 1, ui_left
, "to", "To");
1041 ui_out_table_header (uiout
, 12 - 1, ui_left
, "syms-read", "Syms Read");
1042 ui_out_table_header (uiout
, 0, ui_noalign
,
1043 "name", "Shared Object Library");
1045 ui_out_table_body (uiout
);
1047 for (so
= so_list_head
; so
; so
= so
->next
)
1049 struct cleanup
*lib_cleanup
;
1051 if (! so
->so_name
[0])
1053 if (pattern
&& ! re_exec (so
->so_name
))
1056 lib_cleanup
= make_cleanup_ui_out_tuple_begin_end (uiout
, "lib");
1058 if (so
->addr_high
!= 0)
1060 ui_out_field_core_addr (uiout
, "from", gdbarch
, so
->addr_low
);
1061 ui_out_field_core_addr (uiout
, "to", gdbarch
, so
->addr_high
);
1065 ui_out_field_skip (uiout
, "from");
1066 ui_out_field_skip (uiout
, "to");
1069 if (! ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
1070 && so
->symbols_loaded
1071 && !objfile_has_symbols (so
->objfile
))
1073 so_missing_debug_info
= 1;
1074 ui_out_field_string (uiout
, "syms-read", "Yes (*)");
1077 ui_out_field_string (uiout
, "syms-read",
1078 so
->symbols_loaded
? "Yes" : "No");
1080 ui_out_field_string (uiout
, "name", so
->so_name
);
1082 ui_out_text (uiout
, "\n");
1084 do_cleanups (lib_cleanup
);
1087 do_cleanups (table_cleanup
);
1092 ui_out_message (uiout
, 0,
1093 _("No shared libraries matched.\n"));
1095 ui_out_message (uiout
, 0,
1096 _("No shared libraries loaded at this time.\n"));
1100 if (so_missing_debug_info
)
1101 ui_out_message (uiout
, 0,
1102 _("(*): Shared library is missing "
1103 "debugging information.\n"));
1107 /* Return 1 if ADDRESS lies within SOLIB. */
1110 solib_contains_address_p (const struct so_list
*const solib
,
1113 struct target_section
*p
;
1115 for (p
= solib
->sections
; p
< solib
->sections_end
; p
++)
1116 if (p
->addr
<= address
&& address
< p
->endaddr
)
1122 /* If ADDRESS is in a shared lib in program space PSPACE, return its
1125 Provides a hook for other gdb routines to discover whether or not a
1126 particular address is within the mapped address space of a shared
1129 For example, this routine is called at one point to disable
1130 breakpoints which are in shared libraries that are not currently
1134 solib_name_from_address (struct program_space
*pspace
, CORE_ADDR address
)
1136 struct so_list
*so
= NULL
;
1138 for (so
= pspace
->so_list
; so
; so
= so
->next
)
1139 if (solib_contains_address_p (so
, address
))
1140 return (so
->so_name
);
1145 /* Return whether the data starting at VADDR, size SIZE, must be kept
1146 in a core file for shared libraries loaded before "gcore" is used
1147 to be handled correctly when the core file is loaded. This only
1148 applies when the section would otherwise not be kept in the core
1149 file (in particular, for readonly sections). */
1152 solib_keep_data_in_core (CORE_ADDR vaddr
, unsigned long size
)
1154 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1156 if (ops
->keep_data_in_core
)
1157 return ops
->keep_data_in_core (vaddr
, size
);
1162 /* Called by free_all_symtabs */
1167 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1169 /* This function is expected to handle ELF shared libraries. It is
1170 also used on Solaris, which can run either ELF or a.out binaries
1171 (for compatibility with SunOS 4), both of which can use shared
1172 libraries. So we don't know whether we have an ELF executable or
1173 an a.out executable until the user chooses an executable file.
1175 ELF shared libraries don't get mapped into the address space
1176 until after the program starts, so we'd better not try to insert
1177 breakpoints in them immediately. We have to wait until the
1178 dynamic linker has loaded them; we'll hit a bp_shlib_event
1179 breakpoint (look for calls to create_solib_event_breakpoint) when
1182 SunOS shared libraries seem to be different --- they're present
1183 as soon as the process begins execution, so there's no need to
1184 put off inserting breakpoints. There's also nowhere to put a
1185 bp_shlib_event breakpoint, so if we put it off, we'll never get
1188 So: disable breakpoints only if we're using ELF shared libs. */
1189 if (exec_bfd
!= NULL
1190 && bfd_get_flavour (exec_bfd
) != bfd_target_aout_flavour
)
1191 disable_breakpoints_in_shlibs ();
1193 while (so_list_head
)
1195 struct so_list
*so
= so_list_head
;
1197 so_list_head
= so
->next
;
1198 observer_notify_solib_unloaded (so
);
1199 remove_target_sections (so
);
1203 ops
->clear_solib ();
1206 /* Shared library startup support. When GDB starts up the inferior,
1207 it nurses it along (through the shell) until it is ready to execute
1208 its first instruction. At this point, this function gets
1212 solib_create_inferior_hook (int from_tty
)
1214 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1216 ops
->solib_create_inferior_hook (from_tty
);
1219 /* Check to see if an address is in the dynamic loader's dynamic
1220 symbol resolution code. Return 1 if so, 0 otherwise. */
1223 in_solib_dynsym_resolve_code (CORE_ADDR pc
)
1225 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1227 return ops
->in_dynsym_resolve_code (pc
);
1230 /* Implements the "sharedlibrary" command. */
1233 sharedlibrary_command (char *args
, int from_tty
)
1236 solib_add (args
, from_tty
, (struct target_ops
*) 0, 1);
1239 /* Implements the command "nosharedlibrary", which discards symbols
1240 that have been auto-loaded from shared libraries. Symbols from
1241 shared libraries that were added by explicit request of the user
1242 are not discarded. Also called from remote.c. */
1245 no_shared_libraries (char *ignored
, int from_tty
)
1247 /* The order of the two routines below is important: clear_solib notifies
1248 the solib_unloaded observers, and some of these observers might need
1249 access to their associated objfiles. Therefore, we can not purge the
1250 solibs' objfiles before clear_solib has been called. */
1253 objfile_purge_solibs ();
1259 update_solib_breakpoints (void)
1261 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1263 if (ops
->update_breakpoints
!= NULL
)
1264 ops
->update_breakpoints ();
1270 handle_solib_event (void)
1272 const struct target_so_ops
*ops
= solib_ops (target_gdbarch ());
1274 if (ops
->handle_event
!= NULL
)
1275 ops
->handle_event ();
1277 clear_program_space_solib_cache (current_inferior ()->pspace
);
1279 /* Check for any newly added shared libraries if we're supposed to
1280 be adding them automatically. Switch terminal for any messages
1281 produced by breakpoint_re_set. */
1282 target_terminal_ours_for_output ();
1283 solib_add (NULL
, 0, ¤t_target
, auto_solib_add
);
1284 target_terminal_inferior ();
1287 /* Reload shared libraries, but avoid reloading the same symbol file
1288 we already have loaded. */
1291 reload_shared_libraries_1 (int from_tty
)
1294 struct cleanup
*old_chain
= make_cleanup (null_cleanup
, NULL
);
1296 if (print_symbol_loading_p (from_tty
, 0, 0))
1297 printf_unfiltered (_("Loading symbols for shared libraries.\n"));
1299 for (so
= so_list_head
; so
!= NULL
; so
= so
->next
)
1301 char *filename
, *found_pathname
= NULL
;
1303 int was_loaded
= so
->symbols_loaded
;
1305 SYMFILE_DEFER_BP_RESET
| (from_tty
? SYMFILE_VERBOSE
: 0);
1307 filename
= tilde_expand (so
->so_original_name
);
1308 make_cleanup (xfree
, filename
);
1309 abfd
= solib_bfd_open (filename
);
1312 found_pathname
= xstrdup (bfd_get_filename (abfd
));
1313 make_cleanup (xfree
, found_pathname
);
1314 gdb_bfd_unref (abfd
);
1317 /* If this shared library is no longer associated with its previous
1318 symbol file, close that. */
1319 if ((found_pathname
== NULL
&& was_loaded
)
1320 || (found_pathname
!= NULL
1321 && filename_cmp (found_pathname
, so
->so_name
) != 0))
1323 if (so
->objfile
&& ! (so
->objfile
->flags
& OBJF_USERLOADED
)
1324 && !solib_used (so
))
1325 free_objfile (so
->objfile
);
1326 remove_target_sections (so
);
1330 /* If this shared library is now associated with a new symbol
1332 if (found_pathname
!= NULL
1334 || filename_cmp (found_pathname
, so
->so_name
) != 0))
1340 solib_map_sections (so
);
1343 CATCH (e
, RETURN_MASK_ERROR
)
1345 exception_fprintf (gdb_stderr
, e
,
1346 _("Error while mapping "
1347 "shared library sections:\n"));
1353 && (auto_solib_add
|| was_loaded
|| libpthread_solib_p (so
)))
1354 solib_read_symbols (so
, flags
);
1358 do_cleanups (old_chain
);
1362 reload_shared_libraries (char *ignored
, int from_tty
,
1363 struct cmd_list_element
*e
)
1365 const struct target_so_ops
*ops
;
1367 reload_shared_libraries_1 (from_tty
);
1369 ops
= solib_ops (target_gdbarch ());
1371 /* Creating inferior hooks here has two purposes. First, if we reload
1372 shared libraries then the address of solib breakpoint we've computed
1373 previously might be no longer valid. For example, if we forgot to set
1374 solib-absolute-prefix and are setting it right now, then the previous
1375 breakpoint address is plain wrong. Second, installing solib hooks
1376 also implicitly figures were ld.so is and loads symbols for it.
1377 Absent this call, if we've just connected to a target and set
1378 solib-absolute-prefix or solib-search-path, we'll lose all information
1380 if (target_has_execution
)
1382 /* Reset or free private data structures not associated with
1384 ops
->clear_solib ();
1386 /* Remove any previous solib event breakpoint. This is usually
1387 done in common code, at breakpoint_init_inferior time, but
1388 we're not really starting up the inferior here. */
1389 remove_solib_event_breakpoints ();
1391 solib_create_inferior_hook (from_tty
);
1394 /* Sometimes the platform-specific hook loads initial shared
1395 libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be
1396 incorrectly 0 but such solib targets should be fixed anyway. If we
1397 made all the inferior hook methods consistent, this call could be
1398 removed. Call it only after the solib target has been initialized by
1399 solib_create_inferior_hook. */
1401 solib_add (NULL
, 0, NULL
, auto_solib_add
);
1403 breakpoint_re_set ();
1405 /* We may have loaded or unloaded debug info for some (or all)
1406 shared libraries. However, frames may still reference them. For
1407 example, a frame's unwinder might still point at DWARF FDE
1408 structures that are now freed. Also, getting new symbols may
1409 change our opinion about what is frameless. */
1410 reinit_frame_cache ();
1412 ops
->special_symbol_handling ();
1415 /* Wrapper for reload_shared_libraries that replaces "remote:"
1416 at the start of gdb_sysroot with "target:". */
1419 gdb_sysroot_changed (char *ignored
, int from_tty
,
1420 struct cmd_list_element
*e
)
1422 const char *old_prefix
= "remote:";
1423 const char *new_prefix
= TARGET_SYSROOT_PREFIX
;
1425 if (startswith (gdb_sysroot
, old_prefix
))
1427 static int warning_issued
= 0;
1429 gdb_assert (strlen (old_prefix
) == strlen (new_prefix
));
1430 memcpy (gdb_sysroot
, new_prefix
, strlen (new_prefix
));
1432 if (!warning_issued
)
1434 warning (_("\"%s\" is deprecated, use \"%s\" instead."),
1435 old_prefix
, new_prefix
);
1436 warning (_("sysroot set to \"%s\"."), gdb_sysroot
);
1442 reload_shared_libraries (ignored
, from_tty
, e
);
1446 show_auto_solib_add (struct ui_file
*file
, int from_tty
,
1447 struct cmd_list_element
*c
, const char *value
)
1449 fprintf_filtered (file
, _("Autoloading of shared library symbols is %s.\n"),
1454 /* Handler for library-specific lookup of global symbol NAME in OBJFILE. Call
1455 the library-specific handler if it is installed for the current target. */
1458 solib_global_lookup (struct objfile
*objfile
,
1460 const domain_enum domain
)
1462 const struct target_so_ops
*ops
= solib_ops (get_objfile_arch (objfile
));
1464 if (ops
->lookup_lib_global_symbol
!= NULL
)
1465 return ops
->lookup_lib_global_symbol (objfile
, name
, domain
);
1469 /* Lookup the value for a specific symbol from dynamic symbol table. Look
1470 up symbol from ABFD. MATCH_SYM is a callback function to determine
1471 whether to pick up a symbol. DATA is the input of this callback
1472 function. Return NULL if symbol is not found. */
1475 gdb_bfd_lookup_symbol_from_symtab (bfd
*abfd
,
1476 int (*match_sym
) (asymbol
*, void *),
1479 long storage_needed
= bfd_get_symtab_upper_bound (abfd
);
1480 CORE_ADDR symaddr
= 0;
1482 if (storage_needed
> 0)
1486 asymbol
**symbol_table
= (asymbol
**) xmalloc (storage_needed
);
1487 struct cleanup
*back_to
= make_cleanup (xfree
, symbol_table
);
1488 unsigned int number_of_symbols
=
1489 bfd_canonicalize_symtab (abfd
, symbol_table
);
1491 for (i
= 0; i
< number_of_symbols
; i
++)
1493 asymbol
*sym
= *symbol_table
++;
1495 if (match_sym (sym
, data
))
1497 struct gdbarch
*gdbarch
= target_gdbarch ();
1498 symaddr
= sym
->value
;
1500 /* Some ELF targets fiddle with addresses of symbols they
1501 consider special. They use minimal symbols to do that
1502 and this is needed for correct breakpoint placement,
1503 but we do not have full data here to build a complete
1504 minimal symbol, so just set the address and let the
1505 targets cope with that. */
1506 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
1507 && gdbarch_elf_make_msymbol_special_p (gdbarch
))
1509 struct minimal_symbol msym
;
1511 memset (&msym
, 0, sizeof (msym
));
1512 SET_MSYMBOL_VALUE_ADDRESS (&msym
, symaddr
);
1513 gdbarch_elf_make_msymbol_special (gdbarch
, sym
, &msym
);
1514 symaddr
= MSYMBOL_VALUE_RAW_ADDRESS (&msym
);
1517 /* BFD symbols are section relative. */
1518 symaddr
+= sym
->section
->vma
;
1522 do_cleanups (back_to
);
1528 /* Lookup the value for a specific symbol from symbol table. Look up symbol
1529 from ABFD. MATCH_SYM is a callback function to determine whether to pick
1530 up a symbol. DATA is the input of this callback function. Return NULL
1531 if symbol is not found. */
1534 bfd_lookup_symbol_from_dyn_symtab (bfd
*abfd
,
1535 int (*match_sym
) (asymbol
*, void *),
1538 long storage_needed
= bfd_get_dynamic_symtab_upper_bound (abfd
);
1539 CORE_ADDR symaddr
= 0;
1541 if (storage_needed
> 0)
1544 asymbol
**symbol_table
= (asymbol
**) xmalloc (storage_needed
);
1545 struct cleanup
*back_to
= make_cleanup (xfree
, symbol_table
);
1546 unsigned int number_of_symbols
=
1547 bfd_canonicalize_dynamic_symtab (abfd
, symbol_table
);
1549 for (i
= 0; i
< number_of_symbols
; i
++)
1551 asymbol
*sym
= *symbol_table
++;
1553 if (match_sym (sym
, data
))
1555 /* BFD symbols are section relative. */
1556 symaddr
= sym
->value
+ sym
->section
->vma
;
1560 do_cleanups (back_to
);
1565 /* Lookup the value for a specific symbol from symbol table and dynamic
1566 symbol table. Look up symbol from ABFD. MATCH_SYM is a callback
1567 function to determine whether to pick up a symbol. DATA is the
1568 input of this callback function. Return NULL if symbol is not
1572 gdb_bfd_lookup_symbol (bfd
*abfd
,
1573 int (*match_sym
) (asymbol
*, void *),
1576 CORE_ADDR symaddr
= gdb_bfd_lookup_symbol_from_symtab (abfd
, match_sym
, data
);
1578 /* On FreeBSD, the dynamic linker is stripped by default. So we'll
1579 have to check the dynamic string table too. */
1581 symaddr
= bfd_lookup_symbol_from_dyn_symtab (abfd
, match_sym
, data
);
1586 /* SO_LIST_HEAD may contain user-loaded object files that can be removed
1587 out-of-band by the user. So upon notification of free_objfile remove
1588 all references to any user-loaded file that is about to be freed. */
1591 remove_user_added_objfile (struct objfile
*objfile
)
1595 if (objfile
!= 0 && objfile
->flags
& OBJF_USERLOADED
)
1597 for (so
= so_list_head
; so
!= NULL
; so
= so
->next
)
1598 if (so
->objfile
== objfile
)
1603 extern initialize_file_ftype _initialize_solib
; /* -Wmissing-prototypes */
1606 _initialize_solib (void)
1608 solib_data
= gdbarch_data_register_pre_init (solib_init
);
1610 observer_attach_free_objfile (remove_user_added_objfile
);
1612 add_com ("sharedlibrary", class_files
, sharedlibrary_command
,
1613 _("Load shared object library symbols for files matching REGEXP."));
1614 add_info ("sharedlibrary", info_sharedlibrary_command
,
1615 _("Status of loaded shared object libraries."));
1616 add_com ("nosharedlibrary", class_files
, no_shared_libraries
,
1617 _("Unload all shared object library symbols."));
1619 add_setshow_boolean_cmd ("auto-solib-add", class_support
,
1620 &auto_solib_add
, _("\
1621 Set autoloading of shared library symbols."), _("\
1622 Show autoloading of shared library symbols."), _("\
1623 If \"on\", symbols from all shared object libraries will be loaded\n\
1624 automatically when the inferior begins execution, when the dynamic linker\n\
1625 informs gdb that a new library has been loaded, or when attaching to the\n\
1626 inferior. Otherwise, symbols must be loaded manually, using \
1629 show_auto_solib_add
,
1630 &setlist
, &showlist
);
1632 add_setshow_optional_filename_cmd ("sysroot", class_support
,
1634 Set an alternate system root."), _("\
1635 Show the current system root."), _("\
1636 The system root is used to load absolute shared library symbol files.\n\
1637 For other (relative) files, you can add directories using\n\
1638 `set solib-search-path'."),
1639 gdb_sysroot_changed
,
1641 &setlist
, &showlist
);
1643 add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support
, 0,
1645 add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support
, 0,
1648 add_setshow_optional_filename_cmd ("solib-search-path", class_support
,
1649 &solib_search_path
, _("\
1650 Set the search path for loading non-absolute shared library symbol files."),
1652 Show the search path for loading non-absolute shared library symbol files."),
1654 This takes precedence over the environment variables \
1655 PATH and LD_LIBRARY_PATH."),
1656 reload_shared_libraries
,
1657 show_solib_search_path
,
1658 &setlist
, &showlist
);