Skip to content

Commit eac8733

Browse files
committed
Merge pull request #1 from jon-bell/master
Store debug information to the log
2 parents 473b812 + b6d5960 commit eac8733

9 files changed

Lines changed: 145 additions & 23 deletions

File tree

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/ChroniclerJExportRunner.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public static void export() {
149149
ExportedLog.aLog = Log.aLog;
150150
ExportedLog.aLog_owners = Log.aLog_owners;
151151
ExportedLog.aLog_fill = Log.aLog_fill;
152+
ExportedLog.aLog_debug = Log.aLog_debug;
152153
Log.logsize = 0;
153154
Log.aLog = new Object[Constants.DEFAULT_LOG_SIZE];
154155
Log.aLog_fill = 0;
@@ -211,6 +212,16 @@ public static void exportSerializable() {
211212
ExportedSerializableLog.cLog_owners = SerializableLog.cLog_owners;
212213
ExportedSerializableLog.sLog_owners = SerializableLog.sLog_owners;
213214

215+
ExportedSerializableLog.aLog_debug = SerializableLog.aLog_debug;
216+
ExportedSerializableLog.iLog_debug = SerializableLog.iLog_debug;
217+
ExportedSerializableLog.jLog_debug = SerializableLog.jLog_debug;
218+
ExportedSerializableLog.fLog_debug = SerializableLog.fLog_debug;
219+
ExportedSerializableLog.dLog_debug = SerializableLog.dLog_debug;
220+
ExportedSerializableLog.bLog_debug = SerializableLog.bLog_debug;
221+
ExportedSerializableLog.zLog_debug = SerializableLog.zLog_debug;
222+
ExportedSerializableLog.cLog_debug = SerializableLog.cLog_debug;
223+
ExportedSerializableLog.sLog_debug = SerializableLog.sLog_debug;
224+
214225
SerializableLog.aLog = new Object[Constants.DEFAULT_LOG_SIZE];
215226
SerializableLog.iLog = new int[Constants.DEFAULT_LOG_SIZE];
216227
SerializableLog.jLog = new long[Constants.DEFAULT_LOG_SIZE];
@@ -229,6 +240,15 @@ public static void exportSerializable() {
229240
SerializableLog.zLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
230241
SerializableLog.cLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
231242
SerializableLog.sLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
243+
SerializableLog.aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
244+
SerializableLog.iLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
245+
SerializableLog.jLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
246+
SerializableLog.fLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
247+
SerializableLog.dLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
248+
SerializableLog.bLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
249+
SerializableLog.zLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
250+
SerializableLog.cLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
251+
SerializableLog.sLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
232252
SerializableLog.logsize = 0;
233253
SerializableLog.iLog_fill = 0;
234254
SerializableLog.jLog_fill = 0;

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/ExportedLog.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33

44
import java.util.HashMap;
55

6+
67
public class ExportedLog {
78
public static Object[] aLog = new Object[Constants.DEFAULT_LOG_SIZE];
89

910
public static String[] aLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
1011

12+
public static String[] aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
13+
14+
1115
public static int aLog_fill;
1216

1317
public static int globalReplayIndex = 0;
@@ -17,6 +21,7 @@ public class ExportedLog {
1721
public static void clearLog() {
1822
aLog = new Object[Constants.DEFAULT_LOG_SIZE];
1923
aLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
24+
aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
2025
aLog_fill = 0;
2126
globalReplayIndex = 0;
2227
}

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/ExportedSerializableLog.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,30 @@ public class ExportedSerializableLog implements Serializable {
7171
public static String[] cLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
7272

7373
public static String[] sLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
74+
75+
public static String[] aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
76+
77+
public static String[] iLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
78+
79+
public static String[] jLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
80+
81+
public static String[] fLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
82+
83+
public static String[] dLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
84+
85+
public static String[] bLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
86+
87+
public static String[] zLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
88+
89+
public static String[] cLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
90+
91+
public static String[] sLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
7492

7593
public static void clearLog() {
7694
aLog = new Serializable[Constants.DEFAULT_LOG_SIZE];
7795
aLog_fill = 0;
96+
aLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
97+
aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
7898
}
7999

80100
private void writeObject(ObjectOutputStream oos) throws IOException {
@@ -107,6 +127,16 @@ private void writeObject(ObjectOutputStream oos) throws IOException {
107127
oos.writeObject(zLog_owners);
108128
oos.writeObject(cLog_owners);
109129
oos.writeObject(sLog_owners);
130+
131+
oos.writeObject(aLog_debug);
132+
oos.writeObject(iLog_debug);
133+
oos.writeObject(jLog_debug);
134+
oos.writeObject(fLog_debug);
135+
oos.writeObject(dLog_debug);
136+
oos.writeObject(bLog_debug);
137+
oos.writeObject(zLog_debug);
138+
oos.writeObject(cLog_debug);
139+
oos.writeObject(sLog_debug);
110140

111141
}
112142

@@ -140,6 +170,16 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
140170
zLog_owners = (String[]) ois.readObject();
141171
cLog_owners = (String[]) ois.readObject();
142172
sLog_owners = (String[]) ois.readObject();
173+
174+
aLog_debug = (String[]) ois.readObject();
175+
iLog_debug = (String[]) ois.readObject();
176+
jLog_debug = (String[]) ois.readObject();
177+
fLog_debug = (String[]) ois.readObject();
178+
dLog_debug = (String[]) ois.readObject();
179+
bLog_debug = (String[]) ois.readObject();
180+
zLog_debug = (String[]) ois.readObject();
181+
cLog_debug = (String[]) ois.readObject();
182+
sLog_debug = (String[]) ois.readObject();
143183

144184
ExportedSerializableLog.aLog_replayIndex = new HashMap<String, Integer>();
145185
ExportedSerializableLog.iLog_replayIndex = new HashMap<String, Integer>();

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/Instrumenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class Instrumenter {
5555

5656
private static final int PASS_OUTPUT = 1;
5757

58-
public static final boolean IS_DACAPO = true;
58+
public static final boolean IS_DACAPO = false;
5959

6060
private static int pass_number = 0;
6161

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/Log.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public class Log {
99

1010
public static String[] aLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
1111

12+
public static String[] aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
13+
14+
1215
public static Lock logLock = new ReentrantLock();
1316

1417
public static int logsize = 0;
@@ -21,6 +24,7 @@ public static void clearLog() {
2124
logsize = 0;
2225
aLog = new Object[Constants.DEFAULT_LOG_SIZE];
2326
aLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
27+
aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
2428

2529
aLog_fill = 0;
2630

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/SerializableLog.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ public class SerializableLog implements Serializable {
4343

4444
public static String[] sLog_owners = new String[Constants.DEFAULT_LOG_SIZE];
4545

46+
public static String[] aLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
47+
48+
public static String[] iLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
49+
50+
public static String[] jLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
51+
52+
public static String[] fLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
53+
54+
public static String[] dLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
55+
56+
public static String[] bLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
57+
58+
public static String[] zLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
59+
60+
public static String[] cLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
61+
62+
public static String[] sLog_debug = new String[Constants.DEFAULT_LOG_SIZE];
63+
4664
public static int logsize = 0;
4765

4866
public static int aLog_fill, iLog_fill, jLog_fill, fLog_fill, dLog_fill, bLog_fill, zLog_fill,

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/bench/ChroniclerJLogExplorer.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
import java.util.Arrays;
88

99
import edu.columbia.cs.psl.chroniclerj.ExportedSerializableLog;
10+
import edu.columbia.cs.psl.chroniclerj.replay.ReplayRunner;
1011

1112
public class ChroniclerJLogExplorer {
1213
@SuppressWarnings({
1314
"resource", "unused"
1415
})
1516
public static void main(String[] args) throws Exception {
16-
File f = new File("../chroniclerj-test/inst-bin/chroniclerj_serializable_1362003992533.log");
17+
File f = new File(args[0]);
1718
if (!f.exists())
18-
System.err.println("No such fiel");
19-
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
20-
ExportedSerializableLog log = (ExportedSerializableLog) ois.readObject();
21-
Object[] alog = ExportedSerializableLog.aLog;
22-
23-
char[] clog = ExportedSerializableLog.cLog;
24-
byte[] blog = ExportedSerializableLog.bLog;
25-
String[] ownersA = ExportedSerializableLog.aLog_owners;
26-
String[] ownersI = ExportedSerializableLog.iLog_owners;
27-
System.out.println(ExportedSerializableLog.aLog_fill);
28-
System.out.println(ExportedSerializableLog.cLog_fill);
29-
System.out.println(ExportedSerializableLog.dLog_fill);
30-
double[] dlog = ExportedSerializableLog.dLog;
31-
String[] ownersD = ExportedSerializableLog.dLog_owners;
32-
System.out.println(Arrays.toString(dlog));
33-
System.out.println(Arrays.toString(ownersD));
34-
}
19+
System.err.println("No such file");
20+
String[] cp = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
21+
String[] cp2 = new String[cp.length+1];
22+
cp2[0] = f.getAbsolutePath();
23+
System.arraycopy(cp, 0, cp2, 1, cp.length);
24+
ReplayRunner.setupLogs(cp2);
25+
System.out.println("Log of longs:");
26+
for(int i = 0; i < ExportedSerializableLog.jLog_fill; i++)
27+
{
28+
System.out.println("Entry " + i + " value: " + ExportedSerializableLog.jLog[i] + ", debug:" + ExportedSerializableLog.jLog_debug[i]);
29+
}
30+
}
3531
}

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/replay/ReplayRunner.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ private static void _loadNextLog(String logClass) {
7878

7979
private static URLClassLoader loader = null;
8080

81-
public static void _main(String[] classpath) {
82-
if (!new File(classpath[0]).exists()) {
81+
static String mainClass;
82+
static String[] params;
83+
public static void setupLogs(String[] classpath)
84+
{
85+
if (!new File(classpath[0]).exists()) {
8386
System.err.println("Unable to load test case " + classpath[0]);
8487
System.exit(-1);
8588
}
@@ -97,11 +100,11 @@ public static void _main(String[] classpath) {
97100
InputStream inputStream = loader.getResourceAsStream("main-info");
98101

99102
Scanner s = new Scanner(inputStream);
100-
String mainClass = s.nextLine();
103+
mainClass = s.nextLine();
101104
ArrayList<String> _serializableLogs = new ArrayList<String>();
102105
ArrayList<String> _logs = new ArrayList<String>();
103106
int nArgs = Integer.parseInt(s.nextLine());
104-
String[] params = new String[nArgs];
107+
params = new String[nArgs];
105108
int nSerializableLogs = 0;
106109

107110
int nLogs = 0;
@@ -131,6 +134,9 @@ public static void _main(String[] classpath) {
131134
_loadNextLog(Type.getDescriptor(ExportedSerializableLog.class));
132135

133136
_loadNextLog(Type.getDescriptor(ExportedLog.class));
137+
}
138+
public static void _main(String[] classpath) {
139+
setupLogs(classpath);
134140
ReplayUtils.checkForDispatch();
135141
Class<?> toRun;
136142
try {

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/visitor/CloningAdviceAdapter.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,32 @@ protected void logValueAtTopOfStackToArrayNoDup(String logFieldOwner, String log
290290

291291
loadLocal(newArray2);
292292
visitFieldInsn(putOpcode, logFieldOwner, logFieldName + "_owners", "[Ljava/lang/String;");
293+
294+
295+
int newArray3 = lvsorter.newLocal(Type.getType("[Ljava/lang/String;"));
296+
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_debug", "[Ljava/lang/String;");
297+
arrayLength();
298+
visitInsn(Opcodes.I2D);
299+
visitLdcInsn(Constants.LOG_GROWTH_RATE);
300+
visitInsn(Opcodes.DMUL);
301+
visitInsn(Opcodes.D2I);
302+
303+
newArray(Type.getType("Ljava/lang/String;"));
304+
305+
storeLocal(newArray3, Type.getType("[Ljava/lang/String;"));
306+
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_debug", "[Ljava/lang/String;");
307+
visitInsn(Opcodes.ICONST_0);
308+
loadLocal(newArray3);
309+
visitInsn(Opcodes.ICONST_0);
310+
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_debug", "[Ljava/lang/String;");
311+
arrayLength();
312+
visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/System", "arraycopy",
313+
"(Ljava/lang/Object;ILjava/lang/Object;II)V");
314+
315+
// array = newarray
316+
317+
loadLocal(newArray3);
318+
visitFieldInsn(putOpcode, logFieldOwner, logFieldName + "_debug", "[Ljava/lang/String;");
293319

294320
visitLabel(labelForNoNeedToGrow);
295321
// Load this into the end piece of the array
@@ -341,6 +367,13 @@ protected void logValueAtTopOfStackToArrayNoDup(String logFieldOwner, String log
341367

342368
arrayStore(elementType);
343369

370+
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_debug", "[Ljava/lang/String;");
371+
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_fill",
372+
Type.INT_TYPE.getDescriptor());
373+
visitLdcInsn(debug);
374+
arrayStore(Type.getType(String.class));
375+
376+
344377
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_owners", "[Ljava/lang/String;");
345378
visitFieldInsn(getOpcode, logFieldOwner, logFieldName + "_fill",
346379
Type.INT_TYPE.getDescriptor());

0 commit comments

Comments
 (0)