#include "lineinfo.h"
#include "scopes.h"
#include "segments.h"
+#include "span.h"
/* Output version information */
fprintf (F, "version\tmajor=2,minor=0\n");
- /* Output a line with the item numbers so the debug info module is able
+ /* Output a line with the item numbers so the debug info module is able
* to preallocate the required memory.
*/
fprintf (
F,
- "info\tlib=%u,mod=%u,seg=%u,file=%u,scope=%u\n",
+ "info\tlib=%u,file=%u,mod=%u,scope=%u,seg=%u,span=%u\n",
+ FileInfoCount (),
LibraryCount (),
ObjDataCount (),
+ ScopeCount (),
SegmentCount (),
- FileInfoCount (),
- ScopeCount ()
+ SpanCount ()
);
/* Assign the ids to the items */
/* Output line info */
PrintDbgLineInfo (F);
+ /* Output spans */
+ PrintDbgSpans (F);
+
/* Output symbols */
PrintDbgSyms (F);
S->LabelId = ReadVar (F);
}
- /* Read the segment ranges for this scope */
+ /* Read the spans for this scope */
ReadSpans (&S->Spans, F, Obj);
/* Return the new Scope */
void PrintDbgScopes (FILE* F)
/* Output the scopes to a debug info file */
{
- unsigned I, J;
+ unsigned I, J, K;
/* Print scopes from all modules we have linked into the output file */
for (I = 0; I < CollCount (&ObjDataList); ++I) {
GetObjFileName (O), S->Type);
}
- /* Print the size if available */
+ /* Print the size if available */
if (S->Size != 0) {
fprintf (F, ",size=%lu", S->Size);
}
if (SCOPE_HAS_LABEL (S->Flags)) {
fprintf (F, ",sym=%u", O->SymBaseId + S->LabelId);
}
+ /* Print the list of spans for this scope */
+ if (CollCount (&S->Spans) > 0) {
+ const Span* SP = CollConstAt (&S->Spans, 0);
+ fprintf (F, ",span=%u", SP->Id);
+ for (K = 1; K < CollCount (&S->Spans); ++K) {
+ SP = CollConstAt (&S->Spans, K);
+ fprintf (F, "+%u", SP->Id);
+ }
+ }
/* Terminate the output line */
fputc ('\n', F);
/* common */
#include "xmalloc.h"
-/* ld65 */
+/* ld65 */
#include "fileio.h"
#include "objdata.h"
#include "segments.h"
/*****************************************************************************/
-/* Code */
+/* Data */
+/*****************************************************************************/
+
+
+
+/* List of all spans */
+static Collection SpanList = STATIC_COLLECTION_INITIALIZER;
+
+
+
+/*****************************************************************************/
+/* Code */
/*****************************************************************************/
Span* S = xmalloc (sizeof (*S));
/* Initialize the fields */
+ S->Id = CollCount (&SpanList);
S->Seg = Seg;
S->Offs = Offs;
S->Size = Size;
+ /* Remember this span in the global list */
+ CollAppend (&SpanList, S);
+
/* Return the result */
- return S;
+ return S;
}
+unsigned SpanCount (void)
+/* Return the total number of spans */
+{
+ return CollCount (&SpanList);
+}
+
+
+
+void PrintDbgSpans (FILE* F)
+/* Output the spans to a debug info file */
+{
+ /* Walk over all spans */
+ unsigned I;
+ for (I = 0; I < CollCount (&SpanList); ++I) {
+
+ /* Get this span */
+ const Span* S = CollAtUnchecked (&SpanList, I);
+
+ /* Output the data */
+ fprintf (F, "span\tid=%u,seg=%u,start=%lu,size=%lu\n",
+ S->Id, S->Seg->Id, S->Offs, S->Size);
+ }
+}
+
+
+
typedef struct Span Span;
struct Span {
+ unsigned Id; /* Id of the span */
struct Segment* Seg; /* Segment of this span */
unsigned long Offs; /* Offset of span within segment */
unsigned long Size; /* Size of span */
* possible - merge it with adjacent ones that already exist.
*/
+unsigned SpanCount (void);
+/* Return the total number of spans */
+
+void PrintDbgSpans (FILE* F);
+/* Output the spans to a debug info file */
+
/* End of span.h */