1 /* Copyright (C) 2002-2015 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #define get_dll(inf) ((struct dll_info *)(inf))
23 /* An "unspecified" CORE_ADDR, for match_dll. */
24 #define UNSPECIFIED_CORE_ADDR (~(CORE_ADDR) 0)
26 struct inferior_list all_dlls
;
30 free_one_dll (struct inferior_list_entry
*inf
)
32 struct dll_info
*dll
= get_dll (inf
);
33 if (dll
->name
!= NULL
)
38 /* Find a DLL with the same name and/or base address. A NULL name in
39 the key is ignored; so is an all-ones base address. */
42 match_dll (struct inferior_list_entry
*inf
, void *arg
)
44 struct dll_info
*iter
= (void *) inf
;
45 struct dll_info
*key
= arg
;
47 if (key
->base_addr
!= UNSPECIFIED_CORE_ADDR
48 && iter
->base_addr
== key
->base_addr
)
50 else if (key
->name
!= NULL
52 && strcmp (key
->name
, iter
->name
) == 0)
58 /* Record a newly loaded DLL at BASE_ADDR. */
61 loaded_dll (const char *name
, CORE_ADDR base_addr
)
63 struct dll_info
*new_dll
= xmalloc (sizeof (*new_dll
));
64 memset (new_dll
, 0, sizeof (*new_dll
));
66 new_dll
->entry
.id
= minus_one_ptid
;
68 new_dll
->name
= xstrdup (name
);
69 new_dll
->base_addr
= base_addr
;
71 add_inferior_to_list (&all_dlls
, &new_dll
->entry
);
75 /* Record that the DLL with NAME and BASE_ADDR has been unloaded. */
78 unloaded_dll (const char *name
, CORE_ADDR base_addr
)
81 struct dll_info key_dll
;
83 /* Be careful not to put the key DLL in any list. */
84 key_dll
.name
= (char *) name
;
85 key_dll
.base_addr
= base_addr
;
87 dll
= (void *) find_inferior (&all_dlls
, match_dll
, &key_dll
);
90 /* For some inferiors we might get unloaded_dll events without having
91 a corresponding loaded_dll. In that case, the dll cannot be found
92 in ALL_DLL, and there is nothing further for us to do.
94 This has been observed when running 32bit executables on Windows64
95 (i.e. through WOW64, the interface between the 32bits and 64bits
96 worlds). In that case, the inferior always does some strange
97 unloading of unnamed dll. */
101 /* DLL has been found so remove the entry and free associated
103 remove_inferior (&all_dlls
, &dll
->entry
);
104 free_one_dll (&dll
->entry
);
112 for_each_inferior (&all_dlls
, free_one_dll
);
113 clear_inferior_list (&all_dlls
);
This page took 0.037651 seconds and 4 git commands to generate.