MUIM_List_InsertSingle: if there's no active entry,
[AROS.git] / rom / debug / unregistermodule.c
blobdac0cf60606cb78a9cca5c74f8ae882307e9e06d
1 #include <aros/debug.h>
2 #include <aros/kernel.h>
3 #include <aros/libcall.h>
4 #include <exec/lists.h>
5 #include <proto/exec.h>
7 #include <string.h>
9 #include "debug_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/debug.h>
16 AROS_LH1(void, UnregisterModule,
18 /* SYNOPSIS */
19 AROS_LHA(BPTR, segList, A0),
21 /* LOCATION */
22 struct Library *, DebugBase, 6, Debug)
24 /* FUNCTION
25 Remove previously registered module from the debug information database
27 INPUTS
28 segList - DOS segment list for the module to remove
30 RESULT
31 None
33 NOTES
34 The function correctly supports partial removal of the module
35 (when an existing seglist is broken and only a part of the module
36 is unloaded).
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 ******************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct segment *seg;
52 D(bug("[Debug] UnregisterModule(0x%p)\n", segList));
53 ObtainSemaphore(&DBGBASE(DebugBase)->db_ModSem);
55 while (segList)
57 ForeachNode(&DBGBASE(DebugBase)->db_Modules, seg)
59 if (seg->s_seg == segList)
61 module_t *mod = seg->s_mod;
63 D(bug("[Debug] Removing segment 0x%p\n", segList));
64 Remove((struct Node *)seg);
66 /* If module's segment count reached 0, remove the whole
67 module information */
68 if (--mod->m_segcnt == 0)
70 D(bug("[Debug] Removing module %s\n", mod->m_name));
72 /* Free associated symbols */
73 if (mod->m_symbols) {
74 D(bug("[Debug] Removing symbol table 0x%p\n", mod->m_symbols));
75 FreeVec(mod->m_symbols);
78 /* Free associated string tables */
79 if (mod->m_str) {
80 D(bug("[Debug] Removing symbol name table 0x%p\n", mod->m_str));
81 FreeVec(mod->m_str);
83 if (mod->m_shstr) {
84 D(bug("[Debug] Removing section name table 0x%p\n", mod->m_str));
85 FreeVec(mod->m_shstr);
88 /* Free module descriptor at last */
89 FreeVec(mod);
92 FreeMem(seg, sizeof(struct segment));
94 break;
97 /* Advance to next DOS segment */
98 segList = *(BPTR *)BADDR(segList);
101 ReleaseSemaphore(&DBGBASE(DebugBase)->db_ModSem);
103 AROS_LIBFUNC_EXIT