* gdb_assert when resetting breakpoints
@ 2009-03-10 14:02 Roland Schwingel
2009-03-10 15:39 ` Paul Pluzhnikov
2009-03-17 10:24 ` Kai Tietz
0 siblings, 2 replies; 7+ messages in thread
From: Roland Schwingel @ 2009-03-10 14:02 UTC (permalink / raw)
To: gdb
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==1).
When I debug into it sals.nelts == 2. The assert happens when the
gnustep-base shared
library was loaded.
What has happenend: In breakpoint.c line 7417 you find:
sals = 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb_assert when resetting breakpoints
2009-03-10 14:02 gdb_assert when resetting breakpoints Roland Schwingel
@ 2009-03-10 15:39 ` Paul Pluzhnikov
2009-03-17 10:24 ` Kai Tietz
1 sibling, 0 replies; 7+ messages in thread
From: Paul Pluzhnikov @ 2009-03-10 15:39 UTC (permalink / raw)
To: Roland Schwingel; +Cc: gdb
On Tue, Mar 10, 2009 at 7:02 AM, Roland Schwingel
<roland.schwingel@onevision.de> wrote:
> When using current gdb cvs head sources I encounter a gdb_assert() in
> breakpoint.c line 7451.
How current? It appears that this may have been fixed yesterday :-)
Could you check if this problem is still present in current source?
Thanks,
--
Paul Pluzhnikov
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb_assert when resetting breakpoints
2009-03-10 14:02 gdb_assert when resetting breakpoints Roland Schwingel
2009-03-10 15:39 ` Paul Pluzhnikov
@ 2009-03-17 10:24 ` Kai Tietz
2009-03-21 16:26 ` Kai Tietz
1 sibling, 1 reply; 7+ messages in thread
From: Kai Tietz @ 2009-03-17 10:24 UTC (permalink / raw)
To: gdb; +Cc: Roland Schwingel
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==1).
> When I debug into it sals.nelts == 2. The assert happens when the
> gnustep-base shared
> library was loaded.
>
> What has happenend: In breakpoint.c line 7417 you find:
> sals = 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 Kai Tietz <Kai.Tietz@onevision.com>
* breakpoint.c: take care about multiple breakpoints
possibilities when resetting breakpoints.
Is this patch ok for apply?
Cheers,
Kai
| (\_/) This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.
Patch:
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2009-03-17 11:10:45.000000000 +0100
+++ src/gdb/breakpoint.c 2009-03-17 11:19:01.890880000 +0100
@@ -57,6 +57,7 @@
#include "top.h"
#include "wrapper.h"
#include "valprint.h"
+#include "filenames.h"
#include "mi/mi-common.h"
@@ -7392,6 +7393,7 @@
struct breakpoint *b = (struct breakpoint *) bint;
struct value *mark;
int i;
+ int sals_index = -1;
int not_found = 0;
int *not_found_ptr = ¬_found;
struct symtabs_and_lines sals = {};
@@ -7455,20 +7457,59 @@
if (not_found)
break;
- gdb_assert (sals.nelts == 1);
- resolve_sal_pc (&sals.sals[0]);
- if (b->condition_not_parsed && s && s[0])
+ /* If only one sals entry is found use it directly
+ elsewise cycle over all sals and match breakpoint
+ against all returned sals by checking filenames and
+ linenumbers. */
+ if (sals.nelts == 1)
+ sals_index = 0;
+ else
+ {
+ for (i=0;(i < sals.nelts) && (sals_index == -1);i++)
+ {
+ int symtab_linenum = sals.sals[i].line;
+ int bpoint_linenum = b->line_number;
+
+ if (symtab_linenum == bpoint_linenum)
+ {
+ struct symtab *s = sals.sals[i].symtab;
+
+ if (s)
+ {
+ const char *symtab_filename = s->filename;
+ const char *bpoint_filename = b->source_file;
+
+ if (symtab_filename)
+ symtab_filename = lbasename(symtab_filename);
+
+ if (bpoint_filename)
+ bpoint_filename = lbasename(bpoint_filename);
+
+ if (bpoint_filename && symtab_filename
+ &&
(FILENAME_CMP(bpoint_filename,symtab_filename)
+ == 0))
+ sals_index = i;
+ }
+ }
+ }
+ }
+ gdb_assert(sals_index != -1);
+ if (sals_index == -1)
+ break;
+
+ resolve_sal_pc (&sals.sals[sals_index]);
+ if (b->condition_not_parsed && s && s[sals_index])
{
char *cond_string = 0;
int thread = -1;
- find_condition_and_thread (s, sals.sals[0].pc,
+ find_condition_and_thread (s, sals.sals[sals_index].pc,
&cond_string, &thread);
if (cond_string)
b->cond_string = cond_string;
b->thread = thread;
b->condition_not_parsed = 0;
}
- expanded = expand_line_sal_maybe (sals.sals[0]);
+ expanded = expand_line_sal_maybe (sals.sals[sals_index]);
cleanups = make_cleanup (xfree, sals.sals);
update_breakpoint_locations (b, expanded);
do_cleanups (cleanups);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: gdb_assert when resetting breakpoints
2009-03-17 10:24 ` Kai Tietz
@ 2009-03-21 16:26 ` Kai Tietz
2009-04-30 21:37 ` Joel Brobecker
0 siblings, 1 reply; 7+ messages in thread
From: Kai Tietz @ 2009-03-21 16:26 UTC (permalink / raw)
To: Kai Tietz; +Cc: gdb, Roland Schwingel
Hello all,
any reply would be kind
Cheers,
Kai
2009/3/17 Kai Tietz <Kai.Tietz@onevision.com>:
> 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==1).
>> When I debug into it sals.nelts == 2. The assert happens when the
>> gnustep-base shared
>> library was loaded.
>>
>> What has happenend: In breakpoint.c line 7417 you find:
>> sals = 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 Kai Tietz <Kai.Tietz@onevision.com>
>
> * breakpoint.c: take care about multiple breakpoints
> possibilities when resetting breakpoints.
>
>
> Is this patch ok for apply?
>
> Cheers,
> Kai
>
> | (\_/) This is Bunny. Copy and paste Bunny
> | (='.'=) into your signature to help him gain
> | (")_(") world domination.
>
> Patch:
>
> Index: src/gdb/breakpoint.c
> ===================================================================
> --- src.orig/gdb/breakpoint.c 2009-03-17 11:10:45.000000000 +0100
> +++ src/gdb/breakpoint.c 2009-03-17 11:19:01.890880000 +0100
> @@ -57,6 +57,7 @@
> #include "top.h"
> #include "wrapper.h"
> #include "valprint.h"
> +#include "filenames.h"
>
> #include "mi/mi-common.h"
>
> @@ -7392,6 +7393,7 @@
> struct breakpoint *b = (struct breakpoint *) bint;
> struct value *mark;
> int i;
> + int sals_index = -1;
> int not_found = 0;
> int *not_found_ptr = ¬_found;
> struct symtabs_and_lines sals = {};
> @@ -7455,20 +7457,59 @@
> if (not_found)
> break;
>
> - gdb_assert (sals.nelts == 1);
> - resolve_sal_pc (&sals.sals[0]);
> - if (b->condition_not_parsed && s && s[0])
> + /* If only one sals entry is found use it directly
> + elsewise cycle over all sals and match breakpoint
> + against all returned sals by checking filenames and
> + linenumbers. */
> + if (sals.nelts == 1)
> + sals_index = 0;
> + else
> + {
> + for (i=0;(i < sals.nelts) && (sals_index == -1);i++)
> + {
> + int symtab_linenum = sals.sals[i].line;
> + int bpoint_linenum = b->line_number;
> +
> + if (symtab_linenum == bpoint_linenum)
> + {
> + struct symtab *s = sals.sals[i].symtab;
> +
> + if (s)
> + {
> + const char *symtab_filename = s->filename;
> + const char *bpoint_filename = b->source_file;
> +
> + if (symtab_filename)
> + symtab_filename = lbasename(symtab_filename);
> +
> + if (bpoint_filename)
> + bpoint_filename = lbasename(bpoint_filename);
> +
> + if (bpoint_filename && symtab_filename
> + &&
> (FILENAME_CMP(bpoint_filename,symtab_filename)
> + == 0))
> + sals_index = i;
> + }
> + }
> + }
> + }
> + gdb_assert(sals_index != -1);
> + if (sals_index == -1)
> + break;
> +
> + resolve_sal_pc (&sals.sals[sals_index]);
> + if (b->condition_not_parsed && s && s[sals_index])
> {
> char *cond_string = 0;
> int thread = -1;
> - find_condition_and_thread (s, sals.sals[0].pc,
> + find_condition_and_thread (s, sals.sals[sals_index].pc,
> &cond_string, &thread);
> if (cond_string)
> b->cond_string = cond_string;
> b->thread = thread;
> b->condition_not_parsed = 0;
> }
> - expanded = expand_line_sal_maybe (sals.sals[0]);
> + expanded = expand_line_sal_maybe (sals.sals[sals_index]);
> cleanups = make_cleanup (xfree, sals.sals);
> update_breakpoint_locations (b, expanded);
> do_cleanups (cleanups);
>
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: gdb_assert when resetting breakpoints
2009-03-21 16:26 ` Kai Tietz
@ 2009-04-30 21:37 ` Joel Brobecker
0 siblings, 0 replies; 7+ messages in thread
From: Joel Brobecker @ 2009-04-30 21:37 UTC (permalink / raw)
To: Kai Tietz; +Cc: Kai Tietz, gdb, Roland Schwingel
> >> What has happenend: In breakpoint.c line 7417 you find:
> >> sals = 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]).
The problem, at this point, seems to be the fact that decode_line_1
should NOT be returning a match for this ObjC class method, since
the breakpoint language was C. I think we need to find out why
this method was selected as a match, and prevent it from happening.
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb_assert when resetting breakpoints
@ 2009-03-10 16:45 Roland Schwingel
0 siblings, 0 replies; 7+ messages in thread
From: Roland Schwingel @ 2009-03-10 16:45 UTC (permalink / raw)
To: ppluzhnikov; +Cc: gdb
Hi Paul,
Thanks for your reply.
Paul Pluzhnikov <ppluzhnikov@google.com> wrote on 10.03.2009 16:39:09:
> On Tue, Mar 10, 2009 at 7:02 AM, Roland Schwingel
> <roland.schwingel@onevision.de> wrote:
>
> > When using current gdb cvs head sources I encounter a gdb_assert() in
> > breakpoint.c line 7451.
>
> How current? It appears that this may have been fixed yesterday :-)
> Could you check if this problem is still present in current source?
Just verfied it. I am using the most recent code from CVS.
In the meantime I have hacked myself the matching of sals entries
and infos from breakpoint. It appears to work (for me). I am
matching linenumber and filenames in case of more than one
sals hit. The question for me is: Is this a good solution? I would
prefer a fix from someone knowing gdb's code much better than
me at any time...
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb_assert when resetting breakpoints
@ 2009-03-17 11:44 Roland Schwingel
0 siblings, 0 replies; 7+ messages in thread
From: Roland Schwingel @ 2009-03-17 11:44 UTC (permalink / raw)
To: Kai.tietz, gdb
Hi Kai,
Kai Tietz wrote on 17.03.2009 11:24:25:
> Roland Schwingel 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().
> >
> > ...
> >
> > 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 Kai Tietz <Kai.Tietz@onevision.com>
>
> * breakpoint.c: take care about multiple breakpoints
> possibilities when resetting breakpoints.
>
>
> Is this patch ok for apply?
>
> Cheers,
> Kai
Thanks for your patch and your work. I just tried it and it works
without trouble and solves the problems in resetting the breakpoints for me.
It looks quite similar to what I did for myself. I couldn't find a
problem upto
now with your patch. I think it would be could if this could make it to
gdb's
mainline. Others might also profit from that.
Thank you very much,
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-04-30 20:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10 14:02 gdb_assert when resetting breakpoints Roland Schwingel
2009-03-10 15:39 ` Paul Pluzhnikov
2009-03-17 10:24 ` Kai Tietz
2009-03-21 16:26 ` Kai Tietz
2009-04-30 21:37 ` Joel Brobecker
2009-03-10 16:45 Roland Schwingel
2009-03-17 11:44 Roland Schwingel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox