Bug 481675 - bad DWARF location expressions
Summary: bad DWARF location expressions
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 10
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 516995
TreeView+ depends on / blocked
 
Reported: 2009-01-26 23:42 UTC by Roland McGrath
Modified: 2009-09-25 10:32 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-09-25 10:32:59 UTC
Type: ---
Embargoed:


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

Description Roland McGrath 2009-01-26 23:42:24 UTC
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 11:33:38 UTC
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 18:58:22 UTC
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 23:57:53 UTC
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-13 00:42:40 UTC
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-25 00:39:16 UTC
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 10:32:59 UTC
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.