comp.lang.ada
 help / color / mirror / Atom feed
* ALI Files Cross-References Inconsistency?
@ 2020-08-13 15:24 Leandro Ribeiro
  2020-08-13 15:55 ` Dennis Lee Bieber
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Leandro Ribeiro @ 2020-08-13 15:24 UTC (permalink / raw)


Hello, everyone 

I recently started to take a better look into Ada.

I am currently analyzing .ali files.

In the code snippets below (.ads and .adb), I wrote "|" to show where the ALI file claims a given symbol is.
The (line X) just tells which line number the line had in my local text editor.

I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".


Question:
Is this a bug?
Or did a miss any rule about adding offsets to the references?



======== excep2.ali
...
X 1 excep2.ads
3K9*excep2 13l5 13e11 2|3b14 22l5 22t11
6U19*excep 7>10 8>9 8>12 9<9 10<9 2|5b19 20l13 20t18
7a10 S{string} 2|6b10 10r30 11r28 13r31
8e9 C{character} 2|6b22 13r38
8e12 Delim{character} 2|6b25 11r35
9b9 Found{boolean} 2|6b44 9m17 15m33
10i9 Position{positive} 2|6b64 14m38
X 2 excep2.adb
10i25 J{integer} 11r30 13r33 14r50
...

======== excep2.ads
pragma SPARK_Mode;

package |excep2 
is
(line 5)-- procedure finds first occurence of char C before char Delim
        procedure exce|p 
	(S : |String; 
	C, D|eli|m : Character; 
	Foun|d: out Boolean; 
(line10)Posi|tion : out Positive)
        with Annotate => (GNATprove, Intentional,
               "might not be initialized in", "reviewed by Leandro: If it can be used (Found=True), it is surely initialized");
end excep2;


======== excep2.adb
pragma SPARK_Mode;

package body excep2 is
	-- procedure finds first occurence of char C before char Delim
(line 5)procedure excep 
	(S : String; C, Delim : Character; Found: out Boolean; Position : out Positive)
 is
	begin
		Found := False;
(line 10)	for	J in S'Range| loop
			if S(J) = Delim then
				return;
			elsif S(J) = C
				then Position := J;
(line 15)				Found := True;
				return;
			end if;
		end loop;
		return;
(line 20)end excep;

end excep2;

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 15:24 ALI Files Cross-References Inconsistency? Leandro Ribeiro
@ 2020-08-13 15:55 ` Dennis Lee Bieber
  2020-08-13 21:18   ` Simon Wright
  2020-08-13 17:17 ` Egil H H
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Dennis Lee Bieber @ 2020-08-13 15:55 UTC (permalink / raw)


On Thu, 13 Aug 2020 08:24:45 -0700 (PDT), Leandro Ribeiro
<leandrobribeiro@gmail.com> declaimed the following:


>
>I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
>However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
>And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".
>
	Is your source file using <TAB> or a series of <SPACE> characters for
indentation.

	Much software "counts" a <TAB> as moving to the next multiple of 8
(which was the hardware spacing on things like VT-100 terminals), even
though many editors may be configured to treat it as a multiple of 4 (or
some other value).

>
>======== excep2.ads
>pragma SPARK_Mode;
>
>package |excep2 
>is
>(line 5)-- procedure finds first occurence of char C before char Delim
>        procedure exce|p
THIS line uses a series of <space> to indent 
>	(S : |String; 
THIS line has a single <tab> to indent


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 15:24 ALI Files Cross-References Inconsistency? Leandro Ribeiro
  2020-08-13 15:55 ` Dennis Lee Bieber
@ 2020-08-13 17:17 ` Egil H H
  2020-08-14  8:11   ` Leandro Ribeiro
  2020-09-25 16:16 ` Stephen Leake
  2020-09-30  9:53 ` wj46633
  3 siblings, 1 reply; 15+ messages in thread
From: Egil H H @ 2020-08-13 17:17 UTC (permalink / raw)


On Thursday, August 13, 2020 at 5:24:47 PM UTC+2, Leandro Ribeiro wrote:
> 
> I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
> However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
> And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".
> 
> 
> Question:
> Is this a bug?
> Or did a miss any rule about adding offsets to the references?
> 

Did you by any chance use the TAB character as delimiter? There's a fair chance it would count as 8 when calculating the position

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 15:55 ` Dennis Lee Bieber
@ 2020-08-13 21:18   ` Simon Wright
  2020-08-14 19:45     ` Dennis Lee Bieber
  0 siblings, 1 reply; 15+ messages in thread
From: Simon Wright @ 2020-08-13 21:18 UTC (permalink / raw)


Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:

> Much software "counts" a <TAB> as moving to the next multiple of 8
> (which was the hardware spacing on things like VT-100 terminals

The VT-100 had soft tab stops, didn't it? I don't remember whether the
ASR-33 had tab stops at all, but they _would_ have been hardware.

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 17:17 ` Egil H H
@ 2020-08-14  8:11   ` Leandro Ribeiro
  2020-08-14 16:35     ` Per Sandberg
  2020-08-14 19:47     ` Dennis Lee Bieber
  0 siblings, 2 replies; 15+ messages in thread
From: Leandro Ribeiro @ 2020-08-14  8:11 UTC (permalink / raw)


Am Donnerstag, 13. August 2020 19:17:55 UTC+2 schrieb Egil H H:
> On Thursday, August 13, 2020 at 5:24:47 PM UTC+2, Leandro Ribeiro wrote:
> > 
> > I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
> > However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
> > And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".
> > 
> > 
> > Question:
> > Is this a bug?
> > Or did a miss any rule about adding offsets to the references?
> > 
> 
> Did you by any chance use the TAB character as delimiter? There's a fair chance it would count as 8 when calculating the position

Bingo!

My text editor counts tabs as 4 columns.
The offsets were 4*NumberOfTabs.

I replaced the tabs with spaces, and the ALI file is perfect now.

Thanks a lot!

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-14  8:11   ` Leandro Ribeiro
@ 2020-08-14 16:35     ` Per Sandberg
  2020-08-14 17:23       ` Simon Wright
  2020-08-14 19:47     ` Dennis Lee Bieber
  1 sibling, 1 reply; 15+ messages in thread
From: Per Sandberg @ 2020-08-14 16:35 UTC (permalink / raw)



Just a comment, <TAB>s in source text is a common root of confusion 
since every editor indents <TAB>s in some way.
/P

On 8/14/20 10:11 AM, Leandro Ribeiro wrote:
> Am Donnerstag, 13. August 2020 19:17:55 UTC+2 schrieb Egil H H:
>> On Thursday, August 13, 2020 at 5:24:47 PM UTC+2, Leandro Ribeiro wrote:
>>>
>>> I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
>>> However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
>>> And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".
>>>
>>>
>>> Question:
>>> Is this a bug?
>>> Or did a miss any rule about adding offsets to the references?
>>>
>>
>> Did you by any chance use the TAB character as delimiter? There's a fair chance it would count as 8 when calculating the position
> 
> Bingo!
> 
> My text editor counts tabs as 4 columns.
> The offsets were 4*NumberOfTabs.
> 
> I replaced the tabs with spaces, and the ALI file is perfect now.
> 
> Thanks a lot!
> 

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-14 16:35     ` Per Sandberg
@ 2020-08-14 17:23       ` Simon Wright
  2020-08-15  7:56         ` J-P. Rosen
  0 siblings, 1 reply; 15+ messages in thread
From: Simon Wright @ 2020-08-14 17:23 UTC (permalink / raw)


Per Sandberg <per.s.sandberg@bahnhof.se> writes:

> Just a comment, <TAB>s in source text is a common root of confusion
> since every editor indents <TAB>s in some way.

In GPS (GNAT Studio) the Preferences / Editor / Ada includes a 'Use
tabulations' option that is unchecked (here, and I haven't changed it);
so when you hit TAB in Ada the code is indented the appropriate number
of spaces, not using tabs.

My Emacs is set up to remove any TABs that have found their way into an
Ada file whenever it's saved. (At one point I had this set for any file
type; not a good plan for a Makefile).

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 21:18   ` Simon Wright
@ 2020-08-14 19:45     ` Dennis Lee Bieber
  0 siblings, 0 replies; 15+ messages in thread
From: Dennis Lee Bieber @ 2020-08-14 19:45 UTC (permalink / raw)


On Thu, 13 Aug 2020 22:18:09 +0100, Simon Wright <simon@pushface.org>
declaimed the following:

>Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
>
>> Much software "counts" a <TAB> as moving to the next multiple of 8
>> (which was the hardware spacing on things like VT-100 terminals
>
>The VT-100 had soft tab stops, didn't it? I don't remember whether the
>ASR-33 had tab stops at all, but they _would_ have been hardware.

	Well... the "reset" mode was multiple of 8. But yes, I think one could
manually change the stop positions -- which didn't help in how software
interpreted them <G>


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-14  8:11   ` Leandro Ribeiro
  2020-08-14 16:35     ` Per Sandberg
@ 2020-08-14 19:47     ` Dennis Lee Bieber
  1 sibling, 0 replies; 15+ messages in thread
From: Dennis Lee Bieber @ 2020-08-14 19:47 UTC (permalink / raw)


On Fri, 14 Aug 2020 01:11:23 -0700 (PDT), Leandro Ribeiro
<leandrobribeiro@gmail.com> declaimed the following:


>
>My text editor counts tabs as 4 columns.
>The offsets were 4*NumberOfTabs.
>
>I replaced the tabs with spaces, and the ALI file is perfect now.

	Might want to see if your editor has a setting for "space insertion" on
tabs. If it's really good, it should also have a means to "dedent" by a
"tab" that removes the correct number of spaces.


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-14 17:23       ` Simon Wright
@ 2020-08-15  7:56         ` J-P. Rosen
  0 siblings, 0 replies; 15+ messages in thread
From: J-P. Rosen @ 2020-08-15  7:56 UTC (permalink / raw)


Le 14/08/2020 à 19:23, Simon Wright a écrit :
> Per Sandberg <per.s.sandberg@bahnhof.se> writes:
> 
>> Just a comment, <TAB>s in source text is a common root of confusion
>> since every editor indents <TAB>s in some way.
> 
> In GPS (GNAT Studio) the Preferences / Editor / Ada includes a 'Use
> tabulations' option that is unchecked (here, and I haven't changed it);
> so when you hit TAB in Ada the code is indented the appropriate number
> of spaces, not using tabs.
> 
> My Emacs is set up to remove any TABs that have found their way into an
> Ada file whenever it's saved. (At one point I had this set for any file
> type; not a good plan for a Makefile).
> 
AdaControl has a rule:
check characters (control);

that will indentify all tabs. This rule generate fixes, so the companion
utility adactl_fix can replace them automatically with 4 spaces.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 15:24 ALI Files Cross-References Inconsistency? Leandro Ribeiro
  2020-08-13 15:55 ` Dennis Lee Bieber
  2020-08-13 17:17 ` Egil H H
@ 2020-09-25 16:16 ` Stephen Leake
  2020-09-25 19:35   ` Dmitry A. Kazakov
  2020-09-30  9:53 ` wj46633
  3 siblings, 1 reply; 15+ messages in thread
From: Stephen Leake @ 2020-09-25 16:16 UTC (permalink / raw)


Leandro Ribeiro <leandrobribeiro@gmail.com> writes:

> I am currently analyzing .ali files.

Be aware that AdaCore is moving away from ali files for cross
referencing; that functionality is now provided by libadalang.


-- 
-- Stephe

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

* Re: ALI Files Cross-References Inconsistency?
  2020-09-25 16:16 ` Stephen Leake
@ 2020-09-25 19:35   ` Dmitry A. Kazakov
  2020-09-25 22:33     ` Stephen Leake
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry A. Kazakov @ 2020-09-25 19:35 UTC (permalink / raw)


On 25/09/2020 18:16, Stephen Leake wrote:
> Leandro Ribeiro <leandrobribeiro@gmail.com> writes:
> 
>> I am currently analyzing .ali files.
> 
> Be aware that AdaCore is moving away from ali files for cross
> referencing; that functionality is now provided by libadalang.

Can you elaborate? Presently we keep ALI files as build artifacts. 
Object files are not enough in order to avoid recompilation. What comes 
instead?

BTW, could be broken GPS in the latest GNAT community a result of these 
efforts?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: ALI Files Cross-References Inconsistency?
  2020-09-25 19:35   ` Dmitry A. Kazakov
@ 2020-09-25 22:33     ` Stephen Leake
  2020-09-26  8:03       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 15+ messages in thread
From: Stephen Leake @ 2020-09-25 22:33 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On 25/09/2020 18:16, Stephen Leake wrote:
>> Leandro Ribeiro <leandrobribeiro@gmail.com> writes:
>> 
>>> I am currently analyzing .ali files.
>> Be aware that AdaCore is moving away from ali files for cross
>> referencing; that functionality is now provided by libadalang.
>
> Can you elaborate? 

GNATStudio uses libadalang when navigating between files; it does not
use the .ali files.

> Presently we keep ALI files as build artifacts. Object files are not
> enough in order to avoid recompilation.

Ok, so .ali files will not go away entirely. But they may lose all their
cross-reference info.

-- 
-- Stephe

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

* Re: ALI Files Cross-References Inconsistency?
  2020-09-25 22:33     ` Stephen Leake
@ 2020-09-26  8:03       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry A. Kazakov @ 2020-09-26  8:03 UTC (permalink / raw)


On 26/09/2020 00:33, Stephen Leake wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> On 25/09/2020 18:16, Stephen Leake wrote:
>>> Leandro Ribeiro <leandrobribeiro@gmail.com> writes:
>>>
>>>> I am currently analyzing .ali files.
>>> Be aware that AdaCore is moving away from ali files for cross
>>> referencing; that functionality is now provided by libadalang.
>>
>> Can you elaborate?
> 
> GNATStudio uses libadalang when navigating between files; it does not
> use the .ali files.
> 
>> Presently we keep ALI files as build artifacts. Object files are not
>> enough in order to avoid recompilation.
> 
> Ok, so .ali files will not go away entirely. But they may lose all their
> cross-reference info.

Thanks. Recompilation is only one aspect. We want to freeze the whole 
project state. I see there is the file clang_ref_cache.db. It looks like 
a database (SQLite?). Probably we should to store it as well in the future.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: ALI Files Cross-References Inconsistency?
  2020-08-13 15:24 ALI Files Cross-References Inconsistency? Leandro Ribeiro
                   ` (2 preceding siblings ...)
  2020-09-25 16:16 ` Stephen Leake
@ 2020-09-30  9:53 ` wj46633
  3 siblings, 0 replies; 15+ messages in thread
From: wj46633 @ 2020-09-30  9:53 UTC (permalink / raw)


On Thursday, August 13, 2020 at 8:54:47 PM UTC+5:30, Leandro Ribeiro wrote:
> Hello, everyone 
> 
> I recently started to take a better look into Ada.
> 
> I am currently analyzing .ali files.
> 
> In the code snippets below (.ads and .adb), I wrote "|" to show where the ALI file claims a given symbol is.
> The (line X) just tells which line number the line had in my local text editor.
> 
> I would expect every reference to point to the beginning of the symbol, as it is the case with "3K9*excep2".
> However, all other references to the symbols from excep2.ads are exactly 4 columns ahead of the "expected point".
> And all the references to the symbols from excep2.adb are exactly 12 columns ahead of the "expected point".
> 
> 
> Question:
> Is this a bug?
> Or did a miss any rule about adding offsets to the references?
> 
> 
> 
> ======== excep2.ali
> ...
> X 1 excep2.ads
> 3K9*excep2 13l5 13e11 2|3b14 22l5 22t11
> 6U19*excep 7>10 8>9 8>12 9<9 10<9 2|5b19 20l13 20t18
> 7a10 S{string} 2|6b10 10r30 11r28 13r31
> 8e9 C{character} 2|6b22 13r38
> 8e12 Delim{character} 2|6b25 11r35
> 9b9 Found{boolean} 2|6b44 9m17 15m33
> 10i9 Position{positive} 2|6b64 14m38
> X 2 excep2.adb
> 10i25 J{integer} 11r30 13r33 14r50
> ...
> 
> ======== excep2.ads
> pragma SPARK_Mode;
> 
> package |excep2 
> is
> (line 5)-- procedure finds first occurence of char C before char Delim
>         procedure exce|p 
> 	(S : |String; 
> 	C, D|eli|m : Character; 
> 	Foun|d: out Boolean; 
> (line10)Posi|tion : out Positive)
>         with Annotate => (GNATprove, Intentional,
>                "might not be initialized in", "reviewed by Leandro: If it can be used (Found=True), it is surely initialized");
> end excep2;
> 
> 
> ======== excep2.adb
> pragma SPARK_Mode;
> 
> package body excep2 is
> 	-- procedure finds first occurence of char C before char Delim
> (line 5)procedure excep 
> 	(S : String; C, Delim : Character; Found: out Boolean; Position : out Positive)
>  is
> 	begin
> 		Found := False;
> (line 10)	for	J in S'Range| loop
> 			if S(J) = Delim then
> 				return;
> 			elsif S(J) = C
> 				then Position := J;
> (line 15)				Found := True;
> 				return;
> 			end if;
> 		end loop;
> 		return;
> (line 20)end excep;
> 
> end excep2;

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

end of thread, other threads:[~2020-09-30  9:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 15:24 ALI Files Cross-References Inconsistency? Leandro Ribeiro
2020-08-13 15:55 ` Dennis Lee Bieber
2020-08-13 21:18   ` Simon Wright
2020-08-14 19:45     ` Dennis Lee Bieber
2020-08-13 17:17 ` Egil H H
2020-08-14  8:11   ` Leandro Ribeiro
2020-08-14 16:35     ` Per Sandberg
2020-08-14 17:23       ` Simon Wright
2020-08-15  7:56         ` J-P. Rosen
2020-08-14 19:47     ` Dennis Lee Bieber
2020-09-25 16:16 ` Stephen Leake
2020-09-25 19:35   ` Dmitry A. Kazakov
2020-09-25 22:33     ` Stephen Leake
2020-09-26  8:03       ` Dmitry A. Kazakov
2020-09-30  9:53 ` wj46633

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