This is the mail archive of the gdb@sourceware.org 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: How to avoid "but contains no code." in command "info line"?


> > In a assembly file 'a.s', we define two sections which have code both.
> > For example:
> > 
> > line1: .section mysection
> > line2: load r4, [r3]
> > line3: jump func
> > ......
> > 
> > line6: .text
> > line7: store r4, [r3]
> > line8: jump func
> > ......
> > 
> > "info line a.s:7" will print both the begin and end address of the 
line.
> > but "info line a.s:2" just print the begin address and "but contains 
no 
> > code."
> > 
> > I trace the behavior of gdb (6.6 release) and find if the code is not 
in 
> > .text, 
> > then it will not be put to the 'blockvector structure'
> 
> Are you sure?  It sounds to me like your assembler is not emitting the
> right debug info.  GDB doesn't care what section lines are in.

Hi, I tested this on x86:

1, compile & dump:
gcc -o t -gstabs+ s2.s tp_bt1.c
objdump -dhs t &>log1
objdump -G t &>log2

2, debug:
(gdb) info line s2.s:2
Line 2 of "s2.s" is at address 0x8048490 but contains no code.

3, I trace gdb(6.6 release) behavior in 'find_pc_sect_symtab':
1934      ALL_SYMTABS (objfile, s)
(gdb) 
1936        bv = BLOCKVECTOR (s);
(gdb) 
1937        b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
(gdb) 
1939        if (BLOCK_START (b) <= pc
(gdb) p/x *b
$1 = {
  startaddr = 0x8048334, 
  endaddr = 0x8048340, 
  function = 0x0, 
  superblock = 0x0, 
  dict = 0x9931404, 
  language_specific = {
    cplus_specific = {
      namespace = 0x0
    }
  }, 
  gcc_compile_flag = 0x0
}
(gdb) 

because address 0x8048490 is not in [0x8048334, 0x8048340], so return 
NULL.

4, See the stabs info:

Contents of .stab section:
Symnum n_type n_othr n_desc n_value  n_strx String

-1     HdrSym 0      71     0000043c 1 
0      SO     0      0      08048334 1      s2.s 
1      SLINE  0      2      08048490 0 
2      SLINE  0      3      08048495 0 
3      SLINE  0      5      08048334 0 
4      SLINE  0      6      08048339 0 
5      SO     0      0      08048340 6 
/home/qinwei/GJ283/code/build_linux/debug-gdb/
6      SO     0      0      08048340 53     tp_bt1.c
7      OPT    0      0      00000000 62     gcc2_compiled.

5, My question:
1, Does gdb create a 'block' range from [0x08048334, 0x08048340] according 
to every
'SO' symbol here? And address 0x08048490 is not in the range(s2.s)?
2, How to solve the problem? (make 'line info' print both start & end 
address)
Let linker to link 'my_section' in the proper ranges? Or other solutions?


Attachment: tp_bt1.c
Description: Binary data

Attachment: log1
Description: Binary data

Attachment: log2
Description: Binary data

Attachment: s2.s
Description: Binary data


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