Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl Commits: 5ad11929 by Raymond Toy at 2021-04-13T22:16:26-07:00 Clean up comment and impl In the description of the ud1 format, mention why we can't use ext-reg-reg/mem even though it looks very much like what the ud1 format is. In x86-arch.c, fix typo in arch_install_breakpoint that was setting the result incorrectly (and caused a compiler warning). - - - - - 2 changed files: - src/compiler/x86/insts.lisp - src/lisp/x86-arch.c Changes: ===================================== src/compiler/x86/insts.lisp ===================================== @@ -2064,9 +2064,13 @@ ;; The UD1 instruction. The mod bits of the mod r/m byte MUST be #b11 ;; so that the reg/mem field is actually a register. This is a hack -;; to allow us to print out the reg/mem reg as a 32-bit reg. Using -;; just reg/mem, the register sometimes printed out as a byte reg and -;; I (toy.raymond) don't know why. +;; to allow us to print out the reg/mem reg as a 32-bit reg. +;; +;; While the instruction looks like an ext-reg-reg/mem format with +;; fixed width value of 1, it isn't because we need to disassemble the +;; reg/mem field as a 32-bit reg. ext-reg-reg/mem needs a width prefix +;; byte to specify that, and we definitely don't want that. Hence, +;; use a special instruction format for the UD1 instruction. (disassem:define-instruction-format (ud1 24 :default-printer '(:name :tab reg ", " reg/mem)) (prefix :field (byte 8 0) :value #b00001111) ===================================== src/lisp/x86-arch.c ===================================== @@ -220,13 +220,13 @@ arch_set_pseudo_atomic_interrupted(os_context_t * context) unsigned long arch_install_breakpoint(void *pc) { - unsigned long result = (unsigned char *) pc; + unsigned long result = *(unsigned char *) pc; + *(unsigned char *) pc = BREAKPOINT_INST; DPRINTF(debug_handlers, (stderr, "arch_install_breakpoint at %p, old code = 0x%lx\n", pc, result)); - *(unsigned char *) pc = BREAKPOINT_INST; return result; } View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/5ad119295e582f11d709a28a... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/5ad119295e582f11d709a28a... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy