views:

74

answers:

4

I've got a protected object that presents functions and procedures in its interface. In gdb, when I set a bp on the first line of one of those, I get odd results.

Here's a snippet from my gdb console:

(gdb)
(gdb) b database-access_manager.adb:20001
Breakpoint 3 at 0x1a10588: file y:/svs/central_switch/controller/database/
database-access_manager.ads, line 20001.
(gdb)

You can see that gdb is confused. I specified a bp at 20001 of the .adb file but gdb responded by saying it had set the bp at 20001 of the corresponding ads file - which doesn't have that many lines.

What gives?

+1  A: 

That .ads file wouldn't happen to be defining or using a generic, would it?

I have yet to find a debugger that handles Ada generics very well. The compiler often creates a raft of semi-invisible code that confuses the heck out of debuggers. I suspect C++ templates have the same issue.

Another possibility is that you are looking at a source file that has been modified since your program was compiled.

T.E.D.
I'm not using a generic. The image file is freshly built.I'm hoping that someone out there will spark up their gdb and also try setting a bp on a member function or procedure of a protected type.
Tom
A: 

I'm hoping that someone out there will spark up their gdb and also try setting a bp on a member function or procedure of a protected type.

I tried this successfully with dining philosophers, breaking in the body of protected type Stick in chop. I'm using GNAT 4.3.4 on Mac OS X and 4.4 on Ubuntu 10.

Addendum:

$ gdb --version
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
$ gnat --version
GNAT 4.3.4 20090621 (prerelease) [gcc-4_3-branch revision 148757]
Copyright 1996-2007, Free Software Foundation, Inc.

trashgod
Now that's interesting.What version of gdb have you got?I'm using GNU gdb (GDB) 7.1 for GNAT GPL 2010 (20100603) [rev=gdb-7.1-ref-90-g6d5b58a] on windows.My GPS is same as yours. I'll bet your gdb is 7.1 too.Maybe it's a Windows problem?
Tom
Now the question is "Has anyone out there successfully set and hit a bp in gdb on Windows on a function or procedure within a protected type?"
Tom
@Tom: See above. Absent the `@`, only the author will receive notice of your comment. Editing your question with new findings will bump it among active question.
trashgod
+1  A: 

Running on Windows with GNAT Pro 6.3.1 (I realise this isn't an ideal data point for you!) this worked fine.

I did notice that when I requested a bp on the subprogram specification, GDB effectively set two bps, one in the specification and one at the first statement: so, given

package body Protected_Object is

   protected body PO is
      procedure Put (V : Integer) is
      begin
         Value := V;
      end Put;
      function Get return Integer is
      begin
         return Value;
      end Get;
    end PO;

end Protected_Object;

the GDB console says (for Put)

gdb) break protected_object.adb:4
Breakpoint 1 at 0x401729: file protected_object.adb, line 6. (2 locations)

and at run time, sure enough there are 2 breaks:

Breakpoint 1, <protected_object__po__putP> (<_object>=..., v=42) at protected_object.adb:4
(gdb) cont

Breakpoint 1, protected_object.po.put (<_object>=..., v=42) at protected_object.adb:6

Version: GNU gdb (GDB) 7.0.1 for GNAT Pro 6.3.1 (20100112) [rev:158983]

Simon Wright
A: 

Hi All,

Here's the update on my problem.

I made a protected type with access methods and used it in a small main and found that breakpoints in my example protected type worked fine.

Now I'm trying to understand why, within the context of my company's very large build, the breakpoints don't work.

I'm using the same gdb, GPS, & compiler switches in each case and it works for the small program but not in the large one.

I'll post my results when/if I have any.

Thanks to all the repliers.

Tom

Tom