libunwind-devel
[Top][All Lists]
Advanced

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

[libunwind] Changing the value of "gp"


From: Praveen Vegulla
Subject: [libunwind] Changing the value of "gp"
Date: Fri, 17 Jan 2003 17:49:23 -0800 (PST)

Hi,

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

I'm trying to implement exception handling as follows:

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

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

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

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

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

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

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

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


thank you very much,
Praveen


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


reply via email to

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