This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFA] x86 - jump instruction after the prologue


Hello,

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

Attachment: diff
Description: Text document


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