Bug 481675 - bad DWARF location expressions
bad DWARF location expressions
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
10
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 516995
  Show dependency treegraph
 
Reported: 2009-01-26 18:42 EST by Roland McGrath
Modified: 2009-09-25 06:32 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-25 06:32:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
preprocessed C++ source (1.09 MB, text/plain)
2009-01-26 18:42 EST, Roland McGrath
no flags Details

  None (edit)
Description Roland McGrath 2009-01-26 18:42:24 EST
Created attachment 330044 [details]
preprocessed C++ source

Description of problem:

The compiler produced some exprs like "reg4 deref", which are invalid.
They probably meant to be "breg4 deref" and the like.

Version-Release number of selected component (if applicable):
gcc-4.3.2-7.x86_64


/usr/libexec/gcc/x86_64-redhat-linux/4.3.2/cc1plus -fpreprocessed dwarfcmp.ii -quiet -dumpbase dwarfcmp.cc -mtune=generic -auxbase-strip dwarfcmp.o -g -O1 -Wall -Wshadow -Werror -Wunused -Wextra -Wno-format -Wno-unused-parameter -std=gnu++0x -version -o dwarfcmp.s
as -V -Qy -o dwarfcmp.o dwarfcmp.s

eu-readelf --debug-dump={info,loc} dwarfcmp.o > log

Look for "deref" uses in loc exprs.
Comment 1 Jakub Jelinek 2009-02-11 06:33:38 EST
What is invalid on DW_OP_reg4 DW_OP_deref?  I thought it is the same thing as
DW_OP_breg4 0 DW_OP_deref...
Comment 2 Roland McGrath 2009-02-11 13:58:22 EST
No, DW_OP_reg* means "location in the register".  DWARF says it can only appear alone (which really means only alone before DW_OP_piece et al).  DW_OP_breg* means "push the register value on the stack".  e.g., DW_OP_breg4 0 computes a value of "register 4's value" but is not a location; "DW_OP_reg4" indicates the register is the location, and can be changed.  I think it would make sense if DW_OP_reg* were allowed as other than the last op in an expression, but that is not what the spec says (2.6.1).
Comment 3 Roland McGrath 2009-02-12 18:57:53 EST
How long has gcc produced expressions like this?

I see no sign that gdb has ever accepted them.  It has an error diagnostic specifically for this kind of malformed expression.

Even if we chose to make it a GNU extension of DWARF to interpret DW_OP_reg* this way, or even if a future DWARF spec were amended to allow it, all extant gdb versions (AFAICT) would still not support it.  It's surely easy enough to make gdb support it, but then this gcc version will require using the latest and greatest gdb that supports the extension.

An extra byte in an expression seems like the right trade-off there.
There are so many much larger wastes of space in the DWARF we emit to worry about first.
Comment 4 Jakub Jelinek 2009-02-12 19:42:40 EST
In .dwarf_frame/.eh_frame?  Like forever.  At least gcc-3.2 did this already.
In location expression, I also believe 3.2 was able to emit say DW_OP_reg4 DW_OP_deref.  Haven't looked at older GCCs, but GCC 3.2 is 6.5 years ago.
Comment 5 Roland McGrath 2009-02-24 19:39:16 EST
I see no sign that GDB ever grokked this use.  Perhaps only the EH unwinder ever has?  (It clearly does.)
Comment 6 Jakub Jelinek 2009-09-25 06:32:59 EDT
I believe this problem is fixed in current F12 gcc.  Please reopen if it is not, with a testcase.

Note You need to log in before you can comment on or make changes to this bug.