use m4_normalize on the output strings to remove trailing spaces/tabs and consolidate...
[AROS.git] / workbench / c / SymbolDump.c
blob01ce393f1d278dd343a6d1cc1024db69ac65c1e8
1 /*
2 Copyright © 2013-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /******************************************************************************
12 NAME
14 SymbolDump
16 SYNOPSIS
18 (N/A)
20 LOCATION
24 FUNCTION
26 Dumps debug symbols to the file "SYS:symbols.out" to be used with
27 Callgrind. See "Debugging manual" at www.aros.org.
29 INPUTS
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 HISTORY
45 ******************************************************************************/
47 #include <utility/hooks.h>
48 #include <libraries/debug.h>
49 #include <proto/exec.h>
50 #include <proto/dos.h>
51 #include <proto/debug.h>
53 const TEXT version[] = "$VER: SymbolDump 1.1 (18.5.2014)\n";
55 struct Library * DebugBase = NULL;
57 AROS_UFH3(static void, symbolhandler,
58 AROS_UFHA(struct Hook *, hook, A0),
59 AROS_UFHA(APTR, object, A2),
60 AROS_UFHA(struct SymbolInfo *, message, A1))
62 AROS_USERFUNC_INIT
64 FPrintf((BPTR)hook->h_Data, "S|%s|%s|0x%p|0x%p\n", message->si_ModuleName, message->si_SymbolName,
65 message->si_SymbolStart, message->si_SymbolEnd);
67 AROS_USERFUNC_EXIT
70 static void OpenLibraries()
72 DebugBase = OpenLibrary("debug.library", 0L);
75 static void CloseLibraries()
77 CloseLibrary(DebugBase);
78 DebugBase = NULL;
81 int main(void)
83 BPTR output = BNULL;
85 OpenLibraries();
87 output = Open("SYS:symbols.out", MODE_NEWFILE);
89 if (output != BNULL)
91 struct Hook handler;
92 handler.h_Entry = (HOOKFUNC)symbolhandler;
93 handler.h_Data = (APTR)output;
95 EnumerateSymbolsA(&handler, NULL);
97 Close(output);
100 CloseLibraries();
102 return 0;