]>
git.saurik.com Git - apple/boot.git/blob - i386/nasm/outdbg.c
099d5e565ad5c815980b5f04c3158ed03631fcca
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* outdbg.c output routines for the Netwide Assembler to produce
28 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
29 * Julian Hall. All rights reserved. The software is
30 * redistributable under the licence given in the file "Licence"
31 * distributed in the NASM archive.
54 static void dbg_init(FILE *fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
60 fprintf(fp
,"NASM Output format debug dump\n");
63 static void dbg_cleanup(void)
66 struct Section
*tmp
= dbgsect
;
67 dbgsect
= dbgsect
->next
;
68 nasm_free (tmp
->name
);
74 static long dbg_section_names (char *name
, int pass
, int *bits
)
79 * We must have an initial default: let's make it 16.
85 fprintf(dbgf
, "section_name on init: returning %d\n",
88 int n
= strcspn(name
, " \t");
89 char *sname
= nasm_strndup(name
, n
);
93 for (s
= dbgsect
; s
; s
= s
->next
)
94 if (!strcmp(s
->name
, sname
))
98 s
= nasm_malloc(sizeof(*s
));
100 s
->number
= seg
= seg_alloc();
103 fprintf(dbgf
, "section_name %s (pass %d): returning %d\n",
110 static void dbg_deflabel (char *name
, long segment
, long offset
,
111 int is_global
, char *special
) {
112 fprintf(dbgf
,"deflabel %s := %08lx:%08lx %s (%d)%s%s\n",
113 name
, segment
, offset
,
114 is_global
== 2 ? "common" : is_global
? "global" : "local",
116 special
? ": " : "", special
);
119 static void dbg_out (long segto
, void *data
, unsigned long type
,
120 long segment
, long wrt
) {
121 long realbytes
= type
& OUT_SIZMASK
;
127 fprintf(dbgf
,"out to %lx, len = %ld: ",segto
,realbytes
);
131 fprintf(dbgf
,"reserved.\n"); break;
133 fprintf(dbgf
,"raw data = ");
134 while (realbytes
--) {
135 id
= *(unsigned char *)data
;
136 data
= (char *)data
+ 1;
137 fprintf(dbgf
,"%02x ",id
);
139 fprintf(dbgf
,"\n"); break;
141 ldata
= 0; /* placate gcc */
143 ldata
= *((char *)data
);
144 else if (realbytes
== 2)
145 ldata
= *((short *)data
);
146 else if (realbytes
== 4)
147 ldata
= *((long *)data
);
148 fprintf(dbgf
,"addr %08lx (seg %08lx, wrt %08lx)\n",ldata
,
151 fprintf(dbgf
,"rel2adr %04x (seg %08lx)\n",(int)*(short *)data
,segment
);
154 fprintf(dbgf
,"rel4adr %08lx (seg %08lx)\n",*(long *)data
,segment
);
157 fprintf(dbgf
,"unknown\n");
162 static long dbg_segbase(long segment
) {
166 static int dbg_directive (char *directive
, char *value
, int pass
) {
167 fprintf(dbgf
, "directive [%s] value [%s] (pass %d)\n",
168 directive
, value
, pass
);
172 static void dbg_filename (char *inname
, char *outname
, efunc error
) {
173 standard_extension (inname
, outname
, ".dbg", error
);
176 struct ofmt of_dbg
= {
177 "Trace of all info passed to output stage",