1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-27 19:55:09 +00:00

More debug infos

git-svn-id: svn://svn.cc65.org/cc65/trunk@2320 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-08-15 10:59:22 +00:00
parent 5422c6924a
commit f3e0d3fbb1
4 changed files with 83 additions and 15 deletions

View File

@ -35,7 +35,7 @@
#include <string.h>
/* common */
/* common */
#include "check.h"
#include "symdefs.h"
#include "xmalloc.h"
@ -60,7 +60,7 @@
/* We will collect all debug symbols in the following array and remove
* duplicates before outputing them.
*/
static DbgSym* DbgSymPool [256];
static DbgSym* DbgSymPool[256];
@ -139,20 +139,17 @@ static void InsertDbgSym (DbgSym* D, long Val)
DbgSym* ReadDbgSym (FILE* F, ObjData* O)
/* Read a debug symbol from a file, insert and return it */
{
unsigned char Type;
DbgSym* D;
/* Read the type */
Type = Read8 (F);
unsigned char Type = Read8 (F);
/* Create a new debug symbol */
D = NewDbgSym (Type, O);
DbgSym* D = NewDbgSym (Type, O);
/* Read and assign the name */
D->Name = MakeGlobalStringId (O, ReadVar (F));
/* Read the value */
if (IS_EXP_EXPR (Type)) {
if (IS_EXP_EXPR (D->Type)) {
D->Expr = ReadExpr (F, O);
} else {
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)
/* Get the value of this symbol */
{
@ -176,19 +190,69 @@ long GetDbgSymVal (DbgSym* D)
void PrintDbgSymLabels (ObjData* O, FILE* F)
/* Print the debug symbols in a VICE label file */
void PrintDbgSyms (ObjData* O, FILE* F)
/* Print the debug symbols in a debug 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];
/* 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
* already written to the file, so don't emit it twice. If it is not in

View File

@ -81,6 +81,9 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* Obj);
long GetDbgSymVal (DbgSym* D);
/* 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);
/* Print the debug symbols in a VICE label file */

View File

@ -106,7 +106,7 @@ static void Usage (void)
"Long options:\n"
" --cfg-path path\tSpecify a config file search path\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"
" --help\t\tHelp (this text)\n"
" --lib file\t\tLink this library\n"

View File

@ -149,7 +149,7 @@ void CreateLabelFile (void)
/* Close the file */
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 */
FILE* F = fopen (DbgFileName, "w");
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 */
@ -174,11 +174,12 @@ void CreateDbgFile (void)
/* Output debug info */
PrintDbgInfo (O, F);
PrintDbgSyms (O, F);
}
/* Close the file */
if (fclose (F) != 0) {
Error ("Error closing map file `%s': %s", DbgFileName, strerror (errno));
Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
}
}