1 /*****************************************************************************/
5 /* Debug file creation for the ld65 linker */
9 /* (C) 2003-2011, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
53 /*****************************************************************************/
55 /*****************************************************************************/
59 static void AssignIds (void)
60 /* Assign the base ids for debug info output. Within each module, many of the
61 * items are addressed by ids which are actually the indices of the items in
62 * the collections. To make them unique, we must assign a unique base to each
66 /* Walk over all modules */
68 unsigned SymBaseId = 0;
69 unsigned ScopeBaseId = 0;
70 for (I = 0; I < CollCount (&ObjDataList); ++I) {
73 ObjData* O = CollAt (&ObjDataList, I);
75 /* Assign the module id */
79 O->SymBaseId = SymBaseId;
80 O->ScopeBaseId = ScopeBaseId;
82 /* Bump the base ids */
83 SymBaseId += CollCount (&O->DbgSyms);
84 ScopeBaseId += CollCount (&O->Scopes);
87 /* Assign the ids to the file infos */
93 void CreateDbgFile (void)
94 /* Create a debug info file */
96 /* Open the debug info file */
97 FILE* F = fopen (DbgFileName, "w");
99 Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
102 /* Output version information */
103 fprintf (F, "version\tmajor=1,minor=2\n");
105 /* Assign the ids to the items */
108 /* Output libraries */
109 PrintDbgLibraries (F);
114 /* Output the segment info */
115 PrintDbgSegments (F);
118 PrintDbgFileInfo (F);
120 /* Output line info */
121 PrintDbgLineInfo (F);
130 if (fclose (F) != 0) {
131 Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));