Test "gdb.dwarf2/dw2-case-insensitive.exp: p fuNC_lang" fails.

Bug #929286 reported by Thiago Jung Bauermann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GDB
Fix Released
Undecided
Thiago Jung Bauermann

Bug Description

The handwritten DWARF information for FUNC_lang is wrong.

Ulrich explains:

In general, the last bit in *function
pointer values* indicates whether the target function is an ARM (if 0)
or Thumb (if 1) routine. The *PC address* however should in either case
refer to the actual address.

In the dw2-case-insensive.exp test case, the assembler has this:

        .uleb128 3 /* Abbrev:
DW_TAG_subprogram */
        .byte 1 /* DW_AT_external */
        .ascii "FUNC_lang\0" /* DW_AT_name */
        .4byte FUNC_lang /* DW_AT_low_pc */
        .4byte main /* DW_AT_high_pc */
        .byte 1 /* DW_AT_prototyped */
        .4byte .Ltype - .Lcu1_begin /* DW_AT_type */

Now this reference (via a data operation) to a Thumb function symbol
FUNC_lang is interpreted by binutils as creating a function pointer
value, and therefore it sets the low bit.

This is actually *incorrect*. The DWARF DW_AT_low_pc/high_pc values
should refer to the actual PC range the function spans, so it should
*not* have any low bits set.

If you were to generate DWARF by the compiler itself, this would actually
work out correctly, this the compiler does:

        .global FUNC_lang
        .thumb
        .thumb_func
        .type FUNC_lang, %function
FUNC_lang:
.LFB0:
        .file 1
"/home/uweigand/fsf/gdb-head/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.c"

@ /home/uweigand/fsf/gdb-head/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.c:22
        .loc 1 22 0
        .cfi_startproc
[...]
        .uleb128 0x2 @ (DIE (0x21) DW_TAG_subprogram)
        .byte 0x1 @ DW_AT_external
        .4byte .LASF0 @ DW_AT_name: "FUNC_lang"
        .byte 0x1 @ DW_AT_decl_file
(/home/uweigand/fsf/gdb-head/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.c)
        .byte 0x15 @ DW_AT_decl_line
        .byte 0x1 @ DW_AT_prototyped
        .4byte .LFB0 @ DW_AT_low_pc
        .4byte .LFE0 @ DW_AT_high_pc
        .4byte .LLST0 @ DW_AT_frame_base

Note that while FUNC_lang is marked as .thumb_func (which will
cause the assembler/linker to set the low bit where necessary),
the .LFB0 symbol is not; thus the reference to .LFB0 in the
DW_AT_low_pc attribute will not have the low bit set.

Tags: testsuite
Revision history for this message
Thiago Jung Bauermann (thiago-bauermann) wrote :

This is on gdb-linaro-7.4-2012.02.

Changed in gdb-linaro:
status: New → Confirmed
Revision history for this message
Muhammad Omair Javaid (omair-javaid) wrote :

* Test Host ARM
DISTRIB_ID=Linaro
DISTRIB_RELEASE=13.01
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Linaro 13.01"

** gdb-linaro revno 39073

***Taken from gdb.log file of gdb.dwarf2 testsuite run on ARM host:

GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7l-unknown-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set height 0
(gdb) set width 0
(gdb) dir
Reinitialize source path to empty? (y or n) y
Source directories searched: $cdir:$cwd
(gdb) dir ./gdb.dwarf2
Source directories searched: /home/omair-javaid/gdb-7.5/gdb/testsuite/./gdb.dwarf2:$cdir:$cwd
(gdb) kill
The program is not being run.
(gdb) file /home/omair-javaid/gdb-7.5/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive
Reading symbols from /home/omair-javaid/gdb-7.5/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive...done.
(gdb) show case-sensitive
Case sensitivity in name search is "auto; currently on".
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: show case-sensitive
info functions fUnC_lang
All functions matching regular expression "fUnC_lang":
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: regexp case-sensitive on
set case-sensitive off
warning: the current case sensitivity setting does not match the language.

(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: set case-sensitive off
info functions fUnC_lang
All functions matching regular expression "fUnC_lang":

File file1.txt:
foo FUNC_lang(void);
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: regexp case-sensitive off
p fuNC_lang
$1 = {foo (void)} 0x83bd <FUNC_lang+4294967295>
(gdb) FAIL: gdb.dwarf2/dw2-case-insensitive.exp: p fuNC_lang
p fuNC_symtab
$2 = {<text variable, no debug info>} 0x83c8 <FUNC_symtab>
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: p fuNC_symtab
break fuNC_lang
warning: Breakpoint address adjusted from 0x000083bd to 0x000083bc.
Breakpoint 1 at 0x83bc (2 locations)
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: setting breakpoint at fuNC_lang
break fuNC_symtab
Breakpoint 2 at 0x83c8
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: setting breakpoint at fuNC_symtab
testcase ./gdb.dwarf2/dw2-case-insensitive.exp completed in 1 seconds

Changed in gdb-linaro:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.