From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23282 invoked by alias); 21 Mar 2009 16:26:26 -0000 Received: (qmail 23272 invoked by uid 22791); 21 Mar 2009 16:26:24 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_45,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-bw0-f164.google.com (HELO mail-bw0-f164.google.com) (209.85.218.164) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Mar 2009 16:26:16 +0000 Received: by bwz8 with SMTP id 8so1242568bwz.24 for ; Sat, 21 Mar 2009 09:26:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.57.67 with SMTP id b3mr1728463bkh.99.1237652773098; Sat, 21 Mar 2009 09:26:13 -0700 (PDT) In-Reply-To: References: <49B67300.1020503@onevision.de> Date: Sat, 21 Mar 2009 16:26:00 -0000 Message-ID: <90baa01f0903210926r1758a0a7m379ec93fc4b7d33a@mail.gmail.com> Subject: Re: gdb_assert when resetting breakpoints From: Kai Tietz To: Kai Tietz Cc: gdb , Roland Schwingel Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00135.txt.bz2 Hello all, any reply would be kind Cheers, Kai 2009/3/17 Kai Tietz : > gdb-owner@sourceware.org wrote on 10.03.2009 15:02:40: > >> Hi... >> >> When using current gdb cvs head sources I encounter a gdb_assert() in >> breakpoint.c line 7451. >> This is in function breakpoint_re_set_one(). >> Let me tell you what I am doing to get it (reproduceably). I am not a >> guru to gdb's internals so >> please forgive me if I conclude something wrong. >> >> I am having a mixed C and Objective C application. I am running on >> windows using GNUstep >> for my ObjC Foundation classes. GNUstep-base is a shared library loaded >> lazy. >> Due to the nature of this bug I assume that this will also appear on >> other platforms like linux >> (according to my analysis). So it is not windows specific. >> >> I start gdb and set a breakpoint to main() using "b main". Then I run my > >> app using "r". >> A few seconds later I get the assert in breakpoint.c:7451 >> gdb_assert(sals.nelts=3D=3D1). >> When I debug into it sals.nelts =3D=3D 2. The assert happens when the >> gnustep-base shared >> library was loaded. >> >> What has happenend: In breakpoint.c line 7417 you find: >> sals =3D decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) >> NULL,not_found_ptr); >> s points to "main" at that moment as found in the breakpoint structure >> supplied to breakpoint_re_set_one(). >> >> sals (returned from decode_line_1) contains 2 entries. >> Sals entry 0 points to the ObjectiveC METHOD main of the foundation base > >> class NSThread >> (written in ObjC notation -[NSThread main]). This is a real ObjC >> baseclass not something >> from my own code. It has also nothing to do with an application's >> entrypoint. It also perfectly >> legal in ObjectiveC to name methods like C functions. They do not > collide. >> Sals entry 1 points to the function "main()" of my application. This is >> the entry which I think is >> the correct one to use here. >> >> Obviously decode_line_1 returns every symbol matching a certain string >> independant of >> its language. As far as I understand gdb at the moment this appears to >> be ok. >> >> So what is the correct behaviour here to fix this problem? I assume that > >> there might be more >> areas of symbol duplicates that can occur not only main() vs -[NSThread >> main]. >> >> Maybe the assert should be replaced by a loop over the sals entries >> matching the infos from the >> breakpoint structure passed to breakpoint_re_set_one() and the >> individual symtab entry of one >> sals entry by filename(?) matching? >> >> Thanks in advance for your help, >> >> Roland >> >> > > Hi, > > I prepared a patch for this issue, which should solve the described > problem of Roland. > > Changelog: > > 2009-03-17 =A0Kai Tietz =A0 > > =A0 =A0 =A0 =A0* breakpoint.c: take care about multiple breakpoints > =A0 =A0 =A0 =A0possibilities when resetting breakpoints. > > > Is this patch ok for apply? > > Cheers, > Kai > > | =A0(\_/) =A0This is Bunny. Copy and paste Bunny > | (=3D'.'=3D) into your signature to help him gain > | (")_(") world domination. > > Patch: > > Index: src/gdb/breakpoint.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- src.orig/gdb/breakpoint.c =A0 2009-03-17 11:10:45.000000000 +0100 > +++ src/gdb/breakpoint.c =A0 =A0 =A0 =A02009-03-17 11:19:01.890880000 +01= 00 > @@ -57,6 +57,7 @@ > =A0#include "top.h" > =A0#include "wrapper.h" > =A0#include "valprint.h" > +#include "filenames.h" > > =A0#include "mi/mi-common.h" > > @@ -7392,6 +7393,7 @@ > =A0 struct breakpoint *b =3D (struct breakpoint *) bint; > =A0 struct value *mark; > =A0 int i; > + =A0int sals_index =3D -1; > =A0 int not_found =3D 0; > =A0 int *not_found_ptr =3D ¬_found; > =A0 struct symtabs_and_lines sals =3D {}; > @@ -7455,20 +7457,59 @@ > =A0 =A0 =A0 if (not_found) > =A0 =A0 =A0 =A0break; > > - =A0 =A0 =A0gdb_assert (sals.nelts =3D=3D 1); > - =A0 =A0 =A0resolve_sal_pc (&sals.sals[0]); > - =A0 =A0 =A0if (b->condition_not_parsed && s && s[0]) > + =A0 =A0 =A0/* If only one sals entry is found use it directly > + =A0 =A0 =A0 =A0elsewise cycle over all sals and match breakpoint > + =A0 =A0 =A0 =A0against all returned sals by checking filenames and > + =A0 =A0 =A0 =A0linenumbers. */ > + =A0 =A0 =A0if (sals.nelts =3D=3D 1) > + =A0 =A0 =A0 sals_index =3D 0; > + =A0 =A0 =A0else > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 for (i=3D0;(i < sals.nelts) && (sals_index =3D=3D -1);i= ++) > + =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 int symtab_linenum =3D sals.sals[i].line; > + =A0 =A0 =A0 =A0 =A0 =A0 int bpoint_linenum =3D b->line_number; > + > + =A0 =A0 =A0 =A0 =A0 =A0 if (symtab_linenum =3D=3D bpoint_linenum) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct symtab *s =3D sals.sals[i].symta= b; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (s) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *symtab_filename =3D= s->filename; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *bpoint_filename =3D= b->source_file; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (symtab_filename) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 symtab_filename =3D lbasena= me(symtab_filename); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (bpoint_filename) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bpoint_filename =3D lbasena= me(bpoint_filename); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (bpoint_filename && symtab_f= ilename > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 && > (FILENAME_CMP(bpoint_filename,symtab_filename) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D=3D 0)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sals_index =3D i; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + =A0 =A0 =A0gdb_assert(sals_index !=3D -1); > + =A0 =A0 =A0if (sals_index =3D=3D -1) > + =A0 =A0 =A0 break; > + > + =A0 =A0 =A0resolve_sal_pc (&sals.sals[sals_index]); > + =A0 =A0 =A0if (b->condition_not_parsed && s && s[sals_index]) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0char *cond_string =3D 0; > =A0 =A0 =A0 =A0 =A0int thread =3D -1; > - =A0 =A0 =A0 =A0 find_condition_and_thread (s, sals.sals[0].pc, > + =A0 =A0 =A0 =A0 find_condition_and_thread (s, sals.sals[sals_index].pc, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &= cond_string, &thread); > =A0 =A0 =A0 =A0 =A0if (cond_string) > =A0 =A0 =A0 =A0 =A0 =A0b->cond_string =3D cond_string; > =A0 =A0 =A0 =A0 =A0b->thread =3D thread; > =A0 =A0 =A0 =A0 =A0b->condition_not_parsed =3D 0; > =A0 =A0 =A0 =A0} > - =A0 =A0 =A0expanded =3D expand_line_sal_maybe (sals.sals[0]); > + =A0 =A0 =A0expanded =3D expand_line_sal_maybe (sals.sals[sals_index]); > =A0 =A0 =A0 cleanups =3D make_cleanup (xfree, sals.sals); > =A0 =A0 =A0 update_breakpoint_locations (b, expanded); > =A0 =A0 =A0 do_cleanups (cleanups); > --=20 | (\_/) This is Bunny. Copy and paste | (=3D'.'=3D) Bunny into your signature to help | (")_(") him gain world domination