Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
1b27941a by Raymond Toy at 2021-03-22T20:00:49-07:00
Fix up headings for issue templates
The headings used to be `**foo**`, but it's better to use `## foo`.
The old headings would cause the following paragraph to be appended to
the heading. Thus
```
## foo
Text
```
became
```
foo Text
```
with "foo" in bold.
With the new markup, this doesn't happen.
- - - - -
5c92c14c by Raymond Toy at 2021-03-23T03:34:19+00:00
Merge branch 'fixup-template-headings' into 'master'
Fix up headings for issue templates
See merge request cmucl/cmucl!73
- - - - -
20de3e8e by Jon Boone at 2021-04-09T20:59:59+00:00
adds additional keyword arguments to instance-usage for more fine-grained tracking of space allocation
- - - - -
68e97641 by Raymond Toy at 2021-04-09T21:00:00+00:00
Merge branch 'org.cmucl.debug.dynamic-space' into 'master'
adding additional keyword arguments to instance-usage ....
See merge request cmucl/cmucl!74
- - - - -
73d6de93 by Raymond Toy at 2021-04-10T11:03:40-07:00
Fix #105: Include build logs in artifacts
Include the build logs in the artifacts so we can examine the logs to
see what happened when a build fails.
- - - - -
8e4a873c by Raymond Toy at 2021-04-10T21:24:37+00:00
Merge branch 'issue-105-add-build-logs' into 'master'
Fix #105: Include build logs in artifacts
Closes #105
See merge request cmucl/cmucl!75
- - - - -
7a6c5d35 by Raymond Toy at 2021-04-12T19:45:30-07:00
Merge branch 'master' into issue-97-define-ud2-inst
- - - - -
f3218ee0 by Raymond Toy at 2021-04-12T20:07:53-07:00
Address review comments.
- - - - -
10 changed files:
- .gitlab-ci.yml
- .gitlab/issue_templates/Bug.md
- .gitlab/issue_templates/Feature.md
- src/code/room.lisp
- src/code/x86-vm.lisp
- src/compiler/x86/insts.lisp
- src/compiler/x86/macros.lisp
- src/i18n/locale/cmucl.pot
- src/lisp/x86-arch.c
- src/lisp/x86-assem.S
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -33,6 +33,9 @@ linux:build:
artifacts:
paths:
- dist/
+ - linux-2/*.log
+ - linux-3/*.log
+ - linux-4/*.log
needs:
- job: linux:install
artifacts: true
@@ -117,6 +120,9 @@ osx:build:
artifacts:
paths:
- dist/
+ - darwin-2/*.log
+ - darwin-3/*.log
+ - darwin-4/*.log
needs:
- job: osx:install
artifacts: true
=====================================
.gitlab/issue_templates/Bug.md
=====================================
@@ -1,24 +1,24 @@
-**Describe the bug**
+## Describe the bug
A clear and concise description of what the bug is.
-**To Reproduce**
+## To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
-**Expected behavior**
+## Expected behavior
A clear and concise description of what you expected to happen.
-**Screenshots**
+## Screenshots
If applicable, add screenshots to help explain your problem.
-**Desktop (please complete the following information):**
+## Desktop (please complete the following information):
- OS: [e.g. Linux]
- Version [e.g. 21c]
-**Additional context**
+## Additional context
Add any other context about the problem here.
/label ~bug
=====================================
.gitlab/issue_templates/Feature.md
=====================================
@@ -1,10 +1,10 @@
-**Describe the feature**
+## Describe the feature
Briefly describe the feature you would like see.
-**Is there a prototype?**
+## Is there a prototype?
If you have a prototype, provide links to illustrate this addition. This is the best way to propose a new feature.
-**Describe the feature in more detail**
+## Describe the feature in more detail
Provide more information to describe the feature.
/label ~feature
=====================================
src/code/room.lisp
=====================================
@@ -707,11 +707,24 @@
;;; INSTANCE-USAGE -- Public
;;;
-(defun instance-usage (space &key (top-n 15))
- (declare (type spaces space) (type (or fixnum null) top-n))
- "Print a breakdown by instance type of all the instances allocated in
- Space. If TOP-N is true, print only information for the the TOP-N types with
- largest usage."
+(defun instance-usage (space &key
+ (top-n 15)
+ entries-var
+ (call-source "Unknown Caller"))
+ "Print a breakdown by instance type of all the allocation in Space.
+
+ :TOP-N
+ If true, print only the TOP-N types by largest usage.
+
+ :ENTRIES-VAR
+ If bound, contains the name of the symbol used to store the hash-table
+ of allocated entries for later processing.
+
+ :CALL-SOURCE
+ A string identifying the location from which instance-usage was called."
+
+ (declare (type spaces space) (type (or fixnum null) top-n)
+ (type (or symbol null) entries-var) (type string call-source))
(format t (intl:gettext "~2&~@[Top ~D ~]~(~A~) instance types:~%") top-n space)
(let ((totals (make-hash-table :test #'eq))
(total-objects 0)
@@ -734,6 +747,10 @@
space)
(collect ((totals-list))
+ ;; set entries-var to the list of entries in totals
+ (when entries-var
+ (setf (symbol-value entries-var) (list call-source totals)))
+
(maphash #'(lambda (class what)
(totals-list (cons (prin1-to-string
(class-proper-name class))
=====================================
src/code/x86-vm.lisp
=====================================
@@ -237,18 +237,15 @@
(with-alien ((scp (* unix:sigcontext) scp))
(let ((pc (sigcontext-program-counter scp)))
(declare (type system-area-pointer pc))
- ;; The pc should point to the start of the UD2 instruction. So we have something like:
+ ;; The pc should point to the start of the UD1 instruction. So we have something like:
;; offset contents
- ;; 0 UD2
- ;; 2 code
+ ;; 0 UD1 (contains the trap code)
;; 3 length
;; 4 bytes
(let* ((length (sap-ref-8 pc 3))
(vector (make-array length :element-type '(unsigned-byte 8))))
(declare (type (unsigned-byte 8) length)
(type (simple-array (unsigned-byte 8) (*)) vector))
- #+nil
- (format t "internal-error-args scp ~A: pc ~X len ~D~%" scp pc length)
;; Grab the length bytes after the length byte.
(copy-from-system-area pc (* vm:byte-bits 4)
vector (* vm:word-bits
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -1778,7 +1778,7 @@
(disassem:define-instruction-format
(bit-test-reg/mem 24
:default-printer '(:name :tab reg/mem ", " reg))
- (prefix :field (byte 8 0) :value #b0001111)
+ (prefix :field (byte 8 0) :value #b0001111)
(op :field (byte 8 8))
;;(test :fields (list (byte 2 14) (byte 3 8)))
(reg/mem :fields (list (byte 2 22) (byte 3 16))
@@ -2064,9 +2064,9 @@
;; 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 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. Using
+;; just reg/mem, the register sometimes printed out as a byte reg and
+;; I (toy.raymond) don't know why.
(disassem:define-instruction-format
(ud1 24 :default-printer '(:name :tab reg ", " reg/mem))
(prefix :field (byte 8 0) :value #b00001111)
@@ -2150,12 +2150,6 @@
(ldb (byte 3 3) code)
(ldb (byte 3 0) code))))
-#+nil
-(define-instruction ud2 (segment)
- (:emitter
- (emit-byte segment #b00001111)
- (emit-byte segment #b00001011)))
-
(define-instruction int (segment number)
(:declare (type (unsigned-byte 8) number))
(:printer byte-imm ((op #b11001101)))
=====================================
src/compiler/x86/macros.lisp
=====================================
@@ -254,8 +254,8 @@
`(let ((tn ,tn))
(write-var-integer
(make-sc-offset (sc-number (tn-sc tn))
- ;; tn-offset is zero for constant tns.
- (or (tn-offset tn) 0))
+ ;; tn-offset is zero for constant tns.
+ (or (tn-offset tn) 0))
,vector)))
values)
(let ((,length (length ,vector)))
=====================================
src/i18n/locale/cmucl.pot
=====================================
@@ -6333,10 +6333,19 @@ msgstr ""
#: src/code/room.lisp
msgid ""
-"Print a breakdown by instance type of all the instances allocated in\n"
-" Space. If TOP-N is true, print only information for the the TOP-N types "
-"with\n"
-" largest usage."
+"Print a breakdown by instance type of all the allocation in Space. \n"
+"\n"
+" :TOP-N \n"
+" If true, print only the TOP-N types by largest usage.\n"
+"\n"
+" :ENTRIES-VAR\n"
+" If bound, contains the name of the symbol used to store the hash-table"
+"\n"
+" of allocated entries for later processing.\n"
+"\n"
+" :CALL-SOURCE\n"
+" A string identifying the location from which instance-usage was "
+"called."
msgstr ""
#: src/code/room.lisp
=====================================
src/lisp/x86-arch.c
=====================================
@@ -220,14 +220,13 @@ arch_set_pseudo_atomic_interrupted(os_context_t * context)
unsigned long
arch_install_breakpoint(void *pc)
{
- unsigned char* ptr = (unsigned char *) pc;
- unsigned long result = *ptr;
+ unsigned long result = (unsigned char *) pc;
DPRINTF(debug_handlers,
(stderr, "arch_install_breakpoint at %p, old code = 0x%lx\n",
pc, result));
- *ptr = BREAKPOINT_INST; /* x86 INT3 */
+ *(unsigned char *) pc = BREAKPOINT_INST;
return result;
}
@@ -237,11 +236,11 @@ arch_remove_breakpoint(void *pc, unsigned long orig_inst)
DPRINTF(debug_handlers,
(stderr, "arch_remove_breakpoint: %p orig %lx\n",
pc, orig_inst));
- unsigned char *ptr = (unsigned char *) pc;
+
/*
* Just restore the byte from orig_inst.
*/
- ptr[0] = orig_inst & 0xff;
+ *(unsigned char *) pc = orig_inst & 0xff;
}
=====================================
src/lisp/x86-assem.S
=====================================
@@ -300,13 +300,6 @@ multiple_value_return:
.globl GNAME(function_end_breakpoint_trap)
GNAME(function_end_breakpoint_trap):
- /*
- ud1 0(%ecx), %ecx
- ud1 %ecx, %edx
- .byte 0x0f
- .byte 0xb9
- .byte 0xc0 + trap_PendingInterrupt
- */
TRAP_CODE(trap_FunctionEndBreakpoint)
hlt # Should never return here.
ENDFUNC(function_end_breakpoint_trap)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/85639e3dde6341cc4e171c…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/85639e3dde6341cc4e171c…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
73d6de93 by Raymond Toy at 2021-04-10T11:03:40-07:00
Fix #105: Include build logs in artifacts
Include the build logs in the artifacts so we can examine the logs to
see what happened when a build fails.
- - - - -
8e4a873c by Raymond Toy at 2021-04-10T21:24:37+00:00
Merge branch 'issue-105-add-build-logs' into 'master'
Fix #105: Include build logs in artifacts
Closes #105
See merge request cmucl/cmucl!75
- - - - -
1 changed file:
- .gitlab-ci.yml
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -33,6 +33,9 @@ linux:build:
artifacts:
paths:
- dist/
+ - linux-2/*.log
+ - linux-3/*.log
+ - linux-4/*.log
needs:
- job: linux:install
artifacts: true
@@ -117,6 +120,9 @@ osx:build:
artifacts:
paths:
- dist/
+ - darwin-2/*.log
+ - darwin-3/*.log
+ - darwin-4/*.log
needs:
- job: osx:install
artifacts: true
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/68e9764118c8f4b743d5b0…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/68e9764118c8f4b743d5b0…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
85639e3d by Raymond Toy at 2021-04-10T10:51:31-07:00
Aargh. Really fix the problem.
Can't use `#.(format...)` because `code` is defined. Have to generate
the string at run-time.
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2126,7 +2126,7 @@
(nt #.(format nil "Trap ~D: Function end breakpoint trap"
vm:function-end-breakpoint-trap)))
(t
- (nt #.(format nil "Trap ~D: Unexpected trap type!!!!" code)))))))
+ (nt (format nil "Trap ~D: Unexpected trap type!!!!" code)))))))
;; The ud1 instruction where we smash the code (trap type) into the
;; low 6 bits of the mod r/m byte. The mod bits are set to #b11 to
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/85639e3dde6341cc4e171c4…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/85639e3dde6341cc4e171c4…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
73ea938d by Raymond Toy at 2021-04-10T10:32:26-07:00
Forgot to print out the code for the unexpected trap
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2126,7 +2126,7 @@
(nt #.(format nil "Trap ~D: Function end breakpoint trap"
vm:function-end-breakpoint-trap)))
(t
- (nt #.(format nil "Trap ~D: Unexpected trap type!!!!" )))))))
+ (nt #.(format nil "Trap ~D: Unexpected trap type!!!!" code)))))))
;; The ud1 instruction where we smash the code (trap type) into the
;; low 6 bits of the mod r/m byte. The mod bits are set to #b11 to
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/73ea938d5b32c7bf2069c69…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/73ea938d5b32c7bf2069c69…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
62d67c1e by Raymond Toy at 2021-04-10T09:24:32-07:00
More cleanups
When installing a breakpoint, we only need to save the single byte.
When removing a breakpoint, we only need to restore the single byte.
- - - - -
1 changed file:
- src/lisp/x86-arch.c
Changes:
=====================================
src/lisp/x86-arch.c
=====================================
@@ -213,17 +213,21 @@ arch_set_pseudo_atomic_interrupted(os_context_t * context)
+/*
+ * Installs a breakpoint (INT3) at |pc|. We return the byte that was
+ * replaced by the int3 instruction.
+ */
unsigned long
arch_install_breakpoint(void *pc)
{
unsigned char* ptr = (unsigned char *) pc;
- unsigned long result = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
+ unsigned long result = *ptr;
DPRINTF(debug_handlers,
(stderr, "arch_install_breakpoint at %p, old code = 0x%lx\n",
pc, result));
- *(char *) pc = BREAKPOINT_INST; /* x86 INT3 */
+ *ptr = BREAKPOINT_INST; /* x86 INT3 */
return result;
}
@@ -235,14 +239,9 @@ arch_remove_breakpoint(void *pc, unsigned long orig_inst)
pc, orig_inst));
unsigned char *ptr = (unsigned char *) pc;
/*
- * Just restore all the bytes from orig_inst. Should we just
- * re-install just the one byte that was taken by the int3
- * instruction?
+ * Just restore the byte from orig_inst.
*/
ptr[0] = orig_inst & 0xff;
- ptr[1] = (orig_inst >> 8) & 0xff;
- ptr[2] = (orig_inst >> 16) & 0xff;
- ptr[3] = (orig_inst >> 24) & 0xff;
}
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/62d67c1ed634686a0bc1ac5…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/62d67c1ed634686a0bc1ac5…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
9a86d9f0 by Raymond Toy at 2021-04-10T08:42:04-07:00
Change disassembly note for trap codes
Minor tweak to print the trap number first before the description of
the trap.
- - - - -
9b09c6d9 by Raymond Toy at 2021-04-10T08:50:17-07:00
Add comments
- - - - -
46620f56 by Raymond Toy at 2021-04-10T09:15:38-07:00
Address review comments and add more comments
Fixed up a few things mentioned in the review.
Add a more comments on how things work, and added a TODO on computing
the instruction length and inserting a int3/ud1 after it, kind of like
how other archs handle it.
- - - - -
2 changed files:
- src/compiler/x86/insts.lisp
- src/lisp/x86-arch.c
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2110,32 +2110,39 @@
(defun ud1-control (chunk inst stream dstate)
(declare (ignore inst))
(flet ((nt (x) (if stream (disassem:note x dstate))))
- (case (ldb (byte 6 16) chunk)
- (#.vm:error-trap
- (nt #.(format nil "Error trap: ~D" vm:error-trap))
- (disassem:handle-break-args #'snarf-error-junk stream dstate))
- (#.vm:cerror-trap
- (nt #.(format nil "Cerror trap: ~D" vm:cerror-trap))
- (disassem:handle-break-args #'snarf-error-junk stream dstate))
- (#.vm:breakpoint-trap
- (nt #.(format nil "Breakpoint trap: ~D" vm:breakpoint-trap)))
- (#.vm:pending-interrupt-trap
- (nt #.(format nil "Pending interrupt trap: ~D" vm:pending-interrupt-trap)))
- (#.vm:halt-trap
- (nt #.(format nil "Halt trap: ~D" vm:halt-trap)))
- (#.vm:function-end-breakpoint-trap
- (nt #.(format nil "Function end breakpoint trap: ~D" vm:function-end-breakpoint-trap)))
- )))
+ (let ((code (ldb (byte 6 16) chunk)))
+ (case code
+ (#.vm:error-trap
+ (nt #.(format nil "Trap ~D: Error trap" vm:error-trap))
+ (disassem:handle-break-args #'snarf-error-junk stream dstate))
+ (#.vm:cerror-trap
+ (nt #.(format nil "Trap ~D: Cerror trap" vm:cerror-trap))
+ (disassem:handle-break-args #'snarf-error-junk stream dstate))
+ (#.vm:pending-interrupt-trap
+ (nt #.(format nil "Trap ~D: Pending interrupt trap" vm:pending-interrupt-trap)))
+ (#.vm:halt-trap
+ (nt #.(format nil "Trap ~D: Halt trap" vm:halt-trap)))
+ (#.vm:function-end-breakpoint-trap
+ (nt #.(format nil "Trap ~D: Function end breakpoint trap"
+ vm:function-end-breakpoint-trap)))
+ (t
+ (nt #.(format nil "Trap ~D: Unexpected trap type!!!!" )))))))
;; The ud1 instruction where we smash the code (trap type) into the
-;; mod r/m byte. We don't care about what that actually encodes to.
-;; We just want the trap code in the third byte of the instruction.
+;; low 6 bits of the mod r/m byte. The mod bits are set to #b11 to
+;; make sure the reg/mem part is interpreted to be a register and not
+;; memory.
(define-instruction ud1 (segment code)
(:declare (type (unsigned-byte 8) code))
(:printer ud1 ((op #b10111001) (reg nil :type 'word-reg))
:default
:control #'ud1-control)
(:emitter
+ ;; We should not be using the breakpoint trap with UD1 anymore.
+ ;; Breakpoint traps are handled in C now, using plain int3.
+ (assert (/= code vm:breakpoint-trap))
+
+ ;; Emit the bytes of the instruction.
(emit-byte segment #x0f)
(emit-byte segment #xb9)
(emit-mod-reg-r/m-byte segment
=====================================
src/lisp/x86-arch.c
=====================================
@@ -260,6 +260,23 @@ unsigned int single_step_save2;
unsigned int single_step_save3;
#endif
+/*
+ * This is called when we need to continue after a breakpoint. This
+ * works by putting the original byte back into the code, and then
+ * enabling single-step mode to step one instruction. When we return,
+ * the instruction will get run and a sigtrap will get triggered when
+ * the one instruction is done.
+ *
+ * TODO: Be more like other archs where the original inst is put back,
+ * and the next inst is replaced with a afterBreakpoint trap. When we
+ * run, the afterBreakpoint trap is hit at the next instruction and
+ * then we can put back the original breakpoint and replace the
+ * afterBreakpoint trap with the original inst there too.
+ *
+ * For x86, this means computing how many bytes are used in the
+ * current instruction, and then placing an int3 (or maybe ud1) after
+ * it.
+ */
void
arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst)
{
@@ -273,7 +290,7 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst)
* Put the original instruction back.
*/
- *((char *) pc) = orig_inst & 0xff;
+ *pc = orig_inst & 0xff;
/*
* If we have the SC_EFLAGS macro, we can enable single-stepping
@@ -318,9 +335,8 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst)
/*
- * Handles the break instruction from lisp, which is now UD2 followed
- * by the trap code. In particular, this does not handle the
- * breakpoint traps.
+ * Handles the ud1 instruction from lisp that is used to signal
+ * errors. In particular, this does not handle the breakpoint traps.
*/
void
sigill_handler(HANDLER_ARGS)
@@ -351,10 +367,10 @@ sigill_handler(HANDLER_ARGS)
RESTORE_FPU(os_context);
/*
- * On entry %eip points just after the INT3 byte and aims at the
- * 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a
- * number of bytes will follow, the first is the length of the byte
- * arguments to follow.
+ * On entry %eip points just to the beginning of the UD1
+ * instruction. For error-trap and cerror-trap a number of bytes
+ * will follow, the first is the length of the byte arguments to
+ * follow.
*/
DPRINTF(debug_handlers,
@@ -459,7 +475,13 @@ sigtrap_handler(HANDLER_ARGS)
*((unsigned char*)SC_PC(context) + 3),
*(unsigned char*)(SC_PC(context) + 4)));
- if (single_stepping && (signal == SIGTRAP)) {
+ if (single_stepping) {
+ /*
+ * We were single-stepping so we now need to disable
+ * single-stepping. We want to put back the breakpoint (int3)
+ * instruction so that the next time the breakpoint will be
+ * hit again as expected.
+ */
DPRINTF(debug_handlers, (stderr, "* Single step trap %p\n", single_stepping));
#ifdef SC_EFLAGS
@@ -492,6 +514,9 @@ sigtrap_handler(HANDLER_ARGS)
return;
}
+ /*
+ * We weren't single-stepping, so this we've just hit the breakpoint (int3). Handle it.
+ */
DPRINTF(debug_handlers, (stderr, "*C break\n"));
/*
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/cfb35624edee9113a81d90…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/cfb35624edee9113a81d90…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
cfb35624 by Raymond Toy at 2021-04-09T16:14:44-07:00
Modify UD1 inst so it prints out registers correctly
Hack the definition of the ud1 instruction format so that the reg/mem
field is really a word register. This then makes the pending
interrupt trap print out as "ud1 ecx, ecx" instead of "ud1 ecx, cl".
I don't know why the printer wanted to print cl, but `print-reg` was
passing `:byte` as the size (from the dstate `'width`).
This works around the issue.
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2062,13 +2062,20 @@
(code :field (byte 8 8)))
+;; 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 reg. Using just
+;; reg/mem, the register sometimes printed out as a byte reg and I
+;; (toy.raymond) don't know why.
(disassem:define-instruction-format
(ud1 24 :default-printer '(:name :tab reg ", " reg/mem))
(prefix :field (byte 8 0) :value #b00001111)
(op :field (byte 8 8) :value #b10111001)
- (reg/mem :fields (list (byte 2 22) (byte 3 16))
- :type 'reg/mem)
- (reg :field (byte 3 19) :type 'word-reg))
+ ;; The mod bits ensure that the reg/mem field is interpreted as a
+ ;; register, not memory.
+ (reg/mem :field (byte 3 16) :type 'word-reg)
+ (reg :field (byte 3 19) :type 'word-reg)
+ (mod :field (byte 2 22) :value #b11))
(defun snarf-error-junk (sap offset &optional length-only)
(let* ((length (system:sap-ref-8 sap offset))
@@ -2125,7 +2132,7 @@
;; We just want the trap code in the third byte of the instruction.
(define-instruction ud1 (segment code)
(:declare (type (unsigned-byte 8) code))
- (:printer ud1 ((op #b10111001))
+ (:printer ud1 ((op #b10111001) (reg nil :type 'word-reg))
:default
:control #'ud1-control)
(:emitter
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/cfb35624edee9113a81d900…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/cfb35624edee9113a81d900…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
40fff139 by Raymond Toy at 2021-04-09T14:14:52-07:00
Use TRAP_CODE to insert the desired traps
- - - - -
3adaeb13 by Raymond Toy at 2021-04-09T14:15:50-07:00
Correctly extract the trap code from the instruction stream.
The code is in the low 6 bits. Need to ignore everything else when
extracting it.
Verified that function end breakpoints now work again instead of
getting a sigill error because of an unknown code.
- - - - -
2 changed files:
- src/lisp/x86-arch.c
- src/lisp/x86-assem.S
Changes:
=====================================
src/lisp/x86-arch.c
=====================================
@@ -369,7 +369,12 @@ sigill_handler(HANDLER_ARGS)
* trap code?
*/
if (*(unsigned short *) SC_PC(context) == 0xb90f) {
- trap = *(((char *)SC_PC(context)) + 2);
+ /*
+ * This must match what the lisp code is doing. The trap
+ * number is placed in the low 6-bits of the 3rd byte of the
+ * instruction.
+ */
+ trap = *(((char *)SC_PC(context)) + 2) & 63;
} else {
abort();
}
=====================================
src/lisp/x86-assem.S
=====================================
@@ -18,6 +18,16 @@
#include "internals.h"
#include "lispregs.h"
+/*
+ * Emit the appropriate instruction used for implementing traps.
+ * Currently, this is the UD1 instruction. However, it make it
+ * easy to add the trap code, use a sequence of bytes. The code
+ * is smashed into the mod r/m byte with the mod bits set to
+ * #b11. This MUST be coordinated with the Lisp code and the C
+ * code.
+ *
+ * Also, clang doesn't recognize the ud1 instruction.
+ */
#define TRAP_CODE(code) \
.byte 0x0f ; \
.byte 0xb9 ; \
@@ -249,10 +259,7 @@ ENDFUNC(sse_restore)
* The undefined-function trampoline.
*/
FUNCDEF(undefined_tramp)
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte trap_Error
+ TRAP_CODE(trap_Error)
/* Number of argument bytes */
.byte 2
.byte UNDEFINED_SYMBOL_ERROR
@@ -300,40 +307,28 @@ GNAME(function_end_breakpoint_trap):
.byte 0xb9
.byte 0xc0 + trap_PendingInterrupt
*/
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte 0xc0 + trap_FunctionEndBreakpoint
+ TRAP_CODE(trap_FunctionEndBreakpoint)
hlt # Should never return here.
+ENDFUNC(function_end_breakpoint_trap)
.globl GNAME(function_end_breakpoint_end)
GNAME(function_end_breakpoint_end):
-
FUNCDEF(do_pending_interrupt)
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte trap_PendingInterrupt
+ TRAP_CODE(trap_PendingInterrupt)
ret
ENDFUNC(do_pending_interrupt)
#ifdef trap_DynamicSpaceOverflowError
FUNCDEF(do_dynamic_space_overflow_error)
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte trap_DynamicSpaceOverflowError
+ TRAP_CODE(trap_DynamicSpaceOverflowError)
ret
ENDFUNC(do_dynamic_space_overflow_error)
#endif
#ifdef trap_DynamicSpaceOverflowWarning
FUNCDEF(do_dynamic_space_overflow_warning)
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte trap_DynamicSpaceOverflowWarning
+ TRAP_CODE(trap_DynamicSpaceOverflowWarning)
ret
ENDFUNC(do_dynamic_space_overflow_warning)
#endif
@@ -515,10 +510,7 @@ FUNCDEF(undefined_foreign_symbol_trap)
movl 8(%ebp),%eax
/* Now trap to Lisp */
- # UD1
- .byte 0x0f
- .byte 0xb9
- .byte trap_Error
+ TRAP_CODE(trap_Error)
/* Number of argument bytes */
.byte 2
.byte UNDEFINED_FOREIGN_SYMBOL_ERROR
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/93d7cf02396314c79a176f…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/93d7cf02396314c79a176f…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
20de3e8e by Jon Boone at 2021-04-09T20:59:59+00:00
adds additional keyword arguments to instance-usage for more fine-grained tracking of space allocation
- - - - -
68e97641 by Raymond Toy at 2021-04-09T21:00:00+00:00
Merge branch 'org.cmucl.debug.dynamic-space' into 'master'
adding additional keyword arguments to instance-usage ....
See merge request cmucl/cmucl!74
- - - - -
2 changed files:
- src/code/room.lisp
- src/i18n/locale/cmucl.pot
Changes:
=====================================
src/code/room.lisp
=====================================
@@ -707,11 +707,24 @@
;;; INSTANCE-USAGE -- Public
;;;
-(defun instance-usage (space &key (top-n 15))
- (declare (type spaces space) (type (or fixnum null) top-n))
- "Print a breakdown by instance type of all the instances allocated in
- Space. If TOP-N is true, print only information for the the TOP-N types with
- largest usage."
+(defun instance-usage (space &key
+ (top-n 15)
+ entries-var
+ (call-source "Unknown Caller"))
+ "Print a breakdown by instance type of all the allocation in Space.
+
+ :TOP-N
+ If true, print only the TOP-N types by largest usage.
+
+ :ENTRIES-VAR
+ If bound, contains the name of the symbol used to store the hash-table
+ of allocated entries for later processing.
+
+ :CALL-SOURCE
+ A string identifying the location from which instance-usage was called."
+
+ (declare (type spaces space) (type (or fixnum null) top-n)
+ (type (or symbol null) entries-var) (type string call-source))
(format t (intl:gettext "~2&~@[Top ~D ~]~(~A~) instance types:~%") top-n space)
(let ((totals (make-hash-table :test #'eq))
(total-objects 0)
@@ -734,6 +747,10 @@
space)
(collect ((totals-list))
+ ;; set entries-var to the list of entries in totals
+ (when entries-var
+ (setf (symbol-value entries-var) (list call-source totals)))
+
(maphash #'(lambda (class what)
(totals-list (cons (prin1-to-string
(class-proper-name class))
=====================================
src/i18n/locale/cmucl.pot
=====================================
@@ -6333,10 +6333,19 @@ msgstr ""
#: src/code/room.lisp
msgid ""
-"Print a breakdown by instance type of all the instances allocated in\n"
-" Space. If TOP-N is true, print only information for the the TOP-N types "
-"with\n"
-" largest usage."
+"Print a breakdown by instance type of all the allocation in Space. \n"
+"\n"
+" :TOP-N \n"
+" If true, print only the TOP-N types by largest usage.\n"
+"\n"
+" :ENTRIES-VAR\n"
+" If bound, contains the name of the symbol used to store the hash-table"
+"\n"
+" of allocated entries for later processing.\n"
+"\n"
+" :CALL-SOURCE\n"
+" A string identifying the location from which instance-usage was "
+"called."
msgstr ""
#: src/code/room.lisp
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/5c92c14c7a8497c7f6bf86…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/5c92c14c7a8497c7f6bf86…
You're receiving this email because of your account on gitlab.common-lisp.net.