comp.lang.ada
 help / color / mirror / Atom feed
* Importance of GNAT.Source_Info
@ 2020-01-06 22:03 Jere
  2020-01-07  2:29 ` Optikos
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jere @ 2020-01-06 22:03 UTC (permalink / raw)


I'm working on a baremetal RTS and while looking at
https://wiki.osdev.org/Ada_Bare_bones, one of the files
it suggests is part of the minimum set of RTS files is
g-souinf.ads which contains the package GNAT.Source_Info.

Does anyone know what part of the compiler requires this?
So far I haven't had GNAT barf at me for not having it
while compiling the files I do have, but I don't want to 
leave it out if it is indeed necessary for something.  I
didn't see any info on why it is necessary.  It's definitely
useful in that it gives a lot of compile time values, but
not sure why it would be a "required" file.  I'm assuming
something will break without it, but don't know what.

Sorry that this isn't a pure "Ada" question and is more
focused on GNAT specifically, but thought one of yall
might know why.

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

* Re: Importance of GNAT.Source_Info
  2020-01-06 22:03 Importance of GNAT.Source_Info Jere
@ 2020-01-07  2:29 ` Optikos
  2020-01-07  6:12   ` Niklas Holsti
  2020-01-08 16:38 ` Simon Wright
  2020-01-10 10:54 ` charlet
  2 siblings, 1 reply; 8+ messages in thread
From: Optikos @ 2020-01-07  2:29 UTC (permalink / raw)


On Monday, January 6, 2020 at 4:03:56 PM UTC-6, Jere wrote:
> I'm working on a baremetal RTS and while looking at
> https://wiki.osdev.org/Ada_Bare_bones, one of the files
> it suggests is part of the minimum set of RTS files is
> g-souinf.ads which contains the package GNAT.Source_Info.
> 
> Does anyone know what part of the compiler requires this?
> So far I haven't had GNAT barf at me for not having it
> while compiling the files I do have, but I don't want to 
> leave it out if it is indeed necessary for something.  I
> didn't see any info on why it is necessary.  It's definitely
> useful in that it gives a lot of compile time values, but
> not sure why it would be a "required" file.  I'm assuming
> something will break without it, but don't know what.
> 
> Sorry that this isn't a pure "Ada" question and is more
> focused on GNAT specifically, but thought one of yall
> might know why.

https://www.radford.edu/~nokie/classes/320/std_lib_html/gnat-source_info.html

Speaking in general from RTOS knowledge not specific to GNAT or Ada, I observe that GNAT.Source_Info.Enclosing_Entity (utilized transitively to the task's entry point) would provide information useful to knowing the complete call tree for maximum execution-time analysis in static analyzers of static machine code or in empirical analysis tools of a running system or hybrids thereof.  The A#1 goal of hard realtime systems is to definitively know (via mathematical proof of worst-case) the maximum (not typical) execution time of each subroutine invocation—especially this analysis for each  required use-case from system engineering (but in lieu of each use-case, then the absolute maximum execution-time of each subroutine).  Often this analysis starts with a table of all system calls in an RTOS plus all subroutines in a realtime system (including app-domain) that is derived from the map file of each executibile as output at link-time.  It appears that GNAT.Source_Info.Enclosing_Entity provides a dynamic walk with software assist that would otherwise be a manual or semi-manual walk of the map file of subroutine names & their entry points.

Perhaps someone else will have more GNAT-specific meat to put on this general skeleton.

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

* Re: Importance of GNAT.Source_Info
  2020-01-07  2:29 ` Optikos
@ 2020-01-07  6:12   ` Niklas Holsti
  2020-01-11 15:01     ` Jere
  0 siblings, 1 reply; 8+ messages in thread
From: Niklas Holsti @ 2020-01-07  6:12 UTC (permalink / raw)


On 2020-01-07 4:29, Optikos wrote:
> On Monday, January 6, 2020 at 4:03:56 PM UTC-6, Jere wrote:
>> I'm working on a baremetal RTS and while looking at
>> https://wiki.osdev.org/Ada_Bare_bones, one of the files
>> it suggests is part of the minimum set of RTS files is
>> g-souinf.ads which contains the package GNAT.Source_Info.
>>
>> Does anyone know what part of the compiler requires this?
>> So far I haven't had GNAT barf at me for not having it
>> while compiling the files I do have, but I don't want to
>> leave it out if it is indeed necessary for something.  I
>> didn't see any info on why it is necessary.  It's definitely
>> useful in that it gives a lot of compile time values, but
>> not sure why it would be a "required" file.  I'm assuming
>> something will break without it, but don't know what.
>>
>> Sorry that this isn't a pure "Ada" question and is more
>> focused on GNAT specifically, but thought one of yall
>> might know why.
GNAT might use GNAT.Source_Info in code generated to raise exceptions 
with strings. However, as all subprograms in GNAT.Source_Info are marked 
"Intrinsic", it seems that GNAT could as well generate that "intrinsic" 
code without calling GNAT.Source_Info. So I don't really know.

> https://www.radford.edu/~nokie/classes/320/std_lib_html/gnat-source_info.html
> 
> Speaking in general from RTOS knowledge not specific to GNAT or Ada,
> I observe that GNAT.Source_Info.Enclosing_Entity (utilized
> transitively to the task's entry point) would provide information
> useful to knowing the complete call tree

No, from its description Enclosing_Entity uses the static (lexical) 
nesting and returns the name of the immediately lexically enclosing 
subprogram (the one in which Enclosing_Entity is called). It does not 
return the name of the callee of that subprogram nor can it be used 
transitively.

It is a simple, static, query of the compiler's compile-time knowledge 
of which program part the compiler is compiling now.

> for maximum execution-time
> analysis in static analyzers of static machine code or in empirical
> analysis tools of a running system or hybrids thereof.

I don't think one can discover call-trees with Enclosing_Entity, not 
even by running the program and displaying the results of 
Enclosing_Entity calls. Such Enclosing_Entity calls would have to be 
inserted everywhere in the source code by some automatic instrumentation 
tool, which would also have to insert code to trace subprogram calls and 
returns, so this tool would for sure itself know the name of the 
subprogram it is instrumenting and would not have to use Enclosing_Entity.

> The A#1 goal
> of hard realtime systems is to definitively know (via mathematical
> proof of worst-case) the maximum (not typical) execution time of each
> subroutine invocation—especially this analysis for each  required
> use-case from system engineering (but in lieu of each use-case, then
> the absolute maximum execution-time of each subroutine). 

Indeed.

> Often this
> analysis starts with a table of all system calls in an RTOS plus all
> subroutines in a realtime system (including app-domain) that is
> derived from the map file of each executibile as output at link-time.

Or from the executable file (code + debug info).

To find the call-tree (or call-graph, really) the analysis tool 
generally has to scan the binary code and find all call instructions.

Source-level call-graphs can of course be found by static analysis of 
the source code, but the binary compiled code often has a different 
structure which means that source-level call-graphs are not so useful 
for static WCET analysis.

> It appears that GNAT.Source_Info.Enclosing_Entity provides a dynamic
> walk with software assist that would otherwise be a manual or
> semi-manual walk of the map file of subroutine names & their entry
> points.

No, that is a misunderstanding of Enclosing_Entity.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

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

* Re: Importance of GNAT.Source_Info
  2020-01-06 22:03 Importance of GNAT.Source_Info Jere
  2020-01-07  2:29 ` Optikos
@ 2020-01-08 16:38 ` Simon Wright
  2020-01-11 15:02   ` Jere
  2020-01-10 10:54 ` charlet
  2 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2020-01-08 16:38 UTC (permalink / raw)


Jere <jhb.chat@gmail.com> writes:

> I'm working on a baremetal RTS and while looking at
> https://wiki.osdev.org/Ada_Bare_bones, one of the files it suggests is
> part of the minimum set of RTS files is g-souinf.ads which contains
> the package GNAT.Source_Info.
>
> Does anyone know what part of the compiler requires this?  So far I
> haven't had GNAT barf at me for not having it while compiling the
> files I do have, but I don't want to leave it out if it is indeed
> necessary for something.  I didn't see any info on why it is
> necessary.  It's definitely useful in that it gives a lot of compile
> time values, but not sure why it would be a "required" file.  I'm
> assuming something will break without it, but don't know what.

I wouldn't have thought it'd be "required" either. If you want what it
provides, great, but there's no cost for actually 'with'ing it, because
it's preelaborated & (as someone has pointed out) all the subprograms
are intrinsic.


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

* Re: Importance of GNAT.Source_Info
  2020-01-06 22:03 Importance of GNAT.Source_Info Jere
  2020-01-07  2:29 ` Optikos
  2020-01-08 16:38 ` Simon Wright
@ 2020-01-10 10:54 ` charlet
  2020-01-11 15:03   ` Jere
  2 siblings, 1 reply; 8+ messages in thread
From: charlet @ 2020-01-10 10:54 UTC (permalink / raw)


This package is completely optional and standalone, and not used by the compiler or other runtime units. It's just provided because it doesn't have any associated runtime so portable to all GNAT ports and because it's convenient. You can safely remove or ignore it if that's convenient for you.


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

* Re: Importance of GNAT.Source_Info
  2020-01-07  6:12   ` Niklas Holsti
@ 2020-01-11 15:01     ` Jere
  0 siblings, 0 replies; 8+ messages in thread
From: Jere @ 2020-01-11 15:01 UTC (permalink / raw)


On Tuesday, January 7, 2020 at 1:12:42 AM UTC-5, Niklas Holsti wrote:
> On 2020-01-07 4:29, Optikos wrote:
> > On Monday, January 6, 2020 at 4:03:56 PM UTC-6, Jere wrote:
> >> I'm working on a baremetal RTS and while looking at
> >> https://wiki.osdev.org/Ada_Bare_bones, one of the files
> >> it suggests is part of the minimum set of RTS files is
> >> g-souinf.ads which contains the package GNAT.Source_Info.
> >>
> >> Does anyone know what part of the compiler requires this?
> >> So far I haven't had GNAT barf at me for not having it
> >> while compiling the files I do have, but I don't want to
> >> leave it out if it is indeed necessary for something.  I
> >> didn't see any info on why it is necessary.  It's definitely
> >> useful in that it gives a lot of compile time values, but
> >> not sure why it would be a "required" file.  I'm assuming
> >> something will break without it, but don't know what.
> >>
> >> Sorry that this isn't a pure "Ada" question and is more
> >> focused on GNAT specifically, but thought one of yall
> >> might know why.
> GNAT might use GNAT.Source_Info in code generated to raise exceptions 
> with strings. However, as all subprograms in GNAT.Source_Info are marked 
> "Intrinsic", it seems that GNAT could as well generate that "intrinsic" 
> code without calling GNAT.Source_Info. So I don't really know.
> 

Yeah, that makes sense. TY

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

* Re: Importance of GNAT.Source_Info
  2020-01-08 16:38 ` Simon Wright
@ 2020-01-11 15:02   ` Jere
  0 siblings, 0 replies; 8+ messages in thread
From: Jere @ 2020-01-11 15:02 UTC (permalink / raw)


On Wednesday, January 8, 2020 at 11:38:28 AM UTC-5, Simon Wright wrote:
> 
> 
> > I'm working on a baremetal RTS and while looking at
> > https://wiki.osdev.org/Ada_Bare_bones, one of the files it suggests is
> > part of the minimum set of RTS files is g-souinf.ads which contains
> > the package GNAT.Source_Info.
> >
> > Does anyone know what part of the compiler requires this?  So far I
> > haven't had GNAT barf at me for not having it while compiling the
> > files I do have, but I don't want to leave it out if it is indeed
> > necessary for something.  I didn't see any info on why it is
> > necessary.  It's definitely useful in that it gives a lot of compile
> > time values, but not sure why it would be a "required" file.  I'm
> > assuming something will break without it, but don't know what.
> 
> I wouldn't have thought it'd be "required" either. If you want what it
> provides, great, but there's no cost for actually 'with'ing it, because
> it's preelaborated & (as someone has pointed out) all the subprograms
> are intrinsic.

I might still include it.  My OCD doesn't want to put too much
GNAT specific stuff in if I don't need to, but then, I have to 
use GNAT specific stuff because it is an RTS for GNAT, so I am
probably just being silly here and I shouldn't worry about it and
just add it in too.


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

* Re: Importance of GNAT.Source_Info
  2020-01-10 10:54 ` charlet
@ 2020-01-11 15:03   ` Jere
  0 siblings, 0 replies; 8+ messages in thread
From: Jere @ 2020-01-11 15:03 UTC (permalink / raw)


On Friday, January 10, 2020 at 5:54:20 AM UTC-5, cha...@adacore.com wrote:
> This package is completely optional and standalone, and not used by the compiler or other runtime units. It's just provided because it doesn't have any associated runtime so portable to all GNAT ports and because it's convenient. You can safely remove or ignore it if that's convenient for you.

Thanks so much!  I appreciate it.

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

end of thread, other threads:[~2020-01-11 15:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 22:03 Importance of GNAT.Source_Info Jere
2020-01-07  2:29 ` Optikos
2020-01-07  6:12   ` Niklas Holsti
2020-01-11 15:01     ` Jere
2020-01-08 16:38 ` Simon Wright
2020-01-11 15:02   ` Jere
2020-01-10 10:54 ` charlet
2020-01-11 15:03   ` Jere

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