mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 17:29:50 +00:00
More debug file output
git-svn-id: svn://svn.cc65.org/cc65/trunk@2441 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
67d55e71eb
commit
5537aee205
@ -612,8 +612,7 @@ static void ParseSegments (void)
|
||||
{ "RW", CFGTOK_RW },
|
||||
{ "BSS", CFGTOK_BSS },
|
||||
{ "ZP", CFGTOK_ZP },
|
||||
{ "WP", CFGTOK_WPROT },
|
||||
{ "WPROT", CFGTOK_WPROT },
|
||||
{ "WPROT", CFGTOK_RO }, /* ### OBSOLETE */
|
||||
};
|
||||
|
||||
unsigned Count;
|
||||
@ -706,7 +705,6 @@ static void ParseSegments (void)
|
||||
case CFGTOK_RW: /* Default */ break;
|
||||
case CFGTOK_BSS: S->Flags |= SF_BSS; break;
|
||||
case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break;
|
||||
case CFGTOK_WPROT: S->Flags |= (SF_RO | SF_WPROT); break;
|
||||
default: Internal ("Unexpected token: %d", CfgTok);
|
||||
}
|
||||
break;
|
||||
@ -1473,11 +1471,13 @@ void CfgAssignSegments (void)
|
||||
Addr = NewAddr;
|
||||
}
|
||||
|
||||
/* If this is the run area, set the start address of this segment
|
||||
* and remember if the segment is in a relocatable file or not.
|
||||
/* If this is the run area, set the start address of this segment,
|
||||
* set the readonly flag in the segment and and remember if the
|
||||
* segment is in a relocatable file or not.
|
||||
*/
|
||||
if (S->Run == M) {
|
||||
S->Seg->PC = Addr;
|
||||
S->Seg->ReadOnly = (S->Flags & SF_RO) != 0;
|
||||
S->Seg->Relocatable = M->Relocatable;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
|
||||
|
||||
/* ld65 */
|
||||
#include "segments.h"
|
||||
|
||||
|
||||
@ -111,12 +112,11 @@ extern unsigned SegDescCount; /* Number of entries in list */
|
||||
#define SF_RO 0x0001 /* Read only segment */
|
||||
#define SF_BSS 0x0002 /* Segment is BSS style segment */
|
||||
#define SF_ZP 0x0004 /* Zeropage segment (o65 only) */
|
||||
#define SF_WPROT 0x0008 /* Write protected segment */
|
||||
#define SF_DEFINE 0x0010 /* Define start and size */
|
||||
#define SF_ALIGN 0x0020 /* Align the segment */
|
||||
#define SF_OFFSET 0x0040 /* Segment has offset in memory */
|
||||
#define SF_START 0x0080 /* Segment has fixed start address */
|
||||
#define SF_OPTIONAL 0x0100 /* Segment is optional (must not exist) */
|
||||
#define SF_DEFINE 0x0008 /* Define start and size */
|
||||
#define SF_ALIGN 0x0010 /* Align the segment */
|
||||
#define SF_OFFSET 0x0020 /* Segment has offset in memory */
|
||||
#define SF_START 0x0040 /* Segment has fixed start address */
|
||||
#define SF_OPTIONAL 0x0080 /* Segment is optional (must not exist) */
|
||||
#define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */
|
||||
#define SF_RUN_DEF 0x2000 /* RUN symbols already defined */
|
||||
#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */
|
||||
|
88
src/ld65/dbgfile.c
Normal file
88
src/ld65/dbgfile.c
Normal file
@ -0,0 +1,88 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* dbgfile.c */
|
||||
/* */
|
||||
/* Debug file creation for the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* ld65 */
|
||||
#include "dbgfile.h"
|
||||
#include "dbginfo.h"
|
||||
#include "dbgsyms.h"
|
||||
#include "error.h"
|
||||
#include "global.h"
|
||||
#include "segments.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void CreateDbgFile (void)
|
||||
/* Create a debug info file */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
/* Open the debug info file */
|
||||
FILE* F = fopen (DbgFileName, "w");
|
||||
if (F == 0) {
|
||||
Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
|
||||
/* Output the segment info */
|
||||
PrintDbgSegments (F);
|
||||
|
||||
/* Print line infos from all modules we have linked into the output file */
|
||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||
|
||||
/* Get the object file */
|
||||
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||
|
||||
/* Output debug info */
|
||||
PrintDbgInfo (O, F);
|
||||
PrintDbgSyms (O, F);
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if (fclose (F) != 0) {
|
||||
Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
57
src/ld65/dbgfile.h
Normal file
57
src/ld65/dbgfile.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* dbgfile.h */
|
||||
/* */
|
||||
/* Debug file creation for the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef DBGFILE_H
|
||||
#define DBGFILE_H
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void CreateDbgFile (void);
|
||||
/* Create a debug info file */
|
||||
|
||||
|
||||
|
||||
/* End of dbgfile.h */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "binfmt.h"
|
||||
#include "condes.h"
|
||||
#include "config.h"
|
||||
#include "dbgfile.h"
|
||||
#include "error.h"
|
||||
#include "exports.h"
|
||||
#include "fileio.h"
|
||||
|
@ -23,6 +23,7 @@ OBJS = asserts.o \
|
||||
binfmt.o \
|
||||
condes.o \
|
||||
config.o \
|
||||
dbgfile.o \
|
||||
dbginfo.o \
|
||||
dbgsyms.o \
|
||||
error.o \
|
||||
|
@ -48,6 +48,7 @@ OBJS = asserts.obj \
|
||||
binfmt.obj \
|
||||
condes.obj \
|
||||
config.obj \
|
||||
dbgfile.obj \
|
||||
dbginfo.obj \
|
||||
dbgsyms.obj \
|
||||
error.obj \
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
/* ld65 */
|
||||
#include "config.h"
|
||||
#include "dbginfo.h"
|
||||
#include "dbgsyms.h"
|
||||
#include "exports.h"
|
||||
#include "global.h"
|
||||
@ -155,33 +154,3 @@ void CreateLabelFile (void)
|
||||
|
||||
|
||||
|
||||
void CreateDbgFile (void)
|
||||
/* Create a debug info file */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
/* Open the debug info file */
|
||||
FILE* F = fopen (DbgFileName, "w");
|
||||
if (F == 0) {
|
||||
Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
|
||||
/* Print line infos from all modules we have linked into the output file */
|
||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||
|
||||
/* Get the object file */
|
||||
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||
|
||||
/* Output debug info */
|
||||
PrintDbgInfo (O, F);
|
||||
PrintDbgSyms (O, F);
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if (fclose (F) != 0) {
|
||||
Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
@ -38,10 +38,6 @@
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
@ -54,9 +50,6 @@ void CreateMapFile (void);
|
||||
void CreateLabelFile (void);
|
||||
/* Create a label file */
|
||||
|
||||
void CreateDbgFile (void);
|
||||
/* Create a debug info file */
|
||||
|
||||
|
||||
|
||||
/* End of mapfile.h */
|
||||
|
@ -91,7 +91,6 @@ typedef enum {
|
||||
CFGTOK_RW,
|
||||
CFGTOK_BSS,
|
||||
CFGTOK_ZP,
|
||||
CFGTOK_WPROT,
|
||||
|
||||
CFGTOK_O65,
|
||||
CFGTOK_BIN,
|
||||
|
@ -99,6 +99,7 @@ static Segment* NewSegment (unsigned Name, unsigned char Type)
|
||||
S->Align = 0;
|
||||
S->FillVal = 0;
|
||||
S->Type = Type;
|
||||
S->ReadOnly = 0;
|
||||
S->Relocatable = 0;
|
||||
S->Dumped = 0;
|
||||
|
||||
@ -331,7 +332,7 @@ int IsBSSType (Segment* S)
|
||||
unsigned long Count = F->Size;
|
||||
while (Count--) {
|
||||
if (*Data++ != 0) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (F->Type == FRAG_EXPR || F->Type == FRAG_SEXPR) {
|
||||
@ -602,15 +603,15 @@ void PrintSegmentMap (FILE* F)
|
||||
/* Get a pointer to the segment */
|
||||
S = SegPool [I];
|
||||
|
||||
/* Print empty segments only if explicitly requested */
|
||||
if (VerboseMap || S->Size > 0) {
|
||||
/* Print the segment data */
|
||||
long End = S->PC + S->Size;
|
||||
if (S->Size > 0) {
|
||||
/* Point to last element addressed */
|
||||
--End;
|
||||
}
|
||||
fprintf (F, "%-20s %06lX %06lX %06lX\n",
|
||||
/* Print empty segments only if explicitly requested */
|
||||
if (VerboseMap || S->Size > 0) {
|
||||
/* Print the segment data */
|
||||
long End = S->PC + S->Size;
|
||||
if (S->Size > 0) {
|
||||
/* Point to last element addressed */
|
||||
--End;
|
||||
}
|
||||
fprintf (F, "%-20s %06lX %06lX %06lX\n",
|
||||
GetString (S->Name), S->PC, End, S->Size);
|
||||
}
|
||||
}
|
||||
@ -621,6 +622,32 @@ void PrintSegmentMap (FILE* F)
|
||||
|
||||
|
||||
|
||||
void PrintDbgSegments (FILE* F)
|
||||
/* Output the segments to the debug file */
|
||||
{
|
||||
Segment* S;
|
||||
|
||||
/* Walk over all segments */
|
||||
S = SegRoot;
|
||||
while (S) {
|
||||
|
||||
/* Ignore empty segments */
|
||||
if (S->Size > 0) {
|
||||
|
||||
/* Print the segment data */
|
||||
fprintf (F, "segment\t\"%s\", 0x%06lX, 0x%04lX, %s, %s\n",
|
||||
GetString (S->Name), S->PC, S->Size,
|
||||
SegTypeToStr (S->Type),
|
||||
S->ReadOnly? "ro" : "rw");
|
||||
}
|
||||
|
||||
/* Follow the linked list */
|
||||
S = S->List;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CheckSegments (void)
|
||||
/* Walk through the segment list and check if there are segments that were
|
||||
* not written to the output file. Output an error if this is the case.
|
||||
@ -628,7 +655,7 @@ void CheckSegments (void)
|
||||
{
|
||||
Segment* S = SegRoot;
|
||||
while (S) {
|
||||
if (S->Size > 0 && S->Dumped == 0) {
|
||||
if (S->Size > 0 && S->Dumped == 0) {
|
||||
Error ("Missing memory area assignment for segment `%s'",
|
||||
GetString (S->Name));
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
@ -65,6 +65,7 @@ struct Segment {
|
||||
unsigned char Align; /* Alignment needed */
|
||||
unsigned char FillVal; /* Value to use for fill bytes */
|
||||
unsigned char Type; /* Type of segment */
|
||||
unsigned char ReadOnly; /* True for readonly segments (config) */
|
||||
unsigned char Relocatable; /* True if the segment is relocatable */
|
||||
unsigned char Dumped; /* Did we dump this segment? */
|
||||
};
|
||||
@ -145,6 +146,9 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data);
|
||||
void PrintSegmentMap (FILE* F);
|
||||
/* Print a segment map to the given file */
|
||||
|
||||
void PrintDbgSegments (FILE* F);
|
||||
/* Output the segments to the debug file */
|
||||
|
||||
void CheckSegments (void);
|
||||
/* Walk through the segment list and check if there are segments that were
|
||||
* not written to the output file. Output an error if this is the case.
|
||||
|
Loading…
Reference in New Issue
Block a user