Bump the version number. Fix line number counting. Resolve ids to pointers in

several places.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5142 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-08-10 10:13:31 +00:00
parent 604f74c5c2
commit 3e42ba1a87
2 changed files with 121 additions and 28 deletions

View File

@@ -56,8 +56,8 @@
#define DEBUG 0 #define DEBUG 0
/* Version numbers of the debug format we understand */ /* Version numbers of the debug format we understand */
#define VER_MAJOR 1U #define VER_MAJOR 2U
#define VER_MINOR 3U #define VER_MINOR 0U
/* Dynamic strings */ /* Dynamic strings */
typedef struct StrBuf StrBuf; typedef struct StrBuf StrBuf;
@@ -1032,12 +1032,13 @@ static cc65_lineinfo* new_cc65_lineinfo (unsigned Count)
static void CopyLineInfo (cc65_linedata* D, const LineInfo* L) static void CopyLineInfo (cc65_linedata* D, const LineInfo* L)
/* Copy data from a LineInfo struct to a cc65_linedata struct */ /* Copy data from a LineInfo struct to a cc65_linedata struct */
{ {
D->line_id = L->Id;
D->line_start = L->Start;
D->line_end = L->End;
D->source_name = L->File.Info->Name; D->source_name = L->File.Info->Name;
D->source_size = L->File.Info->Size; D->source_size = L->File.Info->Size;
D->source_mtime = L->File.Info->MTime; D->source_mtime = L->File.Info->MTime;
D->source_line = L->Line; D->source_line = L->Line;
D->line_start = L->Start;
D->line_end = L->End;
if (L->Seg.Info->OutputName) { if (L->Seg.Info->OutputName) {
D->output_name = L->Seg.Info->OutputName; D->output_name = L->Seg.Info->OutputName;
D->output_offs = L->Seg.Info->OutputOffs + L->Start - L->Seg.Info->Start; D->output_offs = L->Seg.Info->OutputOffs + L->Start - L->Seg.Info->Start;
@@ -1331,7 +1332,11 @@ static void CopyModInfo (cc65_moduledata* D, const ModInfo* M)
D->module_id = M->Id; D->module_id = M->Id;
D->module_name = M->Name; D->module_name = M->Name;
D->source_id = M->File.Info->Id; D->source_id = M->File.Info->Id;
if (M->Lib.Info) {
D->library_id = M->Lib.Info->Id; D->library_id = M->Lib.Info->Id;
} else {
D->library_id = CC65_INV_ID;
}
} }
@@ -1385,8 +1390,16 @@ static void CopyScopeInfo (cc65_scopedata* D, const ScopeInfo* S)
D->scope_name = S->Name; D->scope_name = S->Name;
D->scope_type = S->Type; D->scope_type = S->Type;
D->scope_size = S->Size; D->scope_size = S->Size;
if (S->Parent.Info) {
D->scope_parent = S->Parent.Info->Id; D->scope_parent = S->Parent.Info->Id;
} else {
D->scope_parent = CC65_INV_ID;
}
if (S->Label.Info) {
D->symbol_id = S->Label.Info->Id; D->symbol_id = S->Label.Info->Id;
} else {
D->symbol_id = CC65_INV_ID;
}
D->module_id = S->Mod.Info->Id; D->module_id = S->Mod.Info->Id;
} }
@@ -1532,9 +1545,17 @@ static void CopySymInfo (cc65_symboldata* D, const SymInfo* S)
D->symbol_type = S->Type; D->symbol_type = S->Type;
D->symbol_size = S->Size; D->symbol_size = S->Size;
D->symbol_value = S->Value; D->symbol_value = S->Value;
if (S->Seg.Info) {
D->segment_id = S->Seg.Info->Id; D->segment_id = S->Seg.Info->Id;
} else {
D->segment_id = CC65_INV_ID;
}
D->scope_id = S->Scope.Info->Id; D->scope_id = S->Scope.Info->Id;
if (S->Parent.Info) {
D->parent_id = S->Parent.Info->Id; D->parent_id = S->Parent.Info->Id;
} else {
D->parent_id = CC65_INV_ID;
}
} }
@@ -1768,13 +1789,12 @@ static void NextChar (InputData* D)
{ {
/* Check if we've encountered EOF before */ /* Check if we've encountered EOF before */
if (D->C >= 0) { if (D->C >= 0) {
D->C = fgetc (D->F);
if (D->C == '\n') { if (D->C == '\n') {
++D->Line; ++D->Line;
D->Col = 0; D->Col = 0;
} else {
++D->Col;
} }
D->C = fgetc (D->F);
++D->Col;
} }
} }
@@ -3572,6 +3592,78 @@ static int FindLineInfoByLine (Collection* LineInfos, cc65_line Line,
static void ProcessSymInfo (InputData* D) static void ProcessSymInfo (InputData* D)
/* Postprocess symbol infos */ /* Postprocess symbol infos */
{ {
/* Walk over the symbols and resolve the references */
unsigned I;
for (I = 0; I < CollCount (&D->Info->SymInfoById); ++I) {
/* Get the symbol info */
SymInfo* S = CollAt (&D->Info->SymInfoById, I);
/* Resolve segment */
if (S->Seg.Id == CC65_INV_ID) {
S->Seg.Info = 0;
} else if (S->Seg.Id >= CollCount (&D->Info->SegInfoById)) {
ParseError (D,
CC65_ERROR,
"Invalid segment id %u for symbol with id %u",
S->Seg.Id, S->Id);
S->Seg.Info = 0;
} else {
S->Seg.Info = CollAt (&D->Info->SegInfoById, S->Seg.Id);
}
/* Resolve the scope */
if (S->Scope.Id == CC65_INV_ID) {
S->Scope.Info = 0;
} else if (S->Scope.Id >= CollCount (&D->Info->ScopeInfoById)) {
ParseError (D,
CC65_ERROR,
"Invalid scope id %u for symbol with id %u",
S->Scope.Id, S->Id);
S->Scope.Info = 0;
} else {
S->Scope.Info = CollAt (&D->Info->ScopeInfoById, S->Scope.Id);
}
/* Resolve the parent */
if (S->Parent.Id == CC65_INV_ID) {
S->Parent.Info = 0;
} else if (S->Parent.Id >= CollCount (&D->Info->SymInfoById)) {
ParseError (D,
CC65_ERROR,
"Invalid parent id %u for symbol with id %u",
S->Parent.Id, S->Id);
S->Parent.Info = 0;
} else {
S->Parent.Info = CollAt (&D->Info->SymInfoById, S->Parent.Id);
}
}
/* Second run. Resolve scopes for cheap locals */
for (I = 0; I < CollCount (&D->Info->SymInfoById); ++I) {
/* Get the symbol info */
SymInfo* S = CollAt (&D->Info->SymInfoById, I);
/* Resolve the scope */
if (S->Scope.Info == 0) {
/* No scope - must have a parent */
if (S->Parent.Info == 0) {
ParseError (D,
CC65_ERROR,
"Symbol with id %u has no parent and no scope",
S->Id);
} else if (S->Parent.Info->Scope.Info == 0) {
ParseError (D,
CC65_ERROR,
"Symbol with id %u has parent %u without a scope",
S->Id, S->Parent.Info->Id);
} else {
S->Scope.Info = S->Parent.Info->Scope.Info;
}
}
}
/* Sort the symbol infos */ /* Sort the symbol infos */
CollSort (&D->Info->SymInfoByName, CompareSymInfoByName); CollSort (&D->Info->SymInfoByName, CompareSymInfoByName);
CollSort (&D->Info->SymInfoByVal, CompareSymInfoByVal); CollSort (&D->Info->SymInfoByVal, CompareSymInfoByVal);

View File

@@ -167,12 +167,13 @@ typedef enum {
*/ */
typedef struct cc65_linedata cc65_linedata; typedef struct cc65_linedata cc65_linedata;
struct cc65_linedata { struct cc65_linedata {
unsigned line_id; /* Internal id of this record */
cc65_addr line_start; /* Start address for this line */
cc65_addr line_end; /* End address for this line */
const char* source_name; /* Name of the file */ const char* source_name; /* Name of the file */
unsigned long source_size; /* Size of file */ unsigned long source_size; /* Size of file */
unsigned long source_mtime; /* Modification time */ unsigned long source_mtime; /* Modification time */
cc65_line source_line; /* Line number */ cc65_line source_line; /* Line number */
cc65_addr line_start; /* Start address for this line */
cc65_addr line_end; /* End address for this line */
const char* output_name; /* Output file */ const char* output_name; /* Output file */
unsigned long output_offs; /* Offset in output file */ unsigned long output_offs; /* Offset in output file */
cc65_line_type line_type; /* Type of line */ cc65_line_type line_type; /* Type of line */