This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mfentry example


Hello,
  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 .

cat testxyz.c
#include<stdio.h>

void g(int x)
{
        new code that fixes some bugs
}

void f(int x)
{

    int y=x*3;

    printf("y on entry is 9\n");
    int i=0;
    while(1)
    {
        sleep(5);
        i++;
        printf("i now is %d\n",i);
    }
    return ;
}

int main()
{
    f(3);
    return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]