mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
outdbg: add %pragma for maximum size of a raw data dump
A raw data dump can potentially be very large, especially when incbin is used. Allow a %pragma for setting the maximum dump size (defaults to 128 bytes.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
ac06133ed2
commit
17df43c8f2
@ -77,3 +77,4 @@ uppercase ; outieee, outobj
|
||||
; --- Pragma operations
|
||||
subsections_via_symbols ; macho
|
||||
no_dead_strip ; macho
|
||||
maxdump ; dbg
|
||||
|
@ -6217,11 +6217,6 @@ a hint as to where to find requested symbols.
|
||||
|
||||
\H{dbgfmt} \i\c{dbg}: Debugging Format
|
||||
|
||||
The \c{dbg} output format is not built into NASM in the default
|
||||
configuration. If you are building your own NASM executable from the
|
||||
sources, you can define \i\c{OF_DBG} in \c{output/outform.h} or on the
|
||||
compiler command line, and obtain the \c{dbg} output format.
|
||||
|
||||
The \c{dbg} format does not output an object file as such; instead,
|
||||
it outputs a text file which contains a complete list of all the
|
||||
transactions between the main body of NASM and the output-format
|
||||
@ -6262,6 +6257,15 @@ yourself (using \c{EXTERN}, for example) if you really need to get a
|
||||
\c{dbg} accepts any section name and any directives at all, and logs
|
||||
them all to its output file.
|
||||
|
||||
\c{dbg} accepts and logs any \c{%pragma}, but the specific
|
||||
\c{%pragma}:
|
||||
|
||||
\c %pragma dbg maxdump <size>
|
||||
|
||||
where \c{<size>} is either a number or \c{unlimited}, can be used to
|
||||
control the maximum size for dumping the full contents of a
|
||||
\c{rawdata} output object.
|
||||
|
||||
|
||||
\C{16bit} Writing 16-bit Code (DOS, Windows 3/3.1)
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nasm.h"
|
||||
#include "nasmlib.h"
|
||||
@ -170,7 +171,7 @@ static void dbg_out(const struct out_data *data)
|
||||
fprintf(ofile, " ins %s(%d)",
|
||||
nasm_insn_names[data->itemp->opcode], data->itemp->operands);
|
||||
} else {
|
||||
fprintf(ofile, " (data)");
|
||||
fprintf(ofile, " no ins (plain data)");
|
||||
}
|
||||
|
||||
if (data->type == OUT_ADDRESS || data->type == OUT_RELADDR ||
|
||||
@ -304,6 +305,13 @@ dbg_directive(enum directives directive, char *value, int pass)
|
||||
return DIRR_OK;
|
||||
}
|
||||
|
||||
static enum directive_result
|
||||
dbg_pragma(const struct pragma *pragma);
|
||||
|
||||
static const struct pragma_facility dbg_pragma_list[] = {
|
||||
{ NULL, dbg_pragma }
|
||||
};
|
||||
|
||||
static enum directive_result
|
||||
dbg_pragma(const struct pragma *pragma)
|
||||
{
|
||||
@ -313,6 +321,26 @@ dbg_pragma(const struct pragma *pragma)
|
||||
pragma->opname, directive_name(pragma->opcode),
|
||||
pragma->tail);
|
||||
|
||||
if (pragma->facility == &dbg_pragma_list[0] &&
|
||||
pragma->opcode == D_MAXDUMP) {
|
||||
if (!nasm_stricmp(pragma->tail, "unlimited")) {
|
||||
dbg_max_data_dump = -1UL;
|
||||
} else {
|
||||
char *ep;
|
||||
unsigned long arg;
|
||||
|
||||
errno = 0;
|
||||
arg = strtoul(pragma->tail, &ep, 0);
|
||||
if (errno || *nasm_skip_spaces(ep)) {
|
||||
nasm_error(ERR_WARNING | ERR_WARN_BAD_PRAGMA | ERR_PASS2,
|
||||
"invalid %%pragma dbg maxdump argument");
|
||||
return DIRR_ERROR;
|
||||
} else {
|
||||
dbg_max_data_dump = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DIRR_OK;
|
||||
}
|
||||
|
||||
@ -385,10 +413,6 @@ static const struct dfmt * const debug_debug_arr[3] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct pragma_facility dbg_pragma_list[] = {
|
||||
{ NULL, dbg_pragma }
|
||||
};
|
||||
|
||||
const struct ofmt of_dbg = {
|
||||
"Trace of all info passed to output stage",
|
||||
"dbg",
|
||||
|
Loading…
Reference in New Issue
Block a user