Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jerome Guitton <guitton@act-europe.fr>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFA] x86 - jump instruction after the prologue
Date: Tue, 27 Apr 2004 16:37:00 -0000	[thread overview]
Message-ID: <20040427163725.GA7319@act-europe.fr> (raw)
In-Reply-To: <20040419173249.GA22201@act-europe.fr>

Ping? Still waiting for approval...

(I have a testcase for that, coming soon...)

Jerome Guitton (guitton@act-europe.fr):

> For what I understand from the skip_prologue algorithm in i386-tdep.c,
> there are cases when the first instruction of a function is a jump to
> the prologue code, which is located somewhere else in the function
> (e.g.  the end of the function).  The last instruction of the prologue
> in this case is a branch to the "real" code.
> 
> To take this case into account, GDB applies two corrections:
> 
> C1: GDB tests if the first instruction of the function is a jump; if
> so, GDB jumps to the target of the branch (i.e.  it follows the branch).
> 
> C2: GDB tests if the next instruction after the prologue is a jump; if
> so, it considers that it is a branch back to the "real" beginning of
> the program and follows the branch.
> 
> A problem appears if we are in the "usual" case and if the first instruction
> of the "real" code is a branch instruction:
> 
> 0x8049454 <_ada_b>:     push   %ebp
> 0x8049455 <_ada_b+1>:   mov    %esp,%ebp
> 0x8049457 <_ada_b+3>:   jmp    0x8049460 <_ada_b+12>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> In this case, GDB will not apply C1 but will apply C2. That seems wrong to
> me, I cannot see how the pair (not C1, C2) can be correct.
> 
> See a possible fix in attachment. Tested on x86-linux, no regression.
> 
> OK to apply?
> 
> -- 
> Jerome

> 2004-04-19  Jerome Guitton  <guitton@gnat.com>
> 
> 	* i386-tdep.c (i386_skip_prologue): follow the last jump only if the
> 	function begins with a branch instruction.
> 
> Index: i386-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> retrieving revision 1.187
> diff -u -p -r1.187 i386-tdep.c
> --- i386-tdep.c	18 Apr 2004 18:38:04 -0000	1.187
> +++ i386-tdep.c	19 Apr 2004 17:08:36 -0000
> @@ -750,7 +750,15 @@ i386_skip_prologue (CORE_ADDR start_pc)
>  	}
>      }
>  
> -  return i386_follow_jump (pc);
> +  /* If the first instruction of the function is a branch, then the
> +     setup sequence is at the end of the function and the instruction
> +     at pc is branch back to the start. In this case, follow the
> +     jump.  */
> +
> +  if (i386_follow_jump (start_pc) != start_pc)
> +    return i386_follow_jump (pc);
> +  else
> +    return pc;
>  }
>  
>  /* This function is 64-bit safe.  */


  reply	other threads:[~2004-04-27 16:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-19 17:32 Jerome Guitton
2004-04-27 16:37 ` Jerome Guitton [this message]
2004-04-29 16:24   ` Mark Kettenis
2004-04-29 16:29     ` Jerome Guitton
2004-05-10 20:48     ` Daniel Jacobowitz
2004-05-12 10:31       ` Jerome Guitton
2004-08-08 21:36         ` Daniel Jacobowitz
2004-08-08 21:46           ` Michael Chastain
2004-08-08 22:07           ` Mark Kettenis
2004-08-08 22:15             ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040427163725.GA7319@act-europe.fr \
    --to=guitton@act-europe.fr \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox