mirror of
https://github.com/cc65/cc65.git
synced 2025-08-12 17:25:11 +00:00
Allow access to segment information.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4796 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -2376,6 +2376,55 @@ void cc65_free_filelist (cc65_dbginfo Handle, cc65_filelist* List)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cc65_segmentlist* cc65_get_segmentlist (cc65_dbginfo Handle)
|
||||||
|
/* Return a list of all segments referenced in the debug information */
|
||||||
|
{
|
||||||
|
DbgInfo* Info;
|
||||||
|
Collection* SegInfoByName;
|
||||||
|
cc65_segmentlist* D;
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Check the parameter */
|
||||||
|
assert (Handle != 0);
|
||||||
|
|
||||||
|
/* The handle is actually a pointer to a debug info struct */
|
||||||
|
Info = (DbgInfo*) Handle;
|
||||||
|
|
||||||
|
/* Get a pointer to the file list */
|
||||||
|
SegInfoByName = &Info->SegInfoByName;
|
||||||
|
|
||||||
|
/* Allocate memory for the data structure returned to the caller */
|
||||||
|
D = xmalloc (sizeof (*D) - sizeof (D->data[0]) +
|
||||||
|
CollCount (SegInfoByName) * sizeof (D->data[0]));
|
||||||
|
|
||||||
|
/* Fill in the data */
|
||||||
|
D->count = CollCount (SegInfoByName);
|
||||||
|
for (I = 0; I < CollCount (SegInfoByName); ++I) {
|
||||||
|
|
||||||
|
/* Get this item */
|
||||||
|
SegInfo* S = CollAt (SegInfoByName, I);
|
||||||
|
|
||||||
|
/* Copy the data */
|
||||||
|
D->data[I].name = S->SegName;
|
||||||
|
D->data[I].start = S->Start;
|
||||||
|
D->data[I].end = S->Start + S->Size - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the result */
|
||||||
|
return D;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cc65_free_segmentlist (cc65_dbginfo Handle, cc65_segmentlist* List)
|
||||||
|
/* Free a file list returned by cc65_get_filelist() */
|
||||||
|
{
|
||||||
|
/* Just for completeness, check the handle */
|
||||||
|
assert (Handle != 0);
|
||||||
|
|
||||||
|
/* Just free the memory */
|
||||||
|
xfree (List);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -101,6 +101,19 @@ struct cc65_filelist {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* A list of segments with some information */
|
||||||
|
typedef struct cc65_segmentlist cc65_segmentlist;
|
||||||
|
struct cc65_segmentlist {
|
||||||
|
unsigned count; /* Number of data sets that follow */
|
||||||
|
struct {
|
||||||
|
const char* name; /* Name of the file */
|
||||||
|
cc65_addr start; /* Start address of segment */
|
||||||
|
cc65_addr end; /* End address of segment */
|
||||||
|
} data[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -138,6 +151,12 @@ cc65_filelist* cc65_get_filelist (cc65_dbginfo handle);
|
|||||||
void cc65_free_filelist (cc65_dbginfo handle, cc65_filelist* list);
|
void cc65_free_filelist (cc65_dbginfo handle, cc65_filelist* list);
|
||||||
/* free a file list returned by cc65_get_filelist() */
|
/* free a file list returned by cc65_get_filelist() */
|
||||||
|
|
||||||
|
cc65_segmentlist* cc65_get_segmentlist (cc65_dbginfo handle);
|
||||||
|
/* Return a list of all segments referenced in the debug information */
|
||||||
|
|
||||||
|
void cc65_free_segmentlist (cc65_dbginfo handle, cc65_segmentlist* list);
|
||||||
|
/* Free a file list returned by cc65_get_filelist() */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of dbginfo.h */
|
/* End of dbginfo.h */
|
||||||
|
@@ -63,12 +63,13 @@ static void Usage (void)
|
|||||||
|
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
const char* Input;
|
const char* Input;
|
||||||
cc65_dbginfo Info;
|
cc65_dbginfo Info;
|
||||||
cc65_filelist* Files;
|
cc65_filelist* Files;
|
||||||
cc65_lineinfo* L;
|
cc65_segmentlist* Segments;
|
||||||
unsigned I;
|
cc65_lineinfo* L;
|
||||||
unsigned long Addr;
|
unsigned I;
|
||||||
|
unsigned long Addr;
|
||||||
|
|
||||||
|
|
||||||
/* Input file is argument */
|
/* Input file is argument */
|
||||||
@@ -93,6 +94,17 @@ int main (int argc, char** argv)
|
|||||||
}
|
}
|
||||||
cc65_free_filelist (Info, Files);
|
cc65_free_filelist (Info, Files);
|
||||||
|
|
||||||
|
/* Output a list of segments */
|
||||||
|
printf ("Segments processed when linking:\n");
|
||||||
|
Segments = cc65_get_segmentlist (Info);
|
||||||
|
for (I = 0; I < Segments->count; ++I) {
|
||||||
|
printf (" %-20s $%06lX-$%06lX\n",
|
||||||
|
Segments->data[I].name,
|
||||||
|
(unsigned long) Segments->data[I].start,
|
||||||
|
(unsigned long) Segments->data[I].end);
|
||||||
|
}
|
||||||
|
cc65_free_segmentlist (Info, Segments);
|
||||||
|
|
||||||
/* Check one line */
|
/* Check one line */
|
||||||
printf ("Requesting line info for crt0.s(59):\n");
|
printf ("Requesting line info for crt0.s(59):\n");
|
||||||
L = cc65_lineinfo_byname (Info, "crt0.s", 59);
|
L = cc65_lineinfo_byname (Info, "crt0.s", 59);
|
||||||
|
Reference in New Issue
Block a user