From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31742 invoked by alias); 16 Jun 2004 17:58:06 -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 31724 invoked from network); 16 Jun 2004 17:58:04 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.171) by sourceware.org with SMTP; 16 Jun 2004 17:58:04 -0000 Received: from [212.227.126.209] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Baefj-0004ke-00 for gdb-patches@sources.redhat.com; Wed, 16 Jun 2004 19:58:03 +0200 Received: from [217.235.193.91] (helo=[217.235.193.91]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Baefj-0002WK-00 for gdb-patches@sources.redhat.com; Wed, 16 Jun 2004 19:58:03 +0200 Message-ID: <40D08A0C.1050606@kay-mueller.de> Date: Wed, 16 Jun 2004 17:58:00 -0000 From: Michael Mueller User-Agent: Mozilla/5.0 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [RFC]: patch 1 for Sun C compiled target programs Content-Type: multipart/mixed; boundary="------------060600060103010404060200" X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:acfe4e233830c7fd36d26ada4c2bf87e X-SW-Source: 2004-06/txt/msg00386.txt.bz2 This is a multi-part message in MIME format. --------------060600060103010404060200 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2762 Setting a breakpoint on a function name or on the first line of a function doesn't work for Sun C compiled target programs (32 and 64 bit). I verified this against these compiler versions: Sun C 5.5 2003/03/12 Forte Developer 7 C 5.4 2002/03/09 Sun WorkShop 6 update 2 C 5.3 2001/05/15 Sun WorkShop 6 2000/04/07 C 5.1 This is what happens: GNU gdb 20040614 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-sun-solaris2.8"... (gdb) list 1,100 1 #include 2 3 void fun(void); 4 5 int 6 main() 7 { 8 fun(); 9 printf("line %d\n", __LINE__); 10 } 11 12 void 13 fun() 14 { 15 int n = 7; 16 17 printf("fun: n = %d\n", n); 18 } (gdb) b main Breakpoint 1 at 0x106cc: file p1.c, line 9. (gdb) run Starting program: /export/home/michaelm/gdb/gdb-6.1.patch/tst/p1 fun: n = 7 Breakpoint 1, main () at p1.c:9 9 printf("line %d\n", __LINE__); (gdb) # This is the second line in main!!! (gdb) b 8 Breakpoint 2 at 0x0: file p1.c, line 8. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /export/home/michaelm/gdb/gdb-6.1.patch/tst/p1 Warning: Cannot insert breakpoint 2. Error accessing memory address 0x0: I/O error. The reason is that in process_one_symbol the first SLINE address is set to last_function_start which is 0 at that time. There are 2 problems (at least). 1) last_function_start is set = valu underneath case N_FNAME:, which is 0. Valu is then corrected after the following goto define_a_symbol;. Butlast_function_start remains 0. 2) After correcting that I found that this didn't work either and wasn't even necessary (see patch below). I don't know why this was done in the first place and how and for which version this worked. There is this comment: /* If this is the first SLINE note in the function, record it at the start of the function instead of at the listed location. */ Why was this done? 3) last_function_start is used in other places as well. Not sure if this now works correctly. Not sure how to test it. I tested my patch manually against the above compilers. 2004-05-16 Michael Mueller * dbxread.c: make breakpoint at function or first line of function work --------------060600060103010404060200 Content-Type: text/plain; name="dbxread.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dbxread.patch" Content-length: 2367 Index: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.67 diff -c -p -r1.67 dbxread.c *** dbxread.c 10 Jun 2004 20:05:43 -0000 1.67 --- dbxread.c 16 Jun 2004 16:51:05 -0000 *************** process_one_symbol (int type, int desc, *** 2672,2680 **** static CORE_ADDR last_function_start; /* If this is nonzero, we've seen an N_SLINE since the start of the ! current function. We use this to tell us to move the first sline ! to the beginning of the function regardless of what its given ! value is. */ static int sline_found_in_function = 1; /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source --- 2672,2678 ---- static CORE_ADDR last_function_start; /* If this is nonzero, we've seen an N_SLINE since the start of the ! current function. */ static int sline_found_in_function = 1; /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source *************** process_one_symbol (int type, int desc, *** 2962,2976 **** #ifdef SUN_FIXED_LBRAC_BUG last_pc_address = valu; /* Save for SunOS bug circumcision */ #endif - /* If this is the first SLINE note in the function, record it at - the start of the function instead of at the listed location. */ if (within_function && sline_found_in_function == 0) - { - record_line (current_subfile, desc, last_function_start); sline_found_in_function = 1; ! } ! else ! record_line (current_subfile, desc, valu); break; case N_BCOMM: --- 2960,2968 ---- #ifdef SUN_FIXED_LBRAC_BUG last_pc_address = valu; /* Save for SunOS bug circumcision */ #endif if (within_function && sline_found_in_function == 0) sline_found_in_function = 1; ! record_line (current_subfile, desc, valu); break; case N_BCOMM: *************** process_one_symbol (int type, int desc, *** 3117,3123 **** it is likely that the value was set correctly to begin with... */ if (minsym_valu != 0) ! valu = minsym_valu; } #endif --- 3109,3115 ---- it is likely that the value was set correctly to begin with... */ if (minsym_valu != 0) ! last_function_start = valu = minsym_valu; } #endif --------------060600060103010404060200--