diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-07-18 21:07:17 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-07-18 18:43:12 -0700 |
commit | 9bd1506d5999d7c41a4cf6de2f43b97939bb260e (patch) | |
tree | d3dad5bda2b167af7dfe29cad7cb532406ddb1c4 /output/outdbg.c | |
parent | 159178f2aa516718fcb420a281c17adc8b330492 (diff) | |
download | nasm-9bd1506d5999d7c41a4cf6de2f43b97939bb260e.tar.gz |
Remove function pointers in output, simplify error handling
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value. Also make "ofile" a global
variable and let the backend use it directly.
All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.
Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally. That lets us
use direct calls to it.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'output/outdbg.c')
-rw-r--r-- | output/outdbg.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/output/outdbg.c b/output/outdbg.c index 96c110bd..891bc17b 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -56,19 +56,11 @@ struct Section { char *name; } *dbgsect; -FILE *dbgf; -efunc dbgef; - struct ofmt of_dbg; -static void dbg_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval) +static void dbg_init(void) { - (void)eval; - - dbgf = fp; - dbgef = errfunc; dbgsect = NULL; - (void)ldef; - fprintf(fp, "NASM Output format debug dump\n"); + fprintf(ofile, "NASM Output format debug dump\n"); } static void dbg_cleanup(int debuginfo) @@ -94,7 +86,7 @@ static int32_t dbg_section_names(char *name, int pass, int *bits) *bits = 16; if (!name) - fprintf(dbgf, "section_name on init: returning %d\n", + fprintf(ofile, "section_name on init: returning %d\n", seg = seg_alloc()); else { int n = strcspn(name, " \t"); @@ -112,7 +104,7 @@ static int32_t dbg_section_names(char *name, int pass, int *bits) s->number = seg = seg_alloc(); s->next = dbgsect; dbgsect = s; - fprintf(dbgf, "section_name %s (pass %d): returning %d\n", + fprintf(ofile, "section_name %s (pass %d): returning %d\n", name, pass, seg); } } @@ -122,7 +114,7 @@ static int32_t dbg_section_names(char *name, int pass, int *bits) static void dbg_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { - fprintf(dbgf, "deflabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n", + fprintf(ofile, "deflabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n", name, segment, offset, is_global == 2 ? "common" : is_global ? "global" : "local", is_global, special ? ": " : "", special); @@ -135,41 +127,41 @@ static void dbg_out(int32_t segto, const void *data, int32_t ldata; int id; - fprintf(dbgf, "out to %"PRIx32", len = %"PRIu64": ", segto, size); + fprintf(ofile, "out to %"PRIx32", len = %"PRIu64": ", segto, size); switch (type) { case OUT_RESERVE: - fprintf(dbgf, "reserved.\n"); + fprintf(ofile, "reserved.\n"); break; case OUT_RAWDATA: - fprintf(dbgf, "raw data = "); + fprintf(ofile, "raw data = "); while (size--) { id = *(uint8_t *)data; data = (char *)data + 1; - fprintf(dbgf, "%02x ", id); + fprintf(ofile, "%02x ", id); } - fprintf(dbgf, "\n"); + fprintf(ofile, "\n"); break; case OUT_ADDRESS: ldata = *(int64_t *)data; - fprintf(dbgf, "addr %08"PRIx32" (seg %08"PRIx32", wrt %08"PRIx32")\n", ldata, + fprintf(ofile, "addr %08"PRIx32" (seg %08"PRIx32", wrt %08"PRIx32")\n", ldata, segment, wrt); break; case OUT_REL2ADR: - fprintf(dbgf, "rel2adr %04"PRIx16" (seg %08"PRIx32")\n", + fprintf(ofile, "rel2adr %04"PRIx16" (seg %08"PRIx32")\n", (uint16_t)*(int64_t *)data, segment); break; case OUT_REL4ADR: - fprintf(dbgf, "rel4adr %08"PRIx32" (seg %08"PRIx32")\n", + fprintf(ofile, "rel4adr %08"PRIx32" (seg %08"PRIx32")\n", (uint32_t)*(int64_t *)data, segment); break; case OUT_REL8ADR: - fprintf(dbgf, "rel8adr %016"PRIx64" (seg %08"PRIx32")\n", + fprintf(ofile, "rel8adr %016"PRIx64" (seg %08"PRIx32")\n", (uint64_t)*(int64_t *)data, segment); break; default: - fprintf(dbgf, "unknown\n"); + fprintf(ofile, "unknown\n"); break; } } @@ -181,14 +173,14 @@ static int32_t dbg_segbase(int32_t segment) static int dbg_directive(enum directives directive, char *value, int pass) { - fprintf(dbgf, "directive [%s] value [%s] (pass %d)\n", + fprintf(ofile, "directive [%s] value [%s] (pass %d)\n", directives[directive], value, pass); return 1; } -static void dbg_filename(char *inname, char *outname, efunc error) +static void dbg_filename(char *inname, char *outname) { - standard_extension(inname, outname, ".dbg", error); + standard_extension(inname, outname, ".dbg"); } static int dbg_set_info(enum geninfo type, char **val) @@ -201,13 +193,9 @@ static int dbg_set_info(enum geninfo type, char **val) char *types[] = { "unknown", "label", "byte", "word", "dword", "float", "qword", "tbyte" }; -void dbgdbg_init(struct ofmt *of, void *id, FILE * fp, efunc error) +void dbgdbg_init(void) { - (void)of; - (void)id; - (void)fp; - (void)error; - fprintf(fp, " With debug info\n"); + fprintf(ofile, " With debug info\n"); } static void dbgdbg_cleanup(void) { @@ -215,13 +203,13 @@ static void dbgdbg_cleanup(void) static void dbgdbg_linnum(const char *lnfname, int32_t lineno, int32_t segto) { - fprintf(dbgf, "dbglinenum %s(%"PRId32") := %08"PRIx32"\n", + fprintf(ofile, "dbglinenum %s(%"PRId32") := %08"PRIx32"\n", lnfname, lineno, segto); } static void dbgdbg_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { - fprintf(dbgf, "dbglabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n", + fprintf(ofile, "dbglabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n", name, segment, offset, is_global == 2 ? "common" : is_global ? "global" : "local", @@ -229,7 +217,7 @@ static void dbgdbg_deflabel(char *name, int32_t segment, } static void dbgdbg_define(const char *type, const char *params) { - fprintf(dbgf, "dbgdirective [%s] value [%s]\n", type, params); + fprintf(ofile, "dbgdirective [%s] value [%s]\n", type, params); } static void dbgdbg_output(int output_type, void *param) { @@ -238,7 +226,7 @@ static void dbgdbg_output(int output_type, void *param) } static void dbgdbg_typevalue(int32_t type) { - fprintf(dbgf, "new type: %s(%"PRIX32")\n", + fprintf(ofile, "new type: %s(%"PRIX32")\n", types[TYM_TYPE(type) >> 3], TYM_ELEMENTS(type)); } static struct dfmt debug_debug_form = { |