Mercurial > hg-old > index.cgi
comparison lwasm/debug.c @ 370:6b33faa21a0a
Debugging output and bugfixing pass 0
author | lost@starbug |
---|---|
date | Tue, 20 Apr 2010 21:59:58 -0600 |
parents | |
children | 90de73ba0cac |
comparison
equal
deleted
inserted
replaced
369:898a41f7eb59 | 370:6b33faa21a0a |
---|---|
1 /* | |
2 debug.c | |
3 | |
4 Copyright © 2010 William Astle | |
5 | |
6 This file is part of LWTOOLS. | |
7 | |
8 LWTOOLS is free software: you can redistribute it and/or modify it under the | |
9 terms of the GNU General Public License as published by the Free Software | |
10 Foundation, either version 3 of the License, or (at your option) any later | |
11 version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 more details. | |
17 | |
18 You should have received a copy of the GNU General Public License along with | |
19 this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
22 #include <config.h> | |
23 | |
24 #include <stdio.h> | |
25 #include <string.h> | |
26 | |
27 #include "lwasm.h" | |
28 #include "instab.h" | |
29 | |
30 /* | |
31 | |
32 Various debug utilities | |
33 | |
34 */ | |
35 void dump_state(asmstate_t *as, FILE *fp) | |
36 { | |
37 line_t *cl; | |
38 exportlist_t *ex; | |
39 struct symtabe *s; | |
40 importlist_t *im; | |
41 struct line_expr_s *le; | |
42 lwasm_error_t *e; | |
43 | |
44 fprintf(fp, "Lines:\n"); | |
45 | |
46 for (cl = as -> line_head; cl; cl = cl -> next) | |
47 { | |
48 fprintf(fp, "%p ", cl); | |
49 if (cl -> insn >= 0) | |
50 { | |
51 fprintf(fp, "INSN %d (%s) ", cl -> insn, instab[cl -> insn].opcode); | |
52 fprintf(fp, "LEN %d ", cl -> len); | |
53 } | |
54 fprintf(fp, "\n ADDR:"); | |
55 lw_expr_print(cl -> addr, fp); | |
56 for (le = cl -> exprs; le; le = le -> next) | |
57 { | |
58 fprintf(fp, "\n EXPR %d:", le -> id); | |
59 lw_expr_print(le -> expr, fp); | |
60 } | |
61 if (cl -> outputl > 0) | |
62 { | |
63 int i; | |
64 fprintf(fp, "\n OUTPUT:"); | |
65 for (i = 0; i < cl -> outputl; i++) | |
66 { | |
67 fprintf(fp, "%02X", cl -> output[i]); | |
68 } | |
69 } | |
70 for (e = cl -> err; e; e = e -> next) | |
71 { | |
72 fprintf(fp, "\n ERR: %s", e -> mess); | |
73 } | |
74 for (e = cl -> warn; e; e = e -> next) | |
75 { | |
76 fprintf(fp, "\n WARN: %s", e -> mess); | |
77 } | |
78 fprintf(fp, "\n"); | |
79 } | |
80 } |