Created attachment 435918 [details] files needed for reproducing the bug Description of problem: I'm debugging Gnatmake (from the package gcc-gnat). I call a function named Find_File from GDB. Find_File takes two parameters, N and T. When I provide a numeric value for N there is no problem, but when the value of N is provided by another function – Name_Enter or Name_Find – then T gets the wrong value. Version-Release number of selected component (if applicable): 7.1-30.fc13 How reproducible: It's perfectly repeatable in F-13 and Rawhide when Gnatmake is stopped in MLib.Utl.Lib_Directory and I call Osint.Find_File. My attempts to reproduce the bug with a small test program instead of Gnatmake were unsuccessful. Steps to Reproduce: # yum install gcc-gnat $ tar xzf gdb_test_library.tar.gz $ cd gdb_test_library $ gdb /usr/bin/gnatmake GNU gdb (GDB) Fedora (7.1-30.fc13) [...] (gdb) break MLib.Utl.Lib_Directory Breakpoint 1 at 0x485d10: file /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/mlib-utl.adb, line 600. (gdb) run -P gdb_test_library [...] Breakpoint 1, mlib.utl.lib_directory () at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/mlib-utl.adb:600 600 function Lib_Directory return String is (gdb) break Osint.Find_File Breakpoint 2 at 0x493690: file /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb, line 957. (gdb) call Osint.Find_File(Name_Enter, Osint.Library) Breakpoint 2, osint.find_file (n=300001342, t=63) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 957 function Find_File The program being debugged stopped while in a function called from GDB. Evaluation of the expression containing the function (osint.find_file) will be abandoned. When the function is done executing, GDB will silently stop. (gdb) p T $1 = 63 (gdb) p Integer(Osint.Library) $2 = 1 (gdb) set variable T := Osint.Library (gdb) p T $3 = library (gdb) frame #0 osint.find_file (n=300001342, t=library) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 957 function Find_File (gdb) call Osint.Find_File(Name_Enter, Osint.Library) Breakpoint 2, osint.find_file (n=300001344, t=65) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, Osint.Library) Breakpoint 2, osint.find_file (n=300001346, t=67) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Find, Osint.Source) Breakpoint 2, osint.find_file (n=300001301, t=21) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Find, Osint.Library) Breakpoint 2, osint.find_file (n=300001301, t=21) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Find, Osint.Config) Breakpoint 2, osint.find_file (n=300001301, t=21) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Find, Osint.Definition) Breakpoint 2, osint.find_file (n=300001301, t=21) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, 1) Breakpoint 2, osint.find_file (n=300001348, t=69) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, 1) Breakpoint 2, osint.find_file (n=300001350, t=71) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) p Name_Enter $4 = 300001352 (gdb) call Osint.Find_File(Name_Enter, 1) Breakpoint 2, osint.find_file (n=300001353, t=74) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, 1) Breakpoint 2, osint.find_file (n=300001355, t=76) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, Osint.Library) Breakpoint 2, osint.find_file (n=300001357, t=78) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(Name_Enter, Osint.Config) Breakpoint 2, osint.find_file (n=300001359, t=80) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] (gdb) call Osint.Find_File(300001359, 1) Breakpoint 2, osint.find_file (n=300001359, t=library) at /usr/src/debug/gcc-4.4.4-20100630/gcc/ada/osint.adb:957 [...] Actual results: Name_Find returns the same value when called repeatedly, and when I use it for N, T = N mod 256. Name_Enter returns a new value every time, and when I use it for N, then N gets incremented by 2 for every call, and T = N mod 256 + 1. I get the impression that GDB calls Name_Enter twice and uses the second returned value instead of the value I provide for T.
I can confirm the problem is reproducible. Still GNU Ada is most actively developed by AdaCore and they provide their GPL downloadable distribution: http://libre.adacore.com/libre/download/ I tried just their GDB for /usr/bin/gnatmake does not fix it. I believe using also their GNAT compiler may fix it but I am not sure. Could you make a comment if the GPL AdaCore distribution is not suitable for your gnatmake debugging problem?
I'm afraid I don't understand what you want me to do with the distribution from AdaCore. If you have tried AdaCore's GDB and found that it has the same problem, then I don't see why I would need to try it too, so that's probably not what you mean. Debugging AdaCore's Gnatmake instead of Fedora's Gnatmake is of course pointless when my purpose is to figure out why Fedora's Gnatmake crashes. Do you mean that I should replace Fedora's GCC with Adacore's GCC, rebuild Fedora's GCC package using that compiler, and then load the resulting Gnatmake executable in Fedora's GDB and see if the problem goes away? If so, may I ask what information you expect to get from that experiment? Should I do something to deactivate GCC's three-stage bootstrap? If it were just about solving my debugging problem, then I could get by with the current GDB now that I'm aware of the bug and can watch out for it, and I'm done debugging for now anyway, as I've found the error in Gnatmake, but I thought I should be a good community member and report the bug I found in GDB so that it could get fixed.
Sorry, posted upstream, AdaCore may check it there.