]>
git.saurik.com Git - apple/boot.git/blob - i386/nasm/outdbg.c
d7a1af3f779265842eac020ebed87f2aee6f17bf
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
24 /* outdbg.c output routines for the Netwide Assembler to produce
27 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
28 * Julian Hall. All rights reserved. The software is
29 * redistributable under the licence given in the file "Licence"
30 * distributed in the NASM archive.
53 static void dbg_init(FILE *fp
, efunc errfunc
, ldfunc ldef
, evalfunc eval
)
59 fprintf(fp
,"NASM Output format debug dump\n");
62 static void dbg_cleanup(void)
65 struct Section
*tmp
= dbgsect
;
66 dbgsect
= dbgsect
->next
;
67 nasm_free (tmp
->name
);
73 static long dbg_section_names (char *name
, int pass
, int *bits
)
78 * We must have an initial default: let's make it 16.
84 fprintf(dbgf
, "section_name on init: returning %d\n",
87 int n
= strcspn(name
, " \t");
88 char *sname
= nasm_strndup(name
, n
);
92 for (s
= dbgsect
; s
; s
= s
->next
)
93 if (!strcmp(s
->name
, sname
))
97 s
= nasm_malloc(sizeof(*s
));
99 s
->number
= seg
= seg_alloc();
102 fprintf(dbgf
, "section_name %s (pass %d): returning %d\n",
109 static void dbg_deflabel (char *name
, long segment
, long offset
,
110 int is_global
, char *special
) {
111 fprintf(dbgf
,"deflabel %s := %08lx:%08lx %s (%d)%s%s\n",
112 name
, segment
, offset
,
113 is_global
== 2 ? "common" : is_global
? "global" : "local",
115 special
? ": " : "", special
);
118 static void dbg_out (long segto
, void *data
, unsigned long type
,
119 long segment
, long wrt
) {
120 long realbytes
= type
& OUT_SIZMASK
;
126 fprintf(dbgf
,"out to %lx, len = %ld: ",segto
,realbytes
);
130 fprintf(dbgf
,"reserved.\n"); break;
132 fprintf(dbgf
,"raw data = ");
133 while (realbytes
--) {
134 id
= *(unsigned char *)data
;
135 data
= (char *)data
+ 1;
136 fprintf(dbgf
,"%02x ",id
);
138 fprintf(dbgf
,"\n"); break;
140 ldata
= 0; /* placate gcc */
142 ldata
= *((char *)data
);
143 else if (realbytes
== 2)
144 ldata
= *((short *)data
);
145 else if (realbytes
== 4)
146 ldata
= *((long *)data
);
147 fprintf(dbgf
,"addr %08lx (seg %08lx, wrt %08lx)\n",ldata
,
150 fprintf(dbgf
,"rel2adr %04x (seg %08lx)\n",(int)*(short *)data
,segment
);
153 fprintf(dbgf
,"rel4adr %08lx (seg %08lx)\n",*(long *)data
,segment
);
156 fprintf(dbgf
,"unknown\n");
161 static long dbg_segbase(long segment
) {
165 static int dbg_directive (char *directive
, char *value
, int pass
) {
166 fprintf(dbgf
, "directive [%s] value [%s] (pass %d)\n",
167 directive
, value
, pass
);
171 static void dbg_filename (char *inname
, char *outname
, efunc error
) {
172 standard_extension (inname
, outname
, ".dbg", error
);
175 struct ofmt of_dbg
= {
176 "Trace of all info passed to output stage",