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

Addr2Line2Locations for GPS

55 views
Skip to first unread message

Hibou57 (Yannick Duchêne)

unread,
Jan 15, 2010, 7:04:05 PM1/15/10
to
Hi every body out there,

Was it already existing ? I do not know, and any way, I was not able
to find it. So, here is a tiny utility application for GPS; whose
purpose is to parse exception trace message which some Ada application
may return, when compiled with GNAT and the some dedicated build
options. I'm talking about these famous kinds of messages starting
with “ Call stack traceback locations: 0xXXXXX, .... ”.

The functionality this application provide, parse this kind of
exception trace via any many addr2line invocations as required (thus
its name, addr2line2locations) and turns these into entries added to
the GPS Locations pane. Entries are number from the inner most to the
outer most context. This numbering is required to have meaningful
locations, as the Locations pane automatically re-organize its entries
based their association file name.

This Python application is invoked from a menu entry it adds in the
Tools menu, but its main method may also be usefully invoked from any
other modules.

For usage and more informations, please, read the module's
documentation in the heading of the Python file.

http://www.les-ziboux.rasama.org/download/addr2line2locations-for-gps.zip
http://www.les-ziboux.rasama.org/download/addr2line2locations-for-gps.tar.gz


P.S. I've recently discovered an error (well, two, to be honest), in
the application I've presented a few time before, ASISEyes. There will
be an update soon. Sorry for any inconvenience.

Randy Brukardt

unread,
Jan 15, 2010, 9:25:10 PM1/15/10
to
"Hibou57 (Yannick Duch�ne)" <yannick...@yahoo.fr> wrote in message
news:b4e241ea-4a85-418a...@e37g2000yqn.googlegroups.com...

> Hi every body out there,
>
> Was it already existing ? I do not know, and any way, I was not able
> to find it. So, here is a tiny utility application for GPS;

I would put links to your utilities onto AdaIC, but you need to have a web
page describing them somewhere so that I can do that. I don't want to make
links to random .zip or .tar files from our site given the minimal
descriptions that we put there.

Randy Brukardt, AdaIC webmaster


Hibou57 (Yannick Duchêne)

unread,
Jan 15, 2010, 11:40:51 PM1/15/10
to
On 16 jan, 03:25, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> I would put links to your utilities onto AdaIC, but you need to have a web
> page describing them somewhere so that I can do that. I don't want to make
> links to random .zip or .tar files from our site given the minimal
> descriptions that we put there.
>
>                            Randy Brukardt, AdaIC webmaster

I really agree this would be better (for the other as well). This will
be done later, I will tell you.

Dmitry A. Kazakov

unread,
Jan 16, 2010, 3:45:42 AM1/16/10
to
On Fri, 15 Jan 2010 16:04:05 -0800 (PST), Hibou57 (Yannick Duch�ne) wrote:

> Was it already existing ?

[...]
Not in this form, but yes, I have done something similar for the Gtk
tracing tool. If there is a stack trace it can be cut and pasted into the
tool's box. Upon pasting address locations are replaced by the symbolic
ones. Further, when GPS is active you can right click on a symbolic trace
line and that will open in the GPS the source file selecting to
corresponding source line. So it recognizes whether the particular line in
the message box is a symbolic source location (e.g. file name + line
number) or else just a message text:

http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#1.4

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

Hibou57 (Yannick Duchêne)

unread,
Jan 17, 2010, 8:38:45 PM1/17/10
to
On 16 jan, 03:25, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> I would put links to your utilities onto AdaIC, but you need to have a web
> page describing them somewhere so that I can do that. I don't want to make
> links to random .zip or .tar files from our site given the minimal
> descriptions that we put there.
>
>                            Randy Brukardt, AdaIC webmaster

Done : http://www.les-ziboux.rasama.org/addr2line2locations-tool-ada-gps-en.html


On 16 jan, 09:45, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:


> [...]
> Not in this form, but yes, I have done something similar for the Gtk
> tracing tool. If there is a stack trace it can be cut and pasted into the
> tool's box. Upon pasting address locations are replaced by the symbolic
> ones. Further, when GPS is active you can right click on a symbolic trace
> line and that will open in the GPS the source file selecting to
> corresponding source line. So it recognizes whether the particular line in
> the message box is a symbolic source location (e.g. file name + line
> number) or else just a message text:

I've also changed some stuff this way : it now parse the message which
comes with the exception log, at least to add an entry for the
instruction which raised the exception, which is not part of the
traceback (obviously, as a Raise statement is not a subprogram call).

This also now tries to automatically fill-up the exception log input
field based on the text content of any active console at the moment
the command is invoked (very convenient for users), and try to fill-up
the executable name input field based on the project properties. If
there are multiples, then the user may choose among items of a list,
and he/she is still able to manually edit anyway.

Emmanuel Briot

unread,
Jan 18, 2010, 5:59:40 AM1/18/10
to
> Was it already existing ? I do not know, and any way, I was not able
> to find it. So, here is a tiny utility application for GPS; whose
> purpose is to parse exception trace message which some Ada application
> may return, when compiled with GNAT and the some dedicated build
> options. I'm talking about these famous kinds of messages starting
> with “ Call stack traceback locations: 0xXXXXX, .... ”.

Nice to see people developing GPS plugins. In fact, GPS comes with a
plugin called addr2line.py, which, as I understand your description,
has a similar purpose. But better have your own if you are more
combortable with your interface.

Future versions of GNAT can now display symbolic backtraces on their
own, without a need for libaddr2line, so these plugins become a bit
less useful now.

Emmanuel

Hibou57 (Yannick Duchêne)

unread,
Jan 18, 2010, 8:38:11 AM1/18/10
to
On 18 jan, 11:59, Emmanuel Briot <briot.emman...@gmail.com> wrote:
> Nice to see people developing GPS plugins. In fact, GPS comes with a
> plugin called addr2line.py, which, as I understand your description,
> has a similar purpose.
Don't know how I've missed it, while believe me, I've searched for it.
Any way, I've just tried it, and did not feel this one handy at all
(oops, shame on me for such words). Addr2Line2Locations was designed
to be user friendly.

> But better have your own if you are more
> combortable with your interface.

I feel so

> Future versions of GNAT can now display symbolic backtraces on their
> own, without a need for libaddr2line, so these plugins become a bit
> less useful now.

Future versions ? Which ones ?
This will output source locations instead of addresses ?

franck

unread,
Jan 19, 2010, 5:23:34 AM1/19/10
to
This may solve your problem :

use gnatmake -g start -bargs -E to generate exe,
you will get :
--> start

Exception raised
Exception name: CONSTRAINT_ERROR
Message: start.adb:16 range check failed
0x804acdd in start.procedure_b at start.adb:16
0x804acbd in start.procedure_a at start.adb:21
0x804ab03 in start at start.adb:41
0x804a4d6 in main at b~start.adb:179
0xca1dea in ?? at ??:0
start :exception raised Exception name: CONSTRAINT_ERROR
Message: start.adb:16 range check failed
Call stack traceback locations:
0x804acdd 0x804acbd 0x804ab03 0x804a4d6 0xca1de

start.adb:
------


with Ada.Text_IO;
with Ada.Exceptions;
with GNAT.Exception_Traces; use GNAT.Exception_Traces;
with GNAT.Traceback.Symbolic;
procedure start is

procedure Procedure_B is
type Very_Small_Integer is range 0 .. 2;
My_Very_Small_Integer : Very_Small_Integer :=0;
begin

--warning: value not in range of type "Very_Small_Integer"
--warning: "Constraint_Error" will be raised at run time
My_Very_Small_Integer := 3;
end Procedure_B;

procedure Procedure_A is
begin
Procedure_B;
end Procedure_A;

begin
-- reminder
-- to compile this unit, use command :
-- gnatmake -g start -bargs -E

-- -g => for gnatgcc debug information
-- -E => for gnatbind Store tracebacks in exception occurrences when
the target supports it.
-- This is the default with the zero cost exception mechanism. See
also the packages GNAT.Traceback and GNAT.Traceback.Symbolic

-- GNAT init
GNAT.Exception_Traces.Trace_On(GNAT.Exception_Traces.Every_Raise);
GNAT.Exception_Traces.Set_Trace_Decorator
(GNAT.Traceback.Symbolic.Symbolic_Traceback'access);


Ada.Text_IO.Put_Line("--> start");
Procedure_A;
Ada.Text_IO.Put_Line("<-- start");

exception
when Error: others =>
Ada.Text_IO.Put_Line ("start :exception raised " &
Ada.Exceptions.Exception_Information (Error));
end start;

Gautier write-only

unread,
Jan 19, 2010, 8:49:42 AM1/19/10
to
A variant (compatible with older GNAT's): instanciating the TB_Wrap
below and gnatmake that instanciation.
But I guess that Emmanuel wanted to say that future versions (which
are present ones in other time-spaces) spontaneously display a
symbolic trace-back instead of a bunch of addresses. But maybe I'm
just dreaming...
Gautier

------------------------------------------------------------------------------
-- File: TB_Wrap.ads
-- Description: Trace-back wrapper for GNAT 3.13p+ (spec.)
------------------------------------------------------------------------------

generic

with procedure My_main_procedure;

procedure TB_Wrap;
------------------------------------------------------------------------------
-- File: TB_Wrap.adb
-- Description: Trace-back wrapper for GNAT 3.13p+ (body)
------------------------------------------------------------------------------

with GNAT.Traceback.Symbolic, Ada.Exceptions, Ada.Text_IO;
use Ada.Exceptions, Ada.Text_IO;

procedure TB_Wrap is
-- pragma Compiler_options("-g");
-- pragma Binder_options("-E");
begin
My_main_procedure;
exception
when E: others =>
New_Line;
Put_Line("--------------------[ Unhandled
exception ]-----------------");
Put_Line(" > Name of exception . . . . .: " &
Ada.Exceptions.Exception_Name(E) );
Put_Line(" > Message for exception . . .: " &
Ada.Exceptions.Exception_Message(E) );
Put_Line(" > Trace-back of call stack: " );
Put_Line( GNAT.Traceback.Symbolic.Symbolic_Traceback(E) );
end TB_Wrap;


Ludovic Brenta

unread,
Jan 19, 2010, 10:37:58 AM1/19/10
to
Gautier write-only wrote on comp.lang.ada:

> A variant (compatible with older GNAT's): instanciating the TB_Wrap
> below and gnatmake that instanciation.
> But I guess that Emmanuel wanted to say that future versions (which
> are present ones in other time-spaces) spontaneously display a
> symbolic trace-back instead of a bunch of addresses. But maybe I'm
> just dreaming...

The GNAT package in Debian has had support for symbolic tracebacks,
without libaddr2line, since around 2003 in gnat 3.15p. That support
was previously available in the Ada for Linux Team's RPM packages.

--
Ludovic Brenta.

Ludovic Brenta

unread,
Jan 19, 2010, 10:49:08 AM1/19/10
to
I wrote on comp.lang.ada:

Actually I uploaded that as part of gnat 3.15p-13 on 2005-08-28.

--
Ludovic Brenta.

leandrohbatista

unread,
Jan 29, 2011, 8:23:49 AM1/29/11
to
Hello!

I've tried to use this plugin and get an error message.
The exception message was:

====================
Execution terminated by unhandled exception
Exception name: ASIS.EXCEPTIONS.ASIS_INAPPROPRIATE_ELEMENT
Message: a4g-vcheck.adb:885
Call stack traceback locations:
0x494daa 0x4c620c 0x533f47 0x533f78
0x533e00 0x533e00 0x533e00 0x533e00
0x533e00 0x5338ed 0x536516 0x53218d
0x53245f 0x530f04 0x5383c3 0x401235
0x401286 0x7c817075
====================

Then after execute Addr2Line2Locations I got the following message:

====================
Traceback (most recent call last):
File "C:\Documents and Settings\lhbatist\.gps\plug-ins\addr2line2locations.py", line 1301, in on_click_invok_addr2line
invok_addr2line ()
File "C:\Documents and Settings\lhbatist\.gps\plug-ins\addr2line2locations.py", line 1252, in invok_addr2line
exception_log = exception_log)
File "C:\Documents and Settings\lhbatist\.gps\plug-ins\addr2line2locations.py", line 1156, in add_exception_origin_location
category = category_name (executable_name))
GPS.Unexpected_Exception: unexpected internal exception Exception name: CONSTRAINT_ERROR
Message: s-valint.adb:63 explicit raise
Call stack traceback locations:
0x1337643 0x1337693 0xd28333 0x8d76aa 0xca1722 0x1032c25 0x1e08ec29
====================

And the locations pane is not displayed. I'd to like to know if this is a problem with my GPS instalation or if it could a plugin error...

Thanks in advance!

Yannick Duchêne (Hibou57)

unread,
Feb 2, 2011, 11:46:18 AM2/2/11
to
Le Sat, 29 Jan 2011 14:23:49 +0100, leandrohbatista
<leandro...@gmail.com> a écrit:

Leandro,

Sorry to be late, I've just noticed this post right now.

The line “s-valint.adb:63 explicit raise” clearly indicates this does not
come from Addr2Line2Locations, as the source does not make use of krunched
file name. However, the GNAT source do, and I remember I get some
hard-to-figure failures with ASIS for GNAT. You may have faced an
ASIS4GNAT bug for which I could not find a workaround. But I have to be
sure of that. Could you please, post here or send me via e-mail, the
exception trace you were to examine and the file to which it was applying
? I have to check if it's the tool or ASIS4GNAT which is wrong.


--
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour
les chiens.

“I am fluent in ASCII” [Warren 2010]

leandrohbatista

unread,
Feb 3, 2011, 4:19:00 AM2/3/11
to
Salut Yannick! Thanks for your answer!

You are right, this is not a problem with your plugin! I tried to use the method GPS.Locations.Parse and I got the same error. Look at this topic:
https://groups.google.com/d/topic/comp.lang.ada/gs9u1TKt_Qo/discussion

Now I solved this problem using GPS.Locations.Add(). I had done few tests and it seems to work fine.

Again, thanks!

Leandro.

Yannick Duchêne (Hibou57)

unread,
Feb 3, 2011, 8:40:04 AM2/3/11
to
Le Thu, 03 Feb 2011 10:19:00 +0100, leandrohbatista
<leandro...@gmail.com> a écrit:

> Salut Yannick! Thanks for your answer!

You're welcome,

By the way I was silly with the previous reply, as get confused with
another tool I also talked about here. The one of this topic does not rely
on ASIS, obviously.

From my previous experiences with Python scripting in GPS, I would say
defensive programing is the best you can do most of time.

About your other post.

s-valint.adb:
https://www2.adacore.com/gap-static/GNAT_Book/html/rts/s-valint__adb.htm

There is only a single explicit raise statement in that source, and it
belongs to the function named Scan_Integer.
For the location you used “C:\Test.adb:5:1: Message”. Possibly the parser
is confused with the “C:\...” which is expected to be a separator for
location parameters; between file name and line number and then after
between line number and column number. I remember a tool from Jean-Pierre
Rosen, AdaControl, had similar issues with its integration into GPS using
Python and the GPS modules.

You may have a look at AdaControl's source, in the Python files, you may
find some worthy materials there.
http://www.adalog.fr/adacontrol2.htm
See “Source Distribution” at the bottom of the page, unpack, then look at
the relevant Python file.

I will look later at my own source, while this would be easier with some
example which make the bug occurs with precisely the incriminated tool
(but don't bother if you can't send some, I will look at it any way).

Yannick Duchêne (Hibou57)

unread,
Feb 3, 2011, 9:00:16 AM2/3/11
to
Le Thu, 03 Feb 2011 14:40:04 +0100, Yannick Duchêne (Hibou57)
<yannick...@yahoo.fr> a écrit:

> By the way I was silly with the previous reply, as get confused with
> another tool I also talked about here. The one of this topic does not
> rely on ASIS, obviously.

I also forget to post a link to a real page as Randy requested at that
time (just remembered it while looking at the Google Group version of the
thread):
http://www.les-ziboux.rasama.org/addr2line2locations-tool-ada-gps-en.html

0 new messages