// Creates and inserts a probe (from InstrumentationRecord) public ProbeInterface generateProbe( String _id, String _desc, BytecodeLocation _loc, java.util.Map _params) { System.out.println("ZTestProbeType: generateProbe"); // Get a string from the user... String s1 = "ProbeString:"; SimpleProbe sp = null; try { StatementList sl = BytecodeInsertionMgr.createStatementList(_loc); StatementFactory.createStubProbe_SimpleCallStmt(sl, "TestProbe", "print"); // Embed line that includes parameter so it can be referenced when displaying probe info // StatementFactory.createMetadataStmt(sl, "v:"+s1+s); String id = "SP" + idCount++; // generate a new id, to ensure no replicates. sp = new SimpleProbe(id, _desc, pt, sl, _loc); // Still need to generate a record of this action InstrumentationRecord ir = new InstrumentationRecord_Probe(id, _desc, pt, _loc, (Map) null); // This could be a separate method call BytecodeInsertionMgr.insertProbe(sp, ir); com.objs.surveyor.probemeister.Log.out.fine("PrintStringProbeType: Added probe."); } catch (Exception e) { System.out.println("Error creating probe."); e.printStackTrace(); return null; } return sp; }
/* Method for probe creation. Create a probe and inserts it into the * specified location. */ public ProbeInterface generateProbe(Location _loc) { if (!(_loc instanceof BytecodeLocation)) { System.out.println( "ZTestProbeType: Incorrect Location type used for bytecode probe creation."); return null; } System.out.println("ZTestProbeType: generateProbe"); // Get a string from the user... String s1 = "ProbeString:"; /// System.out.println("ZTestProbeType: Asking user for String:"); /// String s = javax.swing.JOptionPane.showInputDialog("Enter a string for this probe to // print:"); SimpleProbe sp = null; try { StatementList sl = BytecodeInsertionMgr.createStatementList((BytecodeLocation) _loc); StatementFactory.createStubProbe_SimpleCallStmt(sl, "TestProbe", "print"); // Embed line that includes parameter so it can be referenced when displaying probe info // StatementFactory.createMetadataStmt(sl, "v:"+s1+s); String id = "SP" + idCount++; String desc = "This probe calls TestProbe"; sp = new SimpleProbe(id, desc, pt, sl, (BytecodeLocation) _loc); InstrumentationRecord ir = new InstrumentationRecord_Probe(id, desc, pt, (BytecodeLocation) _loc, (Map) null); // This could be a separate method call BytecodeInsertionMgr.insertProbe(sp, ir); System.out.println("ZTestProbeType: Added probe."); } catch (Exception e) { System.out.println("Error creating probe."); e.printStackTrace(); return null; } return sp; }