public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How to update .debug_frame CFA offset for function epilogues?
@ 2020-03-26 12:33 Jozef Lawrynowicz
  2020-03-31 21:49 ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Jozef Lawrynowicz @ 2020-03-26 12:33 UTC (permalink / raw)
  To: gcc

Hi,

msp430-elf has an issue in the debugging information generated for function
epilogues, where the CFA offset is not updated as the epilogue progresses and
the stack pointer is modified by different instructions.

For msp430 function prologues, instructions that modify the stack pointer are
marked as frame_related, but the gccint documentation says this should only be
used for prologues.

In some cases, I can fix the CFA offset by marking these epilogue insns as
frame_related anyway, and adding reg notes which describe the stack pointer
operations. For some other epilogue insns, marking them frame_related results in
an ICE, which I'm assuming comes back to the fact that epilogue insns shouldn't
be marked frame related.

I see that i386 handles this by generating assembler directives like
".cfi_def_cfa", but given that for MSP430, the debug frame information
generation is left to the generic code, I'd like to try and get these epilogue
CFA modifications generated there as well.

What is the standard way for updating the CFA offset in the epilogue?

Thanks,
Jozef

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to update .debug_frame CFA offset for function epilogues?
  2020-03-26 12:33 How to update .debug_frame CFA offset for function epilogues? Jozef Lawrynowicz
@ 2020-03-31 21:49 ` Segher Boessenkool
  2020-05-25 17:20   ` Jozef Lawrynowicz
  0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2020-03-31 21:49 UTC (permalink / raw)
  To: Jozef Lawrynowicz; +Cc: gcc

Hi Jozef,

On Thu, Mar 26, 2020 at 12:33:38PM +0000, Jozef Lawrynowicz wrote:
> In some cases, I can fix the CFA offset by marking these epilogue insns as
> frame_related anyway, and adding reg notes which describe the stack pointer
> operations. For some other epilogue insns, marking them frame_related results in
> an ICE, which I'm assuming comes back to the fact that epilogue insns shouldn't
> be marked frame related.

> What is the standard way for updating the CFA offset in the epilogue?

What you already say you do: add notes, and often frame_related is set
as well.  I agree that shouldn't be done, but it often is harmless.

You need reg_notes for more than just the stack updates: importantly,
also for the restores of any saved register.


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to update .debug_frame CFA offset for function epilogues?
  2020-03-31 21:49 ` Segher Boessenkool
@ 2020-05-25 17:20   ` Jozef Lawrynowicz
  2020-05-25 17:54     ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Jozef Lawrynowicz @ 2020-05-25 17:20 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc

Hi Segher,

On Tue, Mar 31, 2020 at 04:49:53PM -0500, Segher Boessenkool wrote:
> Hi Jozef,
> 
> On Thu, Mar 26, 2020 at 12:33:38PM +0000, Jozef Lawrynowicz wrote:
> > In some cases, I can fix the CFA offset by marking these epilogue insns as
> > frame_related anyway, and adding reg notes which describe the stack pointer
> > operations. For some other epilogue insns, marking them frame_related results in
> > an ICE, which I'm assuming comes back to the fact that epilogue insns shouldn't
> > be marked frame related.
> 
> > What is the standard way for updating the CFA offset in the epilogue?
> 
> What you already say you do: add notes, and often frame_related is set
> as well.  I agree that shouldn't be done, but it often is harmless.
> 
> You need reg_notes for more than just the stack updates: importantly,
> also for the restores of any saved register.

Thanks for the advice, indeed the reason I was having problems was
because not all stack operations were properly annotated with reg notes.

The reason I was seeing the ICE was because of unspec insns which were marked
as frame related but didn't have accompanything reg notes, of course it
is now clear that stack modifications in an unspec need to be explicitly
described.

(Apologies for the late response, but I figure I may as well document
the conclusion came to with this.)

Jozef

> 
> 
> Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to update .debug_frame CFA offset for function epilogues?
  2020-05-25 17:20   ` Jozef Lawrynowicz
@ 2020-05-25 17:54     ` Segher Boessenkool
  0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2020-05-25 17:54 UTC (permalink / raw)
  To: gcc

Hi!

On Mon, May 25, 2020 at 06:20:49PM +0100, Jozef Lawrynowicz wrote:
> On Tue, Mar 31, 2020 at 04:49:53PM -0500, Segher Boessenkool wrote:
> > You need reg_notes for more than just the stack updates: importantly,
> > also for the restores of any saved register.
> 
> Thanks for the advice, indeed the reason I was having problems was
> because not all stack operations were properly annotated with reg notes.
> 
> The reason I was seeing the ICE was because of unspec insns which were marked
> as frame related but didn't have accompanything reg notes, of course it
> is now clear that stack modifications in an unspec need to be explicitly
> described.

One thing that helps debugging this is  readelf -wframe  (but there are
other methods).  A bit late for help to you ;-)

> (Apologies for the late response, but I figure I may as well document
> the conclusion came to with this.)

No, thanks, it is good to hear it helped!


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-25 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 12:33 How to update .debug_frame CFA offset for function epilogues? Jozef Lawrynowicz
2020-03-31 21:49 ` Segher Boessenkool
2020-05-25 17:20   ` Jozef Lawrynowicz
2020-05-25 17:54     ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).