PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

let -C to drop core

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
yosuke



Joined: 25 Oct 2004
Posts: 3

PostPosted: Thu Mar 30, 2006 3:11 pm    Post subject: let -C to drop core Reply with quote

Hello,

Is there any way to let an executable to drop a core when array bound was exceeded? I looked and looked at code but it wasnt obvious for me with my code why i got that faulty array index.
Back to top
View user's profile
mleair



Joined: 19 Jul 2004
Posts: 67
Location: Portland Group

PostPosted: Thu Mar 30, 2006 6:58 pm    Post subject: Re: let -C to drop core Reply with quote

yosuke wrote:
Hello,

Is there any way to let an executable to drop a core when array bound was exceeded? I looked and looked at code but it wasnt obvious for me with my code why i got that faulty array index.


Hi,

Sounds to me there could be two scenarios here...

Is your program seg faulting and there is not a core file generated? If so, then you may need to set your core file limit. For example,

For sh/bash users, enter:

$ ulimit -c unlimited

For csh/tcsh users, enter:

% limit coredumpsize unlimited

After you get a core file, you can use pgdbg to read the core file in using pgdbg's -core switch.

If the problem is that you compiled your program with -Mbounds and cannot locate the array bounds error based on the message you are getting, then you can use pgdbg to stop at the point in which the program aborts. Compile your program with the switches -g -Mbounds. Load the program with pgdbg. Set a breakpoint at __hpf_abort. Run your program. When the bounds error is caught, the program will stop at __hpf_abort. You can then enter the "where" command in PGDBG to get a traceback. Below is an example:

program p
integer a(10)
do i=1,11
a(i) = i
print *, a(i)
enddo
end

(Note the obvious array bounds problem in this example)

% pgf90 -g -Mbounds abort.f90
% ./a.out
1
2
3
4
5
6
7
8
9
10
0: Subscript out of range for array a (abort.f90: 5)
subscript=11, lower bound=1, upper bound=10, dimension=1

% pgdbg -text a.out
PGDBG 6.1-3 x86 (Cluster, 32 CPU)
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2005, STMicroelectronics, Inc. All Rights Reserved.
***Reading DWARFv2 Information.
Loaded: /home/mleair/a.out

pgdbg> b __hpf_abort
WARNING: Function __hpf_abort is not compiled using -g
breakpoint set at: __hpf_abort address: 0x804c9c9
1
pgdbg> run
libc.so.6 loaded by ld-linux.so.2.
libpgc.so loaded by ld-linux.so.2.
libm.so.6 loaded by ld-linux.so.2.
1
2
3
4
5
6
7
8
9
10
Breakpoint at 0x804c9c9, function __hpf_abort
804c9c9: 83 7d 8 0 cmpl $0x0,8(%ebp)

pgdbg> where

STACK TRACE:

#4 __libc_start_main address: 0x40043500
#3 main address: 0x80498db
#2 p line: "abort.f90"@5 address: 0x8049982
#1 pgf90_subchk address: 0x804f1b5
=> #0 __hpf_abort address: 0x804c9c9

pgdbg> q
WARNING: The target is running. Exit anyway?
Please enter 'y' or 'n' > y


Using the "where" command, one can see the call chain to the faulty array access...in more complicated problems this can help locate the routine that might have set the incorrect range for the array access. Obviously in my simple example the incorrect range was set at the same place it occured. But in more complicated examples this is not always the case.

I hope this helps,

Mark
Back to top
View user's profile
yosuke



Joined: 25 Oct 2004
Posts: 3

PostPosted: Wed Apr 05, 2006 11:37 pm    Post subject: Re: let -C to drop core Reply with quote

[quote="mleair"]
yosuke wrote:
Hello,

If the problem is that you compiled your program with -Mbounds and cannot locate the array bounds error based on the message you are getting, then you can use pgdbg to stop at the point in which the program aborts. Compile your program with the switches -g -Mbounds. Load the program with pgdbg. Set a breakpoint at __hpf_abort. Run your program. When the bounds error is caught, the program will stop at __hpf_abort. You can then enter the "where" command in PGDBG to get a traceback.

Mark


Thank you Mark, this is what I needed.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group