instrumentation

Wrapping a function in Javascript / jQuery

ぃ、小莉子 提交于 2020-01-09 19:30:32
问题 If I have an arbitrary function myFunc , what I'm aiming to do is replace this function with a wrapped call that runs code before and after it executes, e.g. // note: psuedo-javascript var beforeExecute = function() { ... } var afterExecute = function() { ... } myFunc = wrap(myFunc, beforeExecute, afterExecute); However, I don't have an implementation of the required wrap function. Is there anything that already exists in jQuery like this (I've had a good look through the docs but cannot see

getting the number of local variables in a method

微笑、不失礼 提交于 2020-01-05 09:15:37
问题 So I have some classes into which "dummy method calls" have been inserted; i.e. static methods in a dedicated class that have an empty body. The idea is to take the arguments that were pushed to the stack prior to the method invokation, store them in local variables, then replace the method invocation with the actual implementation. To see how locals are handled, I run A.java package asmvisit; public class A { long y; public long doSomething(int x, A a){ if(a == null){ this.y = (long)x;

getting the number of local variables in a method

与世无争的帅哥 提交于 2020-01-05 09:14:42
问题 So I have some classes into which "dummy method calls" have been inserted; i.e. static methods in a dedicated class that have an empty body. The idea is to take the arguments that were pushed to the stack prior to the method invokation, store them in local variables, then replace the method invocation with the actual implementation. To see how locals are handled, I run A.java package asmvisit; public class A { long y; public long doSomething(int x, A a){ if(a == null){ this.y = (long)x;

How to “interleave” C/C++ souce with my string (only inside functions at appropriate places)?

こ雲淡風輕ζ 提交于 2020-01-04 06:59:42
问题 For example, there is the source: void func1() { func3(); if(qqq) { func2(); } func4( ); } It should be transformed to: void func1() { MYMACRO func3(); MYMACRO if(qqq) { MYMACRO func2(); MYMACRO } MYMACRO func4( ); MYMACRO } I.e. to insert "MYMACRO\n" at the end of each line where statement can be, only inside functions. How to do it easily? Should I use regular expressions? What tools should I use? For example, can gcc output all line numbers of all statement begins (or ends) inside

How to “interleave” C/C++ souce with my string (only inside functions at appropriate places)?

落花浮王杯 提交于 2020-01-04 06:59:06
问题 For example, there is the source: void func1() { func3(); if(qqq) { func2(); } func4( ); } It should be transformed to: void func1() { MYMACRO func3(); MYMACRO if(qqq) { MYMACRO func2(); MYMACRO } MYMACRO func4( ); MYMACRO } I.e. to insert "MYMACRO\n" at the end of each line where statement can be, only inside functions. How to do it easily? Should I use regular expressions? What tools should I use? For example, can gcc output all line numbers of all statement begins (or ends) inside

RuntimeException while using ActivityUnitTestCase, but not while ActivityInstrumentationTestCase2

末鹿安然 提交于 2020-01-03 15:56:22
问题 I am trying to test the MainActvity of an Android application with ActivityUnitTestCase. For some reason, I cannot even start the test, because it fails with the following error trace: java.lang.RuntimeException: Exception during suite construction at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)

Creating jarFile to use Instrumentation for calculating Memory usage of an object in Eclipse

你说的曾经没有我的故事 提交于 2020-01-03 02:01:24
问题 I want to calculate the memory usage of my object with help of instrumentation class. I found the this page as a straightforward instruction but I do not know how create a jar file in eclipse with the following setting. Where should I mention these setting during exporting JAR file in eclipse? jar -cmf manifest.txt agent.jar mypackage/MyAgent.class To answer question of @Rodrigo Ribeiro; I try to compile my code through command prompt with command javac MyAgent.java but I got the following

Interception on constructor causes ClassNotFoundException

社会主义新天地 提交于 2020-01-02 10:18:58
问题 I'm trying to intercept constructors annotated with @Inject . That worked fine in the context of a small unit test. However in the context of a DI container like Spring it fails with a ClassNotFoundException . I managed to narrow down on the root cause. Calling getDeclaredConstructors on the instrumented class will trigger this exception. Interestingly enough, if we first create an instance of that class, the problem disappears. For example: public class InterceptConstructorTest { @Test

Embed the existing code of a method in a try-finally block (2)

自作多情 提交于 2020-01-02 07:11:21
问题 Some time ago, I asked in Embed the existing code of a method in a try-finally block how to wrap the body of a method in a try-finally block using ASM. The solution was to visit a label for the try block at the beginning of the method body in visitCode() and to complete the try-finally block when visiting an instruction with a return opcode in visitInsn() . I was aware that the solution won't be working if a method has no return instruction which applies if the method is always leaving with

What to use instead of mudflap with gcc/llvm (for detecting memory access bugs)?

风格不统一 提交于 2020-01-01 09:16:30
问题 It seems that the -fmudflap feature was removed from GCC. Thus my question: what to use instead of it for dynamically analyzing programs for out-of-bound read/writes, uninitialized reads and such issues? (and perhaps as a side question: why was it removed?) The approach of mudflap (instrumentalizing generated code inside the compiler) looks quite elegant. Background Other tools instrumentalize on a machine-code level (e.g. Purify), on a source-code level (e.g. Insure) or instrumentalize