[off-topic for gcc; redirect to gcc-help] On 15/02/15 22:00, Niklaus wrote: > I'm trying to do a live update of a function without killing or > stopping the program. This is a single threaded application which runs > something similar to the below code. Maximum time is spent in the > while(1) loop. > > What i want to do is compile with gcc-4.8 with -pg and -mfentry and > then call function g() and then do the int y=x*3 and everything else. > I have thought of an idea about registering a sigHandler and then > setjmp/longjmp to g.. Please note i'm trying to fix some bugs here > without stopping the process. > > I want to do something akin to Kgraft/Kpatch or Erlang's dynamic > updation system. > > Can you please help me by throwing some light on this . OK, I'll bite. You want to be able to break out of a function while it is running and return to some other function. There's no portable way to do that is general. However, there are things which are easy, such as calling the loop body via a function pointer. Andrew.