comp.lang.ada
 help / color / mirror / Atom feed
From: Optikos <optikos@verizon.net>
Subject: Re: DEC Ada Exception Information
Date: Fri, 19 Jul 2019 08:11:45 -0700 (PDT)
Date: 2019-07-19T08:11:45-07:00	[thread overview]
Message-ID: <3c063128-bcc4-4758-8b18-91cee75bbc3b@googlegroups.com> (raw)
In-Reply-To: <ea6a4dcf-4166-4781-a4ea-0b2b8f08fa13@googlegroups.com>

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.

  reply	other threads:[~2019-07-19 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 14:06 DEC Ada Exception Information Stephen Davies
2019-07-19 15:11 ` Optikos [this message]
2019-07-19 16:28   ` joviangm
replies disabled

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