1 /* Shared library support for RS/6000 (xcoff) object files, for GDB.
2 Copyright (C) 1991-2013 Free Software Foundation, Inc.
3 Contributed by IBM Corporation.
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 "xcoffsolib.h"
27 #include "gdb_regex.h"
30 /* If ADDR lies in a shared library, return its name.
31 Note that returned name points to static data whose content is overwritten
35 xcoff_solib_address (CORE_ADDR addr
)
37 static char *buffer
= NULL
;
38 struct vmap
*vp
= vmap
;
40 /* The first vmap entry is for the exec file. */
44 for (vp
= vp
->nxt
; vp
; vp
= vp
->nxt
)
45 if (vp
->tstart
<= addr
&& addr
< vp
->tend
)
48 buffer
= xstrprintf ("%s%s%s%s",
50 *vp
->member
? "(" : "",
52 *vp
->member
? ")" : "");
58 static void solib_info (char *, int);
59 static void sharedlibrary_command (char *pattern
, int from_tty
);
62 solib_info (char *args
, int from_tty
)
64 int addr_size
= gdbarch_addr_bit (target_gdbarch ()) / 8;
65 struct vmap
*vp
= vmap
;
67 /* Check for new shared libraries loaded with load (). */
68 if (! ptid_equal (inferior_ptid
, null_ptid
))
69 xcoff_relocate_symtab (PIDGET (inferior_ptid
));
71 if (vp
== NULL
|| vp
->nxt
== NULL
)
73 printf_unfiltered ("No shared libraries loaded at this time.\n");
77 /* Skip over the first vmap, it is the main program, always loaded. */
80 printf_unfiltered ("Text Range Data Range "
81 "Syms Shared Object Library\n");
83 for (; vp
!= NULL
; vp
= vp
->nxt
)
85 printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n",
86 phex (vp
->tstart
, addr_size
),
87 phex (vp
->tend
, addr_size
),
88 phex (vp
->dstart
, addr_size
),
89 phex (vp
->dend
, addr_size
),
90 vp
->loaded
? "Yes" : "No ",
92 *vp
->member
? "(" : "",
94 *vp
->member
? ")" : "");
99 sharedlibrary_command (char *pattern
, int from_tty
)
103 /* Check for new shared libraries loaded with load (). */
104 if (! ptid_equal (inferior_ptid
, null_ptid
))
105 xcoff_relocate_symtab (PIDGET (inferior_ptid
));
109 char *re_err
= re_comp (pattern
);
112 error (_("Invalid regexp: %s"), re_err
);
115 /* Walk the list of currently loaded shared libraries, and read
116 symbols for any that match the pattern --- or any whose symbols
117 aren't already loaded, if no pattern was given. */
120 int loaded_any_symbols
= 0;
121 struct vmap
*vp
= vmap
;
126 /* skip over the first vmap, it is the main program, always loaded. */
127 for (vp
= vp
->nxt
; vp
; vp
= vp
->nxt
)
129 || re_exec (vp
->name
)
130 || (*vp
->member
&& re_exec (vp
->member
)))
137 printf_unfiltered ("Symbols already loaded for %s\n",
142 if (vmap_add_symbols (vp
))
143 loaded_any_symbols
= 1;
147 if (from_tty
&& pattern
&& ! any_matches
)
149 ("No loaded shared libraries match the pattern `%s'.\n", pattern
);
151 if (loaded_any_symbols
)
153 /* Getting new symbols may change our opinion about what is
155 reinit_frame_cache ();
160 void _initialize_xcoffsolib (void);
163 _initialize_xcoffsolib (void)
165 add_com ("sharedlibrary", class_files
, sharedlibrary_command
,
166 _("Load shared object library symbols for files matching REGEXP."));
167 add_info ("sharedlibrary", solib_info
,
168 _("Status of loaded shared object libraries"));
170 add_setshow_boolean_cmd ("auto-solib-add", class_support
,
171 &auto_solib_add
, _("\
172 Set autoloading of shared library symbols."), _("\
173 Show autoloading of shared library symbols."), _("\
174 If \"on\", symbols from all shared object libraries will be loaded\n\
175 automatically when the inferior begins execution, when the dynamic linker\n\
176 informs gdb that a new library has been loaded, or when attaching to the\n\
177 inferior. Otherwise, symbols must be loaded manually, using \
180 NULL
, /* FIXME: i18n: */
181 &setlist
, &showlist
);
This page took 0.032449 seconds and 4 git commands to generate.