More debug infos
git-svn-id: svn://svn.cc65.org/cc65/trunk@2320 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -139,20 +139,17 @@ static void InsertDbgSym (DbgSym* D, long Val)
|
|||||||
DbgSym* ReadDbgSym (FILE* F, ObjData* O)
|
DbgSym* ReadDbgSym (FILE* F, ObjData* O)
|
||||||
/* Read a debug symbol from a file, insert and return it */
|
/* Read a debug symbol from a file, insert and return it */
|
||||||
{
|
{
|
||||||
unsigned char Type;
|
|
||||||
DbgSym* D;
|
|
||||||
|
|
||||||
/* Read the type */
|
/* Read the type */
|
||||||
Type = Read8 (F);
|
unsigned char Type = Read8 (F);
|
||||||
|
|
||||||
/* Create a new debug symbol */
|
/* Create a new debug symbol */
|
||||||
D = NewDbgSym (Type, O);
|
DbgSym* D = NewDbgSym (Type, O);
|
||||||
|
|
||||||
/* Read and assign the name */
|
/* Read and assign the name */
|
||||||
D->Name = MakeGlobalStringId (O, ReadVar (F));
|
D->Name = MakeGlobalStringId (O, ReadVar (F));
|
||||||
|
|
||||||
/* Read the value */
|
/* Read the value */
|
||||||
if (IS_EXP_EXPR (Type)) {
|
if (IS_EXP_EXPR (D->Type)) {
|
||||||
D->Expr = ReadExpr (F, O);
|
D->Expr = ReadExpr (F, O);
|
||||||
} else {
|
} else {
|
||||||
D->Expr = LiteralExpr (Read32 (F), O);
|
D->Expr = LiteralExpr (Read32 (F), O);
|
||||||
@@ -167,6 +164,23 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void ClearDbgSymTable (void)
|
||||||
|
/* Clear the debug symbol table */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
for (I = 0; I < sizeof (DbgSymPool) / sizeof (DbgSymPool[0]); ++I) {
|
||||||
|
DbgSym* Sym = DbgSymPool[I];
|
||||||
|
DbgSymPool[I] = 0;
|
||||||
|
while (Sym) {
|
||||||
|
DbgSym* NextSym = Sym->Next;
|
||||||
|
Sym->Next = 0;
|
||||||
|
Sym = NextSym;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
long GetDbgSymVal (DbgSym* D)
|
long GetDbgSymVal (DbgSym* D)
|
||||||
/* Get the value of this symbol */
|
/* Get the value of this symbol */
|
||||||
{
|
{
|
||||||
@@ -176,19 +190,69 @@ long GetDbgSymVal (DbgSym* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintDbgSymLabels (ObjData* O, FILE* F)
|
void PrintDbgSyms (ObjData* O, FILE* F)
|
||||||
/* Print the debug symbols in a VICE label file */
|
/* Print the debug symbols in a debug file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
|
/* Clear the debug sym table */
|
||||||
|
ClearDbgSymTable ();
|
||||||
|
|
||||||
/* Walk through all debug symbols in this module */
|
/* Walk through all debug symbols in this module */
|
||||||
for (I = 0; I < O->DbgSymCount; ++I) {
|
for (I = 0; I < O->DbgSymCount; ++I) {
|
||||||
|
|
||||||
|
long Val;
|
||||||
|
|
||||||
/* Get the next debug symbol */
|
/* Get the next debug symbol */
|
||||||
DbgSym* D = O->DbgSyms [I];
|
DbgSym* D = O->DbgSyms [I];
|
||||||
|
|
||||||
/* Get the symbol value */
|
/* Get the symbol value */
|
||||||
long Val = GetDbgSymVal (D);
|
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 debug file line */
|
||||||
|
fprintf (F,
|
||||||
|
"sym\t\"%s\", 0x%02X, 0x%08lX\n",
|
||||||
|
GetString (D->Name),
|
||||||
|
D->Type,
|
||||||
|
Val);
|
||||||
|
|
||||||
|
/* Insert the symbol into the table */
|
||||||
|
InsertDbgSym (D, Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PrintDbgSymLabels (ObjData* O, FILE* F)
|
||||||
|
/* Print the debug symbols in a VICE label file */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Clear the debug sym table */
|
||||||
|
ClearDbgSymTable ();
|
||||||
|
|
||||||
|
/* Walk through all debug symbols in this module */
|
||||||
|
for (I = 0; I < O->DbgSymCount; ++I) {
|
||||||
|
|
||||||
|
long Val;
|
||||||
|
|
||||||
|
/* Get the next debug symbol */
|
||||||
|
DbgSym* D = O->DbgSyms [I];
|
||||||
|
|
||||||
|
/* Emit this symbol only if it is a label (ignore equates) */
|
||||||
|
if (IS_EXP_EQUATE (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
|
/* 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
|
* already written to the file, so don't emit it twice. If it is not in
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* Obj);
|
|||||||
long GetDbgSymVal (DbgSym* D);
|
long GetDbgSymVal (DbgSym* D);
|
||||||
/* Get the value of this symbol */
|
/* Get the value of this symbol */
|
||||||
|
|
||||||
|
void PrintDbgSyms (ObjData* O, FILE* F);
|
||||||
|
/* Print the debug symbols in a debug file */
|
||||||
|
|
||||||
void PrintDbgSymLabels (ObjData* O, FILE* F);
|
void PrintDbgSymLabels (ObjData* O, FILE* F);
|
||||||
/* Print the debug symbols in a VICE label file */
|
/* Print the debug symbols in a VICE label file */
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ static void Usage (void)
|
|||||||
"Long options:\n"
|
"Long options:\n"
|
||||||
" --cfg-path path\tSpecify a config file search path\n"
|
" --cfg-path path\tSpecify a config file search path\n"
|
||||||
" --config name\t\tUse linker config file\n"
|
" --config name\t\tUse linker config file\n"
|
||||||
" --dbgfile name\t\tGenerate debug information\n"
|
" --dbgfile name\tGenerate debug information\n"
|
||||||
" --dump-config name\tDump a builtin configuration\n"
|
" --dump-config name\tDump a builtin configuration\n"
|
||||||
" --help\t\tHelp (this text)\n"
|
" --help\t\tHelp (this text)\n"
|
||||||
" --lib file\t\tLink this library\n"
|
" --lib file\t\tLink this library\n"
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void CreateLabelFile (void)
|
|||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
if (fclose (F) != 0) {
|
if (fclose (F) != 0) {
|
||||||
Error ("Error closing map file `%s': %s", LabelFileName, strerror (errno));
|
Error ("Error closing label file `%s': %s", LabelFileName, strerror (errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ void CreateDbgFile (void)
|
|||||||
/* Open the debug info file */
|
/* Open the debug info file */
|
||||||
FILE* F = fopen (DbgFileName, "w");
|
FILE* F = fopen (DbgFileName, "w");
|
||||||
if (F == 0) {
|
if (F == 0) {
|
||||||
Error ("Cannot create label file `%s': %s", DbgFileName, strerror (errno));
|
Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print line infos from all modules we have linked into the output file */
|
/* Print line infos from all modules we have linked into the output file */
|
||||||
@@ -174,11 +174,12 @@ void CreateDbgFile (void)
|
|||||||
|
|
||||||
/* Output debug info */
|
/* Output debug info */
|
||||||
PrintDbgInfo (O, F);
|
PrintDbgInfo (O, F);
|
||||||
|
PrintDbgSyms (O, F);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
if (fclose (F) != 0) {
|
if (fclose (F) != 0) {
|
||||||
Error ("Error closing map file `%s': %s", DbgFileName, strerror (errno));
|
Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user