public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/16157] New: the function get_pc_function_start (CORE_ADDR pc) maybe inaccurate
@ 2013-11-12  6:12 guosheng_gao at realsil dot com.cn
  2013-11-12 11:46 ` [Bug gdb/16157] " palves at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: guosheng_gao at realsil dot com.cn @ 2013-11-12  6:12 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 16157
           Summary: the function get_pc_function_start (CORE_ADDR pc)
                    maybe inaccurate
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: guosheng_gao at realsil dot com.cn

get_pc_function_start(CORE_ADDR pc) try to get the function start for a special
pc, but the function 
lookup_minimal_symbol_by_pc(CORE_ADDR pc) may return a minimal_symbol, which is
not a function(e.g. a label in assembler code). So the fstart is not a function
start address, too.

This may cause a problem: in following code, GDB can not stop when try to next
over Line 1.(lop2 and lop3 are mistaken for a function, so GDB thinks that it
step into a new function, set a breakpoint at the address stored in register
$ra, and run to it)

Is this correct? 

==========================
        #.globl hardware_hazard_hook .text
        .globl  _start
        .ent    _start
_start:
        .set    noreorder
        addiu  v0, 1
    addiu  v0, 1
lop3:
     addiu  v0, 1
    addiu  v0, 1
lop2:
    addiu  v0, 1// Line 1
    addiu  v0, 1
lop1:
    addiu  v0, 1
    addiu  v0, 1
    addiu  v0, 1
    addiu  v0, 1
      nop
...
-------------------------------
gdb/minsyms.c
CORE_ADDR
get_pc_function_start (CORE_ADDR pc)
{
  struct block *bl;
  struct minimal_symbol *msymbol;

  bl = block_for_pc (pc);
  if (bl)
    {
      struct symbol *symbol = block_linkage_function (bl);

      if (symbol)
    {
      bl = SYMBOL_BLOCK_VALUE (symbol);
      return BLOCK_START (bl);
    }
    }

  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;
}

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


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

end of thread, other threads:[~2013-11-14  9:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12  6:12 [Bug gdb/16157] New: the function get_pc_function_start (CORE_ADDR pc) maybe inaccurate 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
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

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