Some code cleanup.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5282 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
eee6068029
commit
c2bf1b9ba4
3 changed files with 40 additions and 47 deletions
|
@ -213,7 +213,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O, unsigned Id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ClearDbgSymTable (void)
|
static void ClearDbgSymTable (void)
|
||||||
/* Clear the debug symbol table */
|
/* Clear the debug symbol table */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
@ -349,39 +349,49 @@ void PrintDbgSyms (FILE* F)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintDbgSymLabels (ObjData* O, FILE* F)
|
void PrintDbgSymLabels (FILE* F)
|
||||||
/* Print the debug symbols in a VICE label file */
|
/* Print the debug symbols in a VICE label file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I, J;
|
||||||
|
|
||||||
/* Walk through all debug symbols in this module */
|
/* Clear the symbol table */
|
||||||
for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
|
ClearDbgSymTable ();
|
||||||
|
|
||||||
long Val;
|
/* Create labels from all modules we have linked into the output file */
|
||||||
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
/* Get the next debug symbol */
|
/* Get the object file */
|
||||||
DbgSym* D = CollAt (&O->DbgSyms, I);
|
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||||
|
|
||||||
/* Emit this symbol only if it is a label (ignore equates and imports) */
|
/* Walk through all debug symbols in this module */
|
||||||
if (SYM_IS_EQUATE (D->Type) || SYM_IS_IMPORT (D->Type)) {
|
for (J = 0; J < CollCount (&O->DbgSyms); ++J) {
|
||||||
continue;
|
|
||||||
|
long Val;
|
||||||
|
|
||||||
|
/* Get the next debug symbol */
|
||||||
|
DbgSym* D = CollAt (&O->DbgSyms, J);
|
||||||
|
|
||||||
|
/* Emit this symbol only if it is a label (ignore equates and imports) */
|
||||||
|
if (SYM_IS_EQUATE (D->Type) || SYM_IS_IMPORT (D->Type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the symbol value */
|
||||||
|
Val = GetDbgSymVal (D);
|
||||||
|
|
||||||
|
/* Lookup this symbol in the table. If it is found in the table, it was
|
||||||
|
* already written to the file, so don't emit it twice. If it is not in
|
||||||
|
* the table, insert and output it.
|
||||||
|
*/
|
||||||
|
if (GetDbgSym (D, Val) == 0) {
|
||||||
|
|
||||||
|
/* Emit the VICE label line */
|
||||||
|
fprintf (F, "al %06lX .%s\n", Val, GetString (D->Name));
|
||||||
|
|
||||||
|
/* Insert the symbol into the table */
|
||||||
|
InsertDbgSym (D, Val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the symbol value */
|
|
||||||
Val = GetDbgSymVal (D);
|
|
||||||
|
|
||||||
/* Lookup this symbol in the table. If it is found in the table, it was
|
|
||||||
* already written to the file, so don't emit it twice. If it is not in
|
|
||||||
* the table, insert and output it.
|
|
||||||
*/
|
|
||||||
if (GetDbgSym (D, Val) == 0) {
|
|
||||||
|
|
||||||
/* Emit the VICE label line */
|
|
||||||
fprintf (F, "al %06lX .%s\n", Val, GetString (D->Name));
|
|
||||||
|
|
||||||
/* Insert the symbol into the table */
|
|
||||||
InsertDbgSym (D, Val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,15 +72,10 @@ typedef struct DbgSym DbgSym;
|
||||||
DbgSym* ReadDbgSym (FILE* F, ObjData* Obj, unsigned Id);
|
DbgSym* ReadDbgSym (FILE* F, ObjData* Obj, unsigned Id);
|
||||||
/* Read a debug symbol from a file, insert and return it */
|
/* Read a debug symbol from a file, insert and return it */
|
||||||
|
|
||||||
void ClearDbgSymTable (void);
|
|
||||||
/* Clear the debug symbol table. Must be called before outputting debug syms
|
|
||||||
* or debug labels the first time.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void PrintDbgSyms (FILE* F);
|
void PrintDbgSyms (FILE* F);
|
||||||
/* Print the debug symbols in a debug file */
|
/* Print the debug symbols in a debug file */
|
||||||
|
|
||||||
void PrintDbgSymLabels (ObjData* O, FILE* F);
|
void PrintDbgSymLabels (FILE* F);
|
||||||
/* Print the debug symbols in a VICE label file */
|
/* Print the debug symbols in a VICE label file */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,29 +132,17 @@ void CreateMapFile (int ShortMap)
|
||||||
void CreateLabelFile (void)
|
void CreateLabelFile (void)
|
||||||
/* Create a label file */
|
/* Create a label file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
|
||||||
|
|
||||||
/* Open the label file */
|
/* Open the label file */
|
||||||
FILE* F = fopen (LabelFileName, "w");
|
FILE* F = fopen (LabelFileName, "w");
|
||||||
if (F == 0) {
|
if (F == 0) {
|
||||||
Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
|
Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the debug sym table (used to detect duplicates) */
|
|
||||||
ClearDbgSymTable ();
|
|
||||||
|
|
||||||
/* Print the labels for the export symbols */
|
/* Print the labels for the export symbols */
|
||||||
PrintExportLabels (F);
|
PrintExportLabels (F);
|
||||||
|
|
||||||
/* Create labels from all modules we have linked into the output file */
|
/* Output the labels */
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
PrintDbgSymLabels (F);
|
||||||
|
|
||||||
/* Get the object file */
|
|
||||||
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
|
||||||
|
|
||||||
/* Output the labels */
|
|
||||||
PrintDbgSymLabels (O, F);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
if (fclose (F) != 0) {
|
if (fclose (F) != 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue