Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception traceback when using TDM-GCC 5.1.0-3

405 views
Skip to first unread message

ahlan.m...@gmail.com

unread,
Jul 19, 2016, 12:40:24 PM7/19/16
to
For licensing reasons we would prefer to use the GNAT GCC packaged by TDM (currently v5.1.0-3) rather than the GPL provided by AdaCore.
Although our programs compile and execute as expected we don't get a traceback when we raise an exception even though (or perhaps because) we use the same gpr file and use GprBuild.

We get the exception name and message but not the traceback.

We bind with the switch -E (which I thought was supposed to add traceback information) but I wonder if there isn't some other switch that we need to use.
I note that the default exception handling mechanism is different between what AdaCore builds and that built by TDM.

Could this have something to do with our problem?

Any suggestions gratefully received,
Ahlan

jrmarino

unread,
Jul 20, 2016, 1:33:09 AM7/20/16
to
On Tuesday, July 19, 2016 at 11:40:24 AM UTC-5, ahlan.m...@gmail.com wrote:
>
> Could this have something to do with our problem?
>
> Any suggestions gratefully received,
> Ahlan

It's not user error. traceback doesn't work on a stock GNAT FSF.
It works on the FreeBSD/DragonFly versions because I patched it though. see here:
https://svnweb.freebsd.org/ports/head/lang/gcc5-aux/files/diff-ada?revision=416524&view=co

Search for traceback and trasym

With those packages, symbolic traceback will work as you expect.


ah...@marriott.org

unread,
Jul 20, 2016, 2:19:09 AM7/20/16
to
Dear John,
Oh dear - That's a bit of a (nasty) surprise.
So where does that leave us?
Can we patch (correct) the TDM release somehow so that traceback does work?
You tantalizingly offer a glimmer of hope when you write "with those packages, symbolic traceback will work" which sort of suggests that if we take some packages from somewhere and perhaps build something using them, then al will be well - which then raises the question as to why TDM (or someone) hasn't applied these fixes to FSF, especially as your work doesn't seem to be new.
I am astounded that people can use a system that doesn't provide a traceback - how on earth can you debug?
If it is possible to fix the FSF version, can you help me do that?
Best regards,
Ahlan

Simon Wright

unread,
Jul 20, 2016, 2:43:18 AM7/20/16
to
ah...@marriott.org writes:

> ... why TDM (or someone) hasn't applied these fixes to FSF, especially
> as your work doesn't seem to be new.

Is this only a Windows thing? You get a hex traceback under macOS, but you
have to rely on an external tool (atos) to symbolicate (?) it.

(Actually, ISTR someone produced symbolic traceback code?)

> I am astounded that people can use a system that doesn't provide a
> traceback - how on earth can you debug?

If atos doesn't ring the bell immediately, it's time for gdb. But maybe
TDM doesn't support gdb? You could always try the AdaCore GPL gdb, that
would carry no GPL flavour into your product.

ah...@marriott.org

unread,
Jul 20, 2016, 3:13:37 AM7/20/16
to
Dear Simon,
Our problem is that we don't get a traceback at all.
In AdaCore's GNAT the traceback is displayed by default in hex.
To convert that into a symbolic traceback we use Gnat.Traceback.Symbolic.
However this is not the problem.
The problem is that we don't get a traceback at all - ie the -E switch doesn't seem to have the desired effect.
In System.ads ZCX_By_Default is set to False for AdaCore GNAT and True for TDM so I wondered if that had anything to do with the problem.
However John seems to think that the problem is more fundamental.

MfG
Ahlan

jrmarino

unread,
Jul 20, 2016, 9:06:51 AM7/20/16
to
On Wednesday, July 20, 2016 at 1:43:18 AM UTC-5, Simon Wright wrote:
> ah...@marriott.org writes:
>
> > ... why TDM (or someone) hasn't applied these fixes to FSF, especially
> > as your work doesn't seem to be new.
>
> Is this only a Windows thing? You get a hex traceback under macOS, but you
> have to rely on an external tool (atos) to symbolicate (?) it.
>

I may have misunderstood what's been seen by Ahlan. My modification removes the need for the external tool (in reality using addr2line behind the scenes) so that requested tracebacks work.

Reference: https://rosettacode.org/wiki/Stack_traces#Ada
With my modification, the rosetta case works on BSD's gnat just like this.

I can't remember if without it there are no symbols or just symbols that you have to manually pass to addr2line

jrmarino

unread,
Jul 20, 2016, 9:09:12 AM7/20/16
to
I misunderstood you I think.
I was fixing GNAT.Traceback.Symbolic (so that it doesn't require addr2line).
I don't have any knowledge of TDM so I can't help further. I does sound like you should be getting some kind of trace though.

gautier...@hotmail.com

unread,
Jul 20, 2016, 11:51:54 PM7/20/16
to
Le mardi 19 juillet 2016 18:40:24 UTC+2, ahlan.m...@gmail.com a écrit :
> For licensing reasons we would prefer to use the GNAT GCC packaged by TDM (currently v5.1.0-3) rather than the GPL provided by AdaCore.

Did you give a try with MinGW ?
With version MinGW 4.7.2 I get at least a usable trace-back.
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address

ah...@marriott.org

unread,
Jul 21, 2016, 3:24:15 AM7/21/16
to
Dear Gautier,

I'm afraid I don't understand your question.
I downloaded TDM-GCC-5.1.0-3.exe from the TDM website.
(I was directed there from GetAdaNow -Windows)
I understand that this is their installer for TDM32 MinGW edition with SJLJ exception handling.
I then downloaded gcc-5.1.0-tdm-1-ada.zip which is supposed to be Ada support with SJLJ exceptions.
I then downloaded the GPR tools from GetAdaNow.
Together I can use these to compile and build my Ada applications that seem to execute correctly.
However, if I raise an exception I only get the name of the exception and the message. The traceback is missing.
In the .gpr we have
package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;
The -E is required in order that you get a traceback.
The other packages in the gpr are
package Builder is
for Default_Switches ("ada") use ("-s", "-g");
end Builder;

package Compiler is
for Default_Switches ("ada") use
("-O1", "-gnatQ", "-gnata", "-gnato", "-g", "-gnat12",
"-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120");
end Compiler;

MfG
Ahlan

gautier...@hotmail.com

unread,
Jul 21, 2016, 6:33:04 AM7/21/16
to
Hi Ahlan,
I meant the MinGW you get from: http://mingw.org/
I am using the 4.7.2 for building, for instance, the binary version of the AZip archive manager.
Cheers
Gautier

ah...@marriott.org

unread,
Jul 21, 2016, 8:15:14 AM7/21/16
to
Dear Gautier,
I see.
However, as I understand it, the MingGw is a build from Oct-13 which would be far too old for our purposes - we already use a lot of Ada 2012 features. TDM is from Jul-15.

MfG
Ahlan

Simon Wright

unread,
Jul 23, 2016, 12:32:28 PM7/23/16
to
ah...@marriott.org writes:

> Our problem is that we don't get a traceback at all.
> In AdaCore's GNAT the traceback is displayed by default in hex.
> To convert that into a symbolic traceback we use Gnat.Traceback.Symbolic.
> However this is not the problem.
> The problem is that we don't get a traceback at all - ie the -E switch
> doesn't seem to have the desired effect.

Using 32-bit TDM GCC 5.1.0 (tdm-1) on Windows 7 with this:

procedure CE is
procedure Raiser (N : Positive) is
begin
Raiser (N - 1);
end Raiser;
begin
Raiser (5);
end CE;

I get this:

>ce

Execution terminated by unhandled exception
Exception name: CONSTRAINT_ERROR
Message: ce.adb:4 range check failed
Call stack traceback locations:
0x401533 0x401533 0x401533 0x40154b 0x4014e6 0x4010fb 0x77a73646 0x77a73619

and I can use the addr2line.exe that came with GNAT GPL 2014 (I just
haven't got round to installing the 2016 release) to get this

>addr2line.exe -e ce.exe 0x401533 0x401533 0x401533 0x40154b 0x4014e6 0x4010fb 0x77a73646 0x77a73619
C:\Users\Simon Wright/ce.adb:4
C:\Users\Simon Wright/ce.adb:4
C:\Users\Simon Wright/ce.adb:4
C:\Users\Simon Wright/ce.adb:7
C:/Users/Simon Wright/b~ce.adb:140
crt1.c:?
??:0
??:0

ahlan.m...@gmail.com

unread,
Jul 24, 2016, 4:43:12 AM7/24/16
to
Dear Simon,
The Call stack traceback locations are what I was expecting but unfortunately are missing when I raise an exception.
So the question is why.
Do you compile or build with different switches than me?

Ahlan

Simon Wright

unread,
Jul 24, 2016, 5:44:27 AM7/24/16
to
ahlan.m...@gmail.com writes:

> The Call stack traceback locations are what I was expecting but
> unfortunately are missing when I raise an exception.
> So the question is why.
> Do you compile or build with different switches than me?

>gnatmake -g -f ce.adb -bargs -E

(-f only to force the recompilation)

No idea why ...

jrmarino

unread,
Jul 24, 2016, 1:14:43 PM7/24/16
to
I had the same experience last month. I had to pass "-bargs -E" through the command line because "-E" as a binder switch did not work. I also did not understand why, but I stopped thinking about it after I got it to work with -bargs.

ahlan.m...@gmail.com

unread,
Jul 24, 2016, 2:54:41 PM7/24/16
to
Hi,
I am using GprBuild not Gnatmake - any ideas what switches I should use either on the command line or within the gpr file to get exception traceback with TDM-GCC.
Code compiled using AdaCore's Gnat Pro and GPL produce tracebacks if I provide -E to bind in the gpr.

Ahlan

Björn Lundin

unread,
Jul 24, 2016, 3:46:09 PM7/24/16
to
On 2016-07-24 20:54, ahlan.m...@gmail.com wrote:

> Hi,
> I am using GprBuild not Gnatmake - any ideas what switches I should use either on the command line or within the gpr file to get exception traceback with TDM-GCC.
> Code compiled using AdaCore's Gnat Pro and GPL produce tracebacks if I provide -E to bind in the gpr.


include

package Compiler is
for Default_Switches ("ada") use ("-g");
end Compiler;


package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;


in your gpr.
Add to that the switches you use now

--
--
Björn

Georg Bauhaus

unread,
Jul 25, 2016, 3:14:19 AM7/25/16
to
On 24.07.16 19:14, jrmarino wrote:
> I had to pass "-bargs -E" through the command line because "-E" as a binder switch did not work. I also did not understand why, but I stopped thinking about it after I got it to work with -bargs.

The -E switch is "overloaded", for gcc it has to do with
preprocessing, gathering more meanings with other tools
potentially(?) in the chain that starts at gcc. So, I guess
that this is a plausible explanation of why both gnatmake
and gprbuild do not list -E among their options.

--
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff

ahlan.m...@gmail.com

unread,
Jul 25, 2016, 4:45:29 AM7/25/16
to
Dear Björn,

As I wrote previously in this thread I use

package Compiler is
for Default_Switches ("ada") use
("-O1", "-gnatQ", "-gnata", "-gnato", "-g", "-gnat12",
"-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120");
end Compiler;

package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;


in my Gpr files - i.e. I am already using "-g".
Or have I misread - are you proposing I do something different to what I currently do?

Ahlan

gautier...@hotmail.com

unread,
Jul 25, 2016, 5:04:20 AM7/25/16
to
Another point to investigate is perhaps an unexpected mix of compilers.
If you have TDM in front in the PATH string, and some other GNAT flavour later, it may work fine, but I had a case yesterday where some components of the second GNAT was inkoved unexpectedly.
_________________________
Gautier's Ada programming
http://www.openhub.net/accounts/gautier_bd

Björn Lundin

unread,
Jul 25, 2016, 7:34:19 AM7/25/16
to
On 2016-07-25 10:45, ahlan.m...@gmail.com wrote:
> Dear Björn,
>
> As I wrote previously in this thread I use

Sorry, my mistake, I missed that.



--
Björn

Simon Wright

unread,
Jul 25, 2016, 8:05:03 AM7/25/16
to
ahlan.m...@gmail.com writes:

> package Compiler is
> for Default_Switches ("ada") use
> ("-O1", "-gnatQ", "-gnata", "-gnato", "-g", "-gnat12",
> "-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120");
> end Compiler;

I think it's better to put -g in Builder:

package Builder is
for Default_Switches ("ada") use ("-g");
end Builder;

so it gets used in the link phase too.

Björn Lundin

unread,
Jul 25, 2016, 10:06:38 AM7/25/16
to
or perhaps i Builder

package Builder is
for Default_Switches ("Ada") use ("-k","-s","-j4","-g");
end Builder;

--
--
Björn

ahlan.m...@gmail.com

unread,
Jul 25, 2016, 2:48:12 PM7/25/16
to
Dear Björn,

Thanks for your suggestions, however I still don't get a traceback.

I call Gprbuild with -P and the name of the Gpr file together with -eS and -q

My gpr is
for Exec_Dir use "W:\Product\Elephant\Windows";
for Main use ("GnatTest.adb");

package Pretty_Printer is
for Default_Switches ("ada") use ("-i2", "-M120", "-aL", "-A1", "-A4");
end Pretty_Printer;

package Builder is
for Default_Switches ("ada") use ("-k", "-s", "-j4", "-g");
for Executable ("GnatTest.adb") use "GnatTest";
end Builder;

package Compiler is
for Default_Switches ("ada") use
("-O1", "-gnatQ", "-gnata", "-gnato", "-g", "-gnat12",
"-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120");
end Compiler;

package Binder is
for Default_Switches ("ada") use ("-E");
end Binder;

package Linker is
for Linker_Options use ();
for Default_Switches ("ada") use
("-g", "-LW:\Product\Elephant\Windows",
"D:\Binary\Elephant\Ada\Projects\Test\GnatTest\objects\resources.o", "-mwindows");
end Linker;

Ahlan

ahlan.m...@gmail.com

unread,
Jul 25, 2016, 2:49:25 PM7/25/16
to
Dear Gautier,

Thanks for the idea - however I have been careful not to mix compilers ;-)

MfG
Ahlan

jrmarino

unread,
Jul 26, 2016, 5:21:01 PM7/26/16
to
On Monday, July 25, 2016 at 1:48:12 PM UTC-5, ahlan.m...@gmail.com wrote:
> package Binder is
> for Default_Switches ("ada") use ("-E");
> end Binder;

Are you reading the replies in your own thread? It's been said that -E in package Binder will not work. You have to pass -bargs when you invoke gprbuild on the command line. From what I can tell, there's nothing wrong TDM-GCC compiler, you're just not invoking gprbuild correctly.

Markus Schöpflin

unread,
Jul 27, 2016, 3:09:26 AM7/27/16
to
I didn't follow the thread but your statement is not true in general. We are
using the following statement in our gpr files:

package BINDER is
for DEFAULT_SWITCHES ("Ada") use ("-E", "-we", "-g");
end BINDER;

and it certainly results in -E being added to the command line of gnatbind, as
can be seen by invoking gprbuild with -v. The resulting invocation of gnatbind
looks e.g.:

gnatbind -o b__foo.adb foo.ali -E -we -g -x -F=GNAT-TEMP-000004.TMP
-O=GNAT-TEMP-000006.TMP

Markus

gautier...@hotmail.com

unread,
Jul 27, 2016, 3:18:07 AM7/27/16
to
On Monday, July 25, 2016 at 8:48:12 PM UTC+2, ahlan.m...@gmail.com wrote:

In package Linker you have "-mwindows".
Are you trying to output your trace-back to the console window ?
If so, no chance then if you have "-mwindows".
_________________________
Gautier's Ada programming

Simon Wright

unread,
Jul 27, 2016, 3:35:29 AM7/27/16
to
I just tried this, and -E in package Binder works on TDM-GCC, just like
it does on macOS. I haven't tried explicitly on Linux.

ahlan.m...@gmail.com

unread,
Jul 27, 2016, 6:41:42 AM7/27/16
to
Of course I am reading the replies and I am trying out everything everyone suggests.
As Markus has written using the binder default switches within the gpr does cause -E to be passed to gnat bind as goes -bargs -E
In fact if I supply -bargs -E on the command and -E in the binder package then gnat bind gets -E twice.
However I still don't get a traceback.

ahlan.m...@gmail.com

unread,
Jul 27, 2016, 6:45:48 AM7/27/16
to
Dear Gautier,

Well spotted but that isn't the problem - that is our default but the test program overwrites it with
Pragma Linker_Options ("-mconsole");
Besides I do get output on the console.
I get the name of the exception and its associated message - all that is missing is the traceback.

MfG
Ahlan

ahlan.m...@gmail.com

unread,
Jul 27, 2016, 6:57:44 AM7/27/16
to
Dear Simon,
I have only tried this out on Windows.
I downloaded and ran TDM-GCC-5.1.0-3.exe and then download and unpacked gcc-5.1.0-tdm-1-ada.zip
I obtained the Gprbuild etc as Gprtools from GetAdaNow.
If I build your example test program and execute it I get the constraint exception but not the traceback.

The very fact that you can get a traceback at least indicates that it is possible.
All we now have to do is figure out is what I am doing differently to you.
The same program and same gpr files gives me a traceback when I use AdaCore's GPL.

Do you use SJLJ executions or DW2?

MfG
Ahlan

Simon Wright

unread,
Jul 27, 2016, 9:22:43 AM7/27/16
to
I already had GNAT GPL 2014 installed.

I downloaded tdm-gcc-webdl.exe and ran it, making sure to select Ada
support.

My PATH is

C:\Users\Simon Wright>echo %PATH%
C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\Sy
stem32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\TDM-GCC-32\bin;C:\GNA
T\2014\bin;C:\Program Files\GnuWin32\bin

Although the gprbuild is GPL 2014, it's clear from 'gprbuild -v' (and
from GPS/Help/About) that the actual compiler in use is GCC 5.1.0,
i.e. the TDM one.

ahlan.m...@gmail.com

unread,
Jul 27, 2016, 10:11:06 AM7/27/16
to
Dear Simon,
What is tdm-gcc-webdl.exe and where did you get it from?
I used TDM-GCC-5.1.0-3.exe and gcc-5.1.0-tdm-1-ada.zip from http://tdm-gcc.tdragon.net
Perhaps this is the difference?

MfG
Ahlan

Simon Wright

unread,
Jul 27, 2016, 11:45:51 AM7/27/16
to
ahlan.m...@gmail.com writes:

> What is tdm-gcc-webdl.exe and where did you get it from?
> I used TDM-GCC-5.1.0-3.exe and gcc-5.1.0-tdm-1-ada.zip from
> http://tdm-gcc.tdragon.net

It's the "on-demand installer" (the box on the right on that page).

My Windows 7 is 32-bit (running under VMware).

Anh Vo

unread,
Jul 27, 2016, 3:32:37 PM7/27/16
to
It worked as expected on PC running Windows 7. Just like Simon, I used on-demand installer tdm-gcc-webdl.exe.

Anh Vo

ahlan.m...@gmail.com

unread,
Jul 27, 2016, 4:33:23 PM7/27/16
to
Dear Simon and Anh,

Yes that seems to be better.
If I use the on demand installer then I get traceback information.
This then begs the question of what exactly is the difference between what I was doing and what the on demand installer has done?

However it is still not quite right.
The traceback I now get consists only of two numbers rather than the 8 Simon had.
They are both above 0x77000000 and like the last two in Simon's traceback (that were also in this range) bring back only ??

So now I am getting a traceback but not the full traceback.

MfG
Ahlan

Anh Vo

unread,
Jul 27, 2016, 5:03:16 PM7/27/16
to
The exception is captured captured and handled in the exception handler. In addition, the traceback information is extracted as shown below.

--...
exception
when Error : others =>
Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback(Error));
--...


ahlan.m...@gmail.com

unread,
Jul 28, 2016, 2:07:02 AM7/28/16
to
Dear Anh,

Yes this is how I catch exceptions and display them symbolically.
My current problem is that although I get some kind of traceback, it isn't complete.
I only get two of the expected eight traceback addresses.
The two I do get have very high addresses and it seems normal that these cannot be resolved symbolically - hence they are displayed as "??" by both Gnat.Traceback.Symbolic.Symbolic_Traceback and addr2line

MfG
Ahlan

ahlan.m...@gmail.com

unread,
Jul 28, 2016, 2:56:27 AM7/28/16
to
Hi,

If I do exactly what Simon does (use gnat make on a single file) then I get eight traceback addresses.
However when I use addr2line I don't get a very useful symbolic traceback as it refers to lines within b~ce.adb rather than the true source ce.adb
If I catch the exception and use gnat.traceback.symbolic.symbolic_traceback then all I get are the addresses and not the symbolic references I expected.

MfG
Ahlan

Björn Lundin

unread,
Jul 28, 2016, 8:26:03 AM7/28/16
to
On 2016-07-28 08:56, ahlan.m...@gmail.com wrote:

>
> If I do exactly what Simon does (use gnat make on a single file) then I get eight traceback addresses.
> However when I use addr2line I don't get a very useful symbolic traceback as it refers to lines within b~ce.adb rather than the true source ce.adb
> If I catch the exception and use gnat.traceback.symbolic.symbolic_traceback then all I get are the addresses and not the symbolic references I expected.
>


since 10 years, we are not useing
gnat.traceback.symbolic.symbolic_traceback.


instead we get the hex addresses with Ada.Exceptions.Exception_Message
and from that we use addr2line.


addr2line --functions --basenames --exe=path/to/exe-file hex-adressess


--
--
Björn

Anh Vo

unread,
Jul 28, 2016, 10:48:17 AM7/28/16
to
On Wednesday, July 27, 2016 at 11:07:02 PM UTC-7, ahlan.m...@gmail.com wrote:
> >
> > The exception is captured captured and handled in the exception handler. In addition, the traceback information is extracted as shown below.
> >
> > --...
> > exception
> > when Error : others =>
> > Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback(Error));
> > --...
>
> Dear Anh,
>
> Yes this is how I catch exceptions and display them symbolically.
> My current problem is that although I get some kind of traceback, it isn't complete.
> I only get two of the expected eight traceback addresses.
> The two I do get have very high addresses and it seems normal that these
> cannot be resolved symbolically - hence they are displayed as "??" by both
> Gnat.Traceback.Symbolic.Symbolic_Traceback and addr2line

Try Simon's code with my modification shown below to see what I get complete traceback. By the way, it work on my PC.

with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_Io; use Ada.Text_Io;
with GNAT.Traceback.Symbolic;
procedure CE is
procedure Raiser (N : Positive) is
begin
Raiser (N - 1);
end Raiser;
begin
Raiser (5);
exception
when Error : others =>
Put_Line ("Houston we have a problem: " & Exception_Information(Error));
Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback(Error));
end Ce;

AV

Anh Vo

unread,
Jul 28, 2016, 11:44:32 AM7/28/16
to
Sorry, what I meant was "Try Simon's code with my modification shown below to see if you get complete traceback. By the way, it worked on my PC."

ahlan.m...@gmail.com

unread,
Jul 28, 2016, 12:00:16 PM7/28/16
to
Dear Anh,

Yes I appreciate that..
This is what I always try to do - and it works with GPL but not with TDM.
But then nor does Addr2line so something is not quite right.

MfG
Ahlan

ahlan.m...@gmail.com

unread,
Jul 28, 2016, 12:07:14 PM7/28/16
to
Dear Björn,

We use Gnat symbolic because we catch the exceptions and write them into a log.
In this case it makes more sense to write the symbolic traceback rather than a series of hexadecimal numbers.
With AdaCore Pro & GPL this works fine.
If only I could get TDM to do the same ;-(

MfG
Ahlan

Anh Vo

unread,
Jul 28, 2016, 12:16:14 PM7/28/16
to
I share your frustration since I was in a similar situation before. Thus, I have a suggestion. Use a PC having no GNAT nor TDM-GCC installed before. Install TDM-GCC and try it one more time. By the way, use command line "gnatmake -f -g ce.adb -bargs -E" first. If you do not have another PC, uninstall GNAT-GPL and TDM-GCC completely before reinstall TDM-GCC.

Anh Vo

Björn Lundin

unread,
Jul 28, 2016, 12:18:56 PM7/28/16
to
We spawn addr2line from the executable, feeding it the hex-adresses (and
path to exe).
We just dump that to a redirected std-out.
You could capture that output, and then put that into a log.
If you get the hex-addresses that is...







--
--
Björn

ahlan.m...@gmail.com

unread,
Jul 28, 2016, 4:34:12 PM7/28/16
to
Dear Anh,
Although it made no real sense, I did as you suggested and much to my surprise I now get a traceback when I use gnatmake that when fed to Addr2line returns the traceback that Simon has.
i.e. Address within CE.adb
At least this is useful.
However trying to convert this into a symbolic traceback using GNAT.Traceback.Symbolic.Symbolic_Traceback(Error)
merely produces eight lines of output - each line with the hexadecimal traceback address.
i.e. GNAT.Traceback.Symbolic.Symbolic_Traceback isn't working.
Does it work for you?

Simon - Does GNAT.Traceback.Symbolic.Symbolic_Traceback work on your system?

Björn has a work around foo this problem - but surely this shouldn't be necessary.
Surely the whole point of GNAT.Traceback.Symbolic.Symbolic_Traceback is to save having to do what Björn does.
GNAT.Traceback.Symbolic.Symbolic_Traceback worked for me using Gnat Pro and GPL so I rather hoped it would work using TDM.

Best wishes,
Ahlan

Björn Lundin

unread,
Jul 28, 2016, 4:54:46 PM7/28/16
to
On 2016-07-28 22:34, ahlan.m...@gmail.com wrote:

> Björn has a work around foo this problem - but surely this shouldn't be necessary.
> Surely the whole point of GNAT.Traceback.Symbolic.Symbolic_Traceback is to save having to do what Björn does.
> GNAT.Traceback.Symbolic.Symbolic_Traceback worked for me using Gnat Pro and GPL so I rather hoped it would work using TDM.


The reason we do it via addr2line is that once (say 10 years ago)
I complained to then ACT that the stacktrace does not produce correct
results on aix. we got traces, but sometimes totally wrong (as in row
num 658425 in a file with 2000 rows)

ACT then said that getting a reliable stacktrace from a dying process
was no good idea. So we just get the hex-dump, and then spawns
addr2line. This we do with Gnat pro and gnat gpl.

I do have noticed that for gnat fsf on linux x64, we sometimes get no
trace when passing the exception_occurence to a procedure in another
package.


--
Björn

ahlan.m...@gmail.com

unread,
Jul 29, 2016, 2:40:14 AM7/29/16
to
Dear Björn,
Thanks for the info.
Although I would have thought trying to spawn a new process and pipe information to it from a dying process would have been a even less of a good idea ;-)

MfG
Ahlan

Simon Wright

unread,
Jul 29, 2016, 3:01:57 AM7/29/16
to
ahlan.m...@gmail.com writes:

> Simon - Does GNAT.Traceback.Symbolic.Symbolic_Traceback work on your
> system?

No, and neither does addr2line - but addr2line isn't available on macOS,
we use the Apple atos instead.

s-trasym.ads (System.Traceback.Symbolic, where the work actually gets
done) says

-- On platforms where the full capability is not supported, function
-- Symbolic_Traceback return a list of addresses expressed as "0x..."
-- separated by line feed.

and the only implementation in GCC 6.1.0 is the hex one. I expect that
the GNAT GPL sources contain alternative versions.

gautier...@hotmail.com

unread,
Jul 29, 2016, 4:21:12 AM7/29/16
to
> GNAT.Traceback.Symbolic.Symbolic_Traceback worked for me using Gnat Pro and GPL so I rather hoped it would work using TDM.

Perhaps you might want to consider continuing using your copy of GNAT PRo even after the license expiration - should be possible and legal, shouldn't it ?
_________________________
Gautier's Ada programming
http://sf.net/users/gdemont/

Björn Lundin

unread,
Jul 29, 2016, 6:07:38 AM7/29/16
to
On 2016-07-29 08:40, ahlan.m...@gmail.com wrote:

> Dear Björn,
> Thanks for the info.
> Although I would have thought trying to spawn a new process and pipe information to it from a dying process would have been a even less of a good idea ;-)
>

Perhaps yes. But we just let addr2line print to std-out as usual.
and the parent's std-out is redirected to a file,
which means addr2line's output is written to the parent's std-out.

But you wanted to log it in a separate file ?

--
--
Björn

Anh Vo

unread,
Jul 29, 2016, 11:57:44 AM7/29/16
to
Yes, it does work as expected. Here are the results I got.

Houston we have a problem: Exception name: CONSTRAINT_ERROR
Message: ce.adb:7 range check failed
Call stack traceback locations:
0x40198b 0x40199b 0x40199b 0x40199b 0x40199b 0x4019bb 0x40194f 0x4013db 0x75883388 0x77949900 0x779498d3

[C:\Ada\Test\ce.exe]
0x0040198B ce.raiser at ce.adb:7
0x0040199B ce.raiser at ce.adb:7
0x0040199B ce.raiser at ce.adb:7
0x0040199B ce.raiser at ce.adb:7
0x0040199B ce.raiser at ce.adb:7
0x004019BB ce at ce.adb:10
0x0040194F main at b~ce.adb:221
0x004013DB .tmainCRTStartup at crtexe.c:332

[C:\Windows\syswow64\kernel32.dll]
[C:\Windows\SysWOW64\ntdll.dll]

Anh Vo

Anh Vo

unread,
Jul 29, 2016, 2:48:54 PM7/29/16
to
MIG,

My apology for crewing up. The gnatmake I invoked was part of GNAT-GPL. After correcting it on my PC at home, I got same results that you did, 9 Hex addresses without traceback location.

Anh Vo

ahlan.m...@gmail.com

unread,
Jul 30, 2016, 4:10:37 AM7/30/16
to
Yes & No,
We want any exceptions to go into the applications log file.
Ideally therefore we want Gnat traceback to work like it does for GPL.
Naively I would think this possible.

ahlan.m...@gmail.com

unread,
Jul 30, 2016, 4:11:34 AM7/30/16
to
Well at least my problem is reproducible by others.
I wonder what we are doing wrong?

MfG
Ahlan

ah...@marriott.org

unread,
Jul 31, 2016, 4:26:24 AM7/31/16
to
Dear Gautier,
Our understanding is that we can legally use Gnatpro after our support has finished and so this is exactly what we do. Unfortunately this means that we are frozen to a particular version of Gnat and will therefore miss out on all the improvements and corrections. This may be inconvenient as we are great fans of Ada-2012!. Hopefully AdaCore will one day offer a cheaper means for us to obtain Gnatpro - the current pricing is outside our league. Hence our interest in TDM. Here the assumption was that it was comparible with the GPL and would be kept roughly up to date.
Sadly this appears not to be the case. :-(
0 new messages