Changes between Initial Version and Version 1 of Ticket #48284


Ignore:
Timestamp:
Jul 8, 2015, 3:06:36 AM (9 years ago)
Author:
larryv (Lawrence Velázquez)
Comment:

Thanks for the report. In future tickets, please use WikiFormatting. You also do not have to Cc “openmaintainer”, as that is a dummy address.

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 to gdb @7.9.1_0: cannot determine type of primitive global variables
  • Ticket #48284 – Description

    initial v1  
    66
    77You can reproduce this bug by creating the following two files m0.c and m1.c:
     8{{{
     9% cat m0.c
     10#include <stdio.h>
     11float gf;
     12extern void func();
     13int main() {
     14        gf= 1.23;
     15        printf("gf: %4.2f\n", gf);
     16        func();
     17}
    818
    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>
     21extern float gf;
    2222void 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}}}
    2728
    2829Then 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
    3233% cc -g -o m m0.o m1.o
     34}}}
    3335
    3436When 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
     39GNU gdb (GDB) 7.9.1
     40...
     41This GDB was configured as "x86_64-apple-darwin14.3.0".
     42...
     43Reading symbols from m...done.
     44(gdb) break main
     45Breakpoint 1 at 0x100000eee: file m0.c, line 5.
     46(gdb) break func
     47Breakpoint 2 at 0x100000f27: file m1.c, line 5.
     48(gdb) run
     49Starting program: /private/tmp/m
     50warning: `/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.
     51warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_ciphersuites.a"
     52warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_handshake.a"
     53warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_record.a"
     54warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.30.2~2/Symbols/BuiltProducts/libcoretls_stream_parser.a"
     55Breakpoint 1, main () at m0.c:5
     565               gf= 1.23;
     57(gdb) s
     586               printf("gf: %4.2f\n", gf);
     59(gdb) s
     60gf: 1.23
     617               func();
     62(gdb) ptype gf
     63type = <data variable, no debug info>
     64(gdb) print gf
    6365$1 = 1067282596
     66}}}
    6467
    6568However, 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
     71Continuing.
     72Breakpoint 2, func () at m1.c:5
     735               lf= 4.56;
     74(gdb) s
     756               printf("lf: %4.2f\n", lf);
     76(gdb) s
     77lf: 4.56
     787       }
     79(gdb) ptype lf
     80type = float
     81(gdb) print lf
    7982$2 = 4.55999994
     83}}}
    8084
    8185The type of the global float gf is also unknown to gdb from within func():
     86{{{
     87(gdb) ptype gf
     88type = <data variable, no debug info>
     89(gdb) print gf
     90$3 = 1067282596
     91}}}
    8292
    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]]
     93If instead you combine the two files m![01].c into the single file s.c with the contents
     94{{{
     95#include <stdio.h>
     96float gf;
    9297int 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);
    96101        func();
    97102}
    98103
    99104void func() {
    100         float lf;[[BR]]
    101         lf= 4.56;[[BR]]
     105        float lf;
     106        lf= 4.56;
    102107        printf("lf: %4.2f\n", lf);
    103108}
    104 
     109}}}
    105110and compile with
    106 
     111{{{
    107112% cc -o s -g s.c
    108 
     113}}}
    109114then gdb works perfectly well, recognizing the type of gf and correctly printing its floating point value within either main() or func().
    110115
     
    118123
    119124Roger Davis
    120