This is the mail archive of the gdb@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]

Re: cannot subscript something of type <data variable, no debug info>


[Taking drow off the "To:" list because this probably isn't a gdb bug].

Okay, your "z1" executable manifests the same symptoms on my system,
native i686-pc-linux-gnu with red-hat-8.0.

  (gdb) break main
  Breakpoint 1 at 0x8048478: file tester.cpp, line 9.
  (gdb) run
  Starting program: /berman/home/mec.gnu/tmp/dm/z1

  Breakpoint 1, main () at tester.cpp:9
  9          Mod[0].powered_up = 1 ;
  (gdb) ptype Mod
  type = <data variable, no debug info>
  (gdb) print Mod[0]
  cannot subscript something of type `<data variable, no debug info>'
  (gdb) print (S_Module) Mod[0]
  No symbol "S_Module" in current context.

In the file z1, there are no symbols for Mod in tester.cpp!
There are some residual type definitions for 'char', 'short', 'int',
et cetera.

Looking at the assembly code for "main", it did not come from:

  g++ -Wall -g tester.cpp -o tester

"main" has optimized code in it, not default code.

The variable 'Mod' is still present with the optimized code.  (It would
be very hard for the compiler to optimize away a global variable).  So
normally, the linker should have kept the type information for it too,
if that type information was ever produced.

I tried some compiler switches on a suse-9 machine but could not quite
get the exact code that your compiler generated.

Can you rebuild the 'tester' executable and check the exact options that
you are using, for both compiling and linking?  The best thing would be:

  script
  g++ -v -Wall -g tester.cpp -o tester
  exit

... and mail in the script, along with the new 'tester' executable.
Also, you don't have to tar+compress the executable if it's only 10k again.


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