author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 17 Feb 2021 15:24:09 +0100 | |
branch | jv |
changeset 4568 | 524471ef6575 |
parent 4384 | e28fcaaf93c7 |
permissions | -rw-r--r-- |
4384
e28fcaaf93c7
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
3128
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
e28fcaaf93c7
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
3128
diff
changeset
|
2 |
|
2299 | 3 |
" |
4 |
COPYRIGHT (c) 2010 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libbasic3' }" |
|
15 |
||
16 |
Array variableSubclass:#TraceBuffer |
|
17 |
instanceVariableNames:'accessLock writeIndex' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Debugging-Support' |
|
21 |
! |
|
22 |
||
2308 | 23 |
!TraceBuffer class methodsFor:'documentation'! |
2299 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2010 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
"Created: / 30-11-2010 / 16:21:33 / cg" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
simple round robin tracebuffer for system debugging. |
|
44 |
" |
|
45 |
||
46 |
"Created: / 30-11-2010 / 16:21:57 / cg" |
|
47 |
! |
|
48 |
||
49 |
examples |
|
50 |
" |
|
51 |
|buffer| |
|
52 |
||
53 |
buffer := self new:100. |
|
54 |
buffer dumpLast:5 on:Transcript. |
|
55 |
buffer trace:1. |
|
56 |
buffer trace:2. |
|
57 |
buffer trace:3. |
|
58 |
buffer dumpLast:5 on:Transcript. |
|
59 |
buffer trace:4. |
|
60 |
buffer trace:5. |
|
61 |
buffer dumpLast:5 on:Transcript. |
|
62 |
buffer trace:6. |
|
63 |
buffer trace:7. |
|
64 |
buffer trace:8. |
|
65 |
buffer dumpLast:5 on:Transcript. |
|
66 |
" |
|
67 |
||
68 |
"Created: / 30-11-2010 / 16:11:55 / cg" |
|
69 |
! ! |
|
70 |
||
2308 | 71 |
!TraceBuffer class methodsFor:'instance creation'! |
72 |
||
73 |
new:n |
|
74 |
"return an initialized instance" |
|
75 |
||
76 |
^ (self basicNew:n*2) initialize. |
|
77 |
||
78 |
"Created: / 30-11-2010 / 16:13:25 / cg" |
|
79 |
! ! |
|
80 |
||
2299 | 81 |
!TraceBuffer methodsFor:'dumping'! |
82 |
||
83 |
dumpLast:n on:aStream |
|
84 |
|count idx entry time| |
|
85 |
||
86 |
count := 0. |
|
87 |
idx := writeIndex. |
|
88 |
||
89 |
aStream showCR:'-----------------'. |
|
90 |
[ |
|
91 |
[ count <= n ] whileTrue:[ |
|
92 |
idx == 0 ifTrue:[ |
|
93 |
idx := self size. |
|
94 |
idx == 0 ifTrue:[ ^ self ]. |
|
95 |
]. |
|
96 |
time := self at:idx. |
|
97 |
entry := self at:idx-1. |
|
98 |
entry isNil ifTrue:[^ self ]. |
|
99 |
aStream show:time; show:' '; showCR:entry. |
|
100 |
idx := idx - 2. |
|
101 |
count := count + 1. |
|
102 |
]. |
|
103 |
] ensure:[ |
|
104 |
aStream showCR:'-----------------'. |
|
105 |
] |
|
106 |
||
107 |
"Created: / 30-11-2010 / 16:10:00 / cg" |
|
108 |
! ! |
|
109 |
||
110 |
!TraceBuffer methodsFor:'initialization'! |
|
111 |
||
112 |
initialize |
|
113 |
writeIndex := 0. |
|
114 |
accessLock := Semaphore forMutualExclusion. |
|
115 |
||
116 |
"Created: / 30-11-2010 / 16:06:47 / cg" |
|
117 |
! ! |
|
118 |
||
119 |
!TraceBuffer methodsFor:'tracing'! |
|
120 |
||
121 |
trace:something |
|
122 |
accessLock critical:[ |
|
123 |
writeIndex == self size ifTrue:[ |
|
124 |
writeIndex := 0. |
|
125 |
]. |
|
126 |
self at:writeIndex+1 put:something. |
|
127 |
self at:writeIndex+2 put:(OperatingSystem getMicrosecondTime). |
|
128 |
writeIndex := writeIndex + 2. |
|
129 |
]. |
|
130 |
||
131 |
"Created: / 30-11-2010 / 16:07:52 / cg" |
|
132 |
! ! |
|
133 |
||
134 |
!TraceBuffer class methodsFor:'documentation'! |
|
135 |
||
136 |
version_CVS |
|
4384
e28fcaaf93c7
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
3128
diff
changeset
|
137 |
^ '§Header: /cvs/stx/stx/libbasic3/TraceBuffer.st,v 1.2 2010/12/03 09:08:31 stefan Exp §' |
3012 | 138 |
! |
139 |
||
3121
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
140 |
version_HG |
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
141 |
|
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
142 |
^ '$Changeset: <not expanded> $' |
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
143 |
! |
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
144 |
|
3012 | 145 |
version_SVN |
4384
e28fcaaf93c7
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
3128
diff
changeset
|
146 |
^ '§Id: TraceBuffer.st 1909 2012-03-31 00:14:49Z vranyj1 §' |
3012 | 147 |
! ! |
3121
19723298dd2c
Bugfix: reading of Java class extensions methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3042
diff
changeset
|
148 |