Debugging executables with shared libraries

A lot of the scoping utilities seem broken using modules compiled as shared libraries. Also, I’m not sure about the error linking the shared library into the main program. Any ideas?

[chulbert@fourier test]$ uname -a
Linux fourier.isl-inc.com 2.6.15-prep #1 SMP Tue Mar 21 11:20:33 EST 2006
x86_64 x86_64 x86_64 GNU/Linux
[chulbert@fourier test]$ cat testm.f90
MODULE A
INTEGER,PUBLIC :: B
END MODULE
[chulbert@fourier test]$ cat test.f90
USE A
B = 1
WRITE(,) B
B = 2
WRITE(,) B
END
[chulbert@fourier test]$ pgf90 -shared -g -otestm.so -fpic testm.f90
[chulbert@fourier test]$ pgf90 -g -I. test.f90 testm.so
test.f90:
/usr/bin/ld: warning: type and size of dynamic symbol `…Dm_a’ are not defined
[chulbert@mellin test]$ cat a.mod
V24 a
9 testm.f90 S526 0
01/09/2007 08:15:19
enduse
S 526 24 0 0 0 8 1 0 3763 4 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
a
S 527 6 4 0 0 6 1 526 3765 4 0 0 0 0 0 0 0 0 0 528 0 0 0 0 0 0 0 0 0 0 526 0 0
0 0 b
S 528 11 0 0 0 8 1 526 3767 40800000 801000 0 4 0 0 527 527 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 a$0
Z
Z
[chulbert@fourier test]$ pgdbg -text a.out
PGDBG 6.2-5 x86-64 (Workstation, 4 CPU)
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2006, STMicroelectronics, Inc. All Rights Reserved.
***Reading DWARFv2 Information.
Loaded: /home/chulbert/test/a.out

pgdbg> files
“/home/chulbert/test/test.f90”

pgdbg> names

pgdbg> names “/home/chulbert/test/testm.f90”
ERROR: BAD SYMBOL “/home/chulbert/test/testm.f90”

pgdbg> enter “/home/chulbert/test/testm.f90”
ERROR: No Symbol called /home/chulbert/test/testm.f90.

pgdbg> decls
arguments:
variables:

pgdbg> decls “/home/chulbert/test/testm.f90”
ERROR: BAD SYMBOL “/home/chulbert/test/testm.f90”

pgdbg> stop at 2
(1)breakpoint set at: MAIN line: “test.f90”@2 address: 0x408294
1
pgdbg> run
testm.so loaded by ld-linux-x86-64.so.2.
libm.so.6 loaded by ld-linux-x86-64.so.2.
libc.so.6 loaded by ld-linux-x86-64.so.2.
libpgf90.so loaded by ld-linux-x86-64.so.2.
libpgf90_rpm1.so loaded by ld-linux-x86-64.so.2.
libpgf902.so loaded by ld-linux-x86-64.so.2.
libpgf90rtl.so loaded by ld-linux-x86-64.so.2.
libpgftnrtl.so loaded by ld-linux-x86-64.so.2.
libpgc.so loaded by ld-linux-x86-64.so.2.
Breakpoint at 0x408294, function MAIN, file test.f90, line 2
#2: B = 1

pgdbg> p B
Internal error: unknown type for tgt_read 0

pgdbg> n
Stopped at 0x40829E, function MAIN, file test.f90, line 3
#3: WRITE(,) B

pgdbg> p B
Internal error: unknown type for tgt_read 0

pgdbg> b
breakpoint at MAIN line: “test.f90”@2 address: 0x408294

pgdbg> n
1
Stopped at 0x4082FA, function MAIN, file test.f90, line 4
#4: B = 2

pgdbg> p B
Internal error: unknown type for tgt_read 0

pgdbg> n
Stopped at 0x408304, function MAIN, file test.f90, line 5
#5: WRITE(,) B

pgdbg> n
2
Stopped at 0x408360, function MAIN, file test.f90, line 6
#6: END

pgdbg> n
(Process Exited)

[chulbert@fourier test]$ pgf90 -c -g -fpic testm.f90
[chulbert@fourier test]$ pgf90 -g -I. test.f90 testm.o
test.f90:
[chulbert@fourier test]$ pgdbg -text a.out
PGDBG 6.2-5 x86-64 (Workstation, 4 CPU)
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2006, STMicroelectronics, Inc. All Rights Reserved.
***Reading DWARFv2 Information.
Loaded: /home/chulbert/test/a.out

pgdbg> stop at 2
(1)breakpoint set at: MAIN line: “test.f90”@2 address: 0x401DE4
1
pgdbg> names

pgdbg> decls
arguments:
variables:

pgdbg> scope
“/home/chulbert/test/test.f90”@MAIN
pgdbg> files
“/home/chulbert/test/test.f90”
“/home/chulbert/test/testm.f90”

pgdbg> names “/home/chulbert/test/testm.f90”
=
=

pgdbg> global
(GLOBAL SCOPE(/home/chulbert/test/a.out))
pgdbg> names “/home/chulbert/test/testm.f90”
=
=

pgdbg> run
libm.so.6 loaded by ld-linux-x86-64.so.2.
libc.so.6 loaded by ld-linux-x86-64.so.2.
Breakpoint at 0x401DE4, function MAIN, file test.f90, line 2
#2: B = 1

pgdbg> p B
0
pgdbg> n
Stopped at 0x401DEE, function MAIN, file test.f90, line 3
#3: WRITE(,) B

pgdbg> p B
1
pgdbg> n
1
Stopped at 0x401E4A, function MAIN, file test.f90, line 4
#4: B = 2

pgdbg> n
Stopped at 0x401E54, function MAIN, file test.f90, line 5
#5: WRITE(,) B

pgdbg> n
2
Stopped at 0x401EB0, function MAIN, file test.f90, line 6
#6: END

pgdbg> n
(Process Exited)

Hi Chris,

I passed this on to our Tools Group for investigation. I’ll let you know once thye have had a chance to look at it in depth.

  • Mat