public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* dwarf-frame.c question
@ 2003-05-27 15:19 Michal Ludvig
  2003-05-29 15:44 ` Mark Kettenis
  0 siblings, 1 reply; 20+ messages in thread
From: Michal Ludvig @ 2003-05-27 15:19 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

Hi Mark,
why do you decrement unwound PC in dwarf_frame_cache() before using it?

dwarf-frame.c:
478       /* Unwind the PC.  */
479       fs->pc = frame_pc_unwind (next_frame);
480       if (get_frame_type (next_frame) == NORMAL_FRAME
481           && frame_relative_level (next_frame) >= 0)
482         fs->pc--;

This makes a problem for a signal trampoline.
If it is sitting on addresses say 0x40000140-0x40000150, the return 
address from signal handler is 0x40000140, but dwarf_frame_cache() says 
it is 0x4000013f and couldn't find it's CFI...

This has a tragic consequence few lines below were you look for FDE but 
don't check if you find one. If you don't, line 488 segfaults.
484       /* Find the correct FDE.  */
485       fde = dwarf_frame_find_fde (&fs->pc);
486
487       /* Extract any interesting information from the CIE.  */
488       fs->data_align = fde->cie->data_alignment_factor;
489       fs->code_align = fde->cie->code_alignment_factor;
490       fs->retaddr_column = fde->cie->return_address_register;

The problem is, that dwarf_frame_p() looks for the real return address 
and says that there is a debug info and sets unwinder to use dwarf2 
methods for this farme.
But the in unwinder itself in dwarf_frame_cache() looks for the 
decreased one and of course doesn't find it.

I couldn't see any problems when I removed the decrementation, so why is 
it there?

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: dwarf-frame.c question
@ 2003-06-01  5:59 Richard Henderson
  2003-06-01 10:00 ` Mark Kettenis
  0 siblings, 1 reply; 20+ messages in thread
From: Richard Henderson @ 2003-06-01  5:59 UTC (permalink / raw)
  To: gdb

[ Pasted from web archives, sorry.  ]

Mark Kettenis:
>  Andrew, it seems that we should tweak the frame code
> to make sure that frame_unwind_by_pc is always passed a PC *within* the
> function.

Andrew Cagney:
> True, but how? It would effectively be frame_unwind_address_in_block() but
> how reliably/where could it be used?

Careful; this silliness of subtracting one is not universal.

ABI's with more thought in them (e.g. IA64) require the compiler
to put *something* after a noreturn call that ends a function.
This being a relatively uncommon case, it does not add much code
size, and it solves some of the ambiguity problems you're seeing.


r~

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

end of thread, other threads:[~2003-06-03 20:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-27 15:19 dwarf-frame.c question Michal Ludvig
2003-05-29 15:44 ` Mark Kettenis
2003-05-29 19:54   ` Andrew Cagney
2003-05-29 22:22     ` Mark Kettenis
2003-05-29 22:43       ` Michal Ludvig
2003-05-29 23:13       ` Andrew Cagney
2003-05-30  1:34         ` Daniel Jacobowitz
2003-05-30 20:21         ` Jim Blandy
2003-05-30 20:32           ` Andrew Cagney
2003-06-03  0:04             ` Jim Blandy
2003-06-03  5:47               ` Richard Henderson
2003-06-03  6:32                 ` Jim Blandy
2003-06-03 15:58                   ` Richard Henderson
2003-06-03 17:38                     ` Richard Henderson
2003-06-03 20:12                   ` Alexandre Oliva
2003-05-30 20:44           ` Alexandre Oliva
2003-05-30 20:21         ` Jim Blandy
2003-06-01  5:59 Richard Henderson
2003-06-01 10:00 ` Mark Kettenis
2003-06-02 20:34   ` Richard Henderson

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).