Update with test case for Poseidon reset scheme fix. Return UHIOERR_HOSTERROR in...
[AROS.git] / rom / debug / enumeratesymbolsa.c
blob7e00e59fa60fe02e17dd34a8a66ff5fc5cd1786c
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <libraries/debug.h>
10 #include <proto/kernel.h>
11 #include <proto/exec.h>
12 #include <aros/debug.h>
14 #include "debug_intern.h"
16 static void EnumerateModules(struct Hook * handler, struct Library * DebugBase);
18 /*****************************************************************************
20 NAME */
21 #include <proto/debug.h>
23 AROS_LH2(void, EnumerateSymbolsA,
25 /* SYNOPSIS */
26 AROS_LHA(struct Hook *, handler, A0),
27 AROS_LHA(struct TagItem *, tags, A1),
29 /* LOCATION */
30 struct Library *, DebugBase, 8, Debug)
32 /* FUNCTION
33 Function will call the handler hook for all symbols from kickstart and
34 loaded modules that match the given search criteria.
36 The message that is passed to hook contains a pointer to struct SymbolInfo.
38 INPUTS
40 RESULT
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 ******************************************************************************/
54 AROS_LIBFUNC_INIT
56 BOOL super;
58 /* We can be called in supervisor mode. No semaphores in the case! */
59 super = KrnIsSuper();
60 if (!super)
61 ObtainSemaphoreShared(&DBGBASE(DebugBase)->db_ModSem);
63 EnumerateModules(handler, DebugBase);
65 if (!super)
66 ReleaseSemaphore(&DBGBASE(DebugBase)->db_ModSem);
68 AROS_LIBFUNC_EXIT
71 static inline void callhook(struct Hook * handler, CONST_STRPTR modname, CONST_STRPTR symname,
72 APTR start, APTR end)
74 struct SymbolInfo sinfo = {0};
76 sinfo.si_Size = sizeof(struct SymbolInfo);
77 sinfo.si_ModuleName = modname;
78 sinfo.si_SymbolName = symname;
79 sinfo.si_SymbolStart = start;
80 sinfo.si_SymbolEnd = end;
82 CALLHOOKPKT(handler, NULL, &sinfo);
85 static void EnumerateModules(struct Hook * handler, struct Library * DebugBase)
87 module_t *mod;
89 ForeachNode(&DBGBASE(DebugBase)->db_Modules, mod)
91 dbg_sym_t *sym = mod->m_symbols;
92 ULONG i;
94 D(bug("[Debug] Checking module %s\n", mod->m_name));
96 for (i = 0; i < mod->m_symcnt; i++)
98 APTR highest = sym[i].s_highest;
100 /* Symbols with zero length have zero in s_highest */
101 if (!highest)
102 highest = sym[i].s_lowest;
104 callhook(handler, mod->m_name, sym[i].s_name, sym[i].s_lowest, sym[i].s_highest);