diff --git a/nasm.c b/nasm.c index 7a699ef6..fc26bba7 100644 --- a/nasm.c +++ b/nasm.c @@ -85,7 +85,9 @@ static void nasm_verror_vc(int severity, const char *fmt, va_list args); static void nasm_verror_common(int severity, const char *fmt, va_list args); static void usage(void); -static int using_debug_info, opt_verbose_info; +static bool using_debug_info, opt_verbose_info; +static const char *debug_format; + bool tasm_compatible_mode = false; int pass0, passn; int globalrel = 0; @@ -356,11 +358,21 @@ int main(int argc, char **argv) return 1; } - /* If debugging info is disabled, suppress any debug calls */ - if (!using_debug_info) + if (!using_debug_info) { + /* No debug info, redirect to the null backend (empty stubs) */ dfmt = &null_debug_form; - else if (!dfmt) + } else if (!debug_format) { + /* Default debug format for this backend */ dfmt = ofmt->default_dfmt; + } else { + dfmt = dfmt_find(ofmt, debug_format); + if (!dfmt) { + nasm_fatal(ERR_NOFILE | ERR_USAGE, + "unrecognized debug format `%s' for" + " output format `%s'", + debug_format, ofmt->shortname); + } + } if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); @@ -666,7 +678,6 @@ static bool process_arg(char *p, char *q) "unrecognised output format `%s' - " "use -hf for a list", param); } - dfmt = NULL; break; case 'O': /* Optimization level */ @@ -744,14 +755,8 @@ static bool process_arg(char *p, char *q) break; case 'F': /* specify debug format */ - dfmt = dfmt_find(ofmt, param); - if (!dfmt) { - nasm_fatal(ERR_NOFILE | ERR_USAGE, - "unrecognized debug format `%s' for" - " output format `%s'", - param, ofmt->shortname); - } using_debug_info = true; + debug_format = param; break; case 'X': /* specify error reporting format */ @@ -767,6 +772,8 @@ static bool process_arg(char *p, char *q) case 'g': using_debug_info = true; + if (p[2]) + debug_format = nasm_skip_spaces(p + 2); break; case 'h': @@ -775,8 +782,7 @@ static bool process_arg(char *p, char *q) "[-l listfile]\n" " [options...] [--] filename\n" " or nasm -v (or --v) for version info\n\n" - " -t assemble in SciTech TASM compatible mode\n" - " -g generate debug information in selected format\n"); + " -t assemble in SciTech TASM compatible mode\n"); printf (" -E (or -e) preprocess only (writes output to stdout by default)\n" " -a don't preprocess (assemble only)\n" @@ -789,7 +795,9 @@ static bool process_arg(char *p, char *q) " -MP emit phony target\n\n" " -Z redirect error messages to file\n" " -s redirect error messages to stdout\n\n" + " -g generate debugging information\n\n" " -F format select a debugging format\n\n" + " -gformat same as -g -F format\n\n" " -o outfile write output to an outfile\n\n" " -f format select an output format\n\n" " -l listfile write listing to a listfile\n\n" diff --git a/nasm.txt b/nasm.txt index 55f9a05b..a28202f9 100644 --- a/nasm.txt +++ b/nasm.txt @@ -47,7 +47,10 @@ OPTIONS formats, use the *-y* option (for example *-felf -y*). *-g*:: - Causes *nasm* to generate debug information in selected format. + Causes *nasm* to generate debug information. + +*-g*'format':: + Equivalent to **-g -F**__ format__. *-h*:: Causes *nasm* to exit immediately, after giving a summary of its diff --git a/output/outform.c b/output/outform.c index 3d70e2a9..17744bb2 100644 --- a/output/outform.c +++ b/output/outform.c @@ -72,7 +72,7 @@ struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias) return NULL; } -struct dfmt *dfmt_find(struct ofmt *ofmt, char *name) +struct dfmt *dfmt_find(struct ofmt *ofmt, const char *name) { struct dfmt **dfp, *df; diff --git a/output/outform.h b/output/outform.h index f52a112a..e34ef752 100644 --- a/output/outform.h +++ b/output/outform.h @@ -371,7 +371,7 @@ static struct ofmt_alias ofmt_aliases[] = { #endif /* BUILD_DRIVERS_ARRAY */ struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias); -struct dfmt *dfmt_find(struct ofmt *, char *); +struct dfmt *dfmt_find(struct ofmt *, const char *); void ofmt_list(struct ofmt *, FILE *); void dfmt_list(struct ofmt *ofmt, FILE * fp); extern struct dfmt null_debug_form;