Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Handle HP SOM shared libraries for GDB, the GNU Debugger. |
b6ba6518 KB |
2 | Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 |
3 | Free Software Foundation, Inc. | |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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 2 of the License, or | |
10 | (at your option) any later version. | |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. | |
c906108c | 21 | |
c5aa993b JM |
22 | Written by the Center for Software Science at the Univerity of Utah |
23 | and by Cygnus Support. */ | |
c906108c SS |
24 | |
25 | ||
26 | #include "defs.h" | |
27 | ||
28 | #include "frame.h" | |
29 | #include "bfd.h" | |
30 | #include "som.h" | |
31 | #include "libhppa.h" | |
32 | #include "gdbcore.h" | |
33 | #include "symtab.h" | |
34 | #include "breakpoint.h" | |
35 | #include "symfile.h" | |
36 | #include "objfiles.h" | |
37 | #include "inferior.h" | |
38 | #include "gdb-stabs.h" | |
39 | #include "gdb_stat.h" | |
40 | #include "gdbcmd.h" | |
41 | #include "assert.h" | |
42 | #include "language.h" | |
4e052eda | 43 | #include "regcache.h" |
c906108c SS |
44 | |
45 | #include <fcntl.h> | |
46 | ||
47 | #ifndef O_BINARY | |
48 | #define O_BINARY 0 | |
49 | #endif | |
50 | ||
51 | /* Uncomment this to turn on some debugging output. | |
52 | */ | |
53 | ||
54 | /* #define SOLIB_DEBUG | |
55 | */ | |
c5aa993b | 56 | |
c906108c SS |
57 | /* Defined in exec.c; used to prevent dangling pointer bug. |
58 | */ | |
59 | extern struct target_ops exec_ops; | |
60 | ||
61 | /* This lives in hppa-tdep.c. */ | |
a14ed312 | 62 | extern struct unwind_table_entry *find_unwind_entry (CORE_ADDR pc); |
c906108c SS |
63 | |
64 | /* These ought to be defined in some public interface, but aren't. They | |
65 | define the meaning of the various bits in the distinguished __dld_flags | |
66 | variable that is declared in every debuggable a.out on HP-UX, and that | |
67 | is shared between the debugger and the dynamic linker. | |
c5aa993b | 68 | */ |
c906108c SS |
69 | #define DLD_FLAGS_MAPPRIVATE 0x1 |
70 | #define DLD_FLAGS_HOOKVALID 0x2 | |
71 | #define DLD_FLAGS_LISTVALID 0x4 | |
72 | #define DLD_FLAGS_BOR_ENABLE 0x8 | |
73 | ||
74 | /* TODO: | |
75 | ||
76 | * Most of this code should work for hp300 shared libraries. Does | |
77 | anyone care enough to weed out any SOM-isms. | |
78 | ||
79 | * Support for hpux8 dynamic linker. */ | |
80 | ||
81 | /* The basic structure which describes a dynamically loaded object. This | |
82 | data structure is private to the dynamic linker and isn't found in | |
83 | any HPUX include file. */ | |
84 | ||
85 | struct som_solib_mapped_entry | |
c5aa993b JM |
86 | { |
87 | /* The name of the library. */ | |
88 | char *name; | |
c906108c | 89 | |
c5aa993b JM |
90 | /* Version of this structure (it is expected to change again in hpux10). */ |
91 | unsigned char struct_version; | |
c906108c | 92 | |
c5aa993b JM |
93 | /* Binding mode for this library. */ |
94 | unsigned char bind_mode; | |
c906108c | 95 | |
c5aa993b JM |
96 | /* Version of this library. */ |
97 | short library_version; | |
c906108c | 98 | |
c5aa993b JM |
99 | /* Start of text address, |
100 | * link-time text location (length of text area), | |
101 | * end of text address. */ | |
102 | CORE_ADDR text_addr; | |
103 | CORE_ADDR text_link_addr; | |
104 | CORE_ADDR text_end; | |
c906108c | 105 | |
c5aa993b JM |
106 | /* Start of data, start of bss and end of data. */ |
107 | CORE_ADDR data_start; | |
108 | CORE_ADDR bss_start; | |
109 | CORE_ADDR data_end; | |
c906108c | 110 | |
c5aa993b JM |
111 | /* Value of linkage pointer (%r19). */ |
112 | CORE_ADDR got_value; | |
c906108c | 113 | |
c5aa993b JM |
114 | /* Next entry. */ |
115 | struct som_solib_mapped_entry *next; | |
c906108c | 116 | |
c5aa993b JM |
117 | /* There are other fields, but I don't have information as to what is |
118 | contained in them. */ | |
c906108c | 119 | |
c5aa993b | 120 | /* For versions from HPUX-10.30 and up */ |
c906108c | 121 | |
c5aa993b JM |
122 | /* Address in target of offset from thread-local register of |
123 | * start of this thread's data. I.e., the first thread-local | |
124 | * variable in this shared library starts at *(tsd_start_addr) | |
125 | * from that area pointed to by cr27 (mpsfu_hi). | |
126 | * | |
127 | * We do the indirection as soon as we read it, so from then | |
128 | * on it's the offset itself. | |
129 | */ | |
130 | CORE_ADDR tsd_start_addr; | |
c906108c | 131 | |
c5aa993b JM |
132 | /* Following this are longwords holding: |
133 | ||
134 | * ?, ?, ?, ptr to -1, ptr to-1, ptr to lib name (leaf name), | |
135 | * ptr to __data_start, ptr to __data_end | |
136 | */ | |
c906108c | 137 | |
c5aa993b JM |
138 | |
139 | }; | |
c906108c SS |
140 | |
141 | /* A structure to keep track of all the known shared objects. */ | |
142 | struct so_list | |
c5aa993b JM |
143 | { |
144 | struct som_solib_mapped_entry som_solib; | |
145 | struct objfile *objfile; | |
146 | bfd *abfd; | |
147 | struct section_table *sections; | |
148 | struct section_table *sections_end; | |
c906108c SS |
149 | /* elz: added this field to store the address in target space (in the |
150 | library) of the library descriptor (handle) which we read into | |
c5aa993b JM |
151 | som_solib_mapped_entry structure */ |
152 | CORE_ADDR solib_addr; | |
153 | struct so_list *next; | |
154 | ||
155 | }; | |
c906108c SS |
156 | |
157 | static struct so_list *so_list_head; | |
158 | ||
159 | ||
160 | /* This is the cumulative size in bytes of the symbol tables of all | |
161 | shared objects on the so_list_head list. (When we say size, here | |
162 | we mean of the information before it is brought into memory and | |
163 | potentially expanded by GDB.) When adding a new shlib, this value | |
164 | is compared against the threshold size, held by auto_solib_add | |
165 | (in megabytes). If adding symbols for the new shlib would cause | |
166 | the total size to exceed the threshold, then the new shlib's symbols | |
167 | are not loaded. | |
c5aa993b JM |
168 | */ |
169 | static LONGEST som_solib_total_st_size; | |
c906108c SS |
170 | |
171 | /* When the threshold is reached for any shlib, we refuse to add | |
172 | symbols for subsequent shlibs, even if those shlibs' symbols would | |
173 | be small enough to fit under the threshold. (Although this may | |
174 | result in one, early large shlib preventing the loading of later, | |
175 | smalller shlibs' symbols, it allows us to issue one informational | |
176 | message. The alternative, to issue a message for each shlib whose | |
177 | symbols aren't loaded, could be a big annoyance where the threshold | |
178 | is exceeded due to a very large number of shlibs.) | |
c5aa993b JM |
179 | */ |
180 | static int som_solib_st_size_threshold_exceeded; | |
c906108c SS |
181 | |
182 | /* These addresses should be filled in by som_solib_create_inferior_hook. | |
183 | They are also used elsewhere in this module. | |
c5aa993b JM |
184 | */ |
185 | typedef struct | |
186 | { | |
187 | CORE_ADDR address; | |
188 | struct unwind_table_entry *unwind; | |
189 | } | |
190 | addr_and_unwind_t; | |
c906108c SS |
191 | |
192 | /* When adding fields, be sure to clear them in _initialize_som_solib. */ | |
c5aa993b JM |
193 | static struct |
194 | { | |
195 | boolean is_valid; | |
196 | addr_and_unwind_t hook; | |
197 | addr_and_unwind_t hook_stub; | |
198 | addr_and_unwind_t load; | |
199 | addr_and_unwind_t load_stub; | |
200 | addr_and_unwind_t unload; | |
201 | addr_and_unwind_t unload2; | |
202 | addr_and_unwind_t unload_stub; | |
203 | } | |
204 | dld_cache; | |
c906108c SS |
205 | |
206 | ||
207 | ||
a14ed312 | 208 | static void som_sharedlibrary_info_command (char *, int); |
c906108c | 209 | |
a14ed312 | 210 | static void som_solib_sharedlibrary_command (char *, int); |
c906108c SS |
211 | |
212 | static LONGEST | |
fba45db2 | 213 | som_solib_sizeof_symbol_table (char *filename) |
c906108c | 214 | { |
c5aa993b JM |
215 | bfd *abfd; |
216 | int desc; | |
217 | char *absolute_name; | |
218 | LONGEST st_size = (LONGEST) 0; | |
219 | asection *sect; | |
c906108c SS |
220 | |
221 | /* We believe that filename was handed to us by the dynamic linker, and | |
222 | is therefore always an absolute path. | |
c5aa993b | 223 | */ |
c906108c SS |
224 | desc = openp (getenv ("PATH"), 1, filename, O_RDONLY | O_BINARY, 0, &absolute_name); |
225 | if (desc < 0) | |
226 | { | |
227 | perror_with_name (filename); | |
228 | } | |
229 | filename = absolute_name; | |
230 | ||
231 | abfd = bfd_fdopenr (filename, gnutarget, desc); | |
c5aa993b | 232 | if (!abfd) |
c906108c SS |
233 | { |
234 | close (desc); | |
b8c9b27d | 235 | make_cleanup (xfree, filename); |
c906108c SS |
236 | error ("\"%s\": can't open to read symbols: %s.", filename, |
237 | bfd_errmsg (bfd_get_error ())); | |
238 | } | |
c5aa993b JM |
239 | |
240 | if (!bfd_check_format (abfd, bfd_object)) /* Reads in section info */ | |
c906108c | 241 | { |
c5aa993b | 242 | bfd_close (abfd); /* This also closes desc */ |
b8c9b27d | 243 | make_cleanup (xfree, filename); |
c906108c SS |
244 | error ("\"%s\": can't read symbols: %s.", filename, |
245 | bfd_errmsg (bfd_get_error ())); | |
246 | } | |
247 | ||
248 | /* Sum the sizes of the various sections that compose debug info. */ | |
249 | ||
250 | /* This contains non-DOC information. */ | |
251 | sect = bfd_get_section_by_name (abfd, "$DEBUG$"); | |
252 | if (sect) | |
253 | st_size += (LONGEST) bfd_section_size (abfd, sect); | |
254 | ||
255 | /* This contains DOC information. */ | |
256 | sect = bfd_get_section_by_name (abfd, "$PINFO$"); | |
257 | if (sect) | |
258 | st_size += (LONGEST) bfd_section_size (abfd, sect); | |
259 | ||
c5aa993b | 260 | bfd_close (abfd); /* This also closes desc */ |
b8c9b27d | 261 | xfree (filename); |
c906108c SS |
262 | |
263 | /* Unfortunately, just summing the sizes of various debug info | |
264 | sections isn't a very accurate measurement of how much heap | |
265 | space the debugger will need to hold them. It also doesn't | |
266 | account for space needed by linker (aka "minimal") symbols. | |
267 | ||
268 | Anecdotal evidence suggests that just summing the sizes of | |
269 | debug-info-related sections understates the heap space needed | |
270 | to represent it internally by about an order of magnitude. | |
271 | ||
272 | Since it's not exactly brain surgery we're doing here, rather | |
273 | than attempt to more accurately measure the size of a shlib's | |
274 | symbol table in GDB's heap, we'll just apply a 10x fudge- | |
275 | factor to the debug info sections' size-sum. No, this doesn't | |
276 | account for minimal symbols in non-debuggable shlibs. But it | |
277 | all roughly washes out in the end. | |
c5aa993b | 278 | */ |
c906108c SS |
279 | return st_size * (LONGEST) 10; |
280 | } | |
281 | ||
282 | ||
283 | static void | |
fba45db2 KB |
284 | som_solib_add_solib_objfile (struct so_list *so, char *name, int from_tty, |
285 | CORE_ADDR text_addr) | |
c906108c SS |
286 | { |
287 | obj_private_data_t *obj_private; | |
9ca0e47c | 288 | struct obj_section *s; |
c5aa993b | 289 | |
9ca0e47c | 290 | so->objfile = symbol_file_add (name, from_tty, NULL, 0, OBJF_SHARED); |
c906108c SS |
291 | so->abfd = so->objfile->obfd; |
292 | ||
9ca0e47c MC |
293 | /* syms_from_objfile has bizarre section offset code, |
294 | so I do my own right here. */ | |
295 | for (s = so->objfile->sections; s < so->objfile->sections_end; s++) | |
296 | { | |
297 | flagword aflag = bfd_get_section_flags(so->abfd, s->the_bfd_section); | |
298 | if (aflag & SEC_CODE) | |
299 | { | |
300 | s->addr += so->som_solib.text_addr - so->som_solib.text_link_addr; | |
301 | s->endaddr += so->som_solib.text_addr - so->som_solib.text_link_addr; | |
302 | } | |
303 | else if (aflag & SEC_DATA) | |
304 | { | |
305 | s->addr += so->som_solib.data_start; | |
306 | s->endaddr += so->som_solib.data_start; | |
307 | } | |
308 | else | |
309 | ; | |
310 | } | |
311 | ||
c906108c SS |
312 | /* Mark this as a shared library and save private data. |
313 | */ | |
314 | so->objfile->flags |= OBJF_SHARED; | |
315 | ||
c5aa993b | 316 | if (so->objfile->obj_private == NULL) |
c906108c SS |
317 | { |
318 | obj_private = (obj_private_data_t *) | |
c5aa993b JM |
319 | obstack_alloc (&so->objfile->psymbol_obstack, |
320 | sizeof (obj_private_data_t)); | |
c906108c | 321 | obj_private->unwind_info = NULL; |
c5aa993b | 322 | obj_private->so_info = NULL; |
c906108c | 323 | so->objfile->obj_private = (PTR) obj_private; |
c5aa993b | 324 | } |
c906108c SS |
325 | |
326 | obj_private = (obj_private_data_t *) so->objfile->obj_private; | |
327 | obj_private->so_info = so; | |
328 | ||
329 | if (!bfd_check_format (so->abfd, bfd_object)) | |
330 | { | |
331 | error ("\"%s\": not in executable format: %s.", | |
c5aa993b | 332 | name, bfd_errmsg (bfd_get_error ())); |
c906108c SS |
333 | } |
334 | } | |
335 | ||
336 | ||
337 | static void | |
fba45db2 KB |
338 | som_solib_load_symbols (struct so_list *so, char *name, int from_tty, |
339 | CORE_ADDR text_addr, struct target_ops *target) | |
c906108c | 340 | { |
c5aa993b JM |
341 | struct section_table *p; |
342 | int status; | |
343 | char buf[4]; | |
344 | CORE_ADDR presumed_data_start; | |
c906108c SS |
345 | |
346 | #ifdef SOLIB_DEBUG | |
c5aa993b | 347 | printf ("--Adding symbols for shared library \"%s\"\n", name); |
c906108c SS |
348 | #endif |
349 | ||
350 | som_solib_add_solib_objfile (so, name, from_tty, text_addr); | |
351 | ||
352 | /* Now we need to build a section table for this library since | |
353 | we might be debugging a core file from a dynamically linked | |
354 | executable in which the libraries were not privately mapped. */ | |
355 | if (build_section_table (so->abfd, | |
c5aa993b JM |
356 | &so->sections, |
357 | &so->sections_end)) | |
c906108c SS |
358 | { |
359 | error ("Unable to build section table for shared library\n."); | |
360 | return; | |
361 | } | |
362 | ||
363 | /* Relocate all the sections based on where they got loaded. */ | |
364 | for (p = so->sections; p < so->sections_end; p++) | |
365 | { | |
366 | if (p->the_bfd_section->flags & SEC_CODE) | |
c5aa993b | 367 | { |
b8fbeb18 EZ |
368 | p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); |
369 | p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); | |
c5aa993b | 370 | } |
c906108c | 371 | else if (p->the_bfd_section->flags & SEC_DATA) |
c5aa993b | 372 | { |
b8fbeb18 EZ |
373 | p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); |
374 | p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); | |
c5aa993b | 375 | } |
c906108c SS |
376 | } |
377 | ||
378 | /* Now see if we need to map in the text and data for this shared | |
379 | library (for example debugging a core file which does not use | |
380 | private shared libraries.). | |
381 | ||
382 | Carefully peek at the first text address in the library. If the | |
383 | read succeeds, then the libraries were privately mapped and were | |
384 | included in the core dump file. | |
385 | ||
386 | If the peek failed, then the libraries were not privately mapped | |
387 | and are not in the core file, we'll have to read them in ourselves. */ | |
388 | status = target_read_memory (text_addr, buf, 4); | |
389 | if (status != 0) | |
390 | { | |
391 | int old, new; | |
c906108c SS |
392 | |
393 | new = so->sections_end - so->sections; | |
6426a772 JM |
394 | |
395 | old = target_resize_to_sections (target, new); | |
396 | ||
c906108c | 397 | /* Copy over the old data before it gets clobbered. */ |
c5aa993b JM |
398 | memcpy ((char *) (target->to_sections + old), |
399 | so->sections, | |
400 | ((sizeof (struct section_table)) * new)); | |
c906108c SS |
401 | } |
402 | } | |
403 | ||
404 | ||
405 | /* Add symbols from shared libraries into the symtab list, unless the | |
406 | size threshold (specified by auto_solib_add, in megabytes) would | |
407 | be exceeded. */ | |
408 | ||
409 | void | |
fba45db2 | 410 | som_solib_add (char *arg_string, int from_tty, struct target_ops *target) |
c906108c SS |
411 | { |
412 | struct minimal_symbol *msymbol; | |
413 | struct so_list *so_list_tail; | |
414 | CORE_ADDR addr; | |
415 | asection *shlib_info; | |
416 | int status; | |
417 | unsigned int dld_flags; | |
418 | char buf[4], *re_err; | |
c5aa993b | 419 | int threshold_warning_given = 0; |
c906108c SS |
420 | |
421 | /* First validate our arguments. */ | |
422 | if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL) | |
423 | { | |
424 | error ("Invalid regexp: %s", re_err); | |
425 | } | |
426 | ||
427 | /* If we're debugging a core file, or have attached to a running | |
428 | process, then som_solib_create_inferior_hook will not have been | |
429 | called. | |
430 | ||
431 | We need to first determine if we're dealing with a dynamically | |
432 | linked executable. If not, then return without an error or warning. | |
433 | ||
434 | We also need to examine __dld_flags to determine if the shared library | |
435 | list is valid and to determine if the libraries have been privately | |
436 | mapped. */ | |
437 | if (symfile_objfile == NULL) | |
438 | return; | |
439 | ||
440 | /* First see if the objfile was dynamically linked. */ | |
441 | shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$"); | |
442 | if (!shlib_info) | |
443 | return; | |
444 | ||
445 | /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */ | |
446 | if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0) | |
447 | return; | |
448 | ||
449 | msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL); | |
450 | if (msymbol == NULL) | |
451 | { | |
452 | error ("Unable to find __dld_flags symbol in object file.\n"); | |
453 | return; | |
454 | } | |
455 | ||
456 | addr = SYMBOL_VALUE_ADDRESS (msymbol); | |
457 | /* Read the current contents. */ | |
458 | status = target_read_memory (addr, buf, 4); | |
459 | if (status != 0) | |
460 | { | |
461 | error ("Unable to read __dld_flags\n"); | |
462 | return; | |
463 | } | |
464 | dld_flags = extract_unsigned_integer (buf, 4); | |
465 | ||
466 | /* __dld_list may not be valid. If not, then we punt, warning the user if | |
467 | we were called as a result of the add-symfile command. | |
c5aa993b | 468 | */ |
c906108c SS |
469 | if ((dld_flags & DLD_FLAGS_LISTVALID) == 0) |
470 | { | |
471 | if (from_tty) | |
c5aa993b | 472 | error ("__dld_list is not valid according to __dld_flags.\n"); |
c906108c SS |
473 | return; |
474 | } | |
475 | ||
476 | /* If the libraries were not mapped private, warn the user. */ | |
477 | if ((dld_flags & DLD_FLAGS_MAPPRIVATE) == 0) | |
478 | warning ("The shared libraries were not privately mapped; setting a\nbreakpoint in a shared library will not work until you rerun the program.\n"); | |
479 | ||
480 | msymbol = lookup_minimal_symbol ("__dld_list", NULL, NULL); | |
481 | if (!msymbol) | |
482 | { | |
483 | /* Older crt0.o files (hpux8) don't have __dld_list as a symbol, | |
c5aa993b | 484 | but the data is still available if you know where to look. */ |
c906108c SS |
485 | msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL); |
486 | if (!msymbol) | |
487 | { | |
488 | error ("Unable to find dynamic library list.\n"); | |
489 | return; | |
490 | } | |
491 | addr = SYMBOL_VALUE_ADDRESS (msymbol) - 8; | |
492 | } | |
493 | else | |
494 | addr = SYMBOL_VALUE_ADDRESS (msymbol); | |
495 | ||
496 | status = target_read_memory (addr, buf, 4); | |
497 | if (status != 0) | |
498 | { | |
499 | error ("Unable to find dynamic library list.\n"); | |
500 | return; | |
501 | } | |
502 | ||
503 | addr = extract_unsigned_integer (buf, 4); | |
504 | ||
505 | /* If addr is zero, then we're using an old dynamic loader which | |
506 | doesn't maintain __dld_list. We'll have to use a completely | |
507 | different approach to get shared library information. */ | |
508 | if (addr == 0) | |
509 | goto old_dld; | |
510 | ||
511 | /* Using the information in __dld_list is the preferred method | |
512 | to get at shared library information. It doesn't depend on | |
513 | any functions in /opt/langtools/lib/end.o and has a chance of working | |
514 | with hpux10 when it is released. */ | |
515 | status = target_read_memory (addr, buf, 4); | |
516 | if (status != 0) | |
517 | { | |
518 | error ("Unable to find dynamic library list.\n"); | |
519 | return; | |
520 | } | |
521 | ||
522 | /* addr now holds the address of the first entry in the dynamic | |
523 | library list. */ | |
524 | addr = extract_unsigned_integer (buf, 4); | |
525 | ||
526 | /* Now that we have a pointer to the dynamic library list, walk | |
527 | through it and add the symbols for each library. */ | |
528 | ||
529 | so_list_tail = so_list_head; | |
530 | /* Find the end of the list of shared objects. */ | |
531 | while (so_list_tail && so_list_tail->next) | |
532 | so_list_tail = so_list_tail->next; | |
533 | ||
534 | #ifdef SOLIB_DEBUG | |
c5aa993b | 535 | printf ("--About to read shared library list data\n"); |
c906108c SS |
536 | #endif |
537 | ||
538 | /* "addr" will always point to the base of the | |
539 | * current data entry describing the current | |
540 | * shared library. | |
541 | */ | |
542 | while (1) | |
543 | { | |
544 | CORE_ADDR name_addr, text_addr; | |
545 | unsigned int name_len; | |
546 | char *name; | |
547 | struct so_list *new_so; | |
548 | struct so_list *so_list = so_list_head; | |
549 | struct stat statbuf; | |
c5aa993b JM |
550 | LONGEST st_size; |
551 | int is_main_program; | |
c906108c SS |
552 | |
553 | if (addr == 0) | |
554 | break; | |
555 | ||
556 | /* Get a pointer to the name of this library. */ | |
557 | status = target_read_memory (addr, buf, 4); | |
558 | if (status != 0) | |
559 | goto err; | |
560 | ||
561 | name_addr = extract_unsigned_integer (buf, 4); | |
562 | name_len = 0; | |
563 | while (1) | |
564 | { | |
565 | target_read_memory (name_addr + name_len, buf, 1); | |
566 | if (status != 0) | |
567 | goto err; | |
568 | ||
569 | name_len++; | |
570 | if (*buf == '\0') | |
571 | break; | |
572 | } | |
573 | name = alloca (name_len); | |
574 | status = target_read_memory (name_addr, name, name_len); | |
575 | if (status != 0) | |
576 | goto err; | |
577 | ||
578 | /* See if we've already loaded something with this name. */ | |
579 | while (so_list) | |
580 | { | |
581 | if (!strcmp (so_list->som_solib.name, name)) | |
582 | break; | |
583 | so_list = so_list->next; | |
584 | } | |
585 | ||
586 | /* See if the file exists. If not, give a warning, but don't | |
c5aa993b | 587 | die. */ |
c906108c SS |
588 | status = stat (name, &statbuf); |
589 | if (status == -1) | |
590 | { | |
591 | warning ("Can't find file %s referenced in dld_list.", name); | |
592 | ||
593 | status = target_read_memory (addr + 36, buf, 4); | |
594 | if (status != 0) | |
595 | goto err; | |
596 | ||
c5aa993b | 597 | addr = (CORE_ADDR) extract_unsigned_integer (buf, 4); |
c906108c SS |
598 | continue; |
599 | } | |
600 | ||
601 | /* If we've already loaded this one or it's the main program, skip it. */ | |
602 | is_main_program = (strcmp (name, symfile_objfile->name) == 0); | |
603 | if (so_list || is_main_program) | |
604 | { | |
c5aa993b JM |
605 | /* This is the "next" pointer in the strcuture. |
606 | */ | |
c906108c SS |
607 | status = target_read_memory (addr + 36, buf, 4); |
608 | if (status != 0) | |
609 | goto err; | |
610 | ||
611 | addr = (CORE_ADDR) extract_unsigned_integer (buf, 4); | |
612 | ||
c5aa993b JM |
613 | /* Record the main program's symbol table size. */ |
614 | if (is_main_program && !so_list) | |
615 | { | |
616 | st_size = som_solib_sizeof_symbol_table (name); | |
617 | som_solib_total_st_size += st_size; | |
618 | } | |
619 | ||
620 | /* Was this a shlib that we noted but didn't load the symbols for? | |
621 | If so, were we invoked this time from the command-line, via | |
622 | a 'sharedlibrary' or 'add-symbol-file' command? If yes to | |
623 | both, we'd better load the symbols this time. | |
624 | */ | |
625 | if (from_tty && so_list && !is_main_program && (so_list->objfile == NULL)) | |
626 | som_solib_load_symbols (so_list, | |
627 | name, | |
628 | from_tty, | |
629 | so_list->som_solib.text_addr, | |
630 | target); | |
c906108c SS |
631 | |
632 | continue; | |
633 | } | |
634 | ||
635 | name = obsavestring (name, name_len - 1, | |
636 | &symfile_objfile->symbol_obstack); | |
637 | ||
638 | status = target_read_memory (addr + 8, buf, 4); | |
639 | if (status != 0) | |
640 | goto err; | |
641 | ||
642 | text_addr = extract_unsigned_integer (buf, 4); | |
643 | ||
644 | new_so = (struct so_list *) xmalloc (sizeof (struct so_list)); | |
c5aa993b | 645 | memset ((char *) new_so, 0, sizeof (struct so_list)); |
c906108c SS |
646 | if (so_list_head == NULL) |
647 | { | |
648 | so_list_head = new_so; | |
649 | so_list_tail = new_so; | |
650 | } | |
651 | else | |
652 | { | |
653 | so_list_tail->next = new_so; | |
654 | so_list_tail = new_so; | |
655 | } | |
656 | ||
657 | /* Fill in all the entries in GDB's shared library list. | |
658 | */ | |
c5aa993b | 659 | |
c906108c SS |
660 | new_so->solib_addr = addr; |
661 | new_so->som_solib.name = name; | |
662 | status = target_read_memory (addr + 4, buf, 4); | |
663 | if (status != 0) | |
664 | goto err; | |
665 | ||
666 | new_so->som_solib.struct_version = extract_unsigned_integer (buf + 3, 1); | |
667 | new_so->som_solib.bind_mode = extract_unsigned_integer (buf + 2, 1); | |
c5aa993b JM |
668 | /* Following is "high water mark", highest version number |
669 | * seen, rather than plain version number. | |
670 | */ | |
c906108c SS |
671 | new_so->som_solib.library_version = extract_unsigned_integer (buf, 2); |
672 | new_so->som_solib.text_addr = text_addr; | |
673 | ||
c5aa993b JM |
674 | /* Q: What about longword at "addr + 8"? |
675 | * A: It's read above, out of order, into "text_addr". | |
676 | */ | |
c906108c SS |
677 | |
678 | status = target_read_memory (addr + 12, buf, 4); | |
679 | if (status != 0) | |
680 | goto err; | |
681 | ||
682 | new_so->som_solib.text_link_addr = extract_unsigned_integer (buf, 4); | |
683 | ||
684 | status = target_read_memory (addr + 16, buf, 4); | |
685 | if (status != 0) | |
686 | goto err; | |
687 | ||
688 | new_so->som_solib.text_end = extract_unsigned_integer (buf, 4); | |
689 | ||
690 | status = target_read_memory (addr + 20, buf, 4); | |
691 | if (status != 0) | |
692 | goto err; | |
693 | ||
694 | new_so->som_solib.data_start = extract_unsigned_integer (buf, 4); | |
695 | ||
696 | status = target_read_memory (addr + 24, buf, 4); | |
697 | if (status != 0) | |
698 | goto err; | |
699 | ||
700 | new_so->som_solib.bss_start = extract_unsigned_integer (buf, 4); | |
701 | ||
702 | status = target_read_memory (addr + 28, buf, 4); | |
703 | if (status != 0) | |
704 | goto err; | |
705 | ||
706 | new_so->som_solib.data_end = extract_unsigned_integer (buf, 4); | |
707 | ||
708 | status = target_read_memory (addr + 32, buf, 4); | |
709 | if (status != 0) | |
710 | goto err; | |
711 | ||
712 | new_so->som_solib.got_value = extract_unsigned_integer (buf, 4); | |
713 | ||
714 | status = target_read_memory (addr + 36, buf, 4); | |
715 | if (status != 0) | |
716 | goto err; | |
717 | ||
c5aa993b | 718 | new_so->som_solib.next = (void *) extract_unsigned_integer (buf, 4); |
c906108c SS |
719 | |
720 | /* Note that we don't re-set "addr" to the next pointer | |
721 | * until after we've read the trailing data. | |
722 | */ | |
723 | ||
724 | status = target_read_memory (addr + 40, buf, 4); | |
725 | new_so->som_solib.tsd_start_addr = extract_unsigned_integer (buf, 4); | |
726 | if (status != 0) | |
c5aa993b | 727 | goto err; |
c906108c SS |
728 | |
729 | /* Now indirect via that value! | |
730 | */ | |
731 | status = target_read_memory (new_so->som_solib.tsd_start_addr, buf, 4); | |
732 | new_so->som_solib.tsd_start_addr = extract_unsigned_integer (buf, 4); | |
733 | if (status != 0) | |
c5aa993b | 734 | goto err; |
c906108c | 735 | #ifdef SOLIB_DEBUG |
c5aa993b JM |
736 | printf ("\n+ library \"%s\" is described at 0x%x\n", name, addr); |
737 | printf (" 'version' is %d\n", new_so->som_solib.struct_version); | |
738 | printf (" 'bind_mode' is %d\n", new_so->som_solib.bind_mode); | |
739 | printf (" 'library_version' is %d\n", new_so->som_solib.library_version); | |
740 | printf (" 'text_addr' is 0x%x\n", new_so->som_solib.text_addr); | |
741 | printf (" 'text_link_addr' is 0x%x\n", new_so->som_solib.text_link_addr); | |
742 | printf (" 'text_end' is 0x%x\n", new_so->som_solib.text_end); | |
743 | printf (" 'data_start' is 0x%x\n", new_so->som_solib.data_start); | |
744 | printf (" 'bss_start' is 0x%x\n", new_so->som_solib.bss_start); | |
745 | printf (" 'data_end' is 0x%x\n", new_so->som_solib.data_end); | |
746 | printf (" 'got_value' is %x\n", new_so->som_solib.got_value); | |
747 | printf (" 'next' is 0x%x\n", new_so->som_solib.next); | |
748 | printf (" 'tsd_start_addr' is 0x%x\n", new_so->som_solib.tsd_start_addr); | |
c906108c SS |
749 | #endif |
750 | ||
751 | /* Go on to the next shared library descriptor. | |
752 | */ | |
c5aa993b | 753 | addr = (CORE_ADDR) new_so->som_solib.next; |
c906108c SS |
754 | |
755 | ||
756 | ||
757 | /* At this point, we have essentially hooked the shlib into the | |
758 | "info share" command. However, we haven't yet loaded its | |
759 | symbol table. We must now decide whether we ought to, i.e., | |
760 | whether doing so would exceed the symbol table size threshold. | |
761 | ||
762 | If the threshold has just now been exceeded, then we'll issue | |
763 | a warning message (which explains how to load symbols manually, | |
764 | if the user so desires). | |
765 | ||
766 | If the threshold has just now or previously been exceeded, | |
767 | we'll just add the shlib to the list of object files, but won't | |
768 | actually load its symbols. (This is more useful than it might | |
769 | sound, for it allows us to e.g., still load and use the shlibs' | |
770 | unwind information for stack tracebacks.) | |
c5aa993b | 771 | */ |
c906108c SS |
772 | |
773 | /* Note that we DON'T want to preclude the user from using the | |
774 | add-symbol-file command! Thus, we only worry about the threshold | |
775 | when we're invoked for other reasons. | |
c5aa993b | 776 | */ |
c906108c SS |
777 | st_size = som_solib_sizeof_symbol_table (name); |
778 | som_solib_st_size_threshold_exceeded = | |
c5aa993b JM |
779 | !from_tty && |
780 | ((st_size + som_solib_total_st_size) > (auto_solib_add * (LONGEST) 1000000)); | |
c906108c SS |
781 | |
782 | if (som_solib_st_size_threshold_exceeded) | |
c5aa993b JM |
783 | { |
784 | if (!threshold_warning_given) | |
785 | warning ("Symbols for some libraries have not been loaded, because\ndoing so would exceed the size threshold specified by auto-solib-add.\nTo manually load symbols, use the 'sharedlibrary' command.\nTo raise the threshold, set auto-solib-add to a larger value and rerun\nthe program.\n"); | |
786 | threshold_warning_given = 1; | |
787 | ||
788 | /* We'll still make note of this shlib, even if we don't | |
789 | read its symbols. This allows us to use its unwind | |
790 | information well enough to know how to e.g., correctly | |
791 | do a traceback from a PC within the shlib, even if we | |
792 | can't symbolize those PCs... | |
793 | */ | |
794 | som_solib_add_solib_objfile (new_so, name, from_tty, text_addr); | |
795 | continue; | |
796 | } | |
c906108c SS |
797 | |
798 | som_solib_total_st_size += st_size; | |
799 | ||
800 | /* This fills in new_so->objfile, among others. */ | |
801 | som_solib_load_symbols (new_so, name, from_tty, text_addr, target); | |
802 | } | |
803 | ||
804 | #ifdef SOLIB_DEBUG | |
c5aa993b | 805 | printf ("--Done reading shared library data\n"); |
c906108c SS |
806 | #endif |
807 | ||
808 | /* Getting new symbols may change our opinion about what is | |
809 | frameless. */ | |
810 | reinit_frame_cache (); | |
811 | return; | |
812 | ||
813 | old_dld: | |
814 | error ("Debugging dynamic executables loaded via the hpux8 dld.sl is not supported.\n"); | |
815 | return; | |
816 | ||
817 | err: | |
818 | error ("Error while reading dynamic library list.\n"); | |
819 | return; | |
820 | } | |
821 | ||
822 | ||
823 | /* This hook gets called just before the first instruction in the | |
824 | inferior process is executed. | |
825 | ||
826 | This is our opportunity to set magic flags in the inferior so | |
827 | that GDB can be notified when a shared library is mapped in and | |
828 | to tell the dynamic linker that a private copy of the library is | |
829 | needed (so GDB can set breakpoints in the library). | |
830 | ||
831 | __dld_flags is the location of the magic flags; as of this implementation | |
832 | there are 3 flags of interest: | |
833 | ||
834 | bit 0 when set indicates that private copies of the libraries are needed | |
835 | bit 1 when set indicates that the callback hook routine is valid | |
836 | bit 2 when set indicates that the dynamic linker should maintain the | |
c5aa993b | 837 | __dld_list structure when loading/unloading libraries. |
c906108c SS |
838 | |
839 | Note that shared libraries are not mapped in at this time, so we have | |
840 | run the inferior until the libraries are mapped in. Typically this | |
841 | means running until the "_start" is called. */ | |
842 | ||
843 | void | |
fba45db2 | 844 | som_solib_create_inferior_hook (void) |
c906108c SS |
845 | { |
846 | struct minimal_symbol *msymbol; | |
847 | unsigned int dld_flags, status, have_endo; | |
848 | asection *shlib_info; | |
849 | char buf[4]; | |
850 | struct objfile *objfile; | |
851 | CORE_ADDR anaddr; | |
852 | ||
853 | /* First, remove all the solib event breakpoints. Their addresses | |
854 | may have changed since the last time we ran the program. */ | |
855 | remove_solib_event_breakpoints (); | |
856 | ||
857 | if (symfile_objfile == NULL) | |
c5aa993b | 858 | return; |
c906108c SS |
859 | |
860 | /* First see if the objfile was dynamically linked. */ | |
861 | shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$"); | |
862 | if (!shlib_info) | |
863 | return; | |
864 | ||
865 | /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */ | |
866 | if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0) | |
867 | return; | |
868 | ||
869 | have_endo = 0; | |
870 | /* Slam the pid of the process into __d_pid; failing is only a warning! */ | |
871 | msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile); | |
872 | if (msymbol == NULL) | |
873 | { | |
874 | warning ("Unable to find __d_pid symbol in object file."); | |
875 | warning ("Suggest linking with /opt/langtools/lib/end.o."); | |
876 | warning ("GDB will be unable to track shl_load/shl_unload calls"); | |
877 | goto keep_going; | |
878 | } | |
879 | ||
880 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
881 | store_unsigned_integer (buf, 4, inferior_pid); | |
882 | status = target_write_memory (anaddr, buf, 4); | |
883 | if (status != 0) | |
884 | { | |
885 | warning ("Unable to write __d_pid"); | |
886 | warning ("Suggest linking with /opt/langtools/lib/end.o."); | |
887 | warning ("GDB will be unable to track shl_load/shl_unload calls"); | |
888 | goto keep_going; | |
889 | } | |
890 | ||
891 | /* Get the value of _DLD_HOOK (an export stub) and put it in __dld_hook; | |
892 | This will force the dynamic linker to call __d_trap when significant | |
893 | events occur. | |
894 | ||
895 | Note that the above is the pre-HP-UX 9.0 behaviour. At 9.0 and above, | |
896 | the dld provides an export stub named "__d_trap" as well as the | |
897 | function named "__d_trap" itself, but doesn't provide "_DLD_HOOK". | |
898 | We'll look first for the old flavor and then the new. | |
c5aa993b | 899 | */ |
c906108c SS |
900 | msymbol = lookup_minimal_symbol ("_DLD_HOOK", NULL, symfile_objfile); |
901 | if (msymbol == NULL) | |
c5aa993b | 902 | msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile); |
c906108c SS |
903 | if (msymbol == NULL) |
904 | { | |
905 | warning ("Unable to find _DLD_HOOK symbol in object file."); | |
906 | warning ("Suggest linking with /opt/langtools/lib/end.o."); | |
907 | warning ("GDB will be unable to track shl_load/shl_unload calls"); | |
908 | goto keep_going; | |
909 | } | |
910 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
911 | dld_cache.hook.address = anaddr; | |
912 | ||
913 | /* Grrr, this might not be an export symbol! We have to find the | |
914 | export stub. */ | |
915 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
916 | { |
917 | struct unwind_table_entry *u; | |
918 | struct minimal_symbol *msymbol2; | |
919 | ||
920 | /* What a crock. */ | |
921 | msymbol2 = lookup_minimal_symbol_solib_trampoline (SYMBOL_NAME (msymbol), | |
922 | NULL, objfile); | |
923 | /* Found a symbol with the right name. */ | |
924 | if (msymbol2) | |
925 | { | |
926 | struct unwind_table_entry *u; | |
927 | /* It must be a shared library trampoline. */ | |
928 | if (SYMBOL_TYPE (msymbol2) != mst_solib_trampoline) | |
929 | continue; | |
930 | ||
931 | /* It must also be an export stub. */ | |
932 | u = find_unwind_entry (SYMBOL_VALUE (msymbol2)); | |
933 | if (!u || u->stub_unwind.stub_type != EXPORT) | |
934 | continue; | |
935 | ||
936 | /* OK. Looks like the correct import stub. */ | |
937 | anaddr = SYMBOL_VALUE (msymbol2); | |
938 | dld_cache.hook_stub.address = anaddr; | |
939 | } | |
940 | } | |
c906108c SS |
941 | store_unsigned_integer (buf, 4, anaddr); |
942 | ||
943 | msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile); | |
944 | if (msymbol == NULL) | |
945 | { | |
946 | warning ("Unable to find __dld_hook symbol in object file."); | |
947 | warning ("Suggest linking with /opt/langtools/lib/end.o."); | |
948 | warning ("GDB will be unable to track shl_load/shl_unload calls"); | |
949 | goto keep_going; | |
950 | } | |
951 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
952 | status = target_write_memory (anaddr, buf, 4); | |
c5aa993b | 953 | |
c906108c SS |
954 | /* Now set a shlib_event breakpoint at __d_trap so we can track |
955 | significant shared library events. */ | |
956 | msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile); | |
957 | if (msymbol == NULL) | |
958 | { | |
959 | warning ("Unable to find __dld_d_trap symbol in object file."); | |
960 | warning ("Suggest linking with /opt/langtools/lib/end.o."); | |
961 | warning ("GDB will be unable to track shl_load/shl_unload calls"); | |
962 | goto keep_going; | |
963 | } | |
964 | create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol)); | |
965 | ||
966 | /* We have all the support usually found in end.o, so we can track | |
967 | shl_load and shl_unload calls. */ | |
968 | have_endo = 1; | |
969 | ||
970 | keep_going: | |
971 | ||
972 | /* Get the address of __dld_flags, if no such symbol exists, then we can | |
973 | not debug the shared code. */ | |
974 | msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL); | |
975 | if (msymbol == NULL) | |
976 | { | |
977 | error ("Unable to find __dld_flags symbol in object file.\n"); | |
978 | } | |
979 | ||
980 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
981 | ||
982 | /* Read the current contents. */ | |
983 | status = target_read_memory (anaddr, buf, 4); | |
984 | if (status != 0) | |
985 | { | |
986 | error ("Unable to read __dld_flags\n"); | |
987 | } | |
988 | dld_flags = extract_unsigned_integer (buf, 4); | |
989 | ||
990 | /* Turn on the flags we care about. */ | |
991 | dld_flags |= DLD_FLAGS_MAPPRIVATE; | |
992 | if (have_endo) | |
993 | dld_flags |= DLD_FLAGS_HOOKVALID; | |
994 | store_unsigned_integer (buf, 4, dld_flags); | |
995 | status = target_write_memory (anaddr, buf, 4); | |
996 | if (status != 0) | |
997 | { | |
998 | error ("Unable to write __dld_flags\n"); | |
999 | } | |
1000 | ||
1001 | /* Now find the address of _start and set a breakpoint there. | |
1002 | We still need this code for two reasons: | |
1003 | ||
c5aa993b JM |
1004 | * Not all sites have /opt/langtools/lib/end.o, so it's not always |
1005 | possible to track the dynamic linker's events. | |
1006 | ||
1007 | * At this time no events are triggered for shared libraries | |
1008 | loaded at startup time (what a crock). */ | |
c906108c | 1009 | |
c906108c SS |
1010 | msymbol = lookup_minimal_symbol ("_start", NULL, symfile_objfile); |
1011 | if (msymbol == NULL) | |
1012 | { | |
1013 | error ("Unable to find _start symbol in object file.\n"); | |
1014 | } | |
1015 | ||
1016 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
1017 | ||
1018 | /* Make the breakpoint at "_start" a shared library event breakpoint. */ | |
1019 | create_solib_event_breakpoint (anaddr); | |
1020 | ||
1021 | /* Wipe out all knowledge of old shared libraries since their | |
1022 | mapping can change from one exec to another! */ | |
1023 | while (so_list_head) | |
1024 | { | |
1025 | struct so_list *temp; | |
1026 | ||
1027 | temp = so_list_head; | |
b8c9b27d | 1028 | xfree (so_list_head); |
c906108c SS |
1029 | so_list_head = temp->next; |
1030 | } | |
1031 | clear_symtab_users (); | |
1032 | } | |
1033 | ||
1034 | ||
1035 | static void | |
fba45db2 | 1036 | reset_inferior_pid (int saved_inferior_pid) |
c906108c SS |
1037 | { |
1038 | inferior_pid = saved_inferior_pid; | |
1039 | } | |
1040 | ||
1041 | ||
1042 | /* This operation removes the "hook" between GDB and the dynamic linker, | |
1043 | which causes the dld to notify GDB of shared library events. | |
1044 | ||
1045 | After this operation completes, the dld will no longer notify GDB of | |
1046 | shared library events. To resume notifications, GDB must call | |
1047 | som_solib_create_inferior_hook. | |
1048 | ||
1049 | This operation does not remove any knowledge of shared libraries which | |
1050 | GDB may already have been notified of. | |
c5aa993b | 1051 | */ |
c906108c | 1052 | void |
fba45db2 | 1053 | som_solib_remove_inferior_hook (int pid) |
c906108c | 1054 | { |
c5aa993b JM |
1055 | CORE_ADDR addr; |
1056 | struct minimal_symbol *msymbol; | |
1057 | int status; | |
1058 | char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT]; | |
1059 | unsigned int dld_flags_value; | |
1060 | int saved_inferior_pid = inferior_pid; | |
1061 | struct cleanup *old_cleanups = make_cleanup (reset_inferior_pid, saved_inferior_pid); | |
c906108c SS |
1062 | |
1063 | /* Ensure that we're really operating on the specified process. */ | |
1064 | inferior_pid = pid; | |
1065 | ||
1066 | /* We won't bother to remove the solib breakpoints from this process. | |
1067 | ||
1068 | In fact, on PA64 the breakpoint is hard-coded into the dld callback, | |
1069 | and thus we're not supposed to remove it. | |
1070 | ||
1071 | Rather, we'll merely clear the dld_flags bit that enables callbacks. | |
c5aa993b | 1072 | */ |
c906108c SS |
1073 | msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL); |
1074 | ||
1075 | addr = SYMBOL_VALUE_ADDRESS (msymbol); | |
c5aa993b | 1076 | status = target_read_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT); |
c906108c SS |
1077 | |
1078 | dld_flags_value = extract_unsigned_integer (dld_flags_buffer, | |
c5aa993b | 1079 | sizeof (dld_flags_value)); |
c906108c SS |
1080 | |
1081 | dld_flags_value &= ~DLD_FLAGS_HOOKVALID; | |
1082 | store_unsigned_integer (dld_flags_buffer, | |
c5aa993b JM |
1083 | sizeof (dld_flags_value), |
1084 | dld_flags_value); | |
1085 | status = target_write_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT); | |
c906108c SS |
1086 | |
1087 | do_cleanups (old_cleanups); | |
1088 | } | |
1089 | ||
1090 | ||
1091 | /* This function creates a breakpoint on the dynamic linker hook, which | |
1092 | is called when e.g., a shl_load or shl_unload call is made. This | |
1093 | breakpoint will only trigger when a shl_load call is made. | |
1094 | ||
1095 | If filename is NULL, then loads of any dll will be caught. Else, | |
1096 | only loads of the file whose pathname is the string contained by | |
1097 | filename will be caught. | |
1098 | ||
1099 | Undefined behaviour is guaranteed if this function is called before | |
1100 | som_solib_create_inferior_hook. | |
c5aa993b | 1101 | */ |
c906108c | 1102 | void |
fba45db2 KB |
1103 | som_solib_create_catch_load_hook (int pid, int tempflag, char *filename, |
1104 | char *cond_string) | |
c906108c SS |
1105 | { |
1106 | create_solib_load_event_breakpoint ("__d_trap", tempflag, filename, cond_string); | |
1107 | } | |
1108 | ||
1109 | /* This function creates a breakpoint on the dynamic linker hook, which | |
1110 | is called when e.g., a shl_load or shl_unload call is made. This | |
1111 | breakpoint will only trigger when a shl_unload call is made. | |
1112 | ||
1113 | If filename is NULL, then unloads of any dll will be caught. Else, | |
1114 | only unloads of the file whose pathname is the string contained by | |
1115 | filename will be caught. | |
1116 | ||
1117 | Undefined behaviour is guaranteed if this function is called before | |
1118 | som_solib_create_inferior_hook. | |
c5aa993b | 1119 | */ |
c906108c | 1120 | void |
fba45db2 KB |
1121 | som_solib_create_catch_unload_hook (int pid, int tempflag, char *filename, |
1122 | char *cond_string) | |
c906108c SS |
1123 | { |
1124 | create_solib_unload_event_breakpoint ("__d_trap", tempflag, filename, cond_string); | |
1125 | } | |
1126 | ||
1127 | int | |
fba45db2 | 1128 | som_solib_have_load_event (int pid) |
c906108c | 1129 | { |
c5aa993b | 1130 | CORE_ADDR event_kind; |
c906108c SS |
1131 | |
1132 | event_kind = read_register (ARG0_REGNUM); | |
1133 | return (event_kind == SHL_LOAD); | |
1134 | } | |
1135 | ||
1136 | int | |
fba45db2 | 1137 | som_solib_have_unload_event (int pid) |
c906108c | 1138 | { |
c5aa993b | 1139 | CORE_ADDR event_kind; |
c906108c SS |
1140 | |
1141 | event_kind = read_register (ARG0_REGNUM); | |
1142 | return (event_kind == SHL_UNLOAD); | |
1143 | } | |
1144 | ||
1145 | static char * | |
fba45db2 | 1146 | som_solib_library_pathname (int pid) |
c906108c | 1147 | { |
c5aa993b JM |
1148 | CORE_ADDR dll_handle_address; |
1149 | CORE_ADDR dll_pathname_address; | |
1150 | struct som_solib_mapped_entry dll_descriptor; | |
1151 | char *p; | |
1152 | static char dll_pathname[1024]; | |
c906108c SS |
1153 | |
1154 | /* Read the descriptor of this newly-loaded library. */ | |
1155 | dll_handle_address = read_register (ARG1_REGNUM); | |
1156 | read_memory (dll_handle_address, (char *) &dll_descriptor, sizeof (dll_descriptor)); | |
1157 | ||
1158 | /* We can find a pointer to the dll's pathname within the descriptor. */ | |
1159 | dll_pathname_address = (CORE_ADDR) dll_descriptor.name; | |
c5aa993b | 1160 | |
c906108c SS |
1161 | /* Read the pathname, one byte at a time. */ |
1162 | p = dll_pathname; | |
1163 | for (;;) | |
1164 | { | |
c5aa993b | 1165 | char b; |
c906108c SS |
1166 | read_memory (dll_pathname_address++, (char *) &b, 1); |
1167 | *p++ = b; | |
1168 | if (b == '\0') | |
c5aa993b | 1169 | break; |
c906108c SS |
1170 | } |
1171 | ||
1172 | return dll_pathname; | |
1173 | } | |
1174 | ||
1175 | char * | |
fba45db2 | 1176 | som_solib_loaded_library_pathname (int pid) |
c906108c | 1177 | { |
c5aa993b | 1178 | if (!som_solib_have_load_event (pid)) |
c906108c SS |
1179 | error ("Must have a load event to use this query"); |
1180 | ||
1181 | return som_solib_library_pathname (pid); | |
1182 | } | |
1183 | ||
1184 | char * | |
fba45db2 | 1185 | som_solib_unloaded_library_pathname (int pid) |
c906108c | 1186 | { |
c5aa993b | 1187 | if (!som_solib_have_unload_event (pid)) |
c906108c SS |
1188 | error ("Must have an unload event to use this query"); |
1189 | ||
1190 | return som_solib_library_pathname (pid); | |
1191 | } | |
1192 | ||
1193 | static void | |
fba45db2 | 1194 | som_solib_desire_dynamic_linker_symbols (void) |
c906108c SS |
1195 | { |
1196 | struct objfile *objfile; | |
1197 | struct unwind_table_entry *u; | |
c5aa993b | 1198 | struct minimal_symbol *dld_msymbol; |
c906108c SS |
1199 | |
1200 | /* Do we already know the value of these symbols? If so, then | |
1201 | we've no work to do. | |
1202 | ||
1203 | (If you add clauses to this test, be sure to likewise update the | |
1204 | test within the loop.) | |
c5aa993b | 1205 | */ |
c906108c SS |
1206 | if (dld_cache.is_valid) |
1207 | return; | |
1208 | ||
1209 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
1210 | { |
1211 | dld_msymbol = lookup_minimal_symbol ("shl_load", NULL, objfile); | |
1212 | if (dld_msymbol != NULL) | |
1213 | { | |
1214 | dld_cache.load.address = SYMBOL_VALUE (dld_msymbol); | |
1215 | dld_cache.load.unwind = find_unwind_entry (dld_cache.load.address); | |
1216 | } | |
1217 | ||
1218 | dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_load", | |
1219 | NULL, | |
1220 | objfile); | |
1221 | if (dld_msymbol != NULL) | |
1222 | { | |
1223 | if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline) | |
1224 | { | |
1225 | u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol)); | |
1226 | if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT)) | |
1227 | { | |
1228 | dld_cache.load_stub.address = SYMBOL_VALUE (dld_msymbol); | |
1229 | dld_cache.load_stub.unwind = u; | |
1230 | } | |
1231 | } | |
1232 | } | |
1233 | ||
1234 | dld_msymbol = lookup_minimal_symbol ("shl_unload", NULL, objfile); | |
1235 | if (dld_msymbol != NULL) | |
1236 | { | |
1237 | dld_cache.unload.address = SYMBOL_VALUE (dld_msymbol); | |
1238 | dld_cache.unload.unwind = find_unwind_entry (dld_cache.unload.address); | |
1239 | ||
1240 | /* ??rehrauer: I'm not sure exactly what this is, but it appears | |
1241 | that on some HPUX 10.x versions, there's two unwind regions to | |
1242 | cover the body of "shl_unload", the second being 4 bytes past | |
1243 | the end of the first. This is a large hack to handle that | |
1244 | case, but since I don't seem to have any legitimate way to | |
1245 | look for this thing via the symbol table... | |
1246 | */ | |
1247 | if (dld_cache.unload.unwind != NULL) | |
1248 | { | |
1249 | u = find_unwind_entry (dld_cache.unload.unwind->region_end + 4); | |
1250 | if (u != NULL) | |
1251 | { | |
1252 | dld_cache.unload2.address = u->region_start; | |
1253 | dld_cache.unload2.unwind = u; | |
1254 | } | |
1255 | } | |
1256 | } | |
1257 | ||
1258 | dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_unload", | |
1259 | NULL, | |
1260 | objfile); | |
1261 | if (dld_msymbol != NULL) | |
1262 | { | |
1263 | if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline) | |
1264 | { | |
1265 | u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol)); | |
1266 | if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT)) | |
1267 | { | |
1268 | dld_cache.unload_stub.address = SYMBOL_VALUE (dld_msymbol); | |
1269 | dld_cache.unload_stub.unwind = u; | |
1270 | } | |
1271 | } | |
1272 | } | |
1273 | ||
1274 | /* Did we find everything we were looking for? If so, stop. */ | |
1275 | if ((dld_cache.load.address != NULL) && (dld_cache.load_stub.address != NULL) | |
1276 | && (dld_cache.unload.address != NULL) && (dld_cache.unload_stub.address != NULL)) | |
1277 | { | |
1278 | dld_cache.is_valid = 1; | |
1279 | break; | |
1280 | } | |
1281 | } | |
c906108c SS |
1282 | |
1283 | dld_cache.hook.unwind = find_unwind_entry (dld_cache.hook.address); | |
1284 | dld_cache.hook_stub.unwind = find_unwind_entry (dld_cache.hook_stub.address); | |
1285 | ||
1286 | /* We're prepared not to find some of these symbols, which is why | |
1287 | this function is a "desire" operation, and not a "require". | |
c5aa993b | 1288 | */ |
c906108c SS |
1289 | } |
1290 | ||
1291 | int | |
fba45db2 | 1292 | som_solib_in_dynamic_linker (int pid, CORE_ADDR pc) |
c906108c | 1293 | { |
c5aa993b | 1294 | struct unwind_table_entry *u_pc; |
c906108c SS |
1295 | |
1296 | /* Are we in the dld itself? | |
1297 | ||
1298 | ??rehrauer: Large hack -- We'll assume that any address in a | |
1299 | shared text region is the dld's text. This would obviously | |
1300 | fall down if the user attached to a process, whose shlibs | |
1301 | weren't mapped to a (writeable) private region. However, in | |
1302 | that case the debugger probably isn't able to set the fundamental | |
1303 | breakpoint in the dld callback anyways, so this hack should be | |
1304 | safe. | |
c5aa993b | 1305 | */ |
c906108c SS |
1306 | if ((pc & (CORE_ADDR) 0xc0000000) == (CORE_ADDR) 0xc0000000) |
1307 | return 1; | |
1308 | ||
1309 | /* Cache the address of some symbols that are part of the dynamic | |
1310 | linker, if not already known. | |
c5aa993b | 1311 | */ |
c906108c SS |
1312 | som_solib_desire_dynamic_linker_symbols (); |
1313 | ||
1314 | /* Are we in the dld callback? Or its export stub? */ | |
1315 | u_pc = find_unwind_entry (pc); | |
1316 | if (u_pc == NULL) | |
1317 | return 0; | |
1318 | ||
1319 | if ((u_pc == dld_cache.hook.unwind) || (u_pc == dld_cache.hook_stub.unwind)) | |
1320 | return 1; | |
1321 | ||
1322 | /* Or the interface of the dld (i.e., "shl_load" or friends)? */ | |
1323 | if ((u_pc == dld_cache.load.unwind) | |
1324 | || (u_pc == dld_cache.unload.unwind) | |
1325 | || (u_pc == dld_cache.unload2.unwind) | |
1326 | || (u_pc == dld_cache.load_stub.unwind) | |
1327 | || (u_pc == dld_cache.unload_stub.unwind)) | |
1328 | return 1; | |
1329 | ||
1330 | /* Apparently this address isn't part of the dld's text. */ | |
1331 | return 0; | |
1332 | } | |
1333 | ||
1334 | ||
1335 | /* Return the GOT value for the shared library in which ADDR belongs. If | |
1336 | ADDR isn't in any known shared library, return zero. */ | |
1337 | ||
1338 | CORE_ADDR | |
fba45db2 | 1339 | som_solib_get_got_by_pc (CORE_ADDR addr) |
c906108c SS |
1340 | { |
1341 | struct so_list *so_list = so_list_head; | |
1342 | CORE_ADDR got_value = 0; | |
1343 | ||
1344 | while (so_list) | |
1345 | { | |
1346 | if (so_list->som_solib.text_addr <= addr | |
1347 | && so_list->som_solib.text_end > addr) | |
1348 | { | |
1349 | got_value = so_list->som_solib.got_value; | |
1350 | break; | |
1351 | } | |
1352 | so_list = so_list->next; | |
1353 | } | |
1354 | return got_value; | |
1355 | } | |
1356 | ||
1357 | /* elz: | |
1358 | Return the address of the handle of the shared library | |
1359 | in which ADDR belongs. If | |
1360 | ADDR isn't in any known shared library, return zero. */ | |
c5aa993b | 1361 | /* this function is used in hppa_fix_call_dummy in hppa-tdep.c */ |
c906108c SS |
1362 | |
1363 | CORE_ADDR | |
fba45db2 | 1364 | som_solib_get_solib_by_pc (CORE_ADDR addr) |
c906108c SS |
1365 | { |
1366 | struct so_list *so_list = so_list_head; | |
1367 | ||
1368 | while (so_list) | |
1369 | { | |
1370 | if (so_list->som_solib.text_addr <= addr | |
1371 | && so_list->som_solib.text_end > addr) | |
c5aa993b | 1372 | { |
c906108c | 1373 | break; |
c5aa993b | 1374 | } |
c906108c SS |
1375 | so_list = so_list->next; |
1376 | } | |
1377 | if (so_list) | |
c5aa993b | 1378 | return so_list->solib_addr; |
c906108c | 1379 | else |
c5aa993b | 1380 | return 0; |
c906108c SS |
1381 | } |
1382 | ||
1383 | ||
1384 | int | |
fba45db2 KB |
1385 | som_solib_section_offsets (struct objfile *objfile, |
1386 | struct section_offsets *offsets) | |
c906108c SS |
1387 | { |
1388 | struct so_list *so_list = so_list_head; | |
1389 | ||
1390 | while (so_list) | |
1391 | { | |
1392 | /* Oh what a pain! We need the offsets before so_list->objfile | |
c5aa993b | 1393 | is valid. The BFDs will never match. Make a best guess. */ |
c906108c SS |
1394 | if (strstr (objfile->name, so_list->som_solib.name)) |
1395 | { | |
1396 | asection *private_section; | |
1397 | ||
1398 | /* The text offset is easy. */ | |
f0a58b0b | 1399 | offsets->offsets[SECT_OFF_TEXT (objfile)] |
c906108c SS |
1400 | = (so_list->som_solib.text_addr |
1401 | - so_list->som_solib.text_link_addr); | |
f0a58b0b | 1402 | offsets->offsets[SECT_OFF_RODATA (objfile)] |
b8fbeb18 | 1403 | = ANOFFSET (offsets, SECT_OFF_TEXT (objfile)); |
c906108c SS |
1404 | |
1405 | /* We should look at presumed_dp in the SOM header, but | |
1406 | that's not easily available. This should be OK though. */ | |
1407 | private_section = bfd_get_section_by_name (objfile->obfd, | |
1408 | "$PRIVATE$"); | |
1409 | if (!private_section) | |
1410 | { | |
1411 | warning ("Unable to find $PRIVATE$ in shared library!"); | |
f0a58b0b EZ |
1412 | offsets->offsets[SECT_OFF_DATA (objfile)] = 0; |
1413 | offsets->offsets[SECT_OFF_BSS (objfile)] = 0; | |
c906108c SS |
1414 | return 1; |
1415 | } | |
f0a58b0b | 1416 | offsets->offsets[SECT_OFF_DATA (objfile)] |
c906108c | 1417 | = (so_list->som_solib.data_start - private_section->vma); |
f0a58b0b | 1418 | offsets->offsets[SECT_OFF_BSS (objfile)] |
b8fbeb18 | 1419 | = ANOFFSET (offsets, SECT_OFF_DATA (objfile)); |
c906108c SS |
1420 | return 1; |
1421 | } | |
1422 | so_list = so_list->next; | |
1423 | } | |
1424 | return 0; | |
1425 | } | |
1426 | ||
1427 | /* Dump information about all the currently loaded shared libraries. */ | |
1428 | ||
1429 | static void | |
fba45db2 | 1430 | som_sharedlibrary_info_command (char *ignore, int from_tty) |
c906108c SS |
1431 | { |
1432 | struct so_list *so_list = so_list_head; | |
1433 | ||
1434 | if (exec_bfd == NULL) | |
1435 | { | |
4ce44c66 | 1436 | printf_unfiltered ("No executable file.\n"); |
c906108c SS |
1437 | return; |
1438 | } | |
1439 | ||
1440 | if (so_list == NULL) | |
1441 | { | |
1442 | printf_unfiltered ("No shared libraries loaded at this time.\n"); | |
1443 | return; | |
1444 | } | |
1445 | ||
1446 | printf_unfiltered ("Shared Object Libraries\n"); | |
1447 | printf_unfiltered (" %-12s%-12s%-12s%-12s%-12s%-12s\n", | |
c5aa993b | 1448 | " flags", " tstart", " tend", " dstart", " dend", " dlt"); |
c906108c SS |
1449 | while (so_list) |
1450 | { | |
1451 | unsigned int flags; | |
1452 | ||
1453 | flags = so_list->som_solib.struct_version << 24; | |
1454 | flags |= so_list->som_solib.bind_mode << 16; | |
1455 | flags |= so_list->som_solib.library_version; | |
1456 | printf_unfiltered ("%s", so_list->som_solib.name); | |
1457 | if (so_list->objfile == NULL) | |
c5aa993b | 1458 | printf_unfiltered (" (symbols not loaded)"); |
c906108c SS |
1459 | printf_unfiltered ("\n"); |
1460 | printf_unfiltered (" %-12s", local_hex_string_custom (flags, "08l")); | |
1461 | printf_unfiltered ("%-12s", | |
c5aa993b | 1462 | local_hex_string_custom (so_list->som_solib.text_addr, "08l")); |
c906108c SS |
1463 | printf_unfiltered ("%-12s", |
1464 | local_hex_string_custom (so_list->som_solib.text_end, "08l")); | |
1465 | printf_unfiltered ("%-12s", | |
c5aa993b | 1466 | local_hex_string_custom (so_list->som_solib.data_start, "08l")); |
c906108c SS |
1467 | printf_unfiltered ("%-12s", |
1468 | local_hex_string_custom (so_list->som_solib.data_end, "08l")); | |
1469 | printf_unfiltered ("%-12s\n", | |
c5aa993b | 1470 | local_hex_string_custom (so_list->som_solib.got_value, "08l")); |
c906108c SS |
1471 | so_list = so_list->next; |
1472 | } | |
1473 | } | |
1474 | ||
1475 | static void | |
fba45db2 | 1476 | som_solib_sharedlibrary_command (char *args, int from_tty) |
c906108c SS |
1477 | { |
1478 | dont_repeat (); | |
1479 | som_solib_add (args, from_tty, (struct target_ops *) 0); | |
1480 | } | |
1481 | ||
1482 | ||
1483 | ||
1484 | char * | |
fba45db2 | 1485 | som_solib_address (CORE_ADDR addr) |
c906108c | 1486 | { |
c5aa993b | 1487 | struct so_list *so = so_list_head; |
c906108c SS |
1488 | |
1489 | while (so) | |
1490 | { | |
1491 | /* Is this address within this shlib's text range? If so, | |
1492 | return the shlib's name. | |
c5aa993b | 1493 | */ |
c906108c | 1494 | if ((addr >= so->som_solib.text_addr) && (addr <= so->som_solib.text_end)) |
c5aa993b | 1495 | return so->som_solib.name; |
c906108c SS |
1496 | |
1497 | /* Nope, keep looking... */ | |
1498 | so = so->next; | |
1499 | } | |
1500 | ||
1501 | /* No, we couldn't prove that the address is within a shlib. */ | |
1502 | return NULL; | |
1503 | } | |
1504 | ||
1505 | ||
1506 | void | |
fba45db2 | 1507 | som_solib_restart (void) |
c906108c | 1508 | { |
c5aa993b | 1509 | struct so_list *sl = so_list_head; |
c906108c SS |
1510 | |
1511 | /* Before the shlib info vanishes, use it to disable any breakpoints | |
1512 | that may still be active in those shlibs. | |
c5aa993b | 1513 | */ |
c906108c SS |
1514 | disable_breakpoints_in_shlibs (0); |
1515 | ||
1516 | /* Discard all the shlib descriptors. | |
c5aa993b | 1517 | */ |
c906108c SS |
1518 | while (sl) |
1519 | { | |
c5aa993b | 1520 | struct so_list *next_sl = sl->next; |
b8c9b27d | 1521 | xfree (sl); |
c906108c SS |
1522 | sl = next_sl; |
1523 | } | |
1524 | so_list_head = NULL; | |
1525 | ||
1526 | som_solib_total_st_size = (LONGEST) 0; | |
1527 | som_solib_st_size_threshold_exceeded = 0; | |
1528 | ||
1529 | dld_cache.is_valid = 0; | |
1530 | ||
1531 | dld_cache.hook.address = 0; | |
1532 | dld_cache.hook.unwind = NULL; | |
1533 | ||
1534 | dld_cache.hook_stub.address = 0; | |
1535 | dld_cache.hook_stub.unwind = NULL; | |
1536 | ||
1537 | dld_cache.load.address = 0; | |
1538 | dld_cache.load.unwind = NULL; | |
1539 | ||
1540 | dld_cache.load_stub.address = 0; | |
1541 | dld_cache.load_stub.unwind = NULL; | |
1542 | ||
1543 | dld_cache.unload.address = 0; | |
1544 | dld_cache.unload.unwind = NULL; | |
1545 | ||
1546 | dld_cache.unload2.address = 0; | |
1547 | dld_cache.unload2.unwind = NULL; | |
1548 | ||
1549 | dld_cache.unload_stub.address = 0; | |
1550 | dld_cache.unload_stub.unwind = NULL; | |
1551 | } | |
1552 | ||
1553 | ||
1554 | ||
1555 | void | |
fba45db2 | 1556 | _initialize_som_solib (void) |
c906108c SS |
1557 | { |
1558 | add_com ("sharedlibrary", class_files, som_solib_sharedlibrary_command, | |
c5aa993b | 1559 | "Load shared object library symbols for files matching REGEXP."); |
c906108c SS |
1560 | add_info ("sharedlibrary", som_sharedlibrary_info_command, |
1561 | "Status of loaded shared object libraries."); | |
1562 | add_show_from_set | |
1563 | (add_set_cmd ("auto-solib-add", class_support, var_zinteger, | |
1564 | (char *) &auto_solib_add, | |
1565 | "Set autoloading size threshold (in megabytes) of shared library symbols.\n\ | |
1566 | If nonzero, symbols from all shared object libraries will be loaded\n\ | |
1567 | automatically when the inferior begins execution or when the dynamic linker\n\ | |
1568 | informs gdb that a new library has been loaded, until the symbol table\n\ | |
1569 | of the program and libraries exceeds this threshold.\n\ | |
1570 | Otherwise, symbols must be loaded manually, using `sharedlibrary'.", | |
1571 | &setlist), | |
1572 | &showlist); | |
1573 | ||
1574 | /* ??rehrauer: On HP-UX, the kernel parameter MAXDSIZ limits how much | |
1575 | data space a process can use. We ought to be reading MAXDSIZ and | |
1576 | setting auto_solib_add to some large fraction of that value. If | |
1577 | not that, we maybe ought to be setting it smaller than the default | |
1578 | for MAXDSIZ (that being 64Mb, I believe). However, [1] this threshold | |
1579 | is only crudely approximated rather than actually measured, and [2] | |
1580 | 50 Mbytes is too small for debugging gdb itself. Thus, the arbitrary | |
1581 | 100 figure. | |
c5aa993b JM |
1582 | */ |
1583 | auto_solib_add = 100; /* Megabytes */ | |
c906108c SS |
1584 | |
1585 | som_solib_restart (); | |
1586 | } | |
1587 | ||
1588 | /* Get some HPUX-specific data from a shared lib. | |
1589 | */ | |
1590 | CORE_ADDR | |
fba45db2 | 1591 | so_lib_thread_start_addr (struct so_list *so) |
c906108c | 1592 | { |
c5aa993b | 1593 | return so->som_solib.tsd_start_addr; |
c906108c | 1594 | } |