* RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers
@ 2016-05-16 14:12 Nick Clifton
2016-05-16 20:08 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2016-05-16 14:12 UTC (permalink / raw)
To: gcc-patches; +Cc: gdb-patches
Hi Guys,
Currently dwarf2out.c:mem_loc_descriptor() has some special case
code to handle the situation where an address is held in a register
whose mode is not of type MODE_INT. It generates a
DW_OP_GNU_regval_type expression which may later on be converted into
a frame pointer based expression. This is a problem for targets which
use a partial integer mode for their pointers (eg the msp430). In
such cases the conversion to a frame pointer based expression could
be wrong if the frame pointer is not being used.
For example the GDB testfile gdb/testsuite/gdb.base/advance.c contains
this code fragment:
int
main ()
{
int result;
int b, c;
c = 5;
b = 3; /* advance this location */
func (c); /* stop here after leaving current frame */
which compiles to these instructions:
suba #6, r1
mov #5, 4(r1)
mov #3, 2(r1)
mov 4(r1), r12
calla #0 ;<func>
(Note that only r1 - the stack pointer - is used. r4 - the frame
pointer - is not).
The debug information produced for the "c" local variable looks like
this:
Abbrev Number: 3 (DW_TAG_variable)
DW_AT_name : c
DW_AT_decl_file : 1
DW_AT_decl_line : 40
DW_AT_type : <0x37>
DW_AT_location : 5 byte block: f5 4 21 32 1c (DW_OP_GNU_regval_type: 4 (r4) <0x21>; DW_OP_lit2; DW_OP_minus)
ie it says that "c" is stored in memory location "r4 - 2", which is
wrong since register r4 is not even used in this function.
The patch below addresses this problem by allowing the normal,
register based descriptor to be produced when the mode is Pmode.
With this patch applied the unexpected failure count in the GDB
testsuite for the MSP430's -mlarge multilib changes from 2253 to 367.
There are no regressions, for MSP430 or x86_64, and no changes to
the GCC testsuite results for either target.
OK to apply ?
Cheers
Nick
gcc/ChangeLog
2016-05-16 Nick Clifton <nickc@redhat.com>
* dwarf2out.c (mem_loc_descriptor): Convert REG based addresses
whose mode is Pmode into basereg descriptors even if Pmode is
not an integer mode.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 236283)
+++ gcc/dwarf2out.c (working copy)
@@ -13396,7 +13396,11 @@
break;
case REG:
- if (GET_MODE_CLASS (mode) != MODE_INT
+ if ((GET_MODE_CLASS (mode) != MODE_INT
+ /* Targets which have pointers that use a partial integer mode
+ (eg the msp430x) still want their debug information to be
+ based on the normal DWARF base register notation. */
+ && mode != Pmode)
|| (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
&& rtl != arg_pointer_rtx
&& rtl != frame_pointer_rtx
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers
2016-05-16 14:12 RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers Nick Clifton
@ 2016-05-16 20:08 ` Jeff Law
2016-05-17 12:37 ` Nick Clifton
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Law @ 2016-05-16 20:08 UTC (permalink / raw)
To: Nick Clifton, gcc-patches; +Cc: gdb-patches
On 05/16/2016 08:12 AM, Nick Clifton wrote:
> Hi Guys,
>
> Currently dwarf2out.c:mem_loc_descriptor() has some special case
> code to handle the situation where an address is held in a register
> whose mode is not of type MODE_INT. It generates a
> DW_OP_GNU_regval_type expression which may later on be converted into
> a frame pointer based expression. This is a problem for targets which
> use a partial integer mode for their pointers (eg the msp430). In
> such cases the conversion to a frame pointer based expression could
> be wrong if the frame pointer is not being used.
>
> For example the GDB testfile gdb/testsuite/gdb.base/advance.c contains
> this code fragment:
>
> int
> main ()
> {
> int result;
> int b, c;
> c = 5;
> b = 3; /* advance this location */
>
> func (c); /* stop here after leaving current frame */
>
> which compiles to these instructions:
>
> suba #6, r1
> mov #5, 4(r1)
> mov #3, 2(r1)
> mov 4(r1), r12
> calla #0 ;<func>
>
> (Note that only r1 - the stack pointer - is used. r4 - the frame
> pointer - is not).
>
> The debug information produced for the "c" local variable looks like
> this:
>
> Abbrev Number: 3 (DW_TAG_variable)
> DW_AT_name : c
> DW_AT_decl_file : 1
> DW_AT_decl_line : 40
> DW_AT_type : <0x37>
> DW_AT_location : 5 byte block: f5 4 21 32 1c (DW_OP_GNU_regval_type: 4 (r4) <0x21>; DW_OP_lit2; DW_OP_minus)
>
> ie it says that "c" is stored in memory location "r4 - 2", which is
> wrong since register r4 is not even used in this function.
>
> The patch below addresses this problem by allowing the normal,
> register based descriptor to be produced when the mode is Pmode.
>
> With this patch applied the unexpected failure count in the GDB
> testsuite for the MSP430's -mlarge multilib changes from 2253 to 367.
> There are no regressions, for MSP430 or x86_64, and no changes to
> the GCC testsuite results for either target.
>
> OK to apply ?
>
> Cheers
> Nick
>
> gcc/ChangeLog
> 2016-05-16 Nick Clifton <nickc@redhat.com>
>
> * dwarf2out.c (mem_loc_descriptor): Convert REG based addresses
> whose mode is Pmode into basereg descriptors even if Pmode is
> not an integer mode.
I'm not real familiar with dwarf, so if one of other maintainers steps
in and says this is OK, then ignore my comments/questions.
I may be missing something, but isn't it the transition to an FP
relative address rather than a SP relative address that's the problem
here? Where does that happen? Is it possible we've got the wrong
DECL_RTL or somesuch?
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers
2016-05-16 20:08 ` Jeff Law
@ 2016-05-17 12:37 ` Nick Clifton
[not found] ` <9f8e1f36-5186-67bc-898e-6910e0d041a6@redhat.com>
0 siblings, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2016-05-17 12:37 UTC (permalink / raw)
To: Jeff Law, gcc-patches; +Cc: gdb-patches
Hi Jeff,
>> Currently dwarf2out.c:mem_loc_descriptor() has some special case
>> code to handle the situation where an address is held in a register
>> whose mode is not of type MODE_INT. It generates a
>> DW_OP_GNU_regval_type expression which may later on be converted into
>> a frame pointer based expression. This is a problem for targets which
>> use a partial integer mode for their pointers (eg the msp430). In
>> such cases the conversion to a frame pointer based expression could
>> be wrong if the frame pointer is not being used.
> I may be missing something, but isn't it the transition to an FP
> relative address rather than a SP relative address that's the problem
> here?
Yes, I believe so.
> Where does that happen?
I did not track it down. But whilst I was searching for the cause I came
across the code that is modified by the patch. Reading the code it seemed
obvious to me that the special case for handling non INT_MODE register modes
was not intended for pointers, and when I tried out a small patch it worked.
> Is it possible we've got the wrong DECL_RTL or somesuch?
I don't think so. I am not familiar with this code myself, but the dump from
the dwarf2 pass shows:
(insn 5 2 6 (set (mem/c:HI (plus:PSI (reg/f:PSI 1 R1)
(const_int 4 [0x4])) [1 c+0 S2 A16])
(const_int 5 [0x5])) /work/sources/binutils/current/gdb/testsuite/gdb.base/advance.c:41 12 {movhi}
(nil))
which to me pretty clearly shows that "c" is being stored at R1+4.
Cheers
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-22 15:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-16 14:12 RFA: Generate normal DWARF DW_LOC descriptors for non integer mode pointers Nick Clifton
2016-05-16 20:08 ` Jeff Law
2016-05-17 12:37 ` Nick Clifton
[not found] ` <9f8e1f36-5186-67bc-898e-6910e0d041a6@redhat.com>
2016-05-26 16:16 ` Nick Clifton
2016-06-21 22:09 ` Jeff Law
2016-06-22 15:13 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox