Merge pull request #2538 from clydeshaffer/dbg_banknum
[LD65] Add bank number to `seg` entries in dbgfile
This commit is contained in:
@@ -127,6 +127,7 @@ typedef enum {
|
|||||||
TOK_ABSOLUTE = TOK_FIRST_KEYWORD, /* ABSOLUTE keyword */
|
TOK_ABSOLUTE = TOK_FIRST_KEYWORD, /* ABSOLUTE keyword */
|
||||||
TOK_ADDRSIZE, /* ADDRSIZE keyword */
|
TOK_ADDRSIZE, /* ADDRSIZE keyword */
|
||||||
TOK_AUTO, /* AUTO keyword */
|
TOK_AUTO, /* AUTO keyword */
|
||||||
|
TOK_BANK, /* BANK keyword */
|
||||||
TOK_COUNT, /* COUNT keyword */
|
TOK_COUNT, /* COUNT keyword */
|
||||||
TOK_CSYM, /* CSYM keyword */
|
TOK_CSYM, /* CSYM keyword */
|
||||||
TOK_DEF, /* DEF keyword */
|
TOK_DEF, /* DEF keyword */
|
||||||
@@ -347,6 +348,7 @@ struct SegInfo {
|
|||||||
cc65_size Size; /* Size of segment */
|
cc65_size Size; /* Size of segment */
|
||||||
char* OutputName; /* Name of output file */
|
char* OutputName; /* Name of output file */
|
||||||
unsigned long OutputOffs; /* Offset in output file */
|
unsigned long OutputOffs; /* Offset in output file */
|
||||||
|
unsigned Bank; /* Bank number of memory area */
|
||||||
char Name[1]; /* Name of segment */
|
char Name[1]; /* Name of segment */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1618,7 +1620,8 @@ static int CompareScopeInfoByName (const void* L, const void* R)
|
|||||||
|
|
||||||
static SegInfo* NewSegInfo (const StrBuf* Name, unsigned Id,
|
static SegInfo* NewSegInfo (const StrBuf* Name, unsigned Id,
|
||||||
cc65_addr Start, cc65_addr Size,
|
cc65_addr Start, cc65_addr Size,
|
||||||
const StrBuf* OutputName, unsigned long OutputOffs)
|
const StrBuf* OutputName, unsigned long OutputOffs,
|
||||||
|
unsigned Bank)
|
||||||
/* Create a new SegInfo struct and return it */
|
/* Create a new SegInfo struct and return it */
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
@@ -1628,6 +1631,7 @@ static SegInfo* NewSegInfo (const StrBuf* Name, unsigned Id,
|
|||||||
S->Id = Id;
|
S->Id = Id;
|
||||||
S->Start = Start;
|
S->Start = Start;
|
||||||
S->Size = Size;
|
S->Size = Size;
|
||||||
|
S->Bank = Bank;
|
||||||
if (SB_GetLen (OutputName) > 0) {
|
if (SB_GetLen (OutputName) > 0) {
|
||||||
/* Output file given */
|
/* Output file given */
|
||||||
S->OutputName = SB_StrDup (OutputName);
|
S->OutputName = SB_StrDup (OutputName);
|
||||||
@@ -1676,6 +1680,7 @@ static void CopySegInfo (cc65_segmentdata* D, const SegInfo* S)
|
|||||||
D->segment_size = S->Size;
|
D->segment_size = S->Size;
|
||||||
D->output_name = S->OutputName;
|
D->output_name = S->OutputName;
|
||||||
D->output_offs = S->OutputOffs;
|
D->output_offs = S->OutputOffs;
|
||||||
|
D->segment_bank = S->Bank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2528,6 +2533,7 @@ static void NextToken (InputData* D)
|
|||||||
{ "abs", TOK_ABSOLUTE },
|
{ "abs", TOK_ABSOLUTE },
|
||||||
{ "addrsize", TOK_ADDRSIZE },
|
{ "addrsize", TOK_ADDRSIZE },
|
||||||
{ "auto", TOK_AUTO },
|
{ "auto", TOK_AUTO },
|
||||||
|
{ "bank", TOK_BANK },
|
||||||
{ "count", TOK_COUNT },
|
{ "count", TOK_COUNT },
|
||||||
{ "csym", TOK_CSYM },
|
{ "csym", TOK_CSYM },
|
||||||
{ "def", TOK_DEF },
|
{ "def", TOK_DEF },
|
||||||
@@ -3838,6 +3844,7 @@ static void ParseSegment (InputData* D)
|
|||||||
StrBuf Name = STRBUF_INITIALIZER;
|
StrBuf Name = STRBUF_INITIALIZER;
|
||||||
StrBuf OutputName = STRBUF_INITIALIZER;
|
StrBuf OutputName = STRBUF_INITIALIZER;
|
||||||
unsigned long OutputOffs = 0;
|
unsigned long OutputOffs = 0;
|
||||||
|
unsigned Bank = 0;
|
||||||
SegInfo* S;
|
SegInfo* S;
|
||||||
enum {
|
enum {
|
||||||
ibNone = 0x000,
|
ibNone = 0x000,
|
||||||
@@ -3850,6 +3857,7 @@ static void ParseSegment (InputData* D)
|
|||||||
ibSize = 0x020,
|
ibSize = 0x020,
|
||||||
ibStart = 0x040,
|
ibStart = 0x040,
|
||||||
ibType = 0x080,
|
ibType = 0x080,
|
||||||
|
ibBank = 0x100,
|
||||||
|
|
||||||
ibRequired = ibId | ibName | ibStart | ibSize | ibAddrSize | ibType,
|
ibRequired = ibId | ibName | ibStart | ibSize | ibAddrSize | ibType,
|
||||||
} InfoBits = ibNone;
|
} InfoBits = ibNone;
|
||||||
@@ -3863,10 +3871,11 @@ static void ParseSegment (InputData* D)
|
|||||||
Token Tok;
|
Token Tok;
|
||||||
|
|
||||||
/* Something we know? */
|
/* Something we know? */
|
||||||
if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_ID &&
|
if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_BANK &&
|
||||||
D->Tok != TOK_NAME && D->Tok != TOK_OUTPUTNAME &&
|
D->Tok != TOK_ID && D->Tok != TOK_NAME &&
|
||||||
D->Tok != TOK_OUTPUTOFFS && D->Tok != TOK_SIZE &&
|
D->Tok != TOK_OUTPUTNAME && D->Tok != TOK_OUTPUTOFFS &&
|
||||||
D->Tok != TOK_START && D->Tok != TOK_TYPE) {
|
D->Tok != TOK_SIZE && D->Tok != TOK_START &&
|
||||||
|
D->Tok != TOK_TYPE) {
|
||||||
|
|
||||||
/* Try smart error recovery */
|
/* Try smart error recovery */
|
||||||
if (D->Tok == TOK_IDENT || TokenIsKeyword (D->Tok)) {
|
if (D->Tok == TOK_IDENT || TokenIsKeyword (D->Tok)) {
|
||||||
@@ -3892,6 +3901,15 @@ static void ParseSegment (InputData* D)
|
|||||||
InfoBits |= ibAddrSize;
|
InfoBits |= ibAddrSize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOK_BANK:
|
||||||
|
if (!IntConstFollows (D)) {
|
||||||
|
goto ErrorExit;
|
||||||
|
}
|
||||||
|
Bank = D->IVal;
|
||||||
|
InfoBits |= ibBank;
|
||||||
|
NextToken (D);
|
||||||
|
break;
|
||||||
|
|
||||||
case TOK_ID:
|
case TOK_ID:
|
||||||
if (!IntConstFollows (D)) {
|
if (!IntConstFollows (D)) {
|
||||||
goto ErrorExit;
|
goto ErrorExit;
|
||||||
@@ -3992,7 +4010,7 @@ static void ParseSegment (InputData* D)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create the segment info and remember it */
|
/* Create the segment info and remember it */
|
||||||
S = NewSegInfo (&Name, Id, Start, Size, &OutputName, OutputOffs);
|
S = NewSegInfo (&Name, Id, Start, Size, &OutputName, OutputOffs, Bank);
|
||||||
CollReplaceExpand (&D->Info->SegInfoById, S, Id);
|
CollReplaceExpand (&D->Info->SegInfoById, S, Id);
|
||||||
CollAppend (&D->Info->SegInfoByName, S);
|
CollAppend (&D->Info->SegInfoByName, S);
|
||||||
|
|
||||||
|
|||||||
@@ -521,6 +521,7 @@ struct cc65_segmentdata {
|
|||||||
cc65_size segment_size; /* Size of segment */
|
cc65_size segment_size; /* Size of segment */
|
||||||
const char* output_name; /* Output file this seg was written to */
|
const char* output_name; /* Output file this seg was written to */
|
||||||
unsigned long output_offs; /* Offset of this seg in output file */
|
unsigned long output_offs; /* Offset of this seg in output file */
|
||||||
|
unsigned segment_bank;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct cc65_segmentinfo cc65_segmentinfo;
|
typedef struct cc65_segmentinfo cc65_segmentinfo;
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ static void PrintSegmentHeader (void)
|
|||||||
/* Output a header for a list of segments */
|
/* Output a header for a list of segments */
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
PrintLine (" id name address size output file offs");
|
PrintLine (" id name address size output file offs bank");
|
||||||
PrintSeparator ();
|
PrintSeparator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,6 +741,7 @@ static void PrintSegments (const cc65_segmentinfo* S)
|
|||||||
PrintSize (D->segment_size, 7);
|
PrintSize (D->segment_size, 7);
|
||||||
Print ("%-16s", D->output_name? D->output_name : "");
|
Print ("%-16s", D->output_name? D->output_name : "");
|
||||||
PrintSize (D->output_offs, 6);
|
PrintSize (D->output_offs, 6);
|
||||||
|
PrintId (D->segment_bank, 8);
|
||||||
NewLine ();
|
NewLine ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -638,6 +638,13 @@ void PrintDbgSegments (FILE* F)
|
|||||||
fprintf (F, ",oname=\"%s\",ooffs=%lu",
|
fprintf (F, ",oname=\"%s\",ooffs=%lu",
|
||||||
S->OutputName, S->OutputOffs);
|
S->OutputName, S->OutputOffs);
|
||||||
}
|
}
|
||||||
|
if (S->MemArea) {
|
||||||
|
if (S->MemArea->BankExpr) {
|
||||||
|
if (IsConstExpr (S->MemArea->BankExpr)) {
|
||||||
|
fprintf (F, ",bank=%lu", GetExprVal(S->MemArea->BankExpr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user