comp.lang.ada
 help / color / mirror / Atom feed
* gdb will not "catch exception" or "catch exception unhandled"
@ 2011-10-06 10:48 Jerry
  2011-10-06 10:57 ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry @ 2011-10-06 10:48 UTC (permalink / raw)


I'm having considerable difficulty getting gdb to break on exceptions;
in fact, I can't get it to work at all.

I'm using the AdaCore 2010 version on OS X 10.6.8, in Terminal.app:

GNU gdb (GDB) 7.1 for GNAT GPL 2010 (20100603) [rev=gdb-7.1-ref-90-
g6d5b58a]
This GDB was configured as "x86_64-apple-darwin9.6.0".

I don't think this is related, but FWIW, this happens every time I use
gdb from a terminal session (not GPS):

unable to read unknown load command 0x1a
warning: `/Volumes/Data/Builds/unix/gtk2.new/bld/pango/.libs/
libpangocairo_1_0_la-module-defs-atsui.o': can't open to read symbols:
No such file or directory.

except that there a a bazillion such gtk-related warnings. /Volumes/
Data is not my computer, but I do have gtk installed. I suppose this
is GPS-related so I don't worry about it too much.

So here's the problem. When I start a debugging session and type
catch exception
or
catch exception unhandled

gdb complains that I have to start my program running first. So I set
a breakpoint on an early line from where I type one of the above
commands, and then it accepts either command. But then my program
bombs a little later with "bus error" while awaiting input from the
keyboard for some user data.

I am able to debug normally if I don't try to catch exceptions.

Any ideas? Would I have better luck with the 2011 AdaCore version?

Jerry



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-06 10:48 gdb will not "catch exception" or "catch exception unhandled" Jerry
@ 2011-10-06 10:57 ` Simon Wright
  2011-10-07  0:22   ` Jerry
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2011-10-06 10:57 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> I'm having considerable difficulty getting gdb to break on exceptions;
> in fact, I can't get it to work at all.

I wrote up something on this here:
http://forward-in-code.blogspot.com/2011/08/debugging-with-mac-os-x-shared.html



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-06 10:57 ` Simon Wright
@ 2011-10-07  0:22   ` Jerry
  2011-10-07 16:34     ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry @ 2011-10-07  0:22 UTC (permalink / raw)


On Oct 6, 3:57 am, Simon Wright <si...@pushface.org> wrote:
> Jerry <lancebo...@qwest.net> writes:
> > I'm having considerable difficulty getting gdb to break on exceptions;
> > in fact, I can't get it to work at all.
>
> I wrote up something on this here:http://forward-in-code.blogspot.com/2011/08/debugging-with-mac-os-x-s...

That's really helpful, Simon. Thanks. I pretty much understood your
article which means that it's really well-written. 8^)

At your suggestion, I tried debugging under Snow Leopard's gdb. After
typing
  break __gnat_debug_raise_exception
I was able to climb up the stack to the bad line of my code and then
figure things out. Not ideal but better than what was before!

I did not understand the first part of this comment in your blog:

"HOWEVER, IF YOU CALL IN AN ADA SHARED LIBRARY BY MISTAKE (PERHAPS
BECAUSE YOU MISSED AN EXTERNAL VARIABLE SETTING IN A .GPR), the linker
will find the dynamic Ada runtime because it's referenced from the Ada
shared library:"

otool on my executable:

MBPro:product-debug me$ otool -L ./run
./run:
	/usr/local/plplot/lib/libplplotd.11.dylib (compatibility version
11.0.0, current version 11.0.0)
	@rpath/libgnat-2010.dylib (compatibility version 0.0.0, current
version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 125.2.11)
	/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
(compatibility version 1.0.0, current version 268.0.1)


libplplotd is the PLplot library which I link to; this is almost
certainly referring to libgnat. But did I do something wrong? This is
the first project on which I have used gpr, and I found the gpr
documentation to be not the finest example of technical writing.

My main gpr file has this:
  with "PLplot_Library";
and
  PLplot_Library.gpr
is this:

  library project PLplot_Library is
	for Externally_Built use "true";
	for Source_Dirs use ();
	for Library_Dir use "/usr/local/plplot/lib";
	for Library_Name use "plplotd";
	for Library_Kind use "dynamic";
  end PLplot_Library;

Is there something that I could do better here or am I stuck because I
need to link to libplplotd which references libgnat?

Jerry



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-07  0:22   ` Jerry
@ 2011-10-07 16:34     ` Simon Wright
  2011-10-08  3:54       ` Jerry
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2011-10-07 16:34 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> On Oct 6, 3:57 am, Simon Wright <si...@pushface.org> wrote:
>> Jerry <lancebo...@qwest.net> writes:
>> > I'm having considerable difficulty getting gdb to break on exceptions;
>> > in fact, I can't get it to work at all.
>>
>> I wrote up something on this here:http://forward-in-code.blogspot.com/2011/08/debugging-with-mac-os-x-s...
>
> That's really helpful, Simon. Thanks. I pretty much understood your
> article which means that it's really well-written. 8^)

Thank you!

> "HOWEVER, IF YOU CALL IN AN ADA SHARED LIBRARY BY MISTAKE (PERHAPS
> BECAUSE YOU MISSED AN EXTERNAL VARIABLE SETTING IN A .GPR), the linker
> will find the dynamic Ada runtime because it's referenced from the Ada
> shared library:"
>
> otool on my executable:
>
> MBPro:product-debug me$ otool -L ./run
> ./run:
> 	/usr/local/plplot/lib/libplplotd.11.dylib (compatibility version
> 11.0.0, current version 11.0.0)
> 	@rpath/libgnat-2010.dylib (compatibility version 0.0.0, current
> version 0.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version 125.2.11)
> 	/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
> (compatibility version 1.0.0, current version 268.0.1)
>
> libplplotd is the PLplot library which I link to; this is almost
> certainly referring to libgnat.

I think so.

>                                 But did I do something wrong? This is
> the first project on which I have used gpr, and I found the gpr
> documentation to be not the finest example of technical writing.

Couldn't possibly comment!

> My main gpr file has this:
>   with "PLplot_Library";
> and
>   PLplot_Library.gpr
> is this:
>
>   library project PLplot_Library is
> 	for Externally_Built use "true";
> 	for Source_Dirs use ();
> 	for Library_Dir use "/usr/local/plplot/lib";
> 	for Library_Name use "plplotd";
> 	for Library_Kind use "dynamic";
>   end PLplot_Library;
>
> Is there something that I could do better here or am I stuck because I
> need to link to libplplotd which references libgnat?

Is there an option in the build GPR for PLplot to build it as a static
library? (actually, plplot-5.9.8 doesn't include any *.gpr* files ...?)



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-07 16:34     ` Simon Wright
@ 2011-10-08  3:54       ` Jerry
  2011-10-08  8:23         ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry @ 2011-10-08  3:54 UTC (permalink / raw)


On Oct 7, 9:34 am, Simon Wright <si...@pushface.org> wrote:
> Jerry <lancebo...@qwest.net> writes:
> > On Oct 6, 3:57 am, Simon Wright <si...@pushface.org> wrote:
> >> Jerry <lancebo...@qwest.net> writes:

> > My main gpr file has this:
> >   with "PLplot_Library";
> > and
> >   PLplot_Library.gpr
> > is this:
>
> >   library project PLplot_Library is
> >    for Externally_Built use "true";
> >    for Source_Dirs use ();
> >    for Library_Dir use "/usr/local/plplot/lib";
> >    for Library_Name use "plplotd";
> >    for Library_Kind use "dynamic";
> >   end PLplot_Library;
>
> > Is there something that I could do better here or am I stuck because I
> > need to link to libplplotd which references libgnat?
>
> Is there an option in the build GPR for PLplot to build it as a static
> library? (actually, plplot-5.9.8 doesn't include any *.gpr* files ...?)

You are correct--plplot is built by gnatmake, not gpr. That is done by
a complicated (many platforms, drivers, languages) build process based
on cmake which is a separate activity from my personal projects which
use PLplot (which I referred to earlier in this thread as "my main gpr
file"). The PLplot team (none Ada guys) figured out how to build GNAT
stuff amazingly quickly and they incorporated it into their build
process. As you can see, it generates a dynamic library. I don't know
what would be involved in getting it to build a static library.
However, I have considered changing the PLplot build to use GPR
because I think it would take care of a slightly awkward conditional
situation with respect to one of the binding source files related to
whether Real_Vector from G.3 is used or not. This would require some
work by other team members so I have let it slide for quite a while.

I was a little puzzled when the PLplot guys built the ada stuff as a
conventional library; wouldn't it be possible to instead bind/link to
the .o and .ali files? Or maybe this doesn't fit with their overall
build process. Or maybe they don't know about this option.

Back to the main idea--if the PLplot library were built as a static
library (or linked to the .o files), would the debugger work better?

Jerry



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-08  3:54       ` Jerry
@ 2011-10-08  8:23         ` Simon Wright
  2011-10-12  2:24           ` Jerry
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2011-10-08  8:23 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

Thanks for the clarification.

When you say "plplot is built by gnatmake, not gpr" do you mean "by
using -I (etc) arguments to gnatmake"?

I take it you wrote PLplot_Library.gpr yourself?

> Back to the main idea--if the PLplot library were built as a static
> library (or linked to the .o files), would the debugger work better?

Yes.

Given that there are so few Ada source files involved, could you include
them in your main GPR's Ada sources and link against the PLplot
libraries built without the Ada parts? (if that makes sense ...)



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-08  8:23         ` Simon Wright
@ 2011-10-12  2:24           ` Jerry
  2011-10-12  6:45             ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry @ 2011-10-12  2:24 UTC (permalink / raw)


On Oct 8, 1:23 am, Simon Wright <si...@pushface.org> wrote:
> Jerry <lancebo...@qwest.net> writes:
>

Back on this task....

> Thanks for the clarification.
>
> When you say "plplot is built by gnatmake, not gpr" do you mean "by
> using -I (etc) arguments to gnatmake"?

I suppose that is the case.
>
> I take it you wrote PLplot_Library.gpr yourself?

Yes.

I think I'm on the verge of being confusing. On the one hand is the
build process for PLplot which is done by the guys on the PLplot team
who are expert in such things (not so much me). They use gnatmake (for
Ada stuff) and create among others two libraries, libplplotd which is
the guts of PLplot (C code) and libplplotadad which is the Ada
bindings. They also leave the .o and .ali files for the Ada bindings
so that one could link to them if desired.

On the other hand, I have personal projects which use PLplot, and that
is the context in which PLplot_Library.gpr appears--as a linking
device, not to build PLplot itself.

For a long time, for my personal projects, I recompiled the PLplot Ada
bindings from sources downloaded from SVN and link them to my other
sources. This is weird because I'm not using the "official" PLplot
build. I have in the past tried to change this but didn't succeed,
until a couple days ago. I now bind/link to the .o/.ali files in the
official PLplot build. This is an improvement in the sense that I am
probably being a better tester than before and at times it speeds up
my own builds.
>
> > Back to the main idea--if the PLplot library were built as a static
> > library (or linked to the .o files), would the debugger work better?
>
> Yes.

Although I (now) link to the .o files from the "official" PLplot
build, I still have to link to the dynamic library libplplotd. I
suspect that getting the build team to create a static library would
not be something that would require a polite amount of time.
>
> Given that there are so few Ada source files involved, could you include
> them in your main GPR's Ada sources and link against the PLplot
> libraries built without the Ada parts? (if that makes sense ...)

I think I understand. That was how I have been building my own
projects for a long time, as I describe above. But there still remains
the libplplotd problem.

I'm pretty satisfied with your work-around (debug with Apple's
debugger) for the relatively rare situations where I need to have the
debugger catch an exception. So as far as I'm concerned, at least for
the time being, I'll consider the problem solved.

Thanks,
Jerry



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-12  2:24           ` Jerry
@ 2011-10-12  6:45             ` Simon Wright
  2011-10-13 22:39               ` Jerry
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2011-10-12  6:45 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> I think I understand. That was how I have been building my own
> projects for a long time, as I describe above. But there still remains
> the libplplotd problem.

When I had a little play with it, it took some time to persuade the
plplot build process from the source distribution to recognise that I
have an Ada compiler (I had to tell it where the .dylibs are); if I'd
gone ahead before I got that right, I don't see that the resulting
libplplotd could have referenced libgnat?



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-12  6:45             ` Simon Wright
@ 2011-10-13 22:39               ` Jerry
  2011-10-14  7:46                 ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jerry @ 2011-10-13 22:39 UTC (permalink / raw)


On Oct 11, 11:45 pm, Simon Wright <si...@pushface.org> wrote:
> Jerry <lancebo...@qwest.net> writes:
> > I think I understand. That was how I have been building my own
> > projects for a long time, as I describe above. But there still remains
> > the libplplotd problem.
>
> When I had a little play with it, it took some time to persuade the
> plplot build process from the source distribution to recognise that I
> have an Ada compiler (I had to tell it where the .dylibs are); if I'd
> gone ahead before I got that right, I don't see that the resulting
> libplplotd could have referenced libgnat?

I also tell the plplot build process where libgnat.dylib is. Not sure
why. But I don't fully understand other stuff about my build script
since I had help writing it from the PLplot team. I could send it to
you or post it somewhere or paste it here if you're interested--it's a
short-ish 70 lines (white space and comments included).

Jerry



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-13 22:39               ` Jerry
@ 2011-10-14  7:46                 ` Simon Wright
  2011-10-14 22:40                   ` Jerry
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2011-10-14  7:46 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> On Oct 11, 11:45 pm, Simon Wright <si...@pushface.org> wrote:
>> Jerry <lancebo...@qwest.net> writes:
>> > I think I understand. That was how I have been building my own
>> > projects for a long time, as I describe above. But there still
>> > remains the libplplotd problem.
>>
>> When I had a little play with it, it took some time to persuade the
>> plplot build process from the source distribution to recognise that I
>> have an Ada compiler (I had to tell it where the .dylibs are); if I'd
>> gone ahead before I got that right, I don't see that the resulting
>> libplplotd could have referenced libgnat?
>
> I also tell the plplot build process where libgnat.dylib is. Not sure
> why. But I don't fully understand other stuff about my build script
> since I had help writing it from the PLplot team. I could send it to
> you or post it somewhere or paste it here if you're interested--it's a
> short-ish 70 lines (white space and comments included).

I'd certainly be interested - mail me?



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

* Re: gdb will not "catch exception" or "catch exception unhandled"
  2011-10-14  7:46                 ` Simon Wright
@ 2011-10-14 22:40                   ` Jerry
  0 siblings, 0 replies; 11+ messages in thread
From: Jerry @ 2011-10-14 22:40 UTC (permalink / raw)


On Oct 14, 12:46 am, Simon Wright <si...@pushface.org> wrote:
>
> I'd certainly be interested - mail me?

I sent a file to your pushface address.
Jerry



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

end of thread, other threads:[~2011-10-14 22:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-06 10:48 gdb will not "catch exception" or "catch exception unhandled" Jerry
2011-10-06 10:57 ` Simon Wright
2011-10-07  0:22   ` Jerry
2011-10-07 16:34     ` Simon Wright
2011-10-08  3:54       ` Jerry
2011-10-08  8:23         ` Simon Wright
2011-10-12  2:24           ` Jerry
2011-10-12  6:45             ` Simon Wright
2011-10-13 22:39               ` Jerry
2011-10-14  7:46                 ` Simon Wright
2011-10-14 22:40                   ` Jerry

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