This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix windows 64 unwinding issues


Hi Tristan,

Looks good to me.  Thanks for the investigations and adding
comments.

Please fix the nits below and push.

On 03/05/2015 01:42 PM, Tristan Gingold wrote:

> 
> commit da3b5213dc072fca195451a04f35a2eb6342bb62
> Author: Tristan Gingold <gingold@adacore.com>
> Date:   Thu Mar 5 14:36:32 2015 +0100
> 
>     Fix amd64 windows unwinding issues within MS dlls.
>     
>     Unwind info in system dlls uses almost all possible codes, contrary to unwind
>     info generated by gcc.  A few issues have been discovered: incorrect handling
>     of SAVE_NONVOL opcodes and incorrect in prologue range checks.  Furthermore I
>     added comments not to forget what has been investigated.
>     
>     gdb/ChangeLog:
>     	* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Move
>     	redirection code to ...
>     	(amd64_windows_frame_decode_insns): ... Here.  Fix in prologue
>     	checks.  Fix SAVE_NONVOL operations.  Add debug code and comments.
> 
> diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
> index 2aa10a1..9278a26 100644
> --- a/gdb/amd64-windows-tdep.c
> +++ b/gdb/amd64-windows-tdep.c
> @@ -621,9 +621,47 @@ amd64_windows_frame_decode_insns (struct frame_info *this_frame,
>    CORE_ADDR cur_sp = cache->sp;
>    struct gdbarch *gdbarch = get_frame_arch (this_frame);
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> -  int j;
> +  int first = 1;
> +
> +  /* There are at least 3 possibilities to share an unwind info entry:
> +     1. Two different runtime_function entries (in .pdata) can point to the
> +        same unwind info entry.  There is no such indication while unwinding,
> +	so we don't really care about that case.  We suppose this scheme is
> +	used to save memory when the unwind entries are exactly the same.

tabs/spaces here don't look right.

> +     2. Chained unwind_info entries, with no unwind codes (no prologue).
> +        There is a major difference with the previous case: the pc range for
> +	the function is different (in case 1, the pc range comes from the
> +	runtime_function entry; in case 2, the pc range for the chained entry
> +	comes from the first unwind entry).  Case 1 cannot be used instead as

Likewise.

> +	the pc is not in the prologue.  This case is officially documented.
> +	(There might be unwind code in the first unwind entry to handle
> +	additionnal unwinding).  GCC (at least until gcc 5.0) doesn't chain

Typo "additionnal".

> +	entries.
> +     3. Undocumented unwind info redirection.  Hard to know the exact purpose,
> +        so it is considered as a memory optimization of case 2.
> +  */
>  
> -  for (j = 0; ; j++)
> +  if (unwind_info & 1)
> +    {
> +      /* Unofficially documented unwind info redirection, when UNWIND_INFO
> +	 address is odd (http://www.codemachine.com/article_x64deepdive.html).
> +      */
> +      struct external_pex64_runtime_function d;
> +      CORE_ADDR sa, ea;
> +
> +      if (target_read_memory (cache->image_base + (unwind_info & ~1),
> +			      (gdb_byte *) &d, sizeof (d)) != 0)
> +	return;
> +
> +      cache->start_rva =
> +	extract_unsigned_integer (d.rva_BeginAddress, 4, byte_order);

"=" goes on the next line.

> +      cache->end_rva =
> +	extract_unsigned_integer (d.rva_EndAddress, 4, byte_order);
> +      unwind_info =
> +	extract_unsigned_integer (d.rva_UnwindData, 4, byte_order);
> +    }

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]