* snapshots.readme: Tell people to always report missing files.
[deliverable/binutils-gdb.git] / gdb / solib.c
CommitLineData
f8b76e70 1/* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
ee0613d1 2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
f8b76e70 3
bd5635a1
RP
4This file is part of GDB.
5
bdbd5f50 6This program is free software; you can redistribute it and/or modify
bd5635a1 7it under the terms of the GNU General Public License as published by
bdbd5f50
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
bd5635a1 10
bdbd5f50 11This program is distributed in the hope that it will be useful,
bd5635a1
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
bdbd5f50
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bd5635a1 19
f8b76e70 20
b0246b3b
FF
21#include "defs.h"
22
bd5635a1 23#include <sys/types.h>
f8b76e70 24#include <signal.h>
bd5635a1
RP
25#include <string.h>
26#include <link.h>
d0237a54
JK
27#include <sys/param.h>
28#include <fcntl.h>
be772100
JG
29
30#ifndef SVR4_SHARED_LIBS
31 /* SunOS shared libs need the nlist structure. */
32#include <a.out.h>
33#endif
f8b76e70 34
bd5635a1 35#include "symtab.h"
b0246b3b
FF
36#include "bfd.h"
37#include "symfile.h"
be772100 38#include "objfiles.h"
bd5635a1
RP
39#include "gdbcore.h"
40#include "command.h"
b3fdaf3d 41#include "target.h"
2403f49b 42#include "frame.h"
bdbd5f50
JG
43#include "regex.h"
44#include "inferior.h"
45
f8b76e70
FF
46#define MAX_PATH_SIZE 256 /* FIXME: Should be dynamic */
47
a608f919
FF
48/* On SVR4 systems, for the initial implementation, use some runtime startup
49 symbol as the "startup mapping complete" breakpoint address. The models
50 for SunOS and SVR4 dynamic linking debugger support are different in that
51 SunOS hits one breakpoint when all mapping is complete while using the SVR4
f8b76e70
FF
52 debugger support takes two breakpoint hits for each file mapped, and
53 there is no way to know when the "last" one is hit. Both these
54 mechanisms should be tied to a "breakpoint service routine" that
55 gets automatically executed whenever one of the breakpoints indicating
56 a change in mapping is hit. This is a future enhancement. (FIXME) */
57
a608f919
FF
58#define BKPT_AT_SYMBOL 1
59
60static char *bkpt_names[] = {
61#ifdef SOLIB_BKPT_NAME
62 SOLIB_BKPT_NAME, /* Prefer configured name if it exists. */
63#endif
64 "_start",
65 "main",
66 NULL
67};
f8b76e70
FF
68
69/* local data declarations */
70
d261ece7 71#ifndef SVR4_SHARED_LIBS
f8b76e70
FF
72
73#define DEBUG_BASE "_DYNAMIC"
74#define LM_ADDR(so) ((so) -> lm.lm_addr)
75#define LM_NEXT(so) ((so) -> lm.lm_next)
76#define LM_NAME(so) ((so) -> lm.lm_name)
77static struct link_dynamic dynamic_copy;
78static struct link_dynamic_2 ld_2_copy;
79static struct ld_debug debug_copy;
80static CORE_ADDR debug_addr;
81static CORE_ADDR flag_addr;
82
d261ece7 83#else /* SVR4_SHARED_LIBS */
f8b76e70
FF
84
85#define DEBUG_BASE "_r_debug"
86#define LM_ADDR(so) ((so) -> lm.l_addr)
87#define LM_NEXT(so) ((so) -> lm.l_next)
88#define LM_NAME(so) ((so) -> lm.l_name)
89static struct r_debug debug_copy;
f8b76e70 90char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
f8b76e70 91
d261ece7 92#endif /* !SVR4_SHARED_LIBS */
bd5635a1 93
bd5635a1 94struct so_list {
f8b76e70
FF
95 struct so_list *next; /* next structure in linked list */
96 struct link_map lm; /* copy of link map from inferior */
97 struct link_map *lmaddr; /* addr in inferior lm was read from */
98 CORE_ADDR lmend; /* upper addr bound of mapped object */
99 char so_name[MAX_PATH_SIZE]; /* shared object lib name (FIXME) */
100 char symbols_loaded; /* flag: symbols read in yet? */
101 char from_tty; /* flag: print msgs? */
b0246b3b 102 struct objfile *objfile; /* objfile for loaded lib */
f8b76e70
FF
103 struct section_table *sections;
104 struct section_table *sections_end;
51b57ded 105 struct section_table *textsection;
a608f919 106 bfd *bfd;
bd5635a1
RP
107};
108
f8b76e70
FF
109static struct so_list *so_list_head; /* List of known shared objects */
110static CORE_ADDR debug_base; /* Base of dynamic linker structures */
111static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
112
51b57ded
FF
113extern int
114fdmatch PARAMS ((int, int)); /* In libiberty */
115
b0246b3b
FF
116/* Local function prototypes */
117
118static void
119special_symbol_handling PARAMS ((struct so_list *));
120
121static void
122sharedlibrary_command PARAMS ((char *, int));
123
124static int
125enable_break PARAMS ((void));
126
127static int
128disable_break PARAMS ((void));
129
130static void
51b57ded 131info_sharedlibrary_command PARAMS ((char *, int));
b0246b3b
FF
132
133static int
134symbol_add_stub PARAMS ((char *));
135
136static struct so_list *
137find_solib PARAMS ((struct so_list *));
138
139static struct link_map *
140first_link_map_member PARAMS ((void));
141
142static CORE_ADDR
143locate_base PARAMS ((void));
144
be772100
JG
145static void
146solib_map_sections PARAMS ((struct so_list *));
147
148#ifdef SVR4_SHARED_LIBS
149
b0246b3b
FF
150static int
151look_for_base PARAMS ((int, CORE_ADDR));
152
153static CORE_ADDR
154bfd_lookup_symbol PARAMS ((bfd *, char *));
155
be772100 156#else
b0246b3b
FF
157
158static void
159solib_add_common_symbols PARAMS ((struct rtc_symb *, struct objfile *));
160
161#endif
bd5635a1 162
d0237a54 163/*
f8b76e70
FF
164
165LOCAL FUNCTION
166
167 solib_map_sections -- open bfd and build sections for shared lib
168
169SYNOPSIS
170
171 static void solib_map_sections (struct so_list *so)
172
173DESCRIPTION
174
175 Given a pointer to one of the shared objects in our list
176 of mapped objects, use the recorded name to open a bfd
177 descriptor for the object, build a section table, and then
178 relocate all the section addresses by the base address at
179 which the shared object was mapped.
180
181FIXMES
182
183 In most (all?) cases the shared object file name recorded in the
184 dynamic linkage tables will be a fully qualified pathname. For
185 cases where it isn't, do we really mimic the systems search
186 mechanism correctly in the below code (particularly the tilde
187 expansion stuff?).
188 */
189
d0237a54 190static void
f8b76e70
FF
191solib_map_sections (so)
192 struct so_list *so;
d0237a54
JK
193{
194 char *filename;
195 char *scratch_pathname;
196 int scratch_chan;
197 struct section_table *p;
de9bef49
JG
198 struct cleanup *old_chain;
199 bfd *abfd;
d0237a54 200
f8b76e70 201 filename = tilde_expand (so -> so_name);
de9bef49 202 old_chain = make_cleanup (free, filename);
d0237a54
JK
203
204 scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
f8b76e70 205 &scratch_pathname);
d0237a54 206 if (scratch_chan < 0)
f8b76e70
FF
207 {
208 scratch_chan = openp (getenv ("LD_LIBRARY_PATH"), 1, filename,
209 O_RDONLY, 0, &scratch_pathname);
210 }
d0237a54 211 if (scratch_chan < 0)
f8b76e70
FF
212 {
213 perror_with_name (filename);
a608f919
FF
214 }
215 /* Leave scratch_pathname allocated. bfd->name will point to it. */
f8b76e70 216
de9bef49
JG
217 abfd = bfd_fdopenr (scratch_pathname, NULL, scratch_chan);
218 if (!abfd)
f8b76e70 219 {
de9bef49 220 close (scratch_chan);
f8b76e70
FF
221 error ("Could not open `%s' as an executable file: %s",
222 scratch_pathname, bfd_errmsg (bfd_error));
223 }
a608f919
FF
224 /* Leave bfd open, core_xfer_memory and "info files" need it. */
225 so -> bfd = abfd;
226 abfd -> cacheable = true;
de9bef49
JG
227
228 if (!bfd_check_format (abfd, bfd_object))
f8b76e70
FF
229 {
230 error ("\"%s\": not in executable format: %s.",
231 scratch_pathname, bfd_errmsg (bfd_error));
232 }
de9bef49 233 if (build_section_table (abfd, &so -> sections, &so -> sections_end))
f8b76e70
FF
234 {
235 error ("Can't find the file sections in `%s': %s",
a608f919 236 bfd_get_filename (exec_bfd), bfd_errmsg (bfd_error));
f8b76e70
FF
237 }
238
239 for (p = so -> sections; p < so -> sections_end; p++)
240 {
241 /* Relocate the section binding addresses as recorded in the shared
242 object's file by the base address to which the object was actually
243 mapped. */
244 p -> addr += (CORE_ADDR) LM_ADDR (so);
245 p -> endaddr += (CORE_ADDR) LM_ADDR (so);
246 so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
2e4964ad 247 if (STREQ (p -> sec_ptr -> name, ".text"))
51b57ded
FF
248 {
249 so -> textsection = p;
250 }
f8b76e70 251 }
de9bef49
JG
252
253 /* Free the file names, close the file now. */
254 do_cleanups (old_chain);
f8b76e70
FF
255}
256
d261ece7 257/* Read all dynamically loaded common symbol definitions from the inferior
b0246b3b 258 and add them to the minimal symbol table for the shared library objfile. */
d261ece7 259
7f435241
FF
260#ifndef SVR4_SHARED_LIBS
261
2a4e8cc3
JK
262/* This routine can be a real performance hog. According to some gprof data
263 which mtranle@paris.IntelliCorp.COM (Minh Tran-Le) sent, almost all the
264 time spend in solib_add (up to 20 minutes with 35 shared libraries) is
265 spent here, with 5/6 in lookup_minimal_symbol and 1/6 in read_memory.
266
267 Possible solutions:
268
269 * Hash the minimal symbols.
270
271 * Just record the name of the minimal symbol and lazily patch the
272 addresses.
273
274 * Tell everyone to switch to Solaris2. */
275
d261ece7 276static void
b0246b3b 277solib_add_common_symbols (rtc_symp, objfile)
d261ece7 278 struct rtc_symb *rtc_symp;
b0246b3b 279 struct objfile *objfile;
d261ece7
SG
280{
281 struct rtc_symb inferior_rtc_symb;
282 struct nlist inferior_rtc_nlist;
b0246b3b
FF
283 int len;
284 char *name;
285 char *origname;
d261ece7 286
b0246b3b
FF
287 init_minimal_symbol_collection ();
288 make_cleanup (discard_minimal_symbols, 0);
d261ece7
SG
289
290 while (rtc_symp)
291 {
b0246b3b
FF
292 read_memory ((CORE_ADDR) rtc_symp,
293 (char *) &inferior_rtc_symb,
294 sizeof (inferior_rtc_symb));
295 read_memory ((CORE_ADDR) inferior_rtc_symb.rtc_sp,
296 (char *) &inferior_rtc_nlist,
297 sizeof(inferior_rtc_nlist));
298 if (inferior_rtc_nlist.n_type == N_COMM)
299 {
300 /* FIXME: The length of the symbol name is not available, but in the
301 current implementation the common symbol is allocated immediately
302 behind the name of the symbol. */
303 len = inferior_rtc_nlist.n_value - inferior_rtc_nlist.n_un.n_strx;
304
305 origname = name = xmalloc (len);
306 read_memory ((CORE_ADDR) inferior_rtc_nlist.n_un.n_name, name, len);
307
308 /* Don't enter the symbol twice if the target is re-run. */
d261ece7 309
de9bef49 310 if (name[0] == bfd_get_symbol_leading_char (objfile->obfd))
b0246b3b
FF
311 {
312 name++;
313 }
de9bef49 314
b0246b3b
FF
315 /* FIXME: Do we really want to exclude symbols which happen
316 to match symbols for other locations in the inferior's
317 address space, even when they are in different linkage units? */
318 if (lookup_minimal_symbol (name, (struct objfile *) NULL) == NULL)
319 {
320 name = obsavestring (name, strlen (name),
321 &objfile -> symbol_obstack);
322 prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
323 mst_bss);
324 }
325 free (origname);
326 }
327 rtc_symp = inferior_rtc_symb.rtc_next;
d261ece7
SG
328 }
329
b0246b3b
FF
330 /* Install any minimal symbols that have been collected as the current
331 minimal symbols for this objfile. */
332
333 install_minimal_symbols (objfile);
d261ece7
SG
334}
335
7f435241
FF
336#endif /* SVR4_SHARED_LIBS */
337
be772100
JG
338#ifdef SVR4_SHARED_LIBS
339
f8b76e70
FF
340/*
341
342LOCAL FUNCTION
343
344 bfd_lookup_symbol -- lookup the value for a specific symbol
345
346SYNOPSIS
347
348 CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
349
350DESCRIPTION
351
352 An expensive way to lookup the value of a single symbol for
353 bfd's that are only temporary anyway. This is used by the
354 shared library support to find the address of the debugger
355 interface structures in the shared library.
356
357 Note that 0 is specifically allowed as an error return (no
358 such symbol).
359
360 FIXME: See if there is a less "expensive" way of doing this.
361 Also see if there is already another bfd or gdb function
362 that specifically does this, and if so, use it.
363*/
364
365static CORE_ADDR
b0246b3b
FF
366bfd_lookup_symbol (abfd, symname)
367 bfd *abfd;
368 char *symname;
f8b76e70
FF
369{
370 unsigned int storage_needed;
371 asymbol *sym;
372 asymbol **symbol_table;
373 unsigned int number_of_symbols;
374 unsigned int i;
375 struct cleanup *back_to;
376 CORE_ADDR symaddr = 0;
f8b76e70
FF
377
378 storage_needed = get_symtab_upper_bound (abfd);
379
380 if (storage_needed > 0)
381 {
be772100
JG
382 symbol_table = (asymbol **) xmalloc (storage_needed);
383 back_to = make_cleanup (free, (PTR)symbol_table);
f8b76e70
FF
384 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
385
386 for (i = 0; i < number_of_symbols; i++)
d0237a54 387 {
f8b76e70 388 sym = *symbol_table++;
2e4964ad 389 if (STREQ (sym -> name, symname))
f8b76e70 390 {
a608f919
FF
391 /* Bfd symbols are section relative. */
392 symaddr = sym -> value + sym -> section -> vma;
f8b76e70
FF
393 break;
394 }
d0237a54 395 }
f8b76e70 396 do_cleanups (back_to);
d0237a54 397 }
f8b76e70 398 return (symaddr);
d0237a54
JK
399}
400
f8b76e70
FF
401/*
402
d261ece7
SG
403LOCAL FUNCTION
404
405 look_for_base -- examine file for each mapped address segment
406
407SYNOPSYS
408
409 static int look_for_base (int fd, CORE_ADDR baseaddr)
410
411DESCRIPTION
412
413 This function is passed to proc_iterate_over_mappings, which
414 causes it to get called once for each mapped address space, with
415 an open file descriptor for the file mapped to that space, and the
416 base address of that mapped space.
417
418 Our job is to find the symbol DEBUG_BASE in the file that this
419 fd is open on, if it exists, and if so, initialize the dynamic
420 linker structure base address debug_base.
421
422 Note that this is a computationally expensive proposition, since
423 we basically have to open a bfd on every call, so we specifically
424 avoid opening the exec file.
425 */
426
427static int
b0246b3b
FF
428look_for_base (fd, baseaddr)
429 int fd;
430 CORE_ADDR baseaddr;
d261ece7
SG
431{
432 bfd *interp_bfd;
433 CORE_ADDR address;
434
435 /* If the fd is -1, then there is no file that corresponds to this
436 mapped memory segment, so skip it. Also, if the fd corresponds
437 to the exec file, skip it as well. */
438
439 if ((fd == -1) || fdmatch (fileno ((FILE *)(exec_bfd -> iostream)), fd))
440 {
441 return (0);
442 }
443
444 /* Try to open whatever random file this fd corresponds to. Note that
445 we have no way currently to find the filename. Don't gripe about
446 any problems we might have, just fail. */
447
448 if ((interp_bfd = bfd_fdopenr ("unnamed", NULL, fd)) == NULL)
449 {
450 return (0);
451 }
452 if (!bfd_check_format (interp_bfd, bfd_object))
453 {
454 bfd_close (interp_bfd);
455 return (0);
456 }
457
458 /* Now try to find our DEBUG_BASE symbol in this file, which we at
459 least know to be a valid ELF executable or shared library. */
460
461 if ((address = bfd_lookup_symbol (interp_bfd, DEBUG_BASE)) == 0)
462 {
463 bfd_close (interp_bfd);
464 return (0);
465 }
466
467 /* Eureka! We found the symbol. But now we may need to relocate it
468 by the base address. If the symbol's value is less than the base
469 address of the shared library, then it hasn't yet been relocated
470 by the dynamic linker, and we have to do it ourself. FIXME: Note
471 that we make the assumption that the first segment that corresponds
472 to the shared library has the base address to which the library
473 was relocated. */
474
475 if (address < baseaddr)
476 {
477 address += baseaddr;
478 }
479 debug_base = address;
480 bfd_close (interp_bfd);
481 return (1);
482}
483
be772100
JG
484#endif
485
d261ece7
SG
486/*
487
f8b76e70
FF
488LOCAL FUNCTION
489
490 locate_base -- locate the base address of dynamic linker structs
491
492SYNOPSIS
493
494 CORE_ADDR locate_base (void)
495
496DESCRIPTION
497
498 For both the SunOS and SVR4 shared library implementations, if the
499 inferior executable has been linked dynamically, there is a single
500 address somewhere in the inferior's data space which is the key to
d261ece7 501 locating all of the dynamic linker's runtime structures. This
f8b76e70
FF
502 address is the value of the symbol defined by the macro DEBUG_BASE.
503 The job of this function is to find and return that address, or to
504 return 0 if there is no such address (the executable is statically
505 linked for example).
506
507 For SunOS, the job is almost trivial, since the dynamic linker and
508 all of it's structures are statically linked to the executable at
509 link time. Thus the symbol for the address we are looking for has
b0246b3b
FF
510 already been added to the minimal symbol table for the executable's
511 objfile at the time the symbol file's symbols were read, and all we
512 have to do is look it up there. Note that we explicitly do NOT want
513 to find the copies in the shared library.
f8b76e70
FF
514
515 The SVR4 version is much more complicated because the dynamic linker
d261ece7
SG
516 and it's structures are located in the shared C library, which gets
517 run as the executable's "interpreter" by the kernel. We have to go
518 to a lot more work to discover the address of DEBUG_BASE. Because
f8b76e70 519 of this complexity, we cache the value we find and return that value
b0246b3b
FF
520 on subsequent invocations. Note there is no copy in the executable
521 symbol tables.
f8b76e70 522
d261ece7
SG
523 Note that we can assume nothing about the process state at the time
524 we need to find this address. We may be stopped on the first instruc-
525 tion of the interpreter (C shared library), the first instruction of
526 the executable itself, or somewhere else entirely (if we attached
527 to the process for example).
f8b76e70
FF
528
529 */
530
531static CORE_ADDR
532locate_base ()
533{
f8b76e70 534
d261ece7 535#ifndef SVR4_SHARED_LIBS
f8b76e70 536
b0246b3b 537 struct minimal_symbol *msymbol;
d261ece7 538 CORE_ADDR address = 0;
f8b76e70 539
b0246b3b
FF
540 /* For SunOS, we want to limit the search for DEBUG_BASE to the executable
541 being debugged, since there is a duplicate named symbol in the shared
542 library. We don't want the shared library versions. */
543
544 msymbol = lookup_minimal_symbol (DEBUG_BASE, symfile_objfile);
2e4964ad 545 if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
f8b76e70 546 {
2e4964ad 547 address = SYMBOL_VALUE_ADDRESS (msymbol);
f8b76e70 548 }
d261ece7 549 return (address);
f8b76e70 550
d261ece7 551#else /* SVR4_SHARED_LIBS */
f8b76e70 552
d261ece7
SG
553 /* Check to see if we have a currently valid address, and if so, avoid
554 doing all this work again and just return the cached address. If
555 we have no cached address, ask the /proc support interface to iterate
556 over the list of mapped address segments, calling look_for_base() for
557 each segment. When we are done, we will have either found the base
558 address or not. */
f8b76e70 559
d261ece7 560 if (debug_base == 0)
f8b76e70 561 {
d261ece7 562 proc_iterate_over_mappings (look_for_base);
f8b76e70 563 }
d261ece7 564 return (debug_base);
f8b76e70 565
d261ece7 566#endif /* !SVR4_SHARED_LIBS */
f8b76e70
FF
567
568}
bd5635a1 569
a608f919
FF
570/*
571
572LOCAL FUNCTION
573
574 first_link_map_member -- locate first member in dynamic linker's map
575
576SYNOPSIS
577
578 static struct link_map *first_link_map_member (void)
579
580DESCRIPTION
581
582 Read in a copy of the first member in the inferior's dynamic
583 link map from the inferior's dynamic linker structures, and return
584 a pointer to the copy in our address space.
585*/
586
f8b76e70
FF
587static struct link_map *
588first_link_map_member ()
bd5635a1 589{
f8b76e70
FF
590 struct link_map *lm = NULL;
591
d261ece7 592#ifndef SVR4_SHARED_LIBS
f8b76e70 593
b0246b3b 594 read_memory (debug_base, (char *) &dynamic_copy, sizeof (dynamic_copy));
f8b76e70
FF
595 if (dynamic_copy.ld_version >= 2)
596 {
597 /* It is a version that we can deal with, so read in the secondary
598 structure and find the address of the link map list from it. */
b0246b3b 599 read_memory ((CORE_ADDR) dynamic_copy.ld_un.ld_2, (char *) &ld_2_copy,
f8b76e70
FF
600 sizeof (struct link_dynamic_2));
601 lm = ld_2_copy.ld_loaded;
602 }
603
d261ece7 604#else /* SVR4_SHARED_LIBS */
f8b76e70 605
b0246b3b 606 read_memory (debug_base, (char *) &debug_copy, sizeof (struct r_debug));
a608f919
FF
607 /* FIXME: Perhaps we should validate the info somehow, perhaps by
608 checking r_version for a known version number, or r_state for
609 RT_CONSISTENT. */
f8b76e70
FF
610 lm = debug_copy.r_map;
611
d261ece7 612#endif /* !SVR4_SHARED_LIBS */
d0237a54 613
f8b76e70
FF
614 return (lm);
615}
616
617/*
618
b0246b3b 619LOCAL FUNCTION
f8b76e70
FF
620
621 find_solib -- step through list of shared objects
622
623SYNOPSIS
624
625 struct so_list *find_solib (struct so_list *so_list_ptr)
626
627DESCRIPTION
628
629 This module contains the routine which finds the names of any
630 loaded "images" in the current process. The argument in must be
631 NULL on the first call, and then the returned value must be passed
632 in on subsequent calls. This provides the capability to "step" down
633 the list of loaded objects. On the last object, a NULL value is
634 returned.
d0237a54 635
f8b76e70
FF
636 The arg and return value are "struct link_map" pointers, as defined
637 in <link.h>.
638 */
d0237a54 639
b0246b3b 640static struct so_list *
f8b76e70
FF
641find_solib (so_list_ptr)
642 struct so_list *so_list_ptr; /* Last lm or NULL for first one */
643{
644 struct so_list *so_list_next = NULL;
645 struct link_map *lm = NULL;
646 struct so_list *new;
647
648 if (so_list_ptr == NULL)
649 {
650 /* We are setting up for a new scan through the loaded images. */
651 if ((so_list_next = so_list_head) == NULL)
652 {
653 /* We have not already read in the dynamic linking structures
654 from the inferior, lookup the address of the base structure. */
655 debug_base = locate_base ();
a608f919 656 if (debug_base != 0)
f8b76e70
FF
657 {
658 /* Read the base structure in and find the address of the first
659 link map list member. */
660 lm = first_link_map_member ();
661 }
662 }
663 }
664 else
665 {
666 /* We have been called before, and are in the process of walking
667 the shared library list. Advance to the next shared object. */
668 if ((lm = LM_NEXT (so_list_ptr)) == NULL)
669 {
670 /* We have hit the end of the list, so check to see if any were
671 added, but be quiet if we can't read from the target any more. */
672 int status = target_read_memory ((CORE_ADDR) so_list_ptr -> lmaddr,
673 (char *) &(so_list_ptr -> lm),
674 sizeof (struct link_map));
675 if (status == 0)
676 {
677 lm = LM_NEXT (so_list_ptr);
678 }
679 else
680 {
681 lm = NULL;
682 }
683 }
684 so_list_next = so_list_ptr -> next;
685 }
686 if ((so_list_next == NULL) && (lm != NULL))
687 {
688 /* Get next link map structure from inferior image and build a local
689 abbreviated load_map structure */
690 new = (struct so_list *) xmalloc (sizeof (struct so_list));
de9bef49 691 memset ((char *) new, 0, sizeof (struct so_list));
f8b76e70
FF
692 new -> lmaddr = lm;
693 /* Add the new node as the next node in the list, or as the root
694 node if this is the first one. */
695 if (so_list_ptr != NULL)
696 {
697 so_list_ptr -> next = new;
698 }
699 else
700 {
701 so_list_head = new;
702 }
703 so_list_next = new;
b0246b3b
FF
704 read_memory ((CORE_ADDR) lm, (char *) &(new -> lm),
705 sizeof (struct link_map));
f8b76e70
FF
706 /* For the SVR4 version, there is one entry that has no name
707 (for the inferior executable) since it is not a shared object. */
708 if (LM_NAME (new) != 0)
709 {
ee0613d1
JG
710 if (!target_read_string((CORE_ADDR) LM_NAME (new), new -> so_name,
711 MAX_PATH_SIZE - 1))
712 error ("find_solib: Can't read pathname for load map\n");
f8b76e70
FF
713 new -> so_name[MAX_PATH_SIZE - 1] = 0;
714 solib_map_sections (new);
715 }
716 }
717 return (so_list_next);
bd5635a1 718}
d0237a54 719
bdbd5f50
JG
720/* A small stub to get us past the arg-passing pinhole of catch_errors. */
721
722static int
723symbol_add_stub (arg)
724 char *arg;
d0237a54 725{
f8b76e70
FF
726 register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
727
b0246b3b 728 so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
51b57ded
FF
729 (unsigned int) so -> textsection -> addr,
730 0, 0, 0);
f8b76e70 731 return (1);
d0237a54 732}
bd5635a1 733
f8b76e70
FF
734/*
735
736GLOBAL FUNCTION
737
738 solib_add -- add a shared library file to the symtab and section list
739
740SYNOPSIS
741
742 void solib_add (char *arg_string, int from_tty,
743 struct target_ops *target)
744
745DESCRIPTION
746
747*/
bdbd5f50
JG
748
749void
750solib_add (arg_string, from_tty, target)
751 char *arg_string;
752 int from_tty;
753 struct target_ops *target;
bd5635a1 754{
f8b76e70
FF
755 register struct so_list *so = NULL; /* link map state variable */
756 char *re_err;
757 int count;
758 int old;
759
760 if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
761 {
762 error ("Invalid regexp: %s", re_err);
763 }
764
bdbd5f50
JG
765 /* Getting new symbols may change our opinion about what is
766 frameless. */
767 reinit_frame_cache ();
bdbd5f50 768
f8b76e70
FF
769 while ((so = find_solib (so)) != NULL)
770 {
771 if (so -> so_name[0] && re_exec (so -> so_name))
772 {
a608f919 773 so -> from_tty = from_tty;
f8b76e70
FF
774 if (so -> symbols_loaded)
775 {
bdbd5f50 776 if (from_tty)
f8b76e70
FF
777 {
778 printf ("Symbols already loaded for %s\n", so -> so_name);
779 }
780 }
a608f919
FF
781 else if (catch_errors
782 (symbol_add_stub, (char *) so,
9748446f
JK
783 "Error while reading shared library symbols:\n",
784 RETURN_MASK_ALL))
f8b76e70 785 {
b0246b3b
FF
786 special_symbol_handling (so);
787 so -> symbols_loaded = 1;
f8b76e70
FF
788 }
789 }
790 }
791
bdbd5f50
JG
792 /* Now add the shared library sections to the section table of the
793 specified target, if any. */
f8b76e70
FF
794 if (target)
795 {
796 /* Count how many new section_table entries there are. */
797 so = NULL;
798 count = 0;
799 while ((so = find_solib (so)) != NULL)
800 {
801 if (so -> so_name[0])
802 {
803 count += so -> sections_end - so -> sections;
804 }
805 }
806
807 if (count)
808 {
809 /* Reallocate the target's section table including the new size. */
ee0613d1 810 if (target -> to_sections)
f8b76e70 811 {
ee0613d1
JG
812 old = target -> to_sections_end - target -> to_sections;
813 target -> to_sections = (struct section_table *)
814 realloc ((char *)target -> to_sections,
f8b76e70
FF
815 (sizeof (struct section_table)) * (count + old));
816 }
817 else
818 {
819 old = 0;
ee0613d1 820 target -> to_sections = (struct section_table *)
f8b76e70
FF
821 malloc ((sizeof (struct section_table)) * count);
822 }
ee0613d1 823 target -> to_sections_end = target -> to_sections + (count + old);
f8b76e70
FF
824
825 /* Add these section table entries to the target's table. */
826 while ((so = find_solib (so)) != NULL)
827 {
828 if (so -> so_name[0])
829 {
830 count = so -> sections_end - so -> sections;
de9bef49
JG
831 memcpy ((char *) (target -> to_sections + old),
832 so -> sections,
833 (sizeof (struct section_table)) * count);
f8b76e70
FF
834 old += count;
835 }
836 }
837 }
838 }
bd5635a1 839}
bdbd5f50 840
f8b76e70 841/*
bd5635a1 842
f8b76e70
FF
843LOCAL FUNCTION
844
845 info_sharedlibrary_command -- code for "info sharedlibrary"
846
847SYNOPSIS
848
849 static void info_sharedlibrary_command ()
850
851DESCRIPTION
bd5635a1 852
f8b76e70
FF
853 Walk through the shared library list and print information
854 about each attached library.
855*/
856
857static void
51b57ded
FF
858info_sharedlibrary_command (ignore, from_tty)
859 char *ignore;
860 int from_tty;
f8b76e70
FF
861{
862 register struct so_list *so = NULL; /* link map state variable */
863 int header_done = 0;
864
865 if (exec_bfd == NULL)
866 {
867 printf ("No exec file.\n");
868 return;
869 }
870 while ((so = find_solib (so)) != NULL)
871 {
872 if (so -> so_name[0])
873 {
874 if (!header_done)
875 {
876 printf("%-12s%-12s%-12s%s\n", "From", "To", "Syms Read",
877 "Shared Object Library");
878 header_done++;
879 }
b0246b3b 880 printf ("%-12s", local_hex_string_custom ((int) LM_ADDR (so), "08"));
f8b76e70
FF
881 printf ("%-12s", local_hex_string_custom (so -> lmend, "08"));
882 printf ("%-12s", so -> symbols_loaded ? "Yes" : "No");
883 printf ("%s\n", so -> so_name);
bd5635a1 884 }
bd5635a1 885 }
f8b76e70
FF
886 if (so_list_head == NULL)
887 {
888 printf ("No shared libraries loaded at this time.\n");
bd5635a1
RP
889 }
890}
891
892/*
f8b76e70
FF
893
894GLOBAL FUNCTION
895
896 solib_address -- check to see if an address is in a shared lib
897
898SYNOPSIS
899
900 int solib_address (CORE_ADDR address)
901
902DESCRIPTION
903
904 Provides a hook for other gdb routines to discover whether or
905 not a particular address is within the mapped address space of
906 a shared library. Any address between the base mapping address
907 and the first address beyond the end of the last mapping, is
908 considered to be within the shared library address space, for
909 our purposes.
910
911 For example, this routine is called at one point to disable
912 breakpoints which are in shared libraries that are not currently
913 mapped in.
914 */
915
bd5635a1 916int
f8b76e70 917solib_address (address)
bd5635a1
RP
918 CORE_ADDR address;
919{
f8b76e70
FF
920 register struct so_list *so = 0; /* link map state variable */
921
922 while ((so = find_solib (so)) != NULL)
923 {
924 if (so -> so_name[0])
925 {
926 if ((address >= (CORE_ADDR) LM_ADDR (so)) &&
927 (address < (CORE_ADDR) so -> lmend))
928 {
929 return (1);
930 }
931 }
932 }
933 return (0);
934}
935
936/* Called by free_all_symtabs */
bd5635a1 937
f8b76e70
FF
938void
939clear_solib()
940{
941 struct so_list *next;
a608f919 942 char *bfd_filename;
f8b76e70
FF
943
944 while (so_list_head)
945 {
946 if (so_list_head -> sections)
947 {
be772100 948 free ((PTR)so_list_head -> sections);
f8b76e70 949 }
a608f919
FF
950 if (so_list_head -> bfd)
951 {
952 bfd_filename = bfd_get_filename (so_list_head -> bfd);
953 bfd_close (so_list_head -> bfd);
954 }
955 else
956 /* This happens for the executable on SVR4. */
957 bfd_filename = NULL;
958
f8b76e70 959 next = so_list_head -> next;
a608f919
FF
960 if (bfd_filename)
961 free ((PTR)bfd_filename);
962 free ((PTR)so_list_head);
f8b76e70 963 so_list_head = next;
bd5635a1 964 }
f8b76e70 965 debug_base = 0;
bd5635a1
RP
966}
967
968/*
f8b76e70
FF
969
970LOCAL FUNCTION
971
972 disable_break -- remove the "mapping changed" breakpoint
973
974SYNOPSIS
975
976 static int disable_break ()
977
978DESCRIPTION
979
980 Removes the breakpoint that gets hit when the dynamic linker
981 completes a mapping change.
982
bd5635a1 983*/
f8b76e70
FF
984
985static int
986disable_break ()
bd5635a1 987{
f8b76e70
FF
988 int status = 1;
989
d261ece7 990#ifndef SVR4_SHARED_LIBS
f8b76e70
FF
991
992 int in_debugger = 0;
993
f8b76e70
FF
994 /* Read the debugger structure from the inferior to retrieve the
995 address of the breakpoint and the original contents of the
996 breakpoint address. Remove the breakpoint by writing the original
997 contents back. */
998
b0246b3b 999 read_memory (debug_addr, (char *) &debug_copy, sizeof (debug_copy));
d261ece7
SG
1000
1001 /* Set `in_debugger' to zero now. */
1002
b0246b3b 1003 write_memory (flag_addr, (char *) &in_debugger, sizeof (in_debugger));
d261ece7 1004
f8b76e70 1005 breakpoint_addr = (CORE_ADDR) debug_copy.ldd_bp_addr;
b0246b3b 1006 write_memory (breakpoint_addr, (char *) &debug_copy.ldd_bp_inst,
f8b76e70
FF
1007 sizeof (debug_copy.ldd_bp_inst));
1008
d261ece7 1009#else /* SVR4_SHARED_LIBS */
f8b76e70
FF
1010
1011 /* Note that breakpoint address and original contents are in our address
1012 space, so we just need to write the original contents back. */
1013
1014 if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
1015 {
1016 status = 0;
1017 }
1018
d261ece7 1019#endif /* !SVR4_SHARED_LIBS */
f8b76e70
FF
1020
1021 /* For the SVR4 version, we always know the breakpoint address. For the
1022 SunOS version we don't know it until the above code is executed.
1023 Grumble if we are stopped anywhere besides the breakpoint address. */
1024
1025 if (stop_pc != breakpoint_addr)
1026 {
1027 warning ("stopped at unknown breakpoint while handling shared libraries");
1028 }
1029
1030 return (status);
bdbd5f50
JG
1031}
1032
f8b76e70 1033/*
bdbd5f50 1034
f8b76e70
FF
1035LOCAL FUNCTION
1036
1037 enable_break -- arrange for dynamic linker to hit breakpoint
1038
1039SYNOPSIS
1040
1041 int enable_break (void)
1042
1043DESCRIPTION
1044
1045 Both the SunOS and the SVR4 dynamic linkers have, as part of their
1046 debugger interface, support for arranging for the inferior to hit
1047 a breakpoint after mapping in the shared libraries. This function
1048 enables that breakpoint.
1049
1050 For SunOS, there is a special flag location (in_debugger) which we
1051 set to 1. When the dynamic linker sees this flag set, it will set
1052 a breakpoint at a location known only to itself, after saving the
1053 original contents of that place and the breakpoint address itself,
1054 in it's own internal structures. When we resume the inferior, it
1055 will eventually take a SIGTRAP when it runs into the breakpoint.
1056 We handle this (in a different place) by restoring the contents of
1057 the breakpointed location (which is only known after it stops),
1058 chasing around to locate the shared libraries that have been
1059 loaded, then resuming.
1060
1061 For SVR4, the debugger interface structure contains a member (r_brk)
1062 which is statically initialized at the time the shared library is
1063 built, to the offset of a function (_r_debug_state) which is guaran-
1064 teed to be called once before mapping in a library, and again when
1065 the mapping is complete. At the time we are examining this member,
1066 it contains only the unrelocated offset of the function, so we have
1067 to do our own relocation. Later, when the dynamic linker actually
1068 runs, it relocates r_brk to be the actual address of _r_debug_state().
1069
1070 The debugger interface structure also contains an enumeration which
1071 is set to either RT_ADD or RT_DELETE prior to changing the mapping,
1072 depending upon whether or not the library is being mapped or unmapped,
1073 and then set to RT_CONSISTENT after the library is mapped/unmapped.
1074*/
1075
1076static int
1077enable_break ()
bdbd5f50 1078{
a608f919 1079 int success = 0;
bdbd5f50 1080
d261ece7 1081#ifndef SVR4_SHARED_LIBS
bdbd5f50 1082
51b57ded 1083 int j;
f8b76e70 1084 int in_debugger;
51b57ded 1085
bdbd5f50 1086 /* Get link_dynamic structure */
f8b76e70
FF
1087
1088 j = target_read_memory (debug_base, (char *) &dynamic_copy,
1089 sizeof (dynamic_copy));
1090 if (j)
1091 {
1092 /* unreadable */
1093 return (0);
1094 }
06b6c733 1095
bdbd5f50 1096 /* Calc address of debugger interface structure */
f8b76e70
FF
1097
1098 debug_addr = (CORE_ADDR) dynamic_copy.ldd;
1099
bdbd5f50 1100 /* Calc address of `in_debugger' member of debugger interface structure */
f8b76e70
FF
1101
1102 flag_addr = debug_addr + (CORE_ADDR) ((char *) &debug_copy.ldd_in_debugger -
1103 (char *) &debug_copy);
1104
bdbd5f50 1105 /* Write a value of 1 to this member. */
f8b76e70 1106
bdbd5f50 1107 in_debugger = 1;
b0246b3b 1108 write_memory (flag_addr, (char *) &in_debugger, sizeof (in_debugger));
a608f919 1109 success = 1;
f8b76e70 1110
d261ece7 1111#else /* SVR4_SHARED_LIBS */
f8b76e70 1112
a608f919 1113#ifdef BKPT_AT_SYMBOL
f8b76e70 1114
b0246b3b 1115 struct minimal_symbol *msymbol;
a608f919
FF
1116 char **bkpt_namep;
1117 CORE_ADDR bkpt_addr;
f8b76e70 1118
a608f919
FF
1119 /* Scan through the list of symbols, trying to look up the symbol and
1120 set a breakpoint there. Terminate loop when we/if we succeed. */
f8b76e70 1121
a608f919
FF
1122 breakpoint_addr = 0;
1123 for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
f8b76e70 1124 {
a608f919
FF
1125 msymbol = lookup_minimal_symbol (*bkpt_namep, symfile_objfile);
1126 if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
1127 {
1128 bkpt_addr = SYMBOL_VALUE_ADDRESS (msymbol);
1129 if (target_insert_breakpoint (bkpt_addr, shadow_contents) == 0)
1130 {
1131 breakpoint_addr = bkpt_addr;
1132 success = 1;
1133 break;
1134 }
1135 }
f8b76e70
FF
1136 }
1137
a608f919 1138#else /* !BKPT_AT_SYMBOL */
f8b76e70
FF
1139
1140 struct symtab_and_line sal;
1141
1142 /* Read the debugger interface structure directly. */
1143
1144 read_memory (debug_base, (char *) &debug_copy, sizeof (debug_copy));
1145
1146 /* Set breakpoint at the debugger interface stub routine that will
1147 be called just prior to each mapping change and again after the
1148 mapping change is complete. Set up the (nonexistent) handler to
1149 deal with hitting these breakpoints. (FIXME). */
1150
1151 warning ("'%s': line %d: missing SVR4 support code", __FILE__, __LINE__);
a608f919 1152 success = 1;
f8b76e70 1153
a608f919 1154#endif /* BKPT_AT_SYMBOL */
f8b76e70 1155
d261ece7 1156#endif /* !SVR4_SHARED_LIBS */
f8b76e70 1157
a608f919 1158 return (success);
f8b76e70
FF
1159}
1160
1161/*
1162
1163GLOBAL FUNCTION
1164
1165 solib_create_inferior_hook -- shared library startup support
1166
1167SYNOPSIS
1168
1169 void solib_create_inferior_hook()
1170
1171DESCRIPTION
1172
1173 When gdb starts up the inferior, it nurses it along (through the
1174 shell) until it is ready to execute it's first instruction. At this
1175 point, this function gets called via expansion of the macro
1176 SOLIB_CREATE_INFERIOR_HOOK.
1177
a608f919
FF
1178 For SunOS executables, this first instruction is typically the
1179 one at "_start", or a similar text label, regardless of whether
1180 the executable is statically or dynamically linked. The runtime
1181 startup code takes care of dynamically linking in any shared
1182 libraries, once gdb allows the inferior to continue.
1183
1184 For SVR4 executables, this first instruction is either the first
1185 instruction in the dynamic linker (for dynamically linked
1186 executables) or the instruction at "start" for statically linked
1187 executables. For dynamically linked executables, the system
1188 first exec's /lib/libc.so.N, which contains the dynamic linker,
1189 and starts it running. The dynamic linker maps in any needed
1190 shared libraries, maps in the actual user executable, and then
1191 jumps to "start" in the user executable.
1192
f8b76e70
FF
1193 For both SunOS shared libraries, and SVR4 shared libraries, we
1194 can arrange to cooperate with the dynamic linker to discover the
1195 names of shared libraries that are dynamically linked, and the
1196 base addresses to which they are linked.
1197
1198 This function is responsible for discovering those names and
1199 addresses, and saving sufficient information about them to allow
1200 their symbols to be read at a later time.
1201
1202FIXME
1203
1204 Between enable_break() and disable_break(), this code does not
1205 properly handle hitting breakpoints which the user might have
1206 set in the startup code or in the dynamic linker itself. Proper
1207 handling will probably have to wait until the implementation is
1208 changed to use the "breakpoint handler function" method.
1209
1210 Also, what if child has exit()ed? Must exit loop somehow.
1211 */
1212
1213void
1214solib_create_inferior_hook()
1215{
ff56144e
JK
1216 /* If we are using the BKPT_AT_SYMBOL code, then we don't need the base
1217 yet. In fact, in the case of a SunOS4 executable being run on
1218 Solaris, we can't get it yet. find_solib will get it when it needs
1219 it. */
1220#if !(defined (SVR4_SHARED_LIBS) && defined (BKPT_AT_SYMBOL))
f8b76e70
FF
1221 if ((debug_base = locate_base ()) == 0)
1222 {
1223 /* Can't find the symbol or the executable is statically linked. */
1224 return;
1225 }
ff56144e 1226#endif
f8b76e70
FF
1227
1228 if (!enable_break ())
1229 {
1230 warning ("shared library handler failed to enable breakpoint");
1231 return;
1232 }
1233
1234 /* Now run the target. It will eventually hit the breakpoint, at
1235 which point all of the libraries will have been mapped in and we
1236 can go groveling around in the dynamic linker structures to find
1237 out what we need to know about them. */
bdbd5f50
JG
1238
1239 clear_proceed_status ();
1240 stop_soon_quietly = 1;
f8b76e70
FF
1241 stop_signal = 0;
1242 do
bdbd5f50 1243 {
bdbd5f50
JG
1244 target_resume (0, stop_signal);
1245 wait_for_inferior ();
1246 }
f8b76e70 1247 while (stop_signal != SIGTRAP);
bdbd5f50 1248 stop_soon_quietly = 0;
f8b76e70
FF
1249
1250 /* We are now either at the "mapping complete" breakpoint (or somewhere
1251 else, a condition we aren't prepared to deal with anyway), so adjust
1252 the PC as necessary after a breakpoint, disable the breakpoint, and
1253 add any shared libraries that were mapped in. */
bdbd5f50 1254
f8b76e70
FF
1255 if (DECR_PC_AFTER_BREAK)
1256 {
1257 stop_pc -= DECR_PC_AFTER_BREAK;
1258 write_register (PC_REGNUM, stop_pc);
1259 }
1260
1261 if (!disable_break ())
1262 {
1263 warning ("shared library handler failed to disable breakpoint");
1264 }
1265
1266 solib_add ((char *) 0, 0, (struct target_ops *) 0);
bdbd5f50
JG
1267}
1268
f8b76e70
FF
1269/*
1270
b0246b3b
FF
1271LOCAL FUNCTION
1272
1273 special_symbol_handling -- additional shared library symbol handling
1274
1275SYNOPSIS
1276
1277 void special_symbol_handling (struct so_list *so)
1278
1279DESCRIPTION
1280
1281 Once the symbols from a shared object have been loaded in the usual
1282 way, we are called to do any system specific symbol handling that
1283 is needed.
1284
1285 For Suns, this consists of grunging around in the dynamic linkers
1286 structures to find symbol definitions for "common" symbols and
1287 adding them to the minimal symbol table for the corresponding
1288 objfile.
1289
1290*/
1291
1292static void
1293special_symbol_handling (so)
1294struct so_list *so;
1295{
1296#ifndef SVR4_SHARED_LIBS
51b57ded
FF
1297 int j;
1298
1299 if (debug_addr == 0)
1300 {
1301 /* Get link_dynamic structure */
1302
1303 j = target_read_memory (debug_base, (char *) &dynamic_copy,
1304 sizeof (dynamic_copy));
1305 if (j)
1306 {
1307 /* unreadable */
1308 return;
1309 }
1310
1311 /* Calc address of debugger interface structure */
1312 /* FIXME, this needs work for cross-debugging of core files
1313 (byteorder, size, alignment, etc). */
1314
1315 debug_addr = (CORE_ADDR) dynamic_copy.ldd;
1316 }
b0246b3b
FF
1317
1318 /* Read the debugger structure from the inferior, just to make sure
1319 we have a current copy. */
1320
51b57ded
FF
1321 j = target_read_memory (debug_addr, (char *) &debug_copy,
1322 sizeof (debug_copy));
1323 if (j)
1324 return; /* unreadable */
b0246b3b
FF
1325
1326 /* Get common symbol definitions for the loaded object. */
1327
1328 if (debug_copy.ldd_cp)
1329 {
1330 solib_add_common_symbols (debug_copy.ldd_cp, so -> objfile);
1331 }
1332
1333#endif /* !SVR4_SHARED_LIBS */
1334}
1335
1336
1337/*
1338
1339LOCAL FUNCTION
f8b76e70
FF
1340
1341 sharedlibrary_command -- handle command to explicitly add library
1342
1343SYNOPSIS
1344
b0246b3b 1345 static void sharedlibrary_command (char *args, int from_tty)
f8b76e70
FF
1346
1347DESCRIPTION
1348
1349*/
1350
b0246b3b 1351static void
bdbd5f50 1352sharedlibrary_command (args, from_tty)
f8b76e70
FF
1353char *args;
1354int from_tty;
bdbd5f50 1355{
f8b76e70
FF
1356 dont_repeat ();
1357 solib_add (args, from_tty, (struct target_ops *) 0);
bd5635a1
RP
1358}
1359
1360void
1361_initialize_solib()
1362{
f8b76e70
FF
1363
1364 add_com ("sharedlibrary", class_files, sharedlibrary_command,
bd5635a1 1365 "Load shared object library symbols for files matching REGEXP.");
f8b76e70
FF
1366 add_info ("sharedlibrary", info_sharedlibrary_command,
1367 "Status of loaded shared object libraries.");
bd5635a1 1368}
This page took 0.166049 seconds and 4 git commands to generate.