libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libunwind] Changing the value of "gp"


From: David Mosberger
Subject: Re: [libunwind] Changing the value of "gp"
Date: Fri, 17 Jan 2003 18:07:49 -0800

Something seems very strange here.  I don't think there should be any
need for setjmp() at all.

When raising an exception, why not just:

        - unwind until the IP is in funcB()
        - execute whatever "exception" handling you need to do
        - do an unw_resume() on the current cursor

That would resume control in funcB().

        --david

>>>>> On Fri, 17 Jan 2003 17:49:23 -0800 (PST), Praveen Vegulla 
>>>>> <address@hidden> said:

  Praveen> Hi,
  Praveen> I'm an absolute newbie to Itanium and I apologize if
  Praveen> this is a very basic question. (Sorry about the length
  Praveen> of the mail.)

  Praveen> I'm trying to implement exception handling as follows:

  Praveen> Assuming the following call sequence:
  Praveen> funcA() -> funcB() -> funcC()

  Praveen> I need to install a exception handler in funcC(). I do
  Praveen> this by calling setjmp() in funcC() and using the
  Praveen> unwind library, I step up to funcB() and change the IP
  Praveen> to an exception cleanup function. At this point I save
  Praveen> the original IP for funcB() in a global. I had to do
  Praveen> it this way since there is no builtin (at least none
  Praveen> that I'm aware of) in gcc equivalent to _Asm_set_rp()
  Praveen> avaliable in the HPUX compiler suite.

  Praveen> The way it works is pretty simple, if I need to raise
  Praveen> an exception in funcC() or any of its callees, all I
  Praveen> need to do is issue a longjmp() to the location where
  Praveen> I setup the exception handler.

  Praveen> The tricky part is, if there was no excpetion, then I
  Praveen> need to cleanup the exception handler that I installed
  Praveen> and hence the reason for setting the return address (a
  Praveen> hack used by changing the IP in funcB()). So when
  Praveen> funcC() returns, it goes back to the IP of its caller,
  Praveen> which has now been changed to the exception cleanup
  Praveen> routine.

  Praveen> In this cleanup function, I remove the handler. And
  Praveen> then try to get the original IP from the global. This
  Praveen> is the place where I'm totally lost.

  Praveen> The cause of this problem is, in funcC(), I'm calling
  Praveen> one of the libc functions just before return. This
  Praveen> changes the "gp". If funcC() were to return naturally
  Praveen> to funcB(), there is code in funcB() to restore "gp".
  Praveen> But in my implementation, it jumps to the cleanup
  Praveen> function and when it tries to access the global
  Praveen> variable, it craps out since "gp" is no longer correct
  Praveen> for this module.

  Praveen> I tried all possible combinations with my limited
  Praveen> knowledge and have totally run out of ideas. Any
  Praveen> suggestions to fix this issue will be of enormous
  Praveen> help.

  Praveen> And is there any good reading material for itanium 2,
  Praveen> the reference manuals are quite cryptic.


  Praveen> thank you very much,
  Praveen> Praveen


  Praveen> __________________________________________________
  Praveen> Do you Yahoo!?
  Praveen> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
  Praveen> http://mailplus.yahoo.com
  Praveen> _______________________________________________
  Praveen> libunwind mailing list
  Praveen> address@hidden
  Praveen> http://linux.hpl.hp.com/cgi-bin/mailman/listinfo/libunwind


reply via email to

[Prev in Thread] Current Thread [Next in Thread]