oops .. forgot to offset from objects bounds
[AROS.git] / rom / debug / unregistermodule.c
blob0902b6666d937dd79f9789f0b898038d7708980e
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 */
8 #include <aros/debug.h>
9 #include <aros/kernel.h>
10 #include <aros/libcall.h>
11 #include <exec/lists.h>
12 #include <proto/exec.h>
14 #include <string.h>
16 #include "debug_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/debug.h>
23 AROS_LH1(void, UnregisterModule,
25 /* SYNOPSIS */
26 AROS_LHA(BPTR, segList, A0),
28 /* LOCATION */
29 struct Library *, DebugBase, 6, Debug)
31 /* FUNCTION
32 Remove previously registered module from the debug information database
34 INPUTS
35 segList - DOS segment list for the module to remove
37 RESULT
38 None
40 NOTES
41 The function correctly supports partial removal of the module
42 (when an existing seglist is broken and only a part of the module
43 is unloaded).
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct segment *seg;
59 D(bug("[Debug] UnregisterModule(0x%p)\n", segList));
60 ObtainSemaphore(&DBGBASE(DebugBase)->db_ModSem);
62 while (segList)
64 ForeachNode(&DBGBASE(DebugBase)->db_Modules, seg)
66 if (seg->s_seg == segList)
68 module_t *mod = seg->s_mod;
70 D(bug("[Debug] Removing segment 0x%p\n", segList));
71 Remove((struct Node *)seg);
73 /* If module's segment count reached 0, remove the whole
74 module information */
75 if (--mod->m_segcnt == 0)
77 D(bug("[Debug] Removing module %s\n", mod->m_name));
79 /* Free associated symbols */
80 if (mod->m_symbols) {
81 D(bug("[Debug] Removing symbol table 0x%p\n", mod->m_symbols));
82 FreeVec(mod->m_symbols);
85 /* Free associated string tables */
86 if (mod->m_str) {
87 D(bug("[Debug] Removing symbol name table 0x%p\n", mod->m_str));
88 FreeVec(mod->m_str);
90 if (mod->m_shstr) {
91 D(bug("[Debug] Removing section name table 0x%p\n", mod->m_str));
92 FreeVec(mod->m_shstr);
95 /* Free module descriptor at last */
96 FreeVec(mod);
99 FreeMem(seg, sizeof(struct segment));
101 break;
104 /* Advance to next DOS segment */
105 segList = *(BPTR *)BADDR(segList);
108 ReleaseSemaphore(&DBGBASE(DebugBase)->db_ModSem);
110 AROS_LIBFUNC_EXIT