comp.lang.ada
 help / color / mirror / Atom feed
* Catching Ada exceptions in C on an SGI
@ 2001-10-16 17:19 Dale Pennington
  2001-10-16 18:48 ` Chris Morgan
  0 siblings, 1 reply; 5+ messages in thread
From: Dale Pennington @ 2001-10-16 17:19 UTC (permalink / raw)


Situation is as follows : A third party is supplying us a library in Ada
with C entry (i.e. pragma export). The library is build with GNAT 3.13a on
SGI Irix 6.5. Unfortunately, while they supply C entries, these entries do
not trap any Ada exceptions raised, so if an exception occurs, our program
(written in C) crashes. It is not feasible to detect the conditions that
would raise an exception before the Ada calls, and we are not sure how long
it will take the third party to fix thing (or even if they will).

In the interim, we would like to somehow catch the Ada exceptions in out C
code. I was wondering if anyone had done work before on this problem, or had
good pointer on where I could look.

Thanks for your time,

Dale Pennington





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Catching Ada exceptions in C on an SGI
  2001-10-16 17:19 Catching Ada exceptions in C on an SGI Dale Pennington
@ 2001-10-16 18:48 ` Chris Morgan
  2001-10-16 20:01   ` Dale Pennington
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Morgan @ 2001-10-16 18:48 UTC (permalink / raw)


"Dale Pennington" <Dale.K.Pennington@boeing.com> writes:

> Situation is as follows : A third party is supplying us a library in Ada
> with C entry (i.e. pragma export). The library is build with GNAT 3.13a on
> SGI Irix 6.5. Unfortunately, while they supply C entries, these entries do
> not trap any Ada exceptions raised, so if an exception occurs, our program
> (written in C) crashes. It is not feasible to detect the conditions that
> would raise an exception before the Ada calls, and we are not sure how long
> it will take the third party to fix thing (or even if they will).
> 
> In the interim, we would like to somehow catch the Ada exceptions in out C
> code. I was wondering if anyone had done work before on this problem, or had
> good pointer on where I could look.

Wrap the functions in Ada, catch exceptions in the wrappers, and call
them from C.
-- 
Chris Morgan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Catching Ada exceptions in C on an SGI
  2001-10-16 18:48 ` Chris Morgan
@ 2001-10-16 20:01   ` Dale Pennington
  2001-10-16 20:22     ` Chris Morgan
  2001-10-17 11:40     ` Marc A. Criley
  0 siblings, 2 replies; 5+ messages in thread
From: Dale Pennington @ 2001-10-16 20:01 UTC (permalink / raw)



"Chris Morgan" <cm@mihalis.net> wrote in message
news:86g08jwhdy.fsf@mihalis.net...
> "Dale Pennington" <Dale.K.Pennington@boeing.com> writes:
>
> > Situation is as follows : A third party is supplying us a library in Ada
> > with C entry (i.e. pragma export). The library is build with GNAT 3.13a
on
> > SGI Irix 6.5. Unfortunately, while they supply C entries, these entries
do
> > not trap any Ada exceptions raised, so if an exception occurs, our
program
> > (written in C) crashes. It is not feasible to detect the conditions that
> > would raise an exception before the Ada calls, and we are not sure how
long
> > it will take the third party to fix thing (or even if they will).
> >
> > In the interim, we would like to somehow catch the Ada exceptions in out
C
> > code. I was wondering if anyone had done work before on this problem, or
had
> > good pointer on where I could look.
>
> Wrap the functions in Ada, catch exceptions in the wrappers, and call
> them from C.

I think that may be where I am heading, as I cannot do it in C and C++ (I
have tried with no success). Of course this means convincing my boss to let
me load GNAT onto our development machine, which will take some work (he is
a C person).

One thing I would like to check. The current Ada library already exports
adainit and adafinal. So this new wrapped library obviously cannot use the
same symbols for its init and final. Would the method be to run the bind
function, then edit the result .ads and .adb for my own name before
gnatmakeing and linking it ?

Thanks, Dale







^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Catching Ada exceptions in C on an SGI
  2001-10-16 20:01   ` Dale Pennington
@ 2001-10-16 20:22     ` Chris Morgan
  2001-10-17 11:40     ` Marc A. Criley
  1 sibling, 0 replies; 5+ messages in thread
From: Chris Morgan @ 2001-10-16 20:22 UTC (permalink / raw)


"Dale Pennington" <Dale.K.Pennington@boeing.com> writes:

> > Wrap the functions in Ada, catch exceptions in the wrappers, and call
> > them from C.
> 
> I think that may be where I am heading, as I cannot do it in C and C++ (I
> have tried with no success). Of course this means convincing my boss to let
> me load GNAT onto our development machine, which will take some work (he is
> a C person).

You can install and use GNAT in your own account without disturbing
anyone elses gcc, and without root privilege. That's enough to at
least try it.

> 
> One thing I would like to check. The current Ada library already exports
> adainit and adafinal. So this new wrapped library obviously cannot use the
> same symbols for its init and final. Would the method be to run the bind
> function, then edit the result .ads and .adb for my own name before
> gnatmakeing and linking it ?

That might work, there may be a better way - check the GNAT
manuals. adainit and adafinal are just made up names (although
possibly emitted by tools) you could change them to be wrapperinit and
wrapperfinal I would guess.

good luck
-- 
Chris Morgan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Catching Ada exceptions in C on an SGI
  2001-10-16 20:01   ` Dale Pennington
  2001-10-16 20:22     ` Chris Morgan
@ 2001-10-17 11:40     ` Marc A. Criley
  1 sibling, 0 replies; 5+ messages in thread
From: Marc A. Criley @ 2001-10-17 11:40 UTC (permalink / raw)


Dale Pennington wrote:
> 
> 
> One thing I would like to check. The current Ada library already exports
> adainit and adafinal. So this new wrapped library obviously cannot use the
> same symbols for its init and final. Would the method be to run the bind
> function, then edit the result .ads and .adb for my own name before
> gnatmakeing and linking it ?

I did something quite similar to this, only in the reverse :-)

The project I worked on provided the library, compiled with GNAT, that
was linked into an Apex Ada project.  So as not to conflict with that
environment's adainit and adafinal, I renamed those functions in the
library to gnatadainit and gnatadafinal.  Tested this with a C program
and then supplied it to the other company along with directions on how
to invoke it, and everything worked fine.

Marc A. Criley
Senior Staff Engineer
Quadrus Corporation
www.quadruscorp.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-17 11:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-16 17:19 Catching Ada exceptions in C on an SGI Dale Pennington
2001-10-16 18:48 ` Chris Morgan
2001-10-16 20:01   ` Dale Pennington
2001-10-16 20:22     ` Chris Morgan
2001-10-17 11:40     ` Marc A. Criley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox