From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6383 invoked by alias); 24 Jan 2013 15:01:06 -0000 Received: (qmail 6370 invoked by uid 22791); 24 Jan 2013 15:01:05 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e24smtp04.br.ibm.com (HELO e24smtp04.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jan 2013 15:00:34 +0000 Received: from /spool/local by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 Jan 2013 13:00:32 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 Jan 2013 13:00:30 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 991141DC0066 for ; Thu, 24 Jan 2013 10:00:29 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0OEx6K31548456 for ; Thu, 24 Jan 2013 12:59:06 -0200 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0OF0Tg0010862 for ; Thu, 24 Jan 2013 13:00:29 -0200 Received: from [9.8.12.62] ([9.8.12.62]) by d24av01.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0OF0SXX010853 for ; Thu, 24 Jan 2013 13:00:28 -0200 Message-ID: <1359039628.28026.76.camel@localhost.localdomain> Subject: Re: [PATCH] Fix handling of #include files during prologue skipping From: Tiago =?ISO-8859-1?Q?St=FCrmer?= Daitx To: gdb-patches@sourceware.org Date: Thu, 24 Jan 2013 15:01:00 -0000 In-Reply-To: <1359037662.28026.70.camel@localhost.localdomain> References: <201301241256.r0OCueFI023763@d06av02.portsmouth.uk.ibm.com> <1359033075.28026.68.camel@localhost.localdomain> <1359037662.28026.70.camel@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13012415-8936-0000-0000-0000092739BC X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00593.txt.bz2 I got a tip from Edjunior to use gdb_get_line_number instead of that hardcoded/magic line number. Works like a charm. Cheers -tiago gdb/ChangeLog 2013-01-24 Ulrich Weigand * symtab.c (skip_prologue_using_sal): Consider a file change the same as an increased line number gdb/testsuite/ChangeLog 2013-01-24 Tiago Stürmer Daitx * gdb.base/prologue-include.c: New file. * gdb.base/prologue-include.exp: New file. * gdb.base/prologue-include.h: New file. diff --git a/gdb/symtab.c b/gdb/symtab.c index d40436a..b200b36 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4905,6 +4905,10 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) line mark the prologue -> body transition. */ if (sal.line >= prologue_sal.line) break; + /* Likewise if we are in a different symtab altogether + (e.g. within a file included via #include). */ + if (sal.symtab != prologue_sal.symtab) + break; /* The line number is smaller. Check that it's from the same function, not something inlined. If it's inlined, diff --git a/gdb/testsuite/gdb.base/prologue-include.c b/gdb/testsuite/gdb.base/prologue-include.c new file mode 100644 index 0000000..c393e75 --- /dev/null +++ b/gdb/testsuite/gdb.base/prologue-include.c @@ -0,0 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +main (void) +{ + int i, j; +#include "prologue-include.h" + return 0; +} + diff --git a/gdb/testsuite/gdb.base/prologue-include.exp b/gdb/testsuite/gdb.base/prologue-include.exp new file mode 100644 index 0000000..ed378b8 --- /dev/null +++ b/gdb/testsuite/gdb.base/prologue-include.exp @@ -0,0 +1,26 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile + +if { [prepare_for_testing ${testfile}.exp ${testfile}] } { + return -1 +} + +set bp_main [gdb_get_line_number "break main" ${testfile}.h] + +gdb_test "break main" \ + "Breakpoint.*at.* file .*$testfile.h, line $bp_main\\." \ + "breakpoint main" diff --git a/gdb/testsuite/gdb.base/prologue-include.h b/gdb/testsuite/gdb.base/prologue-include.h new file mode 100644 index 0000000..77843e0 --- /dev/null +++ b/gdb/testsuite/gdb.base/prologue-include.h @@ -0,0 +1,19 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + i = 2; /* break main should stop here */ + j = 2;