From 86da934b14f15b2262b82308130829f68b0791c0 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 9 Apr 2010 15:31:41 +0000 Subject: [PATCH] * symtab.c (find_function_start_sal): Never return SAL pointing before function start address, even if line info is missing. --- gdb/ChangeLog | 5 +++++ gdb/symtab.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f7c76c73532..4b4b82e28ca 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 Ulrich Weigand + + * symtab.c (find_function_start_sal): Never return SAL pointing + before function start address, even if line info is missing. + 2010-04-09 Pedro Alves * NEWS: Mention tracepoints support. diff --git a/gdb/symtab.c b/gdb/symtab.c index b10cdc8620c..29142dab47f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2295,6 +2295,18 @@ find_function_start_sal (struct symbol *sym, int funfirstline) sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), SYMBOL_OBJ_SECTION (sym), 0); + /* We always should have a line for the function start address. + If we don't, something is odd. Create a plain SAL refering + just the PC and hope that skip_prologue_sal (if requested) + can find a line number for after the prologue. */ + if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym))) + { + init_sal (&sal); + sal.pspace = current_program_space; + sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); + sal.section = SYMBOL_OBJ_SECTION (sym); + } + if (funfirstline) skip_prologue_sal (&sal); -- 2.30.2