mirror of
https://github.com/cc65/cc65.git
synced 2024-12-26 08:32:00 +00:00
Move the collection containing all line infos into the DbgInfo struct and keep
it there. It will be used to search for line info by address in some future version, which is faster than searching through all the source files in a linear fashion. git-svn-id: svn://svn.cc65.org/cc65/trunk@4802 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
5625977188
commit
8f03c4e9cf
@ -89,6 +89,7 @@ struct DbgInfo {
|
|||||||
Collection SegInfoById; /* Segment infos sorted by id */
|
Collection SegInfoById; /* Segment infos sorted by id */
|
||||||
Collection FileInfoByName; /* File infos sorted by name */
|
Collection FileInfoByName; /* File infos sorted by name */
|
||||||
Collection FileInfoById; /* File infos sorted by id */
|
Collection FileInfoById; /* File infos sorted by id */
|
||||||
|
Collection LineInfoByAddr; /* Line information sorted by address */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Input tokens */
|
/* Input tokens */
|
||||||
@ -152,7 +153,6 @@ struct InputData {
|
|||||||
cc65_errorfunc Error; /* Function called in case of errors */
|
cc65_errorfunc Error; /* Function called in case of errors */
|
||||||
unsigned MajorVersion; /* Major version number */
|
unsigned MajorVersion; /* Major version number */
|
||||||
unsigned MinorVersion; /* Minor version number */
|
unsigned MinorVersion; /* Minor version number */
|
||||||
Collection LineInfos; /* Line information */
|
|
||||||
DbgInfo* Info; /* Pointer to debug info */
|
DbgInfo* Info; /* Pointer to debug info */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -673,6 +673,7 @@ static SegInfo* NewSegInfo (const StrBuf* SegName, unsigned Id,
|
|||||||
static void FreeSegInfo (SegInfo* S)
|
static void FreeSegInfo (SegInfo* S)
|
||||||
/* Free a SegInfo struct */
|
/* Free a SegInfo struct */
|
||||||
{
|
{
|
||||||
|
xfree (S->OutputName);
|
||||||
xfree (S);
|
xfree (S);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,6 +854,7 @@ static DbgInfo* NewDbgInfo (void)
|
|||||||
InitCollection (&Info->SegInfoById);
|
InitCollection (&Info->SegInfoById);
|
||||||
InitCollection (&Info->FileInfoByName);
|
InitCollection (&Info->FileInfoByName);
|
||||||
InitCollection (&Info->FileInfoById);
|
InitCollection (&Info->FileInfoById);
|
||||||
|
InitCollection (&Info->LineInfoByAddr);
|
||||||
|
|
||||||
/* Return it */
|
/* Return it */
|
||||||
return Info;
|
return Info;
|
||||||
@ -879,6 +881,9 @@ static void FreeDbgInfo (DbgInfo* Info)
|
|||||||
DoneCollection (&Info->FileInfoByName);
|
DoneCollection (&Info->FileInfoByName);
|
||||||
DoneCollection (&Info->FileInfoById);
|
DoneCollection (&Info->FileInfoById);
|
||||||
|
|
||||||
|
/* Free line info */
|
||||||
|
DoneCollection (&Info->LineInfoByAddr);
|
||||||
|
|
||||||
/* Free the structure itself */
|
/* Free the structure itself */
|
||||||
xfree (Info);
|
xfree (Info);
|
||||||
}
|
}
|
||||||
@ -1511,7 +1516,7 @@ static void ParseLine (InputData* D)
|
|||||||
|
|
||||||
/* Create the line info and remember it */
|
/* Create the line info and remember it */
|
||||||
L = NewLineInfo (File, Segment, Line, Start, End);
|
L = NewLineInfo (File, Segment, Line, Start, End);
|
||||||
CollAppend (&D->LineInfos, L);
|
CollAppend (&D->Info->LineInfoByAddr, L);
|
||||||
|
|
||||||
ErrorExit:
|
ErrorExit:
|
||||||
/* Entry point in case of errors */
|
/* Entry point in case of errors */
|
||||||
@ -1971,7 +1976,7 @@ static void ProcessLineInfo (InputData* D)
|
|||||||
/* Postprocess line infos */
|
/* Postprocess line infos */
|
||||||
{
|
{
|
||||||
/* Get pointers to the collections */
|
/* Get pointers to the collections */
|
||||||
Collection* LineInfos = &D->LineInfos;
|
Collection* LineInfos = &D->Info->LineInfoByAddr;
|
||||||
Collection* FileInfos = &D->Info->FileInfoByName;
|
Collection* FileInfos = &D->Info->FileInfoByName;
|
||||||
|
|
||||||
/* Walk over the line infos and replace the id numbers of file and segment
|
/* Walk over the line infos and replace the id numbers of file and segment
|
||||||
@ -2073,8 +2078,10 @@ static void ProcessLineInfo (InputData* D)
|
|||||||
F->Start = ((const LineInfo*) CollFirst (&F->LineInfoByAddr))->Start;
|
F->Start = ((const LineInfo*) CollFirst (&F->LineInfoByAddr))->Start;
|
||||||
F->End = ((const LineInfo*) CollLast (&F->LineInfoByAddr))->End;
|
F->End = ((const LineInfo*) CollLast (&F->LineInfoByAddr))->End;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sort the collection with all line infos by address */
|
||||||
|
CollSort (LineInfos, CompareLineInfoByAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2193,7 +2200,6 @@ cc65_dbginfo cc65_read_dbginfo (const char* FileName, cc65_errorfunc ErrFunc)
|
|||||||
0, /* Function called in case of errors */
|
0, /* Function called in case of errors */
|
||||||
0, /* Major version number */
|
0, /* Major version number */
|
||||||
0, /* Minor version number */
|
0, /* Minor version number */
|
||||||
COLLECTION_INITIALIZER, /* Line information */
|
|
||||||
0, /* Pointer to debug info */
|
0, /* Pointer to debug info */
|
||||||
};
|
};
|
||||||
D.FileName = FileName;
|
D.FileName = FileName;
|
||||||
@ -2287,10 +2293,10 @@ cc65_dbginfo cc65_read_dbginfo (const char* FileName, cc65_errorfunc ErrFunc)
|
|||||||
if (D.Errors > 0) {
|
if (D.Errors > 0) {
|
||||||
/* Free allocated stuff */
|
/* Free allocated stuff */
|
||||||
unsigned I;
|
unsigned I;
|
||||||
for (I = 0; I < CollCount (&D.LineInfos); ++I) {
|
for (I = 0; I < CollCount (&D.Info->LineInfoByAddr); ++I) {
|
||||||
FreeLineInfo (CollAt (&D.LineInfos, I));
|
FreeLineInfo (CollAt (&D.Info->LineInfoByAddr, I));
|
||||||
}
|
}
|
||||||
DoneCollection (&D.LineInfos);
|
DoneCollection (&D.Info->LineInfoByAddr);
|
||||||
FreeDbgInfo (D.Info);
|
FreeDbgInfo (D.Info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2302,9 +2308,6 @@ cc65_dbginfo cc65_read_dbginfo (const char* FileName, cc65_errorfunc ErrFunc)
|
|||||||
ProcessFileInfo (&D);
|
ProcessFileInfo (&D);
|
||||||
ProcessLineInfo (&D);
|
ProcessLineInfo (&D);
|
||||||
|
|
||||||
/* Free the collection that contained the line info */
|
|
||||||
DoneCollection (&D.LineInfos);
|
|
||||||
|
|
||||||
/* Return the debug info struct that was created */
|
/* Return the debug info struct that was created */
|
||||||
return D.Info;
|
return D.Info;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user