comp.lang.ada
 help / color / mirror / Atom feed
* DEC Ada Exception Information
@ 2019-07-19 14:06 Stephen Davies
  2019-07-19 15:11 ` Optikos
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Davies @ 2019-07-19 14:06 UTC (permalink / raw)


I am using DEC Ada 3.5-20, which provides the function
CURRENT_EXCEPTION.EXCEPTION_INFORMATION.

The string it returns includes the PC value. How do I
convert this to the Ada package/subunit and line number?

TIA

Stephen Davies

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

* Re: DEC Ada Exception Information
  2019-07-19 14:06 DEC Ada Exception Information Stephen Davies
@ 2019-07-19 15:11 ` Optikos
  2019-07-19 16:28   ` joviangm
  0 siblings, 1 reply; 3+ messages in thread
From: Optikos @ 2019-07-19 15:11 UTC (permalink / raw)


On Friday, July 19, 2019 at 9:06:32 AM UTC-5, Stephen Davies wrote:
> I am using DEC Ada 3.5-20, which provides the function
> CURRENT_EXCEPTION.EXCEPTION_INFORMATION.
> 
> The string it returns includes the PC value. How do I
> convert this to the Ada package/subunit and line number?
> 
> TIA
> 
> Stephen Davies

You will need to provide which DEC operating system you are using (e.g., VMS; OSF).  The specific answer (e.g., exact command lines; file naming; file formats) vary drastically per OS.

In general, the technique (nowadays within the source code of an automated tool in your OS, e.g., a debugger) is to:
1) Obtain from the linker/librarian (or build-time linker/librarian plus execution-time link-loader on some OSes) a map file of the relocatable layout of the executable (or DLL).  This map will provide the offsets of subroutines (and static data) from the (variable, established per execution-time) base-address.
2) Obtain from the execution-time link-loader the fixed base-address at which the executable (or DLL) was loaded in this particular execution.
3) Perform the numerous additions of the relocatable addresses of subroutines to see in which range/pair of addresses your particular PC that raised the exception falls.
4) Obtain the name of subroutine that corresponds to that range/pair of addresses.

The aforementioned steps can be performed manually, if need be.  The next step presumes the use of an automated source-debugger:
5) To obtain line number, debug information must already be present in the executable (or DLL) that raised the exception.  The debugger can perform a variant of the latter half of step 3 above to narrow the range of addresses to a more fine-grained range that pins it down to a line number and/or expression within a statement.  But if you were utilizing a source-debugger to perform this step 5, you would have already had your answer and wouldn't be posting to c.l.a.  I give this step 5 for completeness and as recommendation of the automated modern way of doing this without manually performing steps 1 through 4 above like we used to do decades ago before the era of better source-code debuggers being ubiquitous.

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

* Re: DEC Ada Exception Information
  2019-07-19 15:11 ` Optikos
@ 2019-07-19 16:28   ` joviangm
  0 siblings, 0 replies; 3+ messages in thread
From: joviangm @ 2019-07-19 16:28 UTC (permalink / raw)


On Friday, 19 July 2019 16:11:47 UTC+1, Optikos  wrote:
> You will need to provide which DEC operating system you are using
> (e.g., VMS; OSF).  The specific answer (e.g., exact command lines;
> file naming; file formats) vary drastically per OS.
> [snip]
Thanks for the quicj and rather detailed reply.
It sounds like a lot more work than I was hoping.
Think I'll stick to trying to recreate exceptions in the debugger.
FWIW, I'm using VMS V7.1-2 on Alpha.


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

end of thread, other threads:[~2019-07-19 16:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 14:06 DEC Ada Exception Information Stephen Davies
2019-07-19 15:11 ` Optikos
2019-07-19 16:28   ` joviangm

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