Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
cb189a54 by Raymond Toy at 2021-04-21T16:41:54-07:00
Address more review comments
* Replace 63 with 0x3f
* Update comment about checking for UD1. We don't abort anymore if
it's not; we just call interrupt_handle_now like we do on other
ports.
- - - - -
1 changed file:
- src/lisp/x86-arch.c
Changes:
=====================================
src/lisp/x86-arch.c
=====================================
@@ -379,12 +379,9 @@ sigill_handler(HANDLER_ARGS)
(stderr, "pc %x\n", *(unsigned short *)SC_PC(context)));
/*
- * Make sure the trapping instruction is UD1. Abort if not.
- *
- * TODO: aborting is probably not the best idea. Could get here
- * from other illegal instructions in, say, C code? Maybe we
- * should call interrupt_handle_now, as we do below for an unknown
- * trap code?
+ * If the trapping instruction is UD1, assume it's a Lisp trap
+ * that we handle here. Otherwise, just call interrupt_handle_now
+ * for other cases.
*/
if (memcmp((void *)SC_PC(context), ud1, sizeof(ud1)) == 0) {
/*
@@ -392,7 +389,7 @@ sigill_handler(HANDLER_ARGS)
* number is placed in the low 6-bits of the 3rd byte of the
* instruction.
*/
- trap = *(((char *)SC_PC(context)) + 2) & 63;
+ trap = *(((char *)SC_PC(context)) + 2) & 0x3f;
DPRINTF(debug_handlers, (stderr, "code = %x\n", trap));
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/cb189a54e2903e942da595d…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/cb189a54e2903e942da595d…
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:
7e2339c4 by Raymond Toy at 2021-04-13T22:43:12-07:00
Make int3 inst print out as int3
Previously, the instruction was printed as "int 3", but now it prints
as "int3" as we would expect.
(But note that the Solaris assembler doesn't like int3; you have to
use "int 3".)
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2164,7 +2164,7 @@
(:declare (type (unsigned-byte 8) number))
(:printer byte-imm ((op #b11001101)))
(:printer byte ((op #b11001100))
- `(:name :tab 3))
+ `(:name 3))
(:emitter
(etypecase number
((member 3)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7e2339c4bfc189d6c89ee17…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7e2339c4bfc189d6c89ee17…
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:
ae94d97a by Raymond Toy at 2021-04-13T22:34:46-07:00
Update the int instruction to disassemble int3
The int instruction would accept a code of 3 but would produce an int3
instruction. However, the disassembly of this wasn't working since
the printer expected the opcode to be #b11001101 which didn't match
what was generated. Hence, add a new printer to print int3 as "int
3".
Tested this by setting a breakpoint and disassembling the function to
see that the breakpoint is printed as "int 3" instead ".byte #xcc".
(Should we really make a separate int3 instruction?)
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2154,9 +2154,17 @@
(ldb (byte 3 3) code)
(ldb (byte 3 0) code))))
+;; Handles both int and int3. To get int3 you have to say (inst int
+;; 3). But int3 should not be used in Lisp code. This is mainly so
+;; that int3 gets disassembled correctly if a breakpoint has been set
+;; in Lisp code. (But in general the disassembly will be messed up
+;; because the following byte will in general be the second byte of
+;; some instruction, and not the first byte of an instruction.)
(define-instruction int (segment number)
(:declare (type (unsigned-byte 8) number))
(:printer byte-imm ((op #b11001101)))
+ (:printer byte ((op #b11001100))
+ `(:name :tab 3))
(:emitter
(etypecase number
((member 3)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/ae94d97a06968206d030fe9…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/ae94d97a06968206d030fe9…
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:
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/5ad119295e582f11d709a28…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/5ad119295e582f11d709a28…
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:
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.