Skip to content

x86 print-imm-data doesn't print all notes

Describe the bug

print-imm-data doesn't print notes for assembler routines or code-constants.

Desktop (please complete the following information):

  • OS: all x86

Additional context

It's hard to tell what is expected here, but the relevant part of the code is

      (or (disassem::maybe-note-nil-indexed-object offset dstate)
	  (let ((unsigned-offset (ldb (byte vm:word-bits 0) value)))
	    (disassem::maybe-note-assembler-routine unsigned-offset stream dstate))
	  (nth-value 1
		     (disassem::note-code-constant-absolute offset
							    dstate)))

The function disassem::maybe-note-nil-indexed-object always returns T, so that the rest of the or clauses are never executed. Does that matter? I'm not sure. A simple test shows that notes for assembler routines like generic-+ are printed. I'm not sure where that's printed; maybe from the displacement argument type?

Also note that the docstring for disassem::maybe-note-nil-indexed-object says

If the memory address located NIL-BYTE-OFFSET bytes from the constant NIL is a valid lisp object, store a note describing which symbol and slot, to be printed as an end-of-line comment after the current instruction is disassembled. Returns non-NIL iff a note was recorded.

AFAICT, there's no check to see if the memory address is a valid lisp object (what does that really mean here?) and the function always returns T.

Not sure the docstring is wrong or if the implementation of disassem::maybe-note-nil-indexed-object is wrong.