1 /* outdbg.c output routines for the Netwide Assembler to produce
4 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
5 * Julian Hall. All rights reserved. The software is
6 * redistributable under the licence given in the file "Licence"
7 * distributed in the NASM archive.
24 int segcode
,segdata
,segbss
;
26 static void dbg_init(FILE *fp
, efunc errfunc
, ldfunc ldef
)
31 segcode
= seg_alloc();
32 segdata
= seg_alloc();
34 fprintf(fp
,"NASM Output format debug dump - code=%d,data=%d,bss=%d\n",
35 segcode
,segdata
,segbss
);
38 static void dbg_cleanup(void)
43 static long dbg_section_names (char *name
, int pass
, int *bits
)
46 * We must have an initial default: let's make it 16.
54 if (!strcmp(name
, ".text"))
56 else if (!strcmp(name
, ".data"))
58 else if (!strcmp(name
, ".bss"))
64 static void dbg_deflabel (char *name
, long segment
, long offset
,
66 fprintf(dbgf
,"deflabel %s := %08lx:%08lx %s (%d)\n",name
,segment
,offset
,
67 is_global
? "global" : "local", is_global
);
70 static void dbg_out (long segto
, void *data
, unsigned long type
,
71 long segment
, long wrt
) {
72 long realbytes
= type
& OUT_SIZMASK
;
78 fprintf(dbgf
,"out to %lx, len = %ld: ",segto
,realbytes
);
82 fprintf(dbgf
,"reserved.\n"); break;
84 fprintf(dbgf
,"raw data = ");
86 id
= *(unsigned char *)data
;
87 data
= (char *)data
+ 1;
88 fprintf(dbgf
,"%02x ",id
);
90 fprintf(dbgf
,"\n"); break;
92 ldata
= 0; /* placate gcc */
94 ldata
= *((char *)data
);
95 else if (realbytes
== 2)
96 ldata
= *((short *)data
);
97 else if (realbytes
== 4)
98 ldata
= *((long *)data
);
99 fprintf(dbgf
,"addr %08lx (seg %08lx, wrt %08lx)\n",ldata
,
102 fprintf(dbgf
,"rel2adr %04x (seg %08lx)\n",(int)*(short *)data
,segment
);
105 fprintf(dbgf
,"rel4adr %08lx (seg %08lx)\n",*(long *)data
,segment
);
108 fprintf(dbgf
,"unknown\n");
113 static long dbg_segbase(long segment
) {
117 static int dbg_directive (char *directive
, char *value
, int pass
) {
121 static void dbg_filename (char *inname
, char *outname
, efunc error
) {
122 standard_extension (inname
, outname
, ".dbg", error
);
125 struct ofmt of_dbg
= {
126 "Trace of all info passed to output stage",