Changes between Initial Version and Version 1 of Ticket #48284
- Timestamp:
- Jul 8, 2015, 3:06:36 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #48284
- Property Keywords global variable types unknown removed
- Property Owner changed from macports-tickets@… to stuartwesterman@…
- Property Cc stuartwesterman@… openmaintainer@… removed
-
Property
Summary
changed from
gdb 7.9.1 cannot determine type of primitive global variables
togdb @7.9.1_0: cannot determine type of primitive global variables
-
Ticket #48284 – Description
initial v1 6 6 7 7 You can reproduce this bug by creating the following two files m0.c and m1.c: 8 {{{ 9 % cat m0.c 10 #include <stdio.h> 11 float gf; 12 extern void func(); 13 int main() { 14 gf= 1.23; 15 printf("gf: %4.2f\n", gf); 16 func(); 17 } 8 18 9 % cat m0.c[[BR]] 10 #include <stdio.h>[[BR]] 11 float gf;[[BR]] 12 extern void func();[[BR]] 13 int main() { 14 gf= 1.23;[[BR]] 15 printf("gf: %4.2f\n", gf);[[BR]] 16 func();[[BR]] 17 }[[BR]] 18 19 % cat m1.c[[BR]] 20 #include <stdio.h>[[BR]] 21 extern float gf;[[BR]] 19 % cat m1.c 20 #include <stdio.h> 21 extern float gf; 22 22 void func() { 23 float lf;[[BR]] 24 lf= 4.56;[[BR]] 25 printf("lf: %4.2f\n", lf);[[BR]] 26 }[[BR]] 23 float lf; 24 lf= 4.56; 25 printf("lf: %4.2f\n", lf); 26 } 27 }}} 27 28 28 29 Then compile as follows: 29 30 % cc -g -c m0.c -o m0.o [[BR]]31 % cc -g -c m1.c -o m1.o [[BR]]30 {{{ 31 % cc -g -c m0.c -o m0.o 32 % cc -g -c m1.c -o m1.o 32 33 % cc -g -o m m0.o m1.o 34 }}} 33 35 34 36 When you debug with MacPorts gdb 7.9.1, the type of the global float gf is unknown to gdb from within main(): 35 36 % ggdb m [[BR]]37 GNU gdb (GDB) 7.9.1 [[BR]]38 ... [[BR]]39 This GDB was configured as "x86_64-apple-darwin14.3.0". [[BR]]40 ... [[BR]]41 Reading symbols from m...done. [[BR]]42 (gdb) break main [[BR]]43 Breakpoint 1 at 0x100000eee: file m0.c, line 5. [[BR]]44 (gdb) break func [[BR]]45 Breakpoint 2 at 0x100000f27: file m1.c, line 5. [[BR]]46 (gdb) run [[BR]]47 Starting program: /private/tmp/m [[BR]]48 warning: `/BinaryCache/coreTLS/coreTLS-35.30.2~2/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory. [[BR]]49 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_ciphersuites.a" [[BR]]50 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_handshake.a" [[BR]]51 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_record.a" [[BR]]52 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_stream_parser.a" [[BR]]53 Breakpoint 1, main () at m0.c:5 [[BR]]54 5 gf= 1.23; [[BR]]55 (gdb) s [[BR]]56 6 printf("gf: %4.2f\n", gf); [[BR]]57 (gdb) s [[BR]]58 gf: 1.23 [[BR]]59 7 func(); [[BR]]60 (gdb) ptype gf [[BR]]61 type = <data variable, no debug info> [[BR]]62 (gdb) print gf [[BR]]37 {{{ 38 % ggdb m 39 GNU gdb (GDB) 7.9.1 40 ... 41 This GDB was configured as "x86_64-apple-darwin14.3.0". 42 ... 43 Reading symbols from m...done. 44 (gdb) break main 45 Breakpoint 1 at 0x100000eee: file m0.c, line 5. 46 (gdb) break func 47 Breakpoint 2 at 0x100000f27: file m1.c, line 5. 48 (gdb) run 49 Starting program: /private/tmp/m 50 warning: `/BinaryCache/coreTLS/coreTLS-35.30.2~2/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory. 51 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_ciphersuites.a" 52 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_handshake.a" 53 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_record.a" 54 warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_stream_parser.a" 55 Breakpoint 1, main () at m0.c:5 56 5 gf= 1.23; 57 (gdb) s 58 6 printf("gf: %4.2f\n", gf); 59 (gdb) s 60 gf: 1.23 61 7 func(); 62 (gdb) ptype gf 63 type = <data variable, no debug info> 64 (gdb) print gf 63 65 $1 = 1067282596 66 }}} 64 67 65 68 However, the type of local float lf within func is known: 66 67 (gdb) continue [[BR]]68 Continuing. [[BR]]69 Breakpoint 2, func () at m1.c:5 [[BR]]70 5 lf= 4.56; [[BR]]71 (gdb) s [[BR]]72 6 printf("lf: %4.2f\n", lf); [[BR]]73 (gdb) s [[BR]]74 lf: 4.56 [[BR]]75 7 } [[BR]]76 (gdb) ptype lf [[BR]]77 type = float [[BR]]78 (gdb) print lf [[BR]]69 {{{ 70 (gdb) continue 71 Continuing. 72 Breakpoint 2, func () at m1.c:5 73 5 lf= 4.56; 74 (gdb) s 75 6 printf("lf: %4.2f\n", lf); 76 (gdb) s 77 lf: 4.56 78 7 } 79 (gdb) ptype lf 80 type = float 81 (gdb) print lf 79 82 $2 = 4.55999994 83 }}} 80 84 81 85 The type of the global float gf is also unknown to gdb from within func(): 86 {{{ 87 (gdb) ptype gf 88 type = <data variable, no debug info> 89 (gdb) print gf 90 $3 = 1067282596 91 }}} 82 92 83 (gdb) ptype gf[[BR]] 84 type = <data variable, no debug info>[[BR]] 85 (gdb) print gf[[BR]] 86 $3 = 1067282596 87 88 If instead you combine the two files m[01].c into the single file s.c with the contents 89 90 #include <stdio.h>[[BR]] 91 float gf;[[BR]] 93 If instead you combine the two files m![01].c into the single file s.c with the contents 94 {{{ 95 #include <stdio.h> 96 float gf; 92 97 int main() { 93 void func(); [[BR]]94 gf= 1.23; [[BR]]95 printf("gf: %4.2f\n", gf); [[BR]]98 void func(); 99 gf= 1.23; 100 printf("gf: %4.2f\n", gf); 96 101 func(); 97 102 } 98 103 99 104 void func() { 100 float lf; [[BR]]101 lf= 4.56; [[BR]]105 float lf; 106 lf= 4.56; 102 107 printf("lf: %4.2f\n", lf); 103 108 } 104 109 }}} 105 110 and compile with 106 111 {{{ 107 112 % cc -o s -g s.c 108 113 }}} 109 114 then gdb works perfectly well, recognizing the type of gf and correctly printing its floating point value within either main() or func(). 110 115 … … 118 123 119 124 Roger Davis 120