public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "guosheng_gao at realsil dot com.cn" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/16157] the function get_pc_function_start (CORE_ADDR pc) maybe inaccurate
Date: Tue, 12 Nov 2013 13:18:00 -0000	[thread overview]
Message-ID: <bug-16157-4717-NR2E9nMVfh@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-16157-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=16157

--- Comment #3 from ggs334 <guosheng_gao at realsil dot com.cn> ---
look the code in the function get_pc_function_start(CORE_ADDR pc)   
> CORE_ADDR
> get_pc_function_start (CORE_ADDR pc)
> {
> ...........
> ...........
> ...........
> ...........
> ...........
> ...........

>  msymbol = lookup_minimal_symbol_by_pc (pc);
>  if (msymbol)
>    {
>     CORE_ADDR fstart = SYMBOL_VALUE_ADDRESS (msymbol);
>      if (find_pc_section (fstart))
>	return fstart;
>    }

>  return 0;
>}
the label lop2 and lop3 hava adress values, if the pc value is equal to the
address of lop2 or lop3, the msymbol returned from
lookup_minimal_symbol_by_pc() must be lop2 or lop3, then uses
SYMBOL_VALUE_ADDRESS (msymbol) to get the address, and treats the address as
function start address.

I Think this is the problem, is it accurate?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-14671-listarch-gdb-prs=sources.redhat.com@sourceware.org Tue Nov 12 14:26:48 2013
Return-Path: <gdb-prs-return-14671-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 8808 invoked by alias); 12 Nov 2013 14:26:48 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 8778 invoked by uid 48); 12 Nov 2013 14:26:47 -0000
From: "palves at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/16157] the function get_pc_function_start (CORE_ADDR pc)
 maybe inaccurate
Date: Tue, 12 Nov 2013 14:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: palves at redhat dot com
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-16157-4717-GOEPBSNfMo@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-16157-4717@http.sourceware.org/bugzilla/>
References: <bug-16157-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-q4/txt/msg00297.txt.bz2
Content-length: 1881

https://sourceware.org/bugzilla/show_bug.cgi?id\x16157

--- Comment #4 from Pedro Alves <palves at redhat dot com> ---
> the code address are different. So GDB thinking the program stepped into a new
> function

That's not sufficient, the frame that was frame #0 before the step must be
frame #1 after the step for GDB to consider this was a subroutine call.  That's
this part of the condition:

      && (frame_id_eq (frame_unwind_caller_id (get_current_frame ()),
               ecs->event_thread->control.step_stack_frame_id)

If before the stepi you have:

 #0  _start () at crt0.S:93

and then after you have:

 #0  lop2 () at crt0.S:95
 #1  0xfffffffe in ?? ()

Then I don't understand how that frame_id_eq returned true.  Well, unless both
were outer_frame_id.  Please check that.

I also don't understand why GDB thinks the function is _start just before the
stepi, instead of lop3.  What's different between lop3 and lop2?  You need to
step through  lookup_minimal_symbol_by_pc_section_1 and understand that.

> the label lop2 and lop3 hava adress values, if the pc value is equal to the
> address of lop2 or lop3, the msymbol returned from
> lookup_minimal_symbol_by_pc() must be lop2 or lop3, then uses
> SYMBOL_VALUE_ADDRESS (msymbol) to get the address, and treats the address as
> function start address.
> I Think this is the problem, is it accurate?

Not exactly.  lookup_minimal_symbol_by_pc, if not returning the "real"
function, then should be returning the closes label.  That is, for all
instructions between lop3 and lop2, it should return lop3, etc.

But that shouldn't be a problem on its own, the other checks in the
"Check for subroutine calls" bit should catch that.  Unless, again, this is
really the outer_frame_id bits triggering.  outer_frame_id really should die...

--
You are receiving this mail because:
You are on the CC list for the bug.


  parent reply	other threads:[~2013-11-12 13:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12  6:12 [Bug gdb/16157] New: " guosheng_gao at realsil dot com.cn
2013-11-12 11:46 ` [Bug gdb/16157] " palves at redhat dot com
2013-11-12 13:01 ` guosheng_gao at realsil dot com.cn
2013-11-12 13:18 ` guosheng_gao at realsil dot com.cn [this message]
2013-11-12 14:29 ` palves at redhat dot com
2013-11-13  2:49 ` guosheng_gao at realsil dot com.cn
2013-11-13  3:10 ` guosheng_gao at realsil dot com.cn
2013-11-13 10:06 ` palves at redhat dot com
2013-11-14  9:57 ` guosheng_gao at realsil dot com.cn

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=bug-16157-4717-NR2E9nMVfh@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).