Fixed O(n^2) generation of debug info tables (bug 4493, r=fyren).
This commit is contained in:
parent
b5b4bff2fc
commit
f8c2629a3e
@ -724,6 +724,7 @@ SC_FUNC stringlist *insert_dbgline(int linenr);
|
|||||||
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym);
|
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym);
|
||||||
SC_FUNC char *get_dbgstring(int index);
|
SC_FUNC char *get_dbgstring(int index);
|
||||||
SC_FUNC void delete_dbgstringtable(void);
|
SC_FUNC void delete_dbgstringtable(void);
|
||||||
|
SC_FUNC stringlist *get_dbgstrings();
|
||||||
|
|
||||||
/* function prototypes in SCMEMFILE.C */
|
/* function prototypes in SCMEMFILE.C */
|
||||||
#if !defined tMEMFILE
|
#if !defined tMEMFILE
|
||||||
|
@ -1064,13 +1064,15 @@ static void append_dbginfo(FILE *fout)
|
|||||||
AMX_DBG_LINE dbgline;
|
AMX_DBG_LINE dbgline;
|
||||||
AMX_DBG_SYMBOL dbgsym;
|
AMX_DBG_SYMBOL dbgsym;
|
||||||
AMX_DBG_SYMDIM dbgidxtag[sDIMEN_MAX];
|
AMX_DBG_SYMDIM dbgidxtag[sDIMEN_MAX];
|
||||||
int index,dim,dbgsymdim;
|
int dim,dbgsymdim;
|
||||||
char *str,*prevstr,*name,*prevname;
|
char *str,*prevstr,*name,*prevname;
|
||||||
ucell codeidx,previdx;
|
ucell codeidx,previdx;
|
||||||
constvalue *constptr;
|
constvalue *constptr;
|
||||||
char symname[2*sNAMEMAX+16];
|
char symname[2*sNAMEMAX+16];
|
||||||
int16_t id1,id2;
|
int16_t id1,id2;
|
||||||
ucell address;
|
ucell address;
|
||||||
|
stringlist *dbgstrs = get_dbgstrings();
|
||||||
|
stringlist *iter;
|
||||||
|
|
||||||
/* header with general information */
|
/* header with general information */
|
||||||
memset(&dbghdr, 0, sizeof dbghdr);
|
memset(&dbghdr, 0, sizeof dbghdr);
|
||||||
@ -1079,13 +1081,16 @@ static void append_dbginfo(FILE *fout)
|
|||||||
dbghdr.file_version=CUR_FILE_VERSION;
|
dbghdr.file_version=CUR_FILE_VERSION;
|
||||||
dbghdr.amx_version=MIN_AMX_VERSION;
|
dbghdr.amx_version=MIN_AMX_VERSION;
|
||||||
|
|
||||||
|
dbgstrs=dbgstrs->next;
|
||||||
|
|
||||||
/* first pass: collect the number of items in various tables */
|
/* first pass: collect the number of items in various tables */
|
||||||
|
|
||||||
/* file table */
|
/* file table */
|
||||||
previdx=0;
|
previdx=0;
|
||||||
prevstr=NULL;
|
prevstr=NULL;
|
||||||
prevname=NULL;
|
prevname=NULL;
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
|
str = iter->line;
|
||||||
assert(str!=NULL);
|
assert(str!=NULL);
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='F') {
|
if (str[0]=='F') {
|
||||||
@ -1109,7 +1114,8 @@ static void append_dbginfo(FILE *fout)
|
|||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
/* line number table */
|
/* line number table */
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
|
str = iter->line;
|
||||||
assert(str!=NULL);
|
assert(str!=NULL);
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='L') {
|
if (str[0]=='L') {
|
||||||
@ -1119,7 +1125,8 @@ static void append_dbginfo(FILE *fout)
|
|||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
|
str = iter->line;
|
||||||
assert(str!=NULL);
|
assert(str!=NULL);
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='S') {
|
if (str[0]=='S') {
|
||||||
@ -1173,8 +1180,8 @@ static void append_dbginfo(FILE *fout)
|
|||||||
previdx=0;
|
previdx=0;
|
||||||
prevstr=NULL;
|
prevstr=NULL;
|
||||||
prevname=NULL;
|
prevname=NULL;
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
assert(str!=NULL);
|
str = iter->line;
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='F') {
|
if (str[0]=='F') {
|
||||||
codeidx=hex2long(str+2,&name);
|
codeidx=hex2long(str+2,&name);
|
||||||
@ -1203,7 +1210,8 @@ static void append_dbginfo(FILE *fout)
|
|||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
/* line number table */
|
/* line number table */
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
|
str = iter->line;
|
||||||
assert(str!=NULL);
|
assert(str!=NULL);
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='L') {
|
if (str[0]=='L') {
|
||||||
@ -1218,7 +1226,8 @@ static void append_dbginfo(FILE *fout)
|
|||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
for (index=0; (str=get_dbgstring(index))!=NULL; index++) {
|
for (iter=dbgstrs; iter!=NULL; iter=iter->next) {
|
||||||
|
str = iter->line;
|
||||||
assert(str!=NULL);
|
assert(str!=NULL);
|
||||||
assert(str[0]!='\0' && str[1]==':');
|
assert(str[0]!='\0' && str[1]==':');
|
||||||
if (str[0]=='S') {
|
if (str[0]=='S') {
|
||||||
|
@ -519,6 +519,11 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SC_FUNC stringlist *get_dbgstrings()
|
||||||
|
{
|
||||||
|
return &dbgstrings;
|
||||||
|
}
|
||||||
|
|
||||||
SC_FUNC char *get_dbgstring(int index)
|
SC_FUNC char *get_dbgstring(int index)
|
||||||
{
|
{
|
||||||
return get_string(&dbgstrings,index);
|
return get_string(&dbgstrings,index);
|
||||||
|
Loading…
Reference in New Issue
Block a user