Re: Locating where first param of an invoke gets put on the stack
Roberto Andrioli <[email protected]> Sat, 02 Dec 2017 00:11:38 +0000
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CAKJVBvA08xr+dYU7nrMQgNbb+3xT0i9be1S8kMOJGD4AqCRAPQ@mail.gmail.com> |
Hi Jon, You will need to implement a simple symbolic interpreter to know this data flow information. I.e, that the definition of `i` reaches the invoke of the method. I have implemented a simple tool that may help you with that. The tool is available here https://github.com/saeg/asm-defuse. I have no documentation (shame on me). I implemented it for data flow testing coverage, but I think that it may be useful for you needs. Best regards Roberto On Fri, Dec 1, 2017, 2:02 PM Jon Sawyer <[email protected]> wrote: > I want to thank everyone who worked on asm, such a wonderful framework. I > wish I had found it earlier, it would have saved me so much time. I have a > bad habit of reinventing the wheel when I need something, trying to avoid > that here if possible. Really hoping ASM contains some feature that could > make this easier. > > I'd like to inject some code prior to the first param of an invoke* is put > on the stack. My problem here is locating when the first param (or "sub > param" enters the stack); > > If it is something like > > Log.print("hello","world"); > --- > ldc #29 // String TAG > ldc #31 // String MSG > 15: invokestatic #37 // Method > logg/loggl/Log.print:(Ljava/lang/String;Ljava/lang/String;)I > > it is fairly simple, I can just move back two positions and be in front of > the ldc "TAG", and then inject my code. > > > But when something like this happens it gets complicated , dosomething > takes 7 ints. I need to jump to right before the bipush 100, so I can't > simply move back 7 positions. > > int i = 100; > dosomething(x(32,i/2),1,20 * 2,1,1,81,1); > --- > bipush 100 > istore_2 > bipush 32 > iload_2 > iconst_2 > idiv > invokestatic #6 // Method x:(II)I > iconst_1 > bipush 40 > iconst_1 > iconst_1 > bipush 81 > iconst_1 > invokestatic #7 // Method > dosomething:(IIIIIII)Ljava/lang/String; > > So, does ASM hold any magic for me here? Something easier than just > keeping track of the effects of each instruction on the stack, and walking > backwards? > > Thank You, > Jon > > -- > You receive this message as a subscriber of the [email protected] mailing list. > To unsubscribe: mailto:[email protected] > For general help: mailto:[email protected]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws