Skip to content

Commit fe9586f

Browse files
author
H. Peter Anvin (Intel)
committed
listing: separate "user" and "debug" flag, add matching debug option
Adding information about the NASM internal state to the list file can be useful for debugging purposes. Separate the list of options that are "user" options and those that are "debugging" options. The latter are not implied by -L+ and are intended for NASM developer use. Introduce -LX, which lists which instruction patterns are matched by each instruction. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
1 parent a4c5b28 commit fe9586f

4 files changed

Lines changed: 27 additions & 4 deletions

File tree

asm/assemble.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,17 @@ static void out_eops(struct out_data *data, const extop *e)
872872
/* This is totally just a wild guess what is reasonable... */
873873
#define INCBIN_MAX_BUF (ZERO_BUF_SIZE * 16)
874874

875+
static void
876+
list_add_template_info(const insn *ins, const struct itemplate *temp)
877+
{
878+
char *buf;
879+
(void)ins;
880+
881+
buf = nasm_asprintf(" ;;; matched insns.xda:%u", temp->xdaline);
882+
lfmt->line(LIST_INFO, -1, buf);
883+
nasm_free(buf);
884+
}
885+
875886
static int64_t assemble(insn *instruction)
876887
{
877888
struct out_data data;
@@ -1012,6 +1023,9 @@ static int64_t assemble(insn *instruction)
10121023

10131024
if (m >= MOK_GOOD) {
10141025
/* Matches! */
1026+
if (list_option('X'))
1027+
list_add_template_info(instruction, temp);
1028+
10151029
if (unlikely(itemp_has(temp, IF_OBSOLETE))) {
10161030
errflags warning;
10171031
const char *whathappened;

asm/listing.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,15 @@ static inline const_func uint64_t list_option_mask_val(unsigned char x)
136136

137137
static inline const_func uint64_t list_option_mask(unsigned char x)
138138
{
139-
if (x == '+')
140-
return ~(list_option_mask_val('w') | 3);
141-
else
139+
if (x == '+') {
140+
const char *p = "bdefFmps";
141+
uint64_t v = 0;
142+
while (*p)
143+
v |= list_option_mask_val(*p++);
144+
return v;
145+
} else {
142146
return list_option_mask_val(x);
147+
}
143148
}
144149

145150
/* Return true if the listing engine is active and a certain option is set. */

asm/nasm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,7 @@ static void help(FILE *out, const char *what)
19321932
}
19331933
if (help_is(with, 'L')) {
19341934
fputs(
1935+
" -L flags for general usage:\n"
19351936
" -Lb show builtin macro packages (standard and %use)\n"
19361937
" -Ld show byte and repeat counts in decimal, not hex\n"
19371938
" -Le show the preprocessed output\n"
@@ -1940,8 +1941,10 @@ static void help(FILE *out, const char *what)
19401941
" -Lm show multi-line macro calls with expanded parameters\n"
19411942
" -Lp output a list file every pass, in case of errors\n"
19421943
" -Ls show all single-line macro definitions\n"
1944+
" -L+ enable all of the above listing options (very verbose!)\n"
1945+
" -L flags intended for debugging NASM:\n"
19431946
" -Lw flush the output after every line (very slow!)\n"
1944-
" -L+ enable all listing options except -Lw (very verbose!)\n"
1947+
" -LX list instruction pattern line numbers from insns.xda\n"
19451948
, out);
19461949
}
19471950
if (help_optor(with, 'O')) {

include/nasm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ static inline char *nasm_skip_identifier(const char *str)
526526
enum {
527527
LIST_READ,
528528
LIST_MACRO,
529+
LIST_INFO,
529530
LIST_INCLUDE,
530531
LIST_INCBIN,
531532
LIST_TIMES

0 commit comments

Comments
 (0)