Locating where first param of an invoke gets put on the stack
Jon Sawyer <[email protected]> Fri, 1 Dec 2017 08:02:21 -0800
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CABrNosGpGkBiopqK8m+iV3RxVc2JyB+XsBTVuOi7WL2RS4eTHg@mail.gmail.com> |
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