1

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?

Tom
  • 11
  • 1
  • Edited; please revert if incorrect. – trashgod Aug 20 '10 at 12:06
  • 1
    Well, does it break on *some* line when you run the code? (I'm guessing probably not, or you wouldn't be asking here :-) What if you set the break on some other line within the protected body? Or within a subprogram that is called within the body? As you can see, I can't really answer "What gives?" But these are the kinds of things I'd try to get a break when faced with this situation. – Marc C Aug 20 '10 at 12:11
  • That's a big file! I have nothing over ~6K here. It shouldn't matter that it's on a remote file system, but you might try moving the source to `C:`. – trashgod Aug 20 '10 at 12:47
  • Wow, you are trying to debug a 20K+ line source file? My sympathies. I certianly hope it was machine-generated source. Otherwise, you really should create some sub-packages out of it. I start looking to split up anything over about 1K. – T.E.D. Aug 20 '10 at 13:01

3 Answers3

1

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.
  • 44,016
  • 10
  • 73
  • 134
  • 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 Aug 23 '10 at 19:16
1

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
  • 25,108
  • 2
  • 35
  • 62
0

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
  • 11
  • 1