This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/435: gdb fails to break in MPI code that uses C++ streams



>Number:         435
>Category:       gdb
>Synopsis:       gdb fails to break in MPI code that uses C++ streams
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 19 11:48:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Julian Cummings
>Release:        GNU gdb 5.1.1
>Organization:
>Environment:
Linux 2.4.9-ac9, gcc version 3.0, i686-pc-linux-gnu
>Description:
The gdb debugger fails to break in MPI code written in C++
that uses standard C++ streams to do I/O.  I am using mpich
version 1.2.3 for MPI support.  After compiling my simple
MPI code with g++, I run it with mpirun and give the -gdb
option.  This tells the mpirun script to launch gdb on my
executable and break on the call to MPI_Init().  However,
the debugger does not break at MPI_Init() as expected.
Instead it runs the code through to the completion of main()
and then stops during the execution of some global object
destructors from the the STL.  This makes it impossible to
debug MPI codes written in C++ with gdb.

I have made the following observations regarding this bug.
It only occurs when using C++ streams in your code; for 
example, using std::cout to send output to stdout.  If I
remove the use of <iostream> and std::cout from my example
code, gdb stops at MPI_Init() as expected.  This problem
only occurs with the newer version 3.x of gcc, not with 
previous versions of the compiler such as 2.95.2.  Finally,
this problem does not occur with MPI code written in C, 
only C++ code that uses streams.
>How-To-Repeat:
First, you must have a recent version of the mpich library
installed for MPI support.  I am using mpich 1.2.3 from
Argonne National Laboratory.  Compile the simple program
main.cc with "mpiCC -g" which will compile for debugging 
and link with the MPI library.  Then run with "mpirun -gdb"
to automatically launch gdb on the code and break on
MPI_Init().  You will see that gdb does not stop at the
call to MPI_Init() as it should.  If you comment out the 
use of <iostream> and std::cout in my example code and 
recompile it, then running with mpirun -gdb works correctly.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="main.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="main.cc"

I2luY2x1ZGUgIm1waS5oIgojaW5jbHVkZSA8aW9zdHJlYW0+CgppbnQgbWFpbihpbnQgYXJnYyxj
aGFyICphcmd2W10pIAp7CiAgaW50IG15UElkLCBuUHJvY2Vzc29yczsKICBpbnQgbG9jYWwsIGds
b2JhbDsKICBjaGFyIG5hbWVbODBdOwogIGludCBNaW4sIE1heDsKICBpbnQgYSwgYiwgbG9jYWxT
aXplOwogIGludCBuLCBpOwoKICBNUElfSW5pdCgmYXJnYywgJmFyZ3YpOwogIE1QSV9Db21tX3Jh
bmsoTVBJX0NPTU1fV09STEQsICZteVBJZCk7CiAgTVBJX0NvbW1fc2l6ZShNUElfQ09NTV9XT1JM
RCwgJm5Qcm9jZXNzb3JzKTsKCgoKCiAgc3RkOjpjb3V0IDw8IkhlbGxvIHdvcmxkIGZyb20gcHJv
Y2Vzc29yOiIgPDwgbXlQSWQgPDwgIiBvZiAiIDw8CiAgICAgIG5Qcm9jZXNzb3JzIDw8ICIgcHJv
Y2Vzc29ycyIgPDwgc3RkOjplbmRsOwogIAogIGxvY2FsID0gMDsKCiAgYSA9IDA7IGIgPSAxMDAw
OwogIGxvY2FsU2l6ZSA9IChiLWEpIC8gblByb2Nlc3NvcnM7CgogIE1pbiA9IGEgKyBteVBJZCAq
IGxvY2FsU2l6ZTsKICBNYXggPSBNaW4gKyBsb2NhbFNpemU7CgogIGZvciAoaSA9IE1pbjsgaSA8
IE1heDsgKytpKSB7CgogICAgbG9jYWwgPSBsb2NhbCArIGk7CiAgfQogIAoKCiAgTVBJX0FsbHJl
ZHVjZSgmbG9jYWwsICZnbG9iYWwsIDEsTVBJX0lOVCwgTVBJX1NVTSwgTVBJX0NPTU1fV09STEQp
OwoKICBzdGQ6OmNvdXQgPDwgIkxvY2FsIHZhbHVlIG9uIHByb2Nlc3NvcjogIiA8PCBteVBJZCA8
PCAiID0gIiA8PCBsb2NhbCA8PCAiIGdsb2JhbCB2YWx1ZSA9ICIKCSAgICA8PCAgZ2xvYmFsIDw8
IHN0ZDo6ZW5kbDsKICAKICAKICBNUElfRmluYWxpemUoKTsKICByZXR1cm4gMDsKfQo=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]