From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23499 invoked by alias); 7 Jul 2003 20:42:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23492 invoked from network); 7 Jul 2003 20:42:21 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 7 Jul 2003 20:42:21 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id A6E942B5F for ; Mon, 7 Jul 2003 16:42:05 -0400 (EDT) Message-ID: <3F09DB1D.6070003@redhat.com> Date: Mon, 07 Jul 2003 20:42:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch, rfc, 6] Check for "main" in minimal symbols in BT Content-Type: multipart/mixed; boundary="------------000906090405060904010203" X-SW-Source: 2003-07/txt/msg00144.txt.bz2 This is a multi-part message in MIME format. --------------000906090405060904010203 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 790 Hello, This patch extends the inside_main_func() check so that, when "main" isn't found in the symbol table, the mimimal symbol table is searched. In case you're wondering, the logic for finding the end address of "main" was cobbled together from random bits of code from blockframe and the alpha. It certainly appears to work for d10v and i386. Anyway, with this, the d10v's assembler backtrace stops at main goving the short 'n' sharp backtrace foo2 main instead of the current: foo2 main _start _start The patch (since things now stop in "main") also removes the d10v specific frame ID eq test; and updates the testsuite so that it doesn't allow "_start" in the backtrace. I intend checking this into both 6.0 branch and mainline in a few days. comments, Andrew --------------000906090405060904010203 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 4830 2003-07-07 Andrew Cagney * frame.c (get_prev_frame): Add comment about forgetting to check the minimal symbol table for "main". * blockframe.c (inside_main_func): Look for "main" in the minimal symbol table. * d10v-tdep.c (d10v_frame_this_id): Delete check that frames are identical. Index: testsuite/ChangeLog 2003-07-07 Andrew Cagney * gdb.asm/asm-source.exp: Do not allow "start" in the backtrace. Index: blockframe.c =================================================================== RCS file: /cvs/src/src/gdb/blockframe.c,v retrieving revision 1.72 diff -u -r1.72 blockframe.c --- blockframe.c 23 May 2003 17:05:19 -0000 1.72 +++ blockframe.c 7 Jul 2003 20:25:21 -0000 @@ -106,6 +106,47 @@ BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym)); } } + + /* Not in the normal symbol tables, see if "main" is in the partial + symbol table. If it's not, then give up. */ + { + struct minimal_symbol *msymbol + = lookup_minimal_symbol (main_name (), NULL, symfile_objfile); + if (msymbol != NULL && MSYMBOL_TYPE (msymbol) == mst_text) + { + struct obj_section *osect + = find_pc_sect_section (SYMBOL_VALUE_ADDRESS (msymbol), + msymbol->ginfo.bfd_section); + if (osect != NULL) + { + int i; + /* Step over other symbols at this same address, and + symbols in other sections, to find the next symbol in + this section with a different address. */ + for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++) + { + if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol) + && SYMBOL_BFD_SECTION (msymbol + i) == SYMBOL_BFD_SECTION (msymbol)) + break; + } + + symfile_objfile->ei.main_func_lowpc = SYMBOL_VALUE_ADDRESS (msymbol); + + /* Use the lesser of the next minimal symbol in the same + section, or the end of the section, as the end of the + function. */ + if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL + && SYMBOL_VALUE_ADDRESS (msymbol + i) < osect->endaddr) + symfile_objfile->ei.main_func_highpc = SYMBOL_VALUE_ADDRESS (msymbol + i); + else + /* We got the start address from the last msymbol in the + objfile. So the end address is the end of the + section. */ + symfile_objfile->ei.main_func_highpc = osect->endaddr; + } + } + } + return (symfile_objfile->ei.main_func_lowpc <= pc && symfile_objfile->ei.main_func_highpc > pc); } Index: d10v-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/d10v-tdep.c,v retrieving revision 1.127 diff -u -r1.127 d10v-tdep.c --- d10v-tdep.c 7 Jul 2003 14:36:57 -0000 1.127 +++ d10v-tdep.c 7 Jul 2003 20:25:21 -0000 @@ -1417,15 +1417,6 @@ id = frame_id_build (base, func); - /* Check that we're not going round in circles with the same frame - ID (but avoid applying the test to sentinel frames which do go - round in circles). Can't use frame_id_eq() as that doesn't yet - compare the frame's PC value. */ - if (frame_relative_level (next_frame) >= 0 - && get_frame_type (next_frame) != DUMMY_FRAME - && frame_id_eq (get_frame_id (next_frame), id)) - return; - (*this_id) = id; } Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.130 diff -u -r1.130 frame.c --- frame.c 7 Jul 2003 20:07:12 -0000 1.130 +++ frame.c 7 Jul 2003 20:25:22 -0000 @@ -1870,6 +1870,12 @@ be allowed to unwind. */ /* NOTE: cagney/2003-02-25: Don't enable until someone has found hard evidence that this is needed. */ + /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func - wasn't + checking for "main" in the minimal symbols. With that fixed + asm-source tests now stop in "main" instead of halting the + backtrace in wierd and wonderful ways. Suspect that + inside_entry_file and inside_entry_func tests were added to work + around that (now fixed) case. */ if (0 && this_frame->type != DUMMY_FRAME && this_frame->level >= 0 && inside_entry_func (get_frame_pc (this_frame))) Index: testsuite/gdb.asm/asm-source.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v retrieving revision 1.39 diff -u -r1.39 asm-source.exp --- testsuite/gdb.asm/asm-source.exp 7 Jul 2003 14:48:50 -0000 1.39 +++ testsuite/gdb.asm/asm-source.exp 7 Jul 2003 20:25:26 -0000 @@ -244,7 +244,7 @@ # doesn't fall off the stack. gdb_test "bt 10" \ - "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33(.*\#2.*start\[^\r\n\]*)?" \ + "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33" \ "bt ALL in foo2" # See if a capped `bt' prints the right source files. --------------000906090405060904010203--