Using inline assembly and parsing opcodes seems more brittle than using linker flags.
/Staffan On 19 aug 2013, at 23:10, Dmitry Samersoff <dmitry.samers...@oracle.com> wrote: > Staffan, > > It might be better to just use inline assembler to record start and end > of the routine, as nobody guarantee that thread_end is not optimized out > or some function is not inserted in between thread_func and thread_end. > > Something like below should work: > > First line of thread_func: > > _asm( > jmp End_Of_Func_Label > ) > > and, when necessary, read opcode at &thread_func (E9 or EB) and extract > imm that comes afterward. > > -Dmitry > > > > On 2013-08-16 20:51, Staffan Larsen wrote: >> This failure happens when compiling with the VS 2012 compiler. The attach >> code relies on the order of two methods in the compiled binary and VS 2012 >> changed that order. The solution used is the linker flag /ORDER [1] which >> allows us to specify the order in which methods are laid out in the binary >> image. Since the flag only operates on non-static methods, the methods have >> been made non-static and also changed name so that they will not clash with >> other methods. >> >> webrev: http://cr.openjdk.java.net/~sla/8022071/webrev.01/ >> >> The change has been tested with both VS 2010 and VS 2012. >> >> Thanks, >> /Staffan >> >> >> [1] http://msdn.microsoft.com/en-us/library/vstudio/00kh39zz.aspx >> > > > -- > Dmitry Samersoff > Oracle Java development team, Saint Petersburg, Russia > * I would love to change the world, but they won't give me the sources.